tiki-blogs_rss.php 2.07 KB
Newer Older
1
<?php
2
// (c) Copyright 2002-2011 by authors of the Tiki Wiki CMS Groupware Project
3
// 
4 5
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6
// $Id$
changi67's avatar
changi67 committed
7

8
require_once ('tiki-setup.php');
9
require_once ('lib/tikilib.php');
10 11
require_once ('lib/blogs/bloglib.php');
require_once ('lib/rss/rsslib.php');
12 13
$access->check_feature('feature_blogs');

14
if ($prefs['feed_blogs'] != 'y') {
15 16
	$errmsg = tra("rss feed disabled");
	require_once ('tiki-rss_error.php');
17
}
18 19
$res = $access->authorize_rss(array(
	'tiki_p_read_blog',
20 21
	'tiki_p_blog_admin',
	'tiki_p_blog_view_ref'
22 23 24 25 26 27 28 29
));
if ($res) {
	if ($res['header'] == 'y') {
		header('WWW-Authenticate: Basic realm="' . $tikidomain . '"');
		header('HTTP/1.0 401 Unauthorized');
	}
	$errmsg = $res['msg'];
	require_once ('tiki-rss_error.php');
30
}
ohertel's avatar
ohertel committed
31
$feed = "blogs";
mose's avatar
mose committed
32
$uniqueid = $feed;
33
$output = $rsslib->get_from_cache($uniqueid);
34
if ($output["data"] == "EMPTY") {
35 36
	$title = $prefs['feed_blogs_title'];
	$desc = $prefs['feed_blogs_desc'];
37
	$now = date("U");
38
	$id = "postId";
39 40 41 42
	$descId = "data";
	$dateId = "created";
	$titleId = "title";
	$authorId = "user";
43
	$readrepl = "tiki-view_blog_post.php?postId=%s";
44
	$tmp = $prefs['feed_' . $feed . '_title'];
45
	if ($tmp <> '') $title = $tmp;
46
	$tmp = $prefs['feed_' . $feed . '_desc'];
47
	if ($desc <> '') $desc = $tmp;
48
	$changes = $bloglib->list_all_blog_posts(0, $prefs['feed_blogs_max'], $dateId . '_desc', '', $now);
49
	$tmp = array();
50 51 52
	include_once ('tiki-sefurl.php');
	foreach($changes["data"] as $data) {
		global $bloglib;
sampaioprimo's avatar
sampaioprimo committed
53 54 55
		$data["$descId"] = $tikilib->parse_data($data[$descId], array(
			'print' => true
		));
56
		$data['sefurl'] = filter_out_sefurl(sprintf($readrepl, $data['postId'], $data['blogId']) , $smarty, 'blogpost', urlencode($data['title']));
57 58 59 60
		$tmp[] = $data;
	}
	$changes["data"] = $tmp;
	$tmp = null;
sampaioprimo's avatar
sampaioprimo committed
61
	$output = $rsslib->generate_feed($feed, $uniqueid, '', $changes, $readrepl, '', $id, $title, $titleId, $desc, $descId, $dateId, $authorId);
ohertel's avatar
ohertel committed
62
}
63
header("Content-type: " . $output["content-type"]);
64
print $output["data"];