tiki-forum_queue.php 6.85 KB
Newer Older
lrargerich's avatar
lrargerich committed
1
<?php
changi67's avatar
changi67 committed
2 3
// (c) Copyright 2002-2010 by authors of the Tiki Wiki/CMS/Groupware Project
// 
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 20
	die;
}

$smarty->assign('forumId', $_REQUEST["forumId"]);
include_once ("lib/commentslib.php");
lrargerich's avatar
lrargerich committed
21 22 23 24
$commentslib = new Comments($dbTiki);
$forum_info = $commentslib->get_forum($_REQUEST["forumId"]);

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

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

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

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

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

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

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

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

62 63
if (isset($_REQUEST['qId'])) {
	if (isset($_REQUEST['save'])) {
64
		check_ticket('forum-queue');
65 66 67 68 69 70 71 72 73 74
		$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
75

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

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

82 83 84 85 86 87 88
		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
89
		}
90 91 92

		$commentslib->replace_queue($_REQUEST['qId'], $_REQUEST['forumId'], 'forum' . $_REQUEST['forumId'], $_REQUEST['parentId'],
			$user, $_REQUEST['title'], $_REQUEST['data'], $_REQUEST['type'], $_REQUEST['topic_smiley'], $_REQUEST['summary'],
93
			$_REQUEST['topic_title'], $_REQUEST['in_reply_to']);
94
		unset ($_REQUEST['qId']);
lrargerich's avatar
lrargerich committed
95
	}
96 97

	if (isset($_REQUEST['remove'])) {
98 99 100
		$access->check_authenticity();
		$smarty->assign('form', 'n');
		$commentslib->remove_queued($_REQUEST['qId']);
lrargerich's avatar
lrargerich committed
101
	}
102 103

	if (isset($_REQUEST['saveapp'])) {
104
	check_ticket('forum-queue');
105 106 107 108 109 110 111 112 113 114 115 116 117 118
		$smarty->assign('form', 'n');

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

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

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

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

119 120 121
		if (!isset($_REQUEST['in_reply_to']))
			$_REQUEST['in_reply_to'] = '';

122 123 124 125 126 127 128
		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
129
		}
130 131 132

		$commentslib->replace_queue($_REQUEST['qId'], $_REQUEST['forumId'], 'forum' . $_REQUEST['forumId'], $_REQUEST['parentId'],
			$user, $_REQUEST['title'], $_REQUEST['data'], $_REQUEST['type'], $_REQUEST['topic_smiley'], $_REQUEST['summary'],
133
			$_REQUEST['topic_title'], $_REQUEST['in_reply_to']);
lrargerich's avatar
lrargerich committed
134
		$commentslib->approve_queued($_REQUEST['qId']);
135
		unset ($_REQUEST['qId']);
lrargerich's avatar
lrargerich committed
136
	}
137 138

	if (isset($_REQUEST['topicize'])) {
139
	check_ticket('forum-queue');
140 141
		$smarty->assign('form', 'n');

lrargerich's avatar
lrargerich committed
142
		// Convert to a topic
143 144 145 146 147 148 149 150 151 152 153 154
		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'] = '';

155 156 157
		if (!isset($_REQUEST['in_reply_to']))
			$_REQUEST['in_reply_to'] = '';

158 159 160 161
		$_REQUEST['parentId'] = 0;
		$_REQUEST['type'] = 'n';
		$commentslib->replace_queue($_REQUEST['qId'], $_REQUEST['forumId'], 'forum' . $_REQUEST['forumId'], $_REQUEST['parentId'],
			$user, $_REQUEST['title'], $_REQUEST['data'], $_REQUEST['type'], $_REQUEST['topic_smiley'], $_REQUEST['summary'],
162
			$_REQUEST['topic_title'], $_REQUEST['in_reply_to']);
163
		unset ($_REQUEST['qId']);
lrargerich's avatar
lrargerich committed
164 165 166
	}
}

167
if (isset($_REQUEST['rej']) && isset($_REQUEST['msg'])) {
168
	check_ticket('forum-queue');
169 170
	foreach (array_keys($_REQUEST['msg'])as $msg) {
		$commentslib->remove_queued($msg);
lrargerich's avatar
lrargerich committed
171 172 173
	}
}

174
if (isset($_REQUEST['app']) && isset($_REQUEST['msg'])) {
175
	check_ticket('forum-queue');
176
	foreach (array_keys($_REQUEST['msg'])as $msg) {
lrargerich's avatar
lrargerich committed
177 178 179 180 181
		$commentslib->approve_queued($msg);
	}
}

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

186 187
	$temp_max = count($all_forums["data"]);
	for ($i = 0; $i < $temp_max; $i++) {
188 189
		$forumperms = Perms::get( array( 'type' => 'forum', 'object' => $all_forums['data'][$i]['forumId'] ) );
		$all_forums["data"][$i]["can_read"] = $forumperms->forum_read ? 'y' : 'n';
lrargerich's avatar
lrargerich committed
190
	}
191 192

	$smarty->assign('all_forums', $all_forums['data']);
lrargerich's avatar
lrargerich committed
193 194 195
}

// Number of queued messages
196 197
if ($tiki_p_admin_forum == 'y') {
	$smarty->assign('queued', $commentslib->get_num_queued('forum' . $_REQUEST['forumId']));
lrargerich's avatar
lrargerich committed
198 199 200
}

// Items will contain messages
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
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
223
$items = $commentslib->list_forum_queue('forum:' . $_REQUEST['forumId'], $offset, $maxRecords, $sort_mode, $find);
224
$smarty->assign('cant', $items['cant']);
225
$smarty->assign_by_ref('cant_pages', $items['cant']);
226 227

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

229 230
$topics = $commentslib->get_forum_topics($_REQUEST['forumId']);
$smarty->assign_by_ref('topics', $topics);
231
ask_ticket('forum-queue');
232

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