1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8$section = 'forums'; 9require_once('tiki-setup.php'); 10$access->check_feature('feature_forums'); 11 12// forumId must be received 13if (! isset($_REQUEST["forumId"])) { 14 $smarty->assign('msg', tra("No forum indicated")); 15 $smarty->display("error.tpl"); 16 die; 17} 18 19$smarty->assign('forumId', $_REQUEST["forumId"]); 20$commentslib = TikiLib::lib('comments'); 21 22// Approval from email 23if (isset($_REQUEST["ahash"]) && isset($_REQUEST["qId"])) { 24 $msg_info = $commentslib->queue_get($_REQUEST['qId']); 25 $ahash = md5($_REQUEST['qId'] . $msg_info['title'] . $msg_info['data'] . $msg_info['user']); 26 if ($_REQUEST["ahash"] == $ahash) { 27 $commentslib->approve_queued($_REQUEST['qId']); 28 echo ("You have now approved the post by " . htmlspecialchars(TikiLib::lib('user')->clean_user($msg_info['user']))); 29 } else { 30 echo ("Error: Unable to approve queued post."); 31 } 32 die; 33} 34 35$forum_info = $commentslib->get_forum($_REQUEST["forumId"]); 36 37//Check individual permissions for this forum 38$smarty->assign('individual', 'n'); 39 40$tikilib->get_perm_object($_REQUEST["forumId"], 'forum'); 41 42// Now if the user is the moderator then give hime forum admin privs 43if ($user) { 44 if ($forum_info["moderator"] == $user) { 45 $tiki_p_admin_forum = 'y'; 46 $smarty->assign('tiki_p_admin_forum', 'y'); 47 } elseif (in_array($forum_info['moderator_group'], $userlib->get_user_groups($user))) { 48 $tiki_p_admin_forum = 'y'; 49 $smarty->assign('tiki_p_admin_forum', 'y'); 50 } 51} 52 53$access->check_permission('tiki_p_admin_forum'); 54$smarty->assign_by_ref('forum_info', $forum_info); 55include_once('tiki-section_options.php'); 56 57if ($prefs['feature_theme_control'] == 'y') { 58 $cat_type = 'forum'; 59 $cat_objid = $_REQUEST["forumId"]; 60 include('tiki-tc.php'); 61} 62 63if (isset($_REQUEST['qId'])) { 64 $msg_info = $commentslib->queue_get($_REQUEST['qId']); 65 $smarty->assign_by_ref('msg_info', $msg_info); 66} 67 68$smarty->assign('form', 'y'); 69 70if (isset($_REQUEST['remove_attachment'])) { 71 check_ticket('forum-queue'); 72 $commentslib->remove_thread_attachment($_REQUEST['remove_attachment']); 73} 74 75if (isset($_REQUEST['qId'])) { 76 if (isset($_REQUEST['save']) || isset($_REQUEST['saveapp'])) { 77 check_ticket('forum-queue'); 78 $smarty->assign('form', 'n'); 79 80 if (! isset($_REQUEST['summary'])) { 81 $_REQUEST['summary'] = $msg_info['summary']; 82 } 83 84 if (! isset($_REQUEST['topic_smiley'])) { 85 $_REQUEST['topic_smiley'] = $msg_info['topic_smiley']; 86 } 87 88 if (! isset($_REQUEST['type'])) { 89 $_REQUEST['type'] = $msg_info['type']; 90 } 91 92 if (! isset($_REQUEST['topic_title'])) { 93 $_REQUEST['topic_title'] = $msg_info['topic_title']; 94 } 95 96 if (! isset($_REQUEST['in_reply_to'])) { 97 $_REQUEST['in_reply_to'] = $msg_info['in_reply_to']; 98 } 99 100 if (! isset($_REQUEST['parentId'])) { 101 $_REQUEST['parentId'] = $msg_info['parentId']; 102 } 103 104 if ($_REQUEST['parentId'] > 0) { 105 $p_info = $commentslib->get_comment($_REQUEST['parentId']); 106 107 $_REQUEST['topic_title'] = $p_info['title']; 108 } 109 110 $commentslib->replace_queue( 111 $_REQUEST['qId'], 112 $_REQUEST['forumId'], 113 'forum:' . $_REQUEST['forumId'], 114 $_REQUEST['parentId'], 115 $msg_info['user'], 116 $_REQUEST['title'], 117 $_REQUEST['data'], 118 $_REQUEST['type'], 119 $_REQUEST['topic_smiley'], 120 $_REQUEST['summary'], 121 $_REQUEST['topic_title'], 122 $_REQUEST['in_reply_to'] 123 ); 124 if (isset($_REQUEST['saveapp'])) { 125 $commentslib->approve_queued($_REQUEST['qId']); 126 } 127 unset($_REQUEST['qId']); 128 } 129 130 if (isset($_REQUEST['remove'])) { 131 $access->check_authenticity(); 132 $smarty->assign('form', 'n'); 133 $commentslib->remove_queued($_REQUEST['qId']); 134 } 135 136 if (isset($_REQUEST['topicize'])) { 137 check_ticket('forum-queue'); 138 $smarty->assign('form', 'n'); 139 140 // Convert to a topic 141 if (! isset($_REQUEST['summary'])) { 142 $_REQUEST['summary'] = ''; 143 } 144 145 if (! isset($_REQUEST['type'])) { 146 $_REQUEST['type'] = ''; 147 } 148 149 if (! isset($_REQUEST['topic_smiley'])) { 150 $_REQUEST['topic_smiley'] = ''; 151 } 152 153 if (! isset($_REQUEST['topic_title'])) { 154 $_REQUEST['topic_title'] = ''; 155 } 156 157 if (! isset($_REQUEST['in_reply_to'])) { 158 $_REQUEST['in_reply_to'] = ''; 159 } 160 161 $_REQUEST['parentId'] = 0; 162 $_REQUEST['type'] = 'n'; 163 $commentslib->replace_queue( 164 $_REQUEST['qId'], 165 $_REQUEST['forumId'], 166 'forum:' . $_REQUEST['forumId'], 167 $_REQUEST['parentId'], 168 $msg_info['user'], 169 $_REQUEST['title'], 170 $_REQUEST['data'], 171 $_REQUEST['type'], 172 $_REQUEST['topic_smiley'], 173 $_REQUEST['summary'], 174 $_REQUEST['topic_title'], 175 $_REQUEST['in_reply_to'] 176 ); 177 unset($_REQUEST['qId']); 178 } 179} 180 181if (isset($_REQUEST['rej']) && isset($_REQUEST['msg'])) { 182 check_ticket('forum-queue'); 183 foreach (array_keys($_REQUEST['msg']) as $msg) { 184 $commentslib->remove_queued($msg); 185 } 186} 187 188if (isset($_REQUEST['app']) && isset($_REQUEST['msg'])) { 189 check_ticket('forum-queue'); 190 foreach (array_keys($_REQUEST['msg']) as $msg) { 191 $commentslib->approve_queued($msg); 192 } 193} 194 195// Quickjumpt to other forums 196if ($tiki_p_admin_forum == 'y' || $prefs['feature_forum_quickjump'] == 'y') { 197 $all_forums = $commentslib->list_forums(0, -1, 'name_asc', ''); 198 Perms::bulk([ 'type' => 'forum' ], 'object', $all_forums['data'], 'forumId'); 199 200 $temp_max = count($all_forums["data"]); 201 for ($i = 0; $i < $temp_max; $i++) { 202 $forumperms = Perms::get([ 'type' => 'forum', 'object' => $all_forums['data'][$i]['forumId'] ]); 203 $all_forums["data"][$i]["can_read"] = $forumperms->forum_read ? 'y' : 'n'; 204 } 205 206 $smarty->assign('all_forums', $all_forums['data']); 207} 208 209// Number of queued messages 210if ($tiki_p_admin_forum == 'y') { 211 $smarty->assign('queued', $commentslib->get_num_queued('forum' . $_REQUEST['forumId'])); 212} 213 214// Items will contain messages 215if (! isset($_REQUEST["sort_mode"])) { 216 $sort_mode = 'timestamp_asc'; 217} else { 218 $sort_mode = $_REQUEST["sort_mode"]; 219} 220 221if (! isset($_REQUEST["offset"])) { 222 $offset = 0; 223} else { 224 $offset = $_REQUEST["offset"]; 225} 226 227$smarty->assign_by_ref('offset', $offset); 228 229if (isset($_REQUEST["find"])) { 230 $find = $_REQUEST["find"]; 231} else { 232 $find = ''; 233} 234 235$smarty->assign('find', $find); 236$smarty->assign_by_ref('sort_mode', $sort_mode); 237$items = $commentslib->list_forum_queue('forum:' . $_REQUEST['forumId'], $offset, $maxRecords, $sort_mode, $find); 238$smarty->assign('cant', $items['cant']); 239$smarty->assign_by_ref('cant_pages', $items['cant']); 240 241$smarty->assign_by_ref('items', $items["data"]); 242 243$topics = $commentslib->get_forum_topics($_REQUEST['forumId']); 244$smarty->assign_by_ref('topics', $topics); 245ask_ticket('forum-queue'); 246 247// Display the template 248$smarty->assign('mid', 'tiki-forum_queue.tpl'); 249$smarty->display("tiki.tpl"); 250