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

11
$section = 'forums';
rjsmelo's avatar
rjsmelo committed
12
require_once('tiki-setup.php');
13
//get_strings tra('List Forums')
rjsmelo's avatar
rjsmelo committed
14
$auto_query_args = ['sort_mode', 'offset', 'find', 'mode'];
15

16 17
$access->check_feature('feature_forums');
$access->check_permission('tiki_p_forum_read');
lrargerich's avatar
lrargerich committed
18 19

// This shows a list of forums everybody can use this listing
20
$commentslib = TikiLib::lib('comments');
lrargerich's avatar
lrargerich committed
21

rjsmelo's avatar
rjsmelo committed
22
if (! isset($_REQUEST["sort_mode"])) {
23
	$sort_mode = $prefs['forums_ordering'];
lrargerich's avatar
lrargerich committed
24
} else {
25 26
	$sort_mode = $_REQUEST["sort_mode"];
}
lrargerich's avatar
lrargerich committed
27

rjsmelo's avatar
rjsmelo committed
28
if (! isset($_REQUEST["offset"])) {
29
	$offset = 0;
lrargerich's avatar
lrargerich committed
30
} else {
31
	$offset = $_REQUEST["offset"];
lrargerich's avatar
lrargerich committed
32 33
}

34 35 36 37
$smarty->assign_by_ref('offset', $offset);

if (isset($_REQUEST["find"])) {
	$find = $_REQUEST["find"];
lrargerich's avatar
lrargerich committed
38
} else {
39
	$find = '';
lrargerich's avatar
lrargerich committed
40 41
}

42 43
$smarty->assign('find', $find);

44 45 46 47
if (isset($_REQUEST['numrows'])) {
	$maxRecords = $_REQUEST['numrows'];
}

48 49
$smarty->assign_by_ref('sort_mode', $sort_mode);
$channels = $commentslib->list_forums($offset, $maxRecords, $sort_mode, $find);
rjsmelo's avatar
rjsmelo committed
50
Perms::bulk([ 'type' => 'forum' ], 'object', $channels['data'], 'forumId');
51

52 53
$temp_max = count($channels["data"]);
for ($i = 0; $i < $temp_max; $i++) {
rjsmelo's avatar
rjsmelo committed
54
	$forumperms = Perms::get([ 'type' => 'forum', 'object' => $channels['data'][$i]['forumId'] ]);
55 56 57 58 59 60 61 62 63
	$channels["data"][$i]["individual_tiki_p_forum_read"] = $forumperms->forum_read ? 'y' : 'n';
	$channels["data"][$i]["individual_tiki_p_forum_post"] = $forumperms->forum_post ? 'y' : 'n';
	$channels["data"][$i]["individual_tiki_p_forum_post_topic"] = $forumperms->forum_post_topic ? 'y' : 'n';
	$channels["data"][$i]["individual_tiki_p_forum_vote"] = $forumperms->forum_vote ? 'y' : 'n';
	$channels["data"][$i]["individual_tiki_p_admin_forum"] = $forumperms->admin_forum ? 'y' : 'n';
}

$smarty->assign_by_ref('channels', $channels["data"]);
$smarty->assign('cant', $channels["cant"]);
rjsmelo's avatar
rjsmelo committed
64
include_once('tiki-section_options.php');
65

66
//add tablesorter sorting and filtering
67
$ts = Table_Check::setVars('forums', true);
rjsmelo's avatar
rjsmelo committed
68
if ($ts['enabled'] && ! $ts['ajax']) {
69 70 71
	//set tablesorter code
	Table_Factory::build(
		'TikiForums',
rjsmelo's avatar
rjsmelo committed
72
		[
73
			'id' => $ts['tableid'],
74
			'total' => $channels["cant"],
rjsmelo's avatar
rjsmelo committed
75
		]
76
	);
77
}
78

79
ask_ticket('forums');
lrargerich's avatar
lrargerich committed
80
// Display the template
81
if ($ts['ajax']) {
82 83 84 85 86
	$smarty->display('tiki-forums.tpl');
} else {
	$smarty->assign('mid', 'tiki-forums.tpl');
	$smarty->display("tiki.tpl");
}