tiki-forums_reported.php 3.31 KB
Newer Older
lrargerich's avatar
lrargerich committed
1
<?php
changi67's avatar
changi67 committed
2 3 4
/**
 * @package tikiwiki
 */
5
// (c) Copyright 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');
lrargerich's avatar
lrargerich committed
13

14
$access->check_feature('feature_forums');
15

lrargerich's avatar
lrargerich committed
16
// forumId must be received
rjsmelo's avatar
rjsmelo committed
17
if (! isset($_REQUEST["forumId"])) {
18
	$smarty->assign('msg', tra("No forum indicated"));
19
	$smarty->display("error.tpl");
20 21 22 23
	die;
}

$smarty->assign('forumId', $_REQUEST["forumId"]);
24
$commentslib = TikiLib::lib('comments');
lrargerich's avatar
lrargerich committed
25 26 27
$forum_info = $commentslib->get_forum($_REQUEST["forumId"]);

//Check individual permissions for this forum
28 29
$smarty->assign('individual', 'n');

30
$tikilib->get_perm_object($_REQUEST["forumId"], 'forum');
lrargerich's avatar
lrargerich committed
31 32

// Now if the user is the moderator then give hime forum admin privs
33 34 35 36 37 38 39
if ($user) {
	if ($forum_info["moderator"] == $user) {
		$tiki_p_admin_forum = 'y';
		$smarty->assign('tiki_p_admin_forum', 'y');
	} elseif (in_array($forum_info['moderator_group'], $userlib->get_user_groups($user))) {
		$tiki_p_admin_forum = 'y';
		$smarty->assign('tiki_p_admin_forum', 'y');
lrargerich's avatar
lrargerich committed
40 41 42
	}
}

43
$access->check_permission('tiki_p_admin_forum');
lrargerich's avatar
lrargerich committed
44

45
$smarty->assign_by_ref('forum_info', $forum_info);
rjsmelo's avatar
rjsmelo committed
46
include_once('tiki-section_options.php');
lrargerich's avatar
lrargerich committed
47

48
if ($prefs['feature_theme_control'] == 'y') {
49 50
	$cat_type = 'forum';
	$cat_objid = $_REQUEST["forumId"];
rjsmelo's avatar
rjsmelo committed
51
	include('tiki-tc.php');
52 53 54 55 56 57
}

if (isset($_REQUEST['qId'])) {
	$msg_info = $commentslib->queue_get($_REQUEST['qId']);

	$smarty->assign_by_ref('msg_info', $msg_info);
lrargerich's avatar
lrargerich committed
58 59
}

60 61 62
$smarty->assign('form', 'y');

if (isset($_REQUEST['del']) && isset($_REQUEST['msg'])) {
63
	check_ticket('forum-reported');
rjsmelo's avatar
rjsmelo committed
64
	foreach (array_keys($_REQUEST['msg']) as $msg) {
65 66 67
		$commentslib->remove_reported($msg);
	}
}
lrargerich's avatar
lrargerich committed
68 69

// Quickjumpt to other forums
70
if ($tiki_p_admin_forum == 'y' || $prefs['feature_forum_quickjump'] == 'y') {
71
	$all_forums = $commentslib->list_forums(0, -1, 'name_asc', '');
rjsmelo's avatar
rjsmelo committed
72
	Perms::bulk([ 'type' => 'forum' ], 'object', $all_forums['data'], 'forumId');
73

74 75
	$temp_max = count($all_forums["data"]);
	for ($i = 0; $i < $temp_max; $i++) {
rjsmelo's avatar
rjsmelo committed
76
		$forumperms = Perms::get([ 'type' => 'forum', 'object' => $options['data'][$i]['forumId'] ]);
77
		$all_forums["data"][$i]["can_read"] = $forumperms->forum_read ? 'y' : 'n';
lrargerich's avatar
lrargerich committed
78
	}
79 80

	$smarty->assign('all_forums', $all_forums['data']);
lrargerich's avatar
lrargerich committed
81 82 83
}

// Number of queued messages
84 85
if ($tiki_p_admin_forum == 'y') {
	$smarty->assign('reported', $commentslib->get_num_reported($_REQUEST['forumId']));
lrargerich's avatar
lrargerich committed
86 87 88
}

// Items will contain messages
rjsmelo's avatar
rjsmelo committed
89
if (! isset($_REQUEST["sort_mode"])) {
90 91 92 93 94
	$sort_mode = 'timestamp_desc';
} else {
	$sort_mode = $_REQUEST["sort_mode"];
}

rjsmelo's avatar
rjsmelo committed
95
if (! isset($_REQUEST["offset"])) {
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
	$offset = 0;
} else {
	$offset = $_REQUEST["offset"];
}

$smarty->assign_by_ref('offset', $offset);

if (isset($_REQUEST["find"])) {
	$find = $_REQUEST["find"];
} else {
	$find = '';
}

$smarty->assign('find', $find);
$smarty->assign_by_ref('sort_mode', $sort_mode);
$items = $commentslib->list_reported($_REQUEST['forumId'], $offset, $maxRecords, $sort_mode, $find);
$smarty->assign('cant', $items['cant']);
113
$smarty->assign_by_ref('cant_pages', $items["cant"]);
114 115

$smarty->assign_by_ref('items', $items["data"]);
lrargerich's avatar
lrargerich committed
116

117
ask_ticket('forum-reported');
118

lrargerich's avatar
lrargerich committed
119
// Display the template
120
$smarty->assign('mid', 'tiki-forums_reported.tpl');
121
$smarty->display("tiki.tpl");