tiki-list_blogs.php 2.65 KB
Newer Older
1
<?php
2
// (c) Copyright 2002-2011 by authors of the Tiki Wiki CMS Groupware Project
changi67's avatar
changi67 committed
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
$section = 'blogs';
9 10
require_once ('tiki-setup.php');
include_once ('lib/blogs/bloglib.php');
changi67's avatar
changi67 committed
11
$smarty->assign('headtitle', tra('Blogs'));
12
if ($prefs['feature_categories'] == 'y') {
mose's avatar
mose committed
13 14
	include_once ('lib/categories/categlib.php');
}
15 16
$access->check_feature('feature_blogs');
$access->check_permission('tiki_p_read_blog');
17 18
if (isset($_REQUEST["remove"])) {
	// Check if it is the owner
19
	$data = $bloglib->get_blog($_REQUEST["remove"]);
20 21
	if ($data["user"] != $user) {
		if ($tiki_p_blog_admin != 'y') {
22
			$smarty->assign('errortype', 401);
23
			$smarty->assign('msg', tra("You do not have permission to remove this blog"));
24
			$smarty->display("error.tpl");
25 26 27
			die;
		}
	}
28 29
	$access->check_authenticity();
	$bloglib->remove_blog($_REQUEST["remove"]);
30 31 32 33 34
}
// This script can receive the thresold
// for the information as the number of
// days to get in the log 1,3,4,etc
// it will default to 1 recovering information for today
35
if (!isset($_REQUEST["sort_mode"])) {
36
	$sort_mode = $prefs['blog_list_order'];
37
} else {
38 39 40
	$sort_mode = $_REQUEST["sort_mode"];
}
$smarty->assign_by_ref('sort_mode', $sort_mode);
41 42 43
// If offset is set use it if not then use offset =0
// use the maxRecords php variable to set the limit
// if sortMode is not set then use lastModif_desc
44 45
if (!isset($_REQUEST["offset"])) {
	$offset = 0;
46
} else {
47
	$offset = $_REQUEST["offset"];
48
}
49 50 51
$smarty->assign_by_ref('offset', $offset);
if (isset($_REQUEST["find"])) {
	$find = $_REQUEST["find"];
52
} else {
53
	$find = '';
54
}
55
$smarty->assign('find', $find);
56
// Get a list of last changes to the Wiki database
57
$listpages = $bloglib->list_blogs($offset, $maxRecords, $sort_mode, $find);
58
Perms::bulk( array( 'type' => 'blog' ), 'object', $listpages['data'], 'blogId' );
59 60
$temp_max = count($listpages["data"]);
for ($i = 0; $i < $temp_max; $i++) {
61 62 63 64
	$blogperms = Perms::get( array( 'type' => 'blog', 'object' => $listpages['data'][$i]['blogId'] ) );
	$listpages["data"][$i]["individual_tiki_p_read_blog"] = $blogperms->read_blog ? 'y' : 'n';
	$listpages["data"][$i]["individual_tiki_p_blog_post"] = $blogperms->blog_post ? 'y' : 'n';
	$listpages["data"][$i]["individual_tiki_p_create_blogs"] = $blogperms->create_blogs ? 'y' : 'n';
lrargerich's avatar
lrargerich committed
65
}
66
$smarty->assign_by_ref('listpages', $listpages["data"]);
67
$smarty->assign_by_ref('cant', $listpages["cant"]);
68
include_once ('tiki-section_options.php');
69
ask_ticket('list-blogs');
70
// Display the template
71
$smarty->assign('mid', 'tiki-list_blogs.tpl');
72
$smarty->display("tiki.tpl");