tiki-forum_queue.php 5.95 KB
Newer Older
lrargerich's avatar
lrargerich committed
1
<?php
2
// (c) Copyright 2002-2015 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.
changi67's avatar
changi67 committed
6
// $Id$
7

8
$section = 'forums';
9
require_once ('tiki-setup.php');
10
$access->check_feature('feature_forums');
11

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

$smarty->assign('forumId', $_REQUEST["forumId"]);
20
$commentslib = TikiLib::lib('comments');
lrargerich's avatar
lrargerich committed
21 22 23
$forum_info = $commentslib->get_forum($_REQUEST["forumId"]);

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

26
$tikilib->get_perm_object($_REQUEST["forumId"], 'forum');
lrargerich's avatar
lrargerich committed
27 28

// Now if the user is the moderator then give hime forum admin privs
29 30 31 32 33 34 35
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
36 37 38
	}
}

39
$access->check_permission('tiki_p_admin_forum');
40 41 42
$smarty->assign_by_ref('forum_info', $forum_info);
include_once ('tiki-section_options.php');

43
if ($prefs['feature_theme_control'] == 'y') {
44 45 46 47
	$cat_type = 'forum';
	$cat_objid = $_REQUEST["forumId"];
	include ('tiki-tc.php');
}
lrargerich's avatar
lrargerich committed
48

49 50 51
if (isset($_REQUEST['qId'])) {
	$msg_info = $commentslib->queue_get($_REQUEST['qId']);
	$smarty->assign_by_ref('msg_info', $msg_info);
lrargerich's avatar
lrargerich committed
52 53
}

54
$smarty->assign('form', 'y');
lrargerich's avatar
lrargerich committed
55

56
if (isset($_REQUEST['remove_attachment'])) {
57
	check_ticket('forum-queue');
lrargerich's avatar
lrargerich committed
58 59 60
	$commentslib->remove_thread_attachment($_REQUEST['remove_attachment']);
}

61
if (isset($_REQUEST['qId'])) {
62
	if (isset($_REQUEST['save']) || isset($_REQUEST['saveapp'])) {
63
		check_ticket('forum-queue');
64 65 66 67 68 69 70 71 72 73
		$smarty->assign('form', 'n');

		if (!isset($_REQUEST['summary']))
			$_REQUEST['summary'] = '';

		if (!isset($_REQUEST['topic_smiley']))
			$_REQUEST['topic_smiley'] = '';

		if (!isset($_REQUEST['type']))
			$_REQUEST['type'] = '';
lrargerich's avatar
lrargerich committed
74

75 76
		if (!isset($_REQUEST['topic_title']))
			$_REQUEST['topic_title'] = '';
lrargerich's avatar
lrargerich committed
77

78 79 80
		if (!isset($_REQUEST['in_reply_to']))
			$_REQUEST['in_reply_to'] = '';

81 82 83 84 85 86 87
		if (!isset($_REQUEST['parentId']))
			$_REQUEST['parentId'] = $msg_info['parentId'];

		if ($_REQUEST['parentId'] > 0) {
			$p_info = $commentslib->get_comment($_REQUEST['parentId']);

			$_REQUEST['topic_title'] = $p_info['title'];
lrargerich's avatar
lrargerich committed
88
		}
89

90
		$commentslib->replace_queue(
91 92 93 94 95 96 97 98 99 100 101 102
			$_REQUEST['qId'],
			$_REQUEST['forumId'],
			'forum' . $_REQUEST['forumId'],
			$_REQUEST['parentId'],
			$user,
			$_REQUEST['title'],
			$_REQUEST['data'],
			$_REQUEST['type'],
			$_REQUEST['topic_smiley'],
			$_REQUEST['summary'],
			$_REQUEST['topic_title'],
			$_REQUEST['in_reply_to']
103
		);
104
		if ( isset($_REQUEST['saveapp']) )
105
			$commentslib->approve_queued($_REQUEST['qId']);
106
		unset ($_REQUEST['qId']);
lrargerich's avatar
lrargerich committed
107
	}
108 109

	if (isset($_REQUEST['remove'])) {
110 111 112
		$access->check_authenticity();
		$smarty->assign('form', 'n');
		$commentslib->remove_queued($_REQUEST['qId']);
lrargerich's avatar
lrargerich committed
113
	}
114 115

	if (isset($_REQUEST['topicize'])) {
116
	check_ticket('forum-queue');
117 118
		$smarty->assign('form', 'n');

lrargerich's avatar
lrargerich committed
119
		// Convert to a topic
120 121 122 123 124 125 126 127 128 129 130 131
		if (!isset($_REQUEST['summary']))
			$_REQUEST['summary'] = '';

		if (!isset($_REQUEST['type']))
			$_REQUEST['type'] = '';

		if (!isset($_REQUEST['topic_smiley']))
			$_REQUEST['topic_smiley'] = '';

		if (!isset($_REQUEST['topic_title']))
			$_REQUEST['topic_title'] = '';

132 133 134
		if (!isset($_REQUEST['in_reply_to']))
			$_REQUEST['in_reply_to'] = '';

135 136
		$_REQUEST['parentId'] = 0;
		$_REQUEST['type'] = 'n';
137
		$commentslib->replace_queue(
138 139 140 141 142 143 144 145 146 147 148 149
			$_REQUEST['qId'],
			$_REQUEST['forumId'],
			'forum' . $_REQUEST['forumId'],
			$_REQUEST['parentId'],
			$user,
			$_REQUEST['title'],
			$_REQUEST['data'],
			$_REQUEST['type'],
			$_REQUEST['topic_smiley'],
			$_REQUEST['summary'],
			$_REQUEST['topic_title'],
			$_REQUEST['in_reply_to']
150
		);
151
		unset ($_REQUEST['qId']);
lrargerich's avatar
lrargerich committed
152 153 154
	}
}

155
if (isset($_REQUEST['rej']) && isset($_REQUEST['msg'])) {
156
	check_ticket('forum-queue');
157 158
	foreach (array_keys($_REQUEST['msg'])as $msg) {
		$commentslib->remove_queued($msg);
lrargerich's avatar
lrargerich committed
159 160 161
	}
}

162
if (isset($_REQUEST['app']) && isset($_REQUEST['msg'])) {
163
	check_ticket('forum-queue');
164
	foreach (array_keys($_REQUEST['msg'])as $msg) {
lrargerich's avatar
lrargerich committed
165 166 167 168 169
		$commentslib->approve_queued($msg);
	}
}

// Quickjumpt to other forums
170
if ($tiki_p_admin_forum == 'y' || $prefs['feature_forum_quickjump'] == 'y') {
171
	$all_forums = $commentslib->list_forums(0, -1, 'name_asc', '');
172
	Perms::bulk(array( 'type' => 'forum' ), 'object', $all_forums['data'], 'forumId');
173

174 175
	$temp_max = count($all_forums["data"]);
	for ($i = 0; $i < $temp_max; $i++) {
176
		$forumperms = Perms::get(array( 'type' => 'forum', 'object' => $all_forums['data'][$i]['forumId'] ));
177
		$all_forums["data"][$i]["can_read"] = $forumperms->forum_read ? 'y' : 'n';
lrargerich's avatar
lrargerich committed
178
	}
179 180

	$smarty->assign('all_forums', $all_forums['data']);
lrargerich's avatar
lrargerich committed
181 182 183
}

// Number of queued messages
184 185
if ($tiki_p_admin_forum == 'y') {
	$smarty->assign('queued', $commentslib->get_num_queued('forum' . $_REQUEST['forumId']));
lrargerich's avatar
lrargerich committed
186 187 188
}

// Items will contain messages
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
if (!isset($_REQUEST["sort_mode"])) {
	$sort_mode = 'timestamp_asc';
} else {
	$sort_mode = $_REQUEST["sort_mode"];
}

if (!isset($_REQUEST["offset"])) {
	$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);
redflo's avatar
redflo committed
211
$items = $commentslib->list_forum_queue('forum:' . $_REQUEST['forumId'], $offset, $maxRecords, $sort_mode, $find);
212
$smarty->assign('cant', $items['cant']);
213
$smarty->assign_by_ref('cant_pages', $items['cant']);
214 215

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

217 218
$topics = $commentslib->get_forum_topics($_REQUEST['forumId']);
$smarty->assign_by_ref('topics', $topics);
219
ask_ticket('forum-queue');
220

lrargerich's avatar
lrargerich committed
221
// Display the template
222
$smarty->assign('mid', 'tiki-forum_queue.tpl');
223
$smarty->display("tiki.tpl");