tiki-list_blogs.php 2.65 KB
Newer Older
1
<?php
changi67's avatar
changi67 committed
2 3 4
/**
 * @package tikiwiki
 */
5
// (c) Copyright 2002-2015 by authors of the Tiki Wiki CMS Groupware Project
6
//
7 8
// 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.
9
// $Id$
changi67's avatar
changi67 committed
10

11
$section = 'blogs';
12
require_once ('tiki-setup.php');
lphuberdeau's avatar
lphuberdeau committed
13
$bloglib = TikiLib::lib('blog');
14
//get_strings tra('List Blog Posts')
15
if ($prefs['feature_categories'] == 'y') {
16
	$categlib = TikiLib::lib('categ');
17
}
18 19
$access->check_feature('feature_blogs');
$access->check_permission('tiki_p_read_blog');
20 21
if (isset($_REQUEST["remove"])) {
	// Check if it is the owner
22
	$data = $bloglib->get_blog($_REQUEST["remove"]);
23 24
	if ($data["user"] != $user) {
		if ($tiki_p_blog_admin != 'y') {
25
			$smarty->assign('errortype', 401);
26
			$smarty->assign('msg', tra("You do not have permission to remove this blog"));
27
			$smarty->display("error.tpl");
28 29 30
			die;
		}
	}
31 32
	$access->check_authenticity();
	$bloglib->remove_blog($_REQUEST["remove"]);
33
}
marclaporte's avatar
marclaporte committed
34
// This script can receive the threshold
35 36 37
// 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
38
if (!isset($_REQUEST["sort_mode"])) {
39
	$sort_mode = $prefs['blog_list_order'];
40
} else {
41 42 43
	$sort_mode = $_REQUEST["sort_mode"];
}
$smarty->assign_by_ref('sort_mode', $sort_mode);
44 45 46
// 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
47 48
if (!isset($_REQUEST["offset"])) {
	$offset = 0;
49
} else {
50
	$offset = $_REQUEST["offset"];
51
}
52 53 54
$smarty->assign_by_ref('offset', $offset);
if (isset($_REQUEST["find"])) {
	$find = $_REQUEST["find"];
55
} else {
56
	$find = '';
57
}
58
$smarty->assign('find', $find);
59
// Get a list of last changes to the Wiki database
60
$listpages = $bloglib->list_blogs($offset, $maxRecords, $sort_mode, $find);
61
Perms::bulk(array( 'type' => 'blog' ), 'object', $listpages['data'], 'blogId');
62 63
$temp_max = count($listpages["data"]);
for ($i = 0; $i < $temp_max; $i++) {
64
	$blogperms = Perms::get(array( 'type' => 'blog', 'object' => $listpages['data'][$i]['blogId'] ));
65 66 67
	$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
68
}
69
$smarty->assign_by_ref('listpages', $listpages["data"]);
70
$smarty->assign_by_ref('cant', $listpages["cant"]);
71
include_once ('tiki-section_options.php');
72
ask_ticket('list-blogs');
73
// Display the template
74
$smarty->assign('mid', 'tiki-list_blogs.tpl');
75
$smarty->display("tiki.tpl");