| 1 | <?php
|
|---|
| 2 | /**
|
|---|
| 3 | *
|
|---|
| 4 | * @package mcp
|
|---|
| 5 | * @version $Id$
|
|---|
| 6 | * @copyright (c) 2005 phpBB Group
|
|---|
| 7 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|---|
| 8 | *
|
|---|
| 9 | */
|
|---|
| 10 |
|
|---|
| 11 | /**
|
|---|
| 12 | * @ignore
|
|---|
| 13 | */
|
|---|
| 14 | if (!defined('IN_PHPBB'))
|
|---|
| 15 | {
|
|---|
| 16 | exit;
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 | /**
|
|---|
| 20 | * mcp_queue
|
|---|
| 21 | * Handling the moderation queue
|
|---|
| 22 | * @package mcp
|
|---|
| 23 | */
|
|---|
| 24 | class mcp_queue
|
|---|
| 25 | {
|
|---|
| 26 | var $p_master;
|
|---|
| 27 | var $u_action;
|
|---|
| 28 |
|
|---|
| 29 | function mcp_queue(&$p_master)
|
|---|
| 30 | {
|
|---|
| 31 | $this->p_master = &$p_master;
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | function main($id, $mode)
|
|---|
| 35 | {
|
|---|
| 36 | global $auth, $db, $user, $template, $cache;
|
|---|
| 37 | global $config, $phpbb_root_path, $phpEx, $action;
|
|---|
| 38 |
|
|---|
| 39 | include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
|
|---|
| 40 |
|
|---|
| 41 | $forum_id = request_var('f', 0);
|
|---|
| 42 | $start = request_var('start', 0);
|
|---|
| 43 |
|
|---|
| 44 | $this->page_title = 'MCP_QUEUE';
|
|---|
| 45 |
|
|---|
| 46 | switch ($action)
|
|---|
| 47 | {
|
|---|
| 48 | case 'approve':
|
|---|
| 49 | case 'disapprove':
|
|---|
| 50 | include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
|---|
| 51 |
|
|---|
| 52 | $post_id_list = request_var('post_id_list', array(0));
|
|---|
| 53 |
|
|---|
| 54 | if (!sizeof($post_id_list))
|
|---|
| 55 | {
|
|---|
| 56 | trigger_error('NO_POST_SELECTED');
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | if ($action == 'approve')
|
|---|
| 60 | {
|
|---|
| 61 | approve_post($post_id_list, 'queue', $mode);
|
|---|
| 62 | }
|
|---|
| 63 | else
|
|---|
| 64 | {
|
|---|
| 65 | disapprove_post($post_id_list, 'queue', $mode);
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | break;
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | switch ($mode)
|
|---|
| 72 | {
|
|---|
| 73 | case 'approve_details':
|
|---|
| 74 |
|
|---|
| 75 | $this->tpl_name = 'mcp_post';
|
|---|
| 76 |
|
|---|
| 77 | $user->add_lang(array('posting', 'viewtopic'));
|
|---|
| 78 |
|
|---|
| 79 | $post_id = request_var('p', 0);
|
|---|
| 80 | $topic_id = request_var('t', 0);
|
|---|
| 81 |
|
|---|
| 82 | if ($topic_id)
|
|---|
| 83 | {
|
|---|
| 84 | $topic_info = get_topic_data(array($topic_id), 'm_approve');
|
|---|
| 85 | if (isset($topic_info[$topic_id]['topic_first_post_id']))
|
|---|
| 86 | {
|
|---|
| 87 | $post_id = (int) $topic_info[$topic_id]['topic_first_post_id'];
|
|---|
| 88 | }
|
|---|
| 89 | else
|
|---|
| 90 | {
|
|---|
| 91 | $topic_id = 0;
|
|---|
| 92 | }
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | $post_info = get_post_data(array($post_id), 'm_approve', true);
|
|---|
| 96 |
|
|---|
| 97 | if (!sizeof($post_info))
|
|---|
| 98 | {
|
|---|
| 99 | trigger_error('NO_POST_SELECTED');
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | $post_info = $post_info[$post_id];
|
|---|
| 103 |
|
|---|
| 104 | if ($post_info['topic_first_post_id'] != $post_id && topic_review($post_info['topic_id'], $post_info['forum_id'], 'topic_review', 0, false))
|
|---|
| 105 | {
|
|---|
| 106 | $template->assign_vars(array(
|
|---|
| 107 | 'S_TOPIC_REVIEW' => true,
|
|---|
| 108 | 'S_BBCODE_ALLOWED' => $post_info['enable_bbcode'],
|
|---|
| 109 | 'TOPIC_TITLE' => $post_info['topic_title'])
|
|---|
| 110 | );
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | $extensions = $attachments = $topic_tracking_info = array();
|
|---|
| 114 |
|
|---|
| 115 | // Get topic tracking info
|
|---|
| 116 | if ($config['load_db_lastread'])
|
|---|
| 117 | {
|
|---|
| 118 | $tmp_topic_data = array($post_info['topic_id'] => $post_info);
|
|---|
| 119 | $topic_tracking_info = get_topic_tracking($post_info['forum_id'], $post_info['topic_id'], $tmp_topic_data, array($post_info['forum_id'] => $post_info['forum_mark_time']));
|
|---|
| 120 | unset($tmp_topic_data);
|
|---|
| 121 | }
|
|---|
| 122 | else
|
|---|
| 123 | {
|
|---|
| 124 | $topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']);
|
|---|
| 125 | }
|
|---|
| 126 |
|
|---|
| 127 | $post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false;
|
|---|
| 128 |
|
|---|
| 129 | // Process message, leave it uncensored
|
|---|
| 130 | $message = $post_info['post_text'];
|
|---|
| 131 |
|
|---|
| 132 | if ($post_info['bbcode_bitfield'])
|
|---|
| 133 | {
|
|---|
| 134 | include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
|
|---|
| 135 | $bbcode = new bbcode($post_info['bbcode_bitfield']);
|
|---|
| 136 | $bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']);
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 | $message = bbcode_nl2br($message);
|
|---|
| 140 | $message = smiley_text($message);
|
|---|
| 141 |
|
|---|
| 142 | if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id']))
|
|---|
| 143 | {
|
|---|
| 144 | $extensions = $cache->obtain_attach_extensions($post_info['forum_id']);
|
|---|
| 145 |
|
|---|
| 146 | $sql = 'SELECT *
|
|---|
| 147 | FROM ' . ATTACHMENTS_TABLE . '
|
|---|
| 148 | WHERE post_msg_id = ' . $post_id . '
|
|---|
| 149 | AND in_message = 0
|
|---|
| 150 | ORDER BY filetime DESC, post_msg_id ASC';
|
|---|
| 151 | $result = $db->sql_query($sql);
|
|---|
| 152 |
|
|---|
| 153 | while ($row = $db->sql_fetchrow($result))
|
|---|
| 154 | {
|
|---|
| 155 | $attachments[] = $row;
|
|---|
| 156 | }
|
|---|
| 157 | $db->sql_freeresult($result);
|
|---|
| 158 |
|
|---|
| 159 | if (sizeof($attachments))
|
|---|
| 160 | {
|
|---|
| 161 | $update_count = array();
|
|---|
| 162 | parse_attachments($post_info['forum_id'], $message, $attachments, $update_count);
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | // Display not already displayed Attachments for this post, we already parsed them. ;)
|
|---|
| 166 | if (!empty($attachments))
|
|---|
| 167 | {
|
|---|
| 168 | $template->assign_var('S_HAS_ATTACHMENTS', true);
|
|---|
| 169 |
|
|---|
| 170 | foreach ($attachments as $attachment)
|
|---|
| 171 | {
|
|---|
| 172 | $template->assign_block_vars('attachment', array(
|
|---|
| 173 | 'DISPLAY_ATTACHMENT' => $attachment)
|
|---|
| 174 | );
|
|---|
| 175 | }
|
|---|
| 176 | }
|
|---|
| 177 | }
|
|---|
| 178 |
|
|---|
| 179 | $post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']);
|
|---|
| 180 | $topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']);
|
|---|
| 181 |
|
|---|
| 182 | $template->assign_vars(array(
|
|---|
| 183 | 'S_MCP_QUEUE' => true,
|
|---|
| 184 | 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&p=$post_id&f=$forum_id"),
|
|---|
| 185 | 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']),
|
|---|
| 186 | 'S_POST_REPORTED' => $post_info['post_reported'],
|
|---|
| 187 | 'S_POST_UNAPPROVED' => !$post_info['post_approved'],
|
|---|
| 188 | 'S_POST_LOCKED' => $post_info['post_edit_locked'],
|
|---|
| 189 | 'S_USER_NOTES' => true,
|
|---|
| 190 |
|
|---|
| 191 | 'U_EDIT' => ($auth->acl_get('m_edit', $post_info['forum_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '',
|
|---|
| 192 | 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id),
|
|---|
| 193 | 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id),
|
|---|
| 194 | 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $post_info['user_id']),
|
|---|
| 195 | 'U_MCP_WARN_USER' => ($auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $post_info['user_id']) : '',
|
|---|
| 196 | 'U_VIEW_POST' => $post_url,
|
|---|
| 197 | 'U_VIEW_TOPIC' => $topic_url,
|
|---|
| 198 |
|
|---|
| 199 | 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'),
|
|---|
| 200 |
|
|---|
| 201 | 'RETURN_QUEUE' => sprintf($user->lang['RETURN_QUEUE'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue' . (($topic_id) ? '&mode=unapproved_topics' : '&mode=unapproved_posts')) . "&start=$start\">", '</a>'),
|
|---|
| 202 | 'RETURN_POST' => sprintf($user->lang['RETURN_POST'], '<a href="' . $post_url . '">', '</a>'),
|
|---|
| 203 | 'RETURN_TOPIC_SIMPLE' => sprintf($user->lang['RETURN_TOPIC_SIMPLE'], '<a href="' . $topic_url . '">', '</a>'),
|
|---|
| 204 | 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']),
|
|---|
| 205 | 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']),
|
|---|
| 206 | 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']),
|
|---|
| 207 |
|
|---|
| 208 | 'POST_AUTHOR_FULL' => get_username_string('full', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
|
|---|
| 209 | 'POST_AUTHOR_COLOUR' => get_username_string('colour', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
|
|---|
| 210 | 'POST_AUTHOR' => get_username_string('username', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
|
|---|
| 211 | 'U_POST_AUTHOR' => get_username_string('profile', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
|
|---|
| 212 |
|
|---|
| 213 | 'POST_PREVIEW' => $message,
|
|---|
| 214 | 'POST_SUBJECT' => $post_info['post_subject'],
|
|---|
| 215 | 'POST_DATE' => $user->format_date($post_info['post_time']),
|
|---|
| 216 | 'POST_IP' => $post_info['poster_ip'],
|
|---|
| 217 | 'POST_IPADDR' => ($auth->acl_get('m_info', $post_info['forum_id']) && request_var('lookup', '')) ? @gethostbyaddr($post_info['poster_ip']) : '',
|
|---|
| 218 | 'POST_ID' => $post_info['post_id'],
|
|---|
| 219 |
|
|---|
| 220 | 'U_LOOKUP_IP' => ($auth->acl_get('m_info', $post_info['forum_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id . '&lookup=' . $post_info['poster_ip']) . '#ip' : '',
|
|---|
| 221 | ));
|
|---|
| 222 |
|
|---|
| 223 | break;
|
|---|
| 224 |
|
|---|
| 225 | case 'unapproved_topics':
|
|---|
| 226 | case 'unapproved_posts':
|
|---|
| 227 | $user->add_lang(array('viewtopic', 'viewforum'));
|
|---|
| 228 |
|
|---|
| 229 | $topic_id = request_var('t', 0);
|
|---|
| 230 | $forum_info = array();
|
|---|
| 231 |
|
|---|
| 232 | if ($topic_id)
|
|---|
| 233 | {
|
|---|
| 234 | $topic_info = get_topic_data(array($topic_id));
|
|---|
| 235 |
|
|---|
| 236 | if (!sizeof($topic_info))
|
|---|
| 237 | {
|
|---|
| 238 | trigger_error('TOPIC_NOT_EXIST');
|
|---|
| 239 | }
|
|---|
| 240 |
|
|---|
| 241 | $topic_info = $topic_info[$topic_id];
|
|---|
| 242 | $forum_id = $topic_info['forum_id'];
|
|---|
| 243 | }
|
|---|
| 244 |
|
|---|
| 245 | $forum_list_approve = get_forum_list('m_approve', false, true);
|
|---|
| 246 | $forum_list_read = array_flip(get_forum_list('f_read', true, true)); // Flipped so we can isset() the forum IDs
|
|---|
| 247 |
|
|---|
| 248 | // Remove forums we cannot read
|
|---|
| 249 | foreach ($forum_list_approve as $k => $forum_data)
|
|---|
| 250 | {
|
|---|
| 251 | if (!isset($forum_list_read[$forum_data['forum_id']]))
|
|---|
| 252 | {
|
|---|
| 253 | unset($forum_list_approve[$k]);
|
|---|
| 254 | }
|
|---|
| 255 | }
|
|---|
| 256 | unset($forum_list_read);
|
|---|
| 257 |
|
|---|
| 258 | if (!$forum_id)
|
|---|
| 259 | {
|
|---|
| 260 | $forum_list = array();
|
|---|
| 261 | foreach ($forum_list_approve as $row)
|
|---|
| 262 | {
|
|---|
| 263 | $forum_list[] = $row['forum_id'];
|
|---|
| 264 | }
|
|---|
| 265 |
|
|---|
| 266 | if (!sizeof($forum_list))
|
|---|
| 267 | {
|
|---|
| 268 | trigger_error('NOT_MODERATOR');
|
|---|
| 269 | }
|
|---|
| 270 |
|
|---|
| 271 | $global_id = $forum_list[0];
|
|---|
| 272 |
|
|---|
| 273 | $forum_list = implode(', ', $forum_list);
|
|---|
| 274 |
|
|---|
| 275 | $sql = 'SELECT SUM(forum_topics) as sum_forum_topics
|
|---|
| 276 | FROM ' . FORUMS_TABLE . "
|
|---|
| 277 | WHERE forum_id IN (0, $forum_list)";
|
|---|
| 278 | $result = $db->sql_query($sql);
|
|---|
| 279 | $forum_info['forum_topics'] = (int) $db->sql_fetchfield('sum_forum_topics');
|
|---|
| 280 | $db->sql_freeresult($result);
|
|---|
| 281 | }
|
|---|
| 282 | else
|
|---|
| 283 | {
|
|---|
| 284 | $forum_info = get_forum_data(array($forum_id), 'm_approve');
|
|---|
| 285 |
|
|---|
| 286 | if (!sizeof($forum_info))
|
|---|
| 287 | {
|
|---|
| 288 | trigger_error('NOT_MODERATOR');
|
|---|
| 289 | }
|
|---|
| 290 |
|
|---|
| 291 | $forum_info = $forum_info[$forum_id];
|
|---|
| 292 | $forum_list = $forum_id;
|
|---|
| 293 | $global_id = $forum_id;
|
|---|
| 294 | }
|
|---|
| 295 |
|
|---|
| 296 | $forum_options = '<option value="0"' . (($forum_id == 0) ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>';
|
|---|
| 297 | foreach ($forum_list_approve as $row)
|
|---|
| 298 | {
|
|---|
| 299 | $forum_options .= '<option value="' . $row['forum_id'] . '"' . (($forum_id == $row['forum_id']) ? ' selected="selected"' : '') . '>' . str_repeat(' ', $row['padding']) . $row['forum_name'] . '</option>';
|
|---|
| 300 | }
|
|---|
| 301 |
|
|---|
| 302 | $sort_days = $total = 0;
|
|---|
| 303 | $sort_key = $sort_dir = '';
|
|---|
| 304 | $sort_by_sql = $sort_order_sql = array();
|
|---|
| 305 | mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id);
|
|---|
| 306 |
|
|---|
| 307 | $forum_topics = ($total == -1) ? $forum_info['forum_topics'] : $total;
|
|---|
| 308 | $limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : '';
|
|---|
| 309 |
|
|---|
| 310 | $forum_names = array();
|
|---|
| 311 |
|
|---|
| 312 | if ($mode == 'unapproved_posts')
|
|---|
| 313 | {
|
|---|
| 314 | $sql = 'SELECT p.post_id
|
|---|
| 315 | FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . "
|
|---|
| 316 | WHERE p.forum_id IN (0, $forum_list)
|
|---|
| 317 | AND p.post_approved = 0
|
|---|
| 318 | " . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . '
|
|---|
| 319 | ' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . "
|
|---|
| 320 | AND t.topic_id = p.topic_id
|
|---|
| 321 | AND t.topic_first_post_id <> p.post_id
|
|---|
| 322 | $limit_time_sql
|
|---|
| 323 | ORDER BY $sort_order_sql";
|
|---|
| 324 | $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
|
|---|
| 325 |
|
|---|
| 326 | $i = 0;
|
|---|
| 327 | $post_ids = array();
|
|---|
| 328 | while ($row = $db->sql_fetchrow($result))
|
|---|
| 329 | {
|
|---|
| 330 | $post_ids[] = $row['post_id'];
|
|---|
| 331 | $row_num[$row['post_id']] = $i++;
|
|---|
| 332 | }
|
|---|
| 333 | $db->sql_freeresult($result);
|
|---|
| 334 |
|
|---|
| 335 | if (sizeof($post_ids))
|
|---|
| 336 | {
|
|---|
| 337 | $sql = 'SELECT t.topic_id, t.topic_title, t.forum_id, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, u.username, u.username_clean, u.user_colour
|
|---|
| 338 | FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u
|
|---|
| 339 | WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . '
|
|---|
| 340 | AND t.topic_id = p.topic_id
|
|---|
| 341 | AND u.user_id = p.poster_id
|
|---|
| 342 | ORDER BY ' . $sort_order_sql;
|
|---|
| 343 | $result = $db->sql_query($sql);
|
|---|
| 344 |
|
|---|
| 345 | $post_data = $rowset = array();
|
|---|
| 346 | while ($row = $db->sql_fetchrow($result))
|
|---|
| 347 | {
|
|---|
| 348 | if ($row['forum_id'])
|
|---|
| 349 | {
|
|---|
| 350 | $forum_names[] = $row['forum_id'];
|
|---|
| 351 | }
|
|---|
| 352 | $post_data[$row['post_id']] = $row;
|
|---|
| 353 | }
|
|---|
| 354 | $db->sql_freeresult($result);
|
|---|
| 355 |
|
|---|
| 356 | foreach ($post_ids as $post_id)
|
|---|
| 357 | {
|
|---|
| 358 | $rowset[] = $post_data[$post_id];
|
|---|
| 359 | }
|
|---|
| 360 | unset($post_data, $post_ids);
|
|---|
| 361 | }
|
|---|
| 362 | else
|
|---|
| 363 | {
|
|---|
| 364 | $rowset = array();
|
|---|
| 365 | }
|
|---|
| 366 | }
|
|---|
| 367 | else
|
|---|
| 368 | {
|
|---|
| 369 | $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, t.topic_title AS post_subject, t.topic_time AS post_time, t.topic_poster AS poster_id, t.topic_first_post_id AS post_id, t.topic_first_poster_name AS username, t.topic_first_poster_colour AS user_colour
|
|---|
| 370 | FROM ' . TOPICS_TABLE . " t
|
|---|
| 371 | WHERE forum_id IN (0, $forum_list)
|
|---|
| 372 | AND topic_approved = 0
|
|---|
| 373 | $limit_time_sql
|
|---|
| 374 | ORDER BY $sort_order_sql";
|
|---|
| 375 | $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
|
|---|
| 376 |
|
|---|
| 377 | $rowset = array();
|
|---|
| 378 | while ($row = $db->sql_fetchrow($result))
|
|---|
| 379 | {
|
|---|
| 380 | if ($row['forum_id'])
|
|---|
| 381 | {
|
|---|
| 382 | $forum_names[] = $row['forum_id'];
|
|---|
| 383 | }
|
|---|
| 384 | $rowset[] = $row;
|
|---|
| 385 | }
|
|---|
| 386 | $db->sql_freeresult($result);
|
|---|
| 387 | }
|
|---|
| 388 |
|
|---|
| 389 | if (sizeof($forum_names))
|
|---|
| 390 | {
|
|---|
| 391 | // Select the names for the forum_ids
|
|---|
| 392 | $sql = 'SELECT forum_id, forum_name
|
|---|
| 393 | FROM ' . FORUMS_TABLE . '
|
|---|
| 394 | WHERE ' . $db->sql_in_set('forum_id', $forum_names);
|
|---|
| 395 | $result = $db->sql_query($sql, 3600);
|
|---|
| 396 |
|
|---|
| 397 | $forum_names = array();
|
|---|
| 398 | while ($row = $db->sql_fetchrow($result))
|
|---|
| 399 | {
|
|---|
| 400 | $forum_names[$row['forum_id']] = $row['forum_name'];
|
|---|
| 401 | }
|
|---|
| 402 | $db->sql_freeresult($result);
|
|---|
| 403 | }
|
|---|
| 404 |
|
|---|
| 405 | foreach ($rowset as $row)
|
|---|
| 406 | {
|
|---|
| 407 | $global_topic = ($row['forum_id']) ? false : true;
|
|---|
| 408 | if ($global_topic)
|
|---|
| 409 | {
|
|---|
| 410 | $row['forum_id'] = $global_id;
|
|---|
| 411 | }
|
|---|
| 412 |
|
|---|
| 413 | if (empty($row['post_username']))
|
|---|
| 414 | {
|
|---|
| 415 | $row['post_username'] = $user->lang['GUEST'];
|
|---|
| 416 | }
|
|---|
| 417 |
|
|---|
| 418 | $template->assign_block_vars('postrow', array(
|
|---|
| 419 | 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']),
|
|---|
| 420 | 'U_VIEWFORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '',
|
|---|
| 421 | 'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . (($mode == 'unapproved_posts') ? '#p' . $row['post_id'] : ''),
|
|---|
| 422 | 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&start=$start&mode=approve_details&f={$row['forum_id']}&p={$row['post_id']}" . (($mode == 'unapproved_topics') ? "&t={$row['topic_id']}" : '')),
|
|---|
| 423 |
|
|---|
| 424 | 'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
|---|
| 425 | 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
|---|
| 426 | 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
|---|
| 427 | 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
|---|
| 428 |
|
|---|
| 429 | 'POST_ID' => $row['post_id'],
|
|---|
| 430 | 'FORUM_NAME' => (!$global_topic) ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'],
|
|---|
| 431 | 'POST_SUBJECT' => $row['post_subject'],
|
|---|
| 432 | 'TOPIC_TITLE' => $row['topic_title'],
|
|---|
| 433 | 'POST_TIME' => $user->format_date($row['post_time']))
|
|---|
| 434 | );
|
|---|
| 435 | }
|
|---|
| 436 | unset($rowset, $forum_names);
|
|---|
| 437 |
|
|---|
| 438 | // Now display the page
|
|---|
| 439 | $template->assign_vars(array(
|
|---|
| 440 | 'L_DISPLAY_ITEMS' => ($mode == 'unapproved_posts') ? $user->lang['DISPLAY_POSTS'] : $user->lang['DISPLAY_TOPICS'],
|
|---|
| 441 | 'L_EXPLAIN' => ($mode == 'unapproved_posts') ? $user->lang['MCP_QUEUE_UNAPPROVED_POSTS_EXPLAIN'] : $user->lang['MCP_QUEUE_UNAPPROVED_TOPICS_EXPLAIN'],
|
|---|
| 442 | 'L_TITLE' => ($mode == 'unapproved_posts') ? $user->lang['MCP_QUEUE_UNAPPROVED_POSTS'] : $user->lang['MCP_QUEUE_UNAPPROVED_TOPICS'],
|
|---|
| 443 | 'L_ONLY_TOPIC' => ($topic_id) ? sprintf($user->lang['ONLY_TOPIC'], $topic_info['topic_title']) : '',
|
|---|
| 444 |
|
|---|
| 445 | 'S_FORUM_OPTIONS' => $forum_options,
|
|---|
| 446 | 'S_MCP_ACTION' => build_url(array('t', 'f', 'sd', 'st', 'sk')),
|
|---|
| 447 | 'S_TOPICS' => ($mode == 'unapproved_posts') ? false : true,
|
|---|
| 448 |
|
|---|
| 449 | 'PAGINATION' => generate_pagination($this->u_action . "&f=$forum_id&st=$sort_days&sk=$sort_key&sd=$sort_dir", $total, $config['topics_per_page'], $start),
|
|---|
| 450 | 'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start),
|
|---|
| 451 | 'TOPIC_ID' => $topic_id,
|
|---|
| 452 | 'TOTAL' => ($total == 1) ? (($mode == 'unapproved_posts') ? $user->lang['VIEW_TOPIC_POST'] : $user->lang['VIEW_FORUM_TOPIC']) : sprintf((($mode == 'unapproved_posts') ? $user->lang['VIEW_TOPIC_POSTS'] : $user->lang['VIEW_FORUM_TOPICS']), $total),
|
|---|
| 453 | ));
|
|---|
| 454 |
|
|---|
| 455 | $this->tpl_name = 'mcp_queue';
|
|---|
| 456 | break;
|
|---|
| 457 | }
|
|---|
| 458 | }
|
|---|
| 459 | }
|
|---|
| 460 |
|
|---|
| 461 | /**
|
|---|
| 462 | * Approve Post/Topic
|
|---|
| 463 | */
|
|---|
| 464 | function approve_post($post_id_list, $id, $mode)
|
|---|
| 465 | {
|
|---|
| 466 | global $db, $template, $user, $config;
|
|---|
| 467 | global $phpEx, $phpbb_root_path;
|
|---|
| 468 |
|
|---|
| 469 | if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve')))
|
|---|
| 470 | {
|
|---|
| 471 | trigger_error('NOT_AUTHORISED');
|
|---|
| 472 | }
|
|---|
| 473 |
|
|---|
| 474 | $redirect = request_var('redirect', build_url(array('quickmod')));
|
|---|
| 475 | $success_msg = '';
|
|---|
| 476 |
|
|---|
| 477 | $s_hidden_fields = build_hidden_fields(array(
|
|---|
| 478 | 'i' => $id,
|
|---|
| 479 | 'mode' => $mode,
|
|---|
| 480 | 'post_id_list' => $post_id_list,
|
|---|
| 481 | 'action' => 'approve',
|
|---|
| 482 | 'redirect' => $redirect)
|
|---|
| 483 | );
|
|---|
| 484 |
|
|---|
| 485 | $post_info = get_post_data($post_id_list, 'm_approve');
|
|---|
| 486 |
|
|---|
| 487 | if (confirm_box(true))
|
|---|
| 488 | {
|
|---|
| 489 | $notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false;
|
|---|
| 490 |
|
|---|
| 491 | // If Topic -> total_topics = total_topics+1, total_posts = total_posts+1, forum_topics = forum_topics+1, forum_posts = forum_posts+1
|
|---|
| 492 | // If Post -> total_posts = total_posts+1, forum_posts = forum_posts+1, topic_replies = topic_replies+1
|
|---|
| 493 |
|
|---|
| 494 | $total_topics = $total_posts = 0;
|
|---|
| 495 | $topic_approve_sql = $post_approve_sql = $topic_id_list = $forum_id_list = $approve_log = array();
|
|---|
| 496 | $user_posts_sql = $post_approved_list = array();
|
|---|
| 497 |
|
|---|
| 498 | foreach ($post_info as $post_id => $post_data)
|
|---|
| 499 | {
|
|---|
| 500 | if ($post_data['post_approved'])
|
|---|
| 501 | {
|
|---|
| 502 | $post_approved_list[] = $post_id;
|
|---|
| 503 | continue;
|
|---|
| 504 | }
|
|---|
| 505 |
|
|---|
| 506 | $topic_id_list[$post_data['topic_id']] = 1;
|
|---|
| 507 |
|
|---|
| 508 | if ($post_data['forum_id'])
|
|---|
| 509 | {
|
|---|
| 510 | $forum_id_list[$post_data['forum_id']] = 1;
|
|---|
| 511 | }
|
|---|
| 512 |
|
|---|
| 513 | // User post update (we do not care about topic or post, since user posts are strictly connected to posts)
|
|---|
| 514 | // But we care about forums where post counts get not increased. ;)
|
|---|
| 515 | if ($post_data['post_postcount'])
|
|---|
| 516 | {
|
|---|
| 517 | $user_posts_sql[$post_data['poster_id']] = (empty($user_posts_sql[$post_data['poster_id']])) ? 1 : $user_posts_sql[$post_data['poster_id']] + 1;
|
|---|
| 518 | }
|
|---|
| 519 |
|
|---|
| 520 | // Topic or Post. ;)
|
|---|
| 521 | if ($post_data['topic_first_post_id'] == $post_id)
|
|---|
| 522 | {
|
|---|
| 523 | if ($post_data['forum_id'])
|
|---|
| 524 | {
|
|---|
| 525 | $total_topics++;
|
|---|
| 526 | }
|
|---|
| 527 | $topic_approve_sql[] = $post_data['topic_id'];
|
|---|
| 528 |
|
|---|
| 529 | $approve_log[] = array(
|
|---|
| 530 | 'type' => 'topic',
|
|---|
| 531 | 'post_subject' => $post_data['post_subject'],
|
|---|
| 532 | 'forum_id' => $post_data['forum_id'],
|
|---|
| 533 | 'topic_id' => $post_data['topic_id'],
|
|---|
| 534 | );
|
|---|
| 535 | }
|
|---|
| 536 | else
|
|---|
| 537 | {
|
|---|
| 538 | $approve_log[] = array(
|
|---|
| 539 | 'type' => 'post',
|
|---|
| 540 | 'post_subject' => $post_data['post_subject'],
|
|---|
| 541 | 'forum_id' => $post_data['forum_id'],
|
|---|
| 542 | 'topic_id' => $post_data['topic_id'],
|
|---|
| 543 | );
|
|---|
| 544 | }
|
|---|
| 545 |
|
|---|
| 546 | if ($post_data['forum_id'])
|
|---|
| 547 | {
|
|---|
| 548 | $total_posts++;
|
|---|
| 549 |
|
|---|
| 550 | // Increment by topic_replies if we approve a topic...
|
|---|
| 551 | // This works because we do not adjust the topic_replies when re-approving a topic after an edit.
|
|---|
| 552 | if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_replies'])
|
|---|
| 553 | {
|
|---|
| 554 | $total_posts += $post_data['topic_replies'];
|
|---|
| 555 | }
|
|---|
| 556 | }
|
|---|
| 557 |
|
|---|
| 558 | $post_approve_sql[] = $post_id;
|
|---|
| 559 | }
|
|---|
| 560 |
|
|---|
| 561 | $post_id_list = array_values(array_diff($post_id_list, $post_approved_list));
|
|---|
| 562 | for ($i = 0, $size = sizeof($post_approved_list); $i < $size; $i++)
|
|---|
| 563 | {
|
|---|
| 564 | unset($post_info[$post_approved_list[$i]]);
|
|---|
| 565 | }
|
|---|
| 566 |
|
|---|
| 567 | if (sizeof($topic_approve_sql))
|
|---|
| 568 | {
|
|---|
| 569 | $sql = 'UPDATE ' . TOPICS_TABLE . '
|
|---|
| 570 | SET topic_approved = 1
|
|---|
| 571 | WHERE ' . $db->sql_in_set('topic_id', $topic_approve_sql);
|
|---|
| 572 | $db->sql_query($sql);
|
|---|
| 573 | }
|
|---|
| 574 |
|
|---|
| 575 | if (sizeof($post_approve_sql))
|
|---|
| 576 | {
|
|---|
| 577 | $sql = 'UPDATE ' . POSTS_TABLE . '
|
|---|
| 578 | SET post_approved = 1
|
|---|
| 579 | WHERE ' . $db->sql_in_set('post_id', $post_approve_sql);
|
|---|
| 580 | $db->sql_query($sql);
|
|---|
| 581 | }
|
|---|
| 582 |
|
|---|
| 583 | unset($topic_approve_sql, $post_approve_sql);
|
|---|
| 584 |
|
|---|
| 585 | foreach ($approve_log as $log_data)
|
|---|
| 586 | {
|
|---|
| 587 | add_log('mod', $log_data['forum_id'], $log_data['topic_id'], ($log_data['type'] == 'topic') ? 'LOG_TOPIC_APPROVED' : 'LOG_POST_APPROVED', $log_data['post_subject']);
|
|---|
| 588 | }
|
|---|
| 589 |
|
|---|
| 590 | if (sizeof($user_posts_sql))
|
|---|
| 591 | {
|
|---|
| 592 | // Try to minimize the query count by merging users with the same post count additions
|
|---|
| 593 | $user_posts_update = array();
|
|---|
| 594 |
|
|---|
| 595 | foreach ($user_posts_sql as $user_id => $user_posts)
|
|---|
| 596 | {
|
|---|
| 597 | $user_posts_update[$user_posts][] = $user_id;
|
|---|
| 598 | }
|
|---|
| 599 |
|
|---|
| 600 | foreach ($user_posts_update as $user_posts => $user_id_ary)
|
|---|
| 601 | {
|
|---|
| 602 | $sql = 'UPDATE ' . USERS_TABLE . '
|
|---|
| 603 | SET user_posts = user_posts + ' . $user_posts . '
|
|---|
| 604 | WHERE ' . $db->sql_in_set('user_id', $user_id_ary);
|
|---|
| 605 | $db->sql_query($sql);
|
|---|
| 606 | }
|
|---|
| 607 | }
|
|---|
| 608 |
|
|---|
| 609 | if ($total_topics)
|
|---|
| 610 | {
|
|---|
| 611 | set_config_count('num_topics', $total_topics, true);
|
|---|
| 612 | }
|
|---|
| 613 |
|
|---|
| 614 | if ($total_posts)
|
|---|
| 615 | {
|
|---|
| 616 | set_config_count('num_posts', $total_posts, true);
|
|---|
| 617 | }
|
|---|
| 618 |
|
|---|
| 619 | sync('topic', 'topic_id', array_keys($topic_id_list), true);
|
|---|
| 620 | sync('forum', 'forum_id', array_keys($forum_id_list), true, true);
|
|---|
| 621 | unset($topic_id_list, $forum_id_list);
|
|---|
| 622 |
|
|---|
| 623 | $messenger = new messenger();
|
|---|
| 624 |
|
|---|
| 625 | // Notify Poster?
|
|---|
| 626 | if ($notify_poster)
|
|---|
| 627 | {
|
|---|
| 628 | foreach ($post_info as $post_id => $post_data)
|
|---|
| 629 | {
|
|---|
| 630 | if ($post_data['poster_id'] == ANONYMOUS)
|
|---|
| 631 | {
|
|---|
| 632 | continue;
|
|---|
| 633 | }
|
|---|
| 634 |
|
|---|
| 635 | $email_template = ($post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id']) ? 'topic_approved' : 'post_approved';
|
|---|
| 636 |
|
|---|
| 637 | $messenger->template($email_template, $post_data['user_lang']);
|
|---|
| 638 |
|
|---|
| 639 | $messenger->to($post_data['user_email'], $post_data['username']);
|
|---|
| 640 | $messenger->im($post_data['user_jabber'], $post_data['username']);
|
|---|
| 641 |
|
|---|
| 642 | $messenger->assign_vars(array(
|
|---|
| 643 | 'USERNAME' => htmlspecialchars_decode($post_data['username']),
|
|---|
| 644 | 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_data['post_subject'])),
|
|---|
| 645 | 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_data['topic_title'])),
|
|---|
| 646 |
|
|---|
| 647 | 'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f={$post_data['forum_id']}&t={$post_data['topic_id']}&e=0",
|
|---|
| 648 | 'U_VIEW_POST' => generate_board_url() . "/viewtopic.$phpEx?f={$post_data['forum_id']}&t={$post_data['topic_id']}&p=$post_id&e=$post_id")
|
|---|
| 649 | );
|
|---|
| 650 |
|
|---|
| 651 | $messenger->send($post_data['user_notify_type']);
|
|---|
| 652 | }
|
|---|
| 653 | }
|
|---|
| 654 |
|
|---|
| 655 | $messenger->save_queue();
|
|---|
| 656 |
|
|---|
| 657 | // Send out normal user notifications
|
|---|
| 658 | $email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
|
|---|
| 659 |
|
|---|
| 660 | foreach ($post_info as $post_id => $post_data)
|
|---|
| 661 | {
|
|---|
| 662 | if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id'])
|
|---|
| 663 | {
|
|---|
| 664 | // Forum Notifications
|
|---|
| 665 | user_notification('post', $post_data['topic_title'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id);
|
|---|
| 666 | }
|
|---|
| 667 | else
|
|---|
| 668 | {
|
|---|
| 669 | // Topic Notifications
|
|---|
| 670 | user_notification('reply', $post_data['post_subject'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id);
|
|---|
| 671 | }
|
|---|
| 672 | }
|
|---|
| 673 |
|
|---|
| 674 | if (sizeof($post_id_list) == 1)
|
|---|
| 675 | {
|
|---|
| 676 | $post_data = $post_info[$post_id_list[0]];
|
|---|
| 677 | $post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$post_data['forum_id']}&t={$post_data['topic_id']}&p={$post_data['post_id']}") . '#p' . $post_data['post_id'];
|
|---|
| 678 | }
|
|---|
| 679 | unset($post_info);
|
|---|
| 680 |
|
|---|
| 681 | if ($total_topics)
|
|---|
| 682 | {
|
|---|
| 683 | $success_msg = ($total_topics == 1) ? 'TOPIC_APPROVED_SUCCESS' : 'TOPICS_APPROVED_SUCCESS';
|
|---|
| 684 | }
|
|---|
| 685 | else
|
|---|
| 686 | {
|
|---|
| 687 | $success_msg = (sizeof($post_id_list) + sizeof($post_approved_list) == 1) ? 'POST_APPROVED_SUCCESS' : 'POSTS_APPROVED_SUCCESS';
|
|---|
| 688 | }
|
|---|
| 689 | }
|
|---|
| 690 | else
|
|---|
| 691 | {
|
|---|
| 692 | $show_notify = false;
|
|---|
| 693 |
|
|---|
| 694 | foreach ($post_info as $post_data)
|
|---|
| 695 | {
|
|---|
| 696 | if ($post_data['poster_id'] == ANONYMOUS)
|
|---|
| 697 | {
|
|---|
| 698 | continue;
|
|---|
| 699 | }
|
|---|
| 700 | else
|
|---|
| 701 | {
|
|---|
| 702 | $show_notify = true;
|
|---|
| 703 | break;
|
|---|
| 704 | }
|
|---|
| 705 | }
|
|---|
| 706 |
|
|---|
| 707 | $template->assign_vars(array(
|
|---|
| 708 | 'S_NOTIFY_POSTER' => $show_notify,
|
|---|
| 709 | 'S_APPROVE' => true)
|
|---|
| 710 | );
|
|---|
| 711 |
|
|---|
| 712 | confirm_box(false, 'APPROVE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html');
|
|---|
| 713 | }
|
|---|
| 714 |
|
|---|
| 715 | $redirect = request_var('redirect', "index.$phpEx");
|
|---|
| 716 | $redirect = reapply_sid($redirect);
|
|---|
| 717 |
|
|---|
| 718 | if (!$success_msg)
|
|---|
| 719 | {
|
|---|
| 720 | redirect($redirect);
|
|---|
| 721 | }
|
|---|
| 722 | else
|
|---|
| 723 | {
|
|---|
| 724 | meta_refresh(3, $redirect);
|
|---|
| 725 |
|
|---|
| 726 | // If approving one post, also give links back to post...
|
|---|
| 727 | $add_message = '';
|
|---|
| 728 | if (sizeof($post_id_list) == 1 && !empty($post_url))
|
|---|
| 729 | {
|
|---|
| 730 | $add_message = '<br /><br />' . sprintf($user->lang['RETURN_POST'], '<a href="' . $post_url . '">', '</a>');
|
|---|
| 731 | }
|
|---|
| 732 |
|
|---|
| 733 | trigger_error($user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], "<a href=\"$redirect\">", '</a>') . $add_message);
|
|---|
| 734 | }
|
|---|
| 735 | }
|
|---|
| 736 |
|
|---|
| 737 | /**
|
|---|
| 738 | * Disapprove Post/Topic
|
|---|
| 739 | */
|
|---|
| 740 | function disapprove_post($post_id_list, $id, $mode)
|
|---|
| 741 | {
|
|---|
| 742 | global $db, $template, $user, $config;
|
|---|
| 743 | global $phpEx, $phpbb_root_path;
|
|---|
| 744 |
|
|---|
| 745 | if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve')))
|
|---|
| 746 | {
|
|---|
| 747 | trigger_error('NOT_AUTHORISED');
|
|---|
| 748 | }
|
|---|
| 749 |
|
|---|
| 750 | $redirect = request_var('redirect', build_url(array('t', 'mode', 'quickmod')) . "&mode=$mode");
|
|---|
| 751 | $reason = utf8_normalize_nfc(request_var('reason', '', true));
|
|---|
| 752 | $reason_id = request_var('reason_id', 0);
|
|---|
| 753 | $success_msg = $additional_msg = '';
|
|---|
| 754 |
|
|---|
| 755 | $s_hidden_fields = build_hidden_fields(array(
|
|---|
| 756 | 'i' => $id,
|
|---|
| 757 | 'mode' => $mode,
|
|---|
| 758 | 'post_id_list' => $post_id_list,
|
|---|
| 759 | 'action' => 'disapprove',
|
|---|
| 760 | 'redirect' => $redirect)
|
|---|
| 761 | );
|
|---|
| 762 |
|
|---|
| 763 | $notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false;
|
|---|
| 764 | $disapprove_reason = '';
|
|---|
| 765 |
|
|---|
| 766 | if ($reason_id)
|
|---|
| 767 | {
|
|---|
| 768 | $sql = 'SELECT reason_title, reason_description
|
|---|
| 769 | FROM ' . REPORTS_REASONS_TABLE . "
|
|---|
| 770 | WHERE reason_id = $reason_id";
|
|---|
| 771 | $result = $db->sql_query($sql);
|
|---|
| 772 | $row = $db->sql_fetchrow($result);
|
|---|
| 773 | $db->sql_freeresult($result);
|
|---|
| 774 |
|
|---|
| 775 | if (!$row || (!$reason && strtolower($row['reason_title']) == 'other'))
|
|---|
| 776 | {
|
|---|
| 777 | $additional_msg = $user->lang['NO_REASON_DISAPPROVAL'];
|
|---|
| 778 | unset($_POST['confirm']);
|
|---|
| 779 | }
|
|---|
| 780 | else
|
|---|
| 781 | {
|
|---|
| 782 | // If the reason is defined within the language file, we will use the localized version, else just use the database entry...
|
|---|
| 783 | $disapprove_reason = (strtolower($row['reason_title']) != 'other') ? ((isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])])) ? $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])] : $row['reason_description']) : '';
|
|---|
| 784 | $disapprove_reason .= ($reason) ? "\n\n" . $reason : '';
|
|---|
| 785 |
|
|---|
| 786 | if (isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]))
|
|---|
| 787 | {
|
|---|
| 788 | $disapprove_reason_lang = strtoupper($row['reason_title']);
|
|---|
| 789 | }
|
|---|
| 790 |
|
|---|
| 791 | $email_disapprove_reason = $disapprove_reason;
|
|---|
| 792 | }
|
|---|
| 793 | }
|
|---|
| 794 |
|
|---|
| 795 | $post_info = get_post_data($post_id_list, 'm_approve');
|
|---|
| 796 |
|
|---|
| 797 | if (confirm_box(true))
|
|---|
| 798 | {
|
|---|
| 799 | $disapprove_log = $disapprove_log_topics = $disapprove_log_posts = array();
|
|---|
| 800 | $topic_replies_real = $post_disapprove_list = array();
|
|---|
| 801 |
|
|---|
| 802 | // Build a list of posts to be unapproved and get the related topics real replies count
|
|---|
| 803 | foreach ($post_info as $post_id => $post_data)
|
|---|
| 804 | {
|
|---|
| 805 | $post_disapprove_list[$post_id] = $post_data['topic_id'];
|
|---|
| 806 | if (!isset($topic_replies_real[$post_data['topic_id']]))
|
|---|
| 807 | {
|
|---|
| 808 | $topic_replies_real[$post_data['topic_id']] = $post_data['topic_replies_real'];
|
|---|
| 809 | }
|
|---|
| 810 | }
|
|---|
| 811 |
|
|---|
| 812 | // Now we build the log array
|
|---|
| 813 | foreach ($post_disapprove_list as $post_id => $topic_id)
|
|---|
| 814 | {
|
|---|
| 815 | // If the count of disapproved posts for the topic is greater
|
|---|
| 816 | // than topic's real replies count, the whole topic is disapproved/deleted
|
|---|
| 817 | if (sizeof(array_keys($post_disapprove_list, $topic_id)) > $topic_replies_real[$topic_id])
|
|---|
| 818 | {
|
|---|
| 819 | // Don't write the log more than once for every topic
|
|---|
| 820 | if (!isset($disapprove_log_topics[$topic_id]))
|
|---|
| 821 | {
|
|---|
| 822 | // Build disapproved topics log
|
|---|
| 823 | $disapprove_log_topics[$topic_id] = array(
|
|---|
| 824 | 'type' => 'topic',
|
|---|
| 825 | 'post_subject' => $post_info[$post_id]['topic_title'],
|
|---|
| 826 | 'forum_id' => $post_info[$post_id]['forum_id'],
|
|---|
| 827 | 'topic_id' => 0, // useless to log a topic id, as it will be deleted
|
|---|
| 828 | );
|
|---|
| 829 | }
|
|---|
| 830 | }
|
|---|
| 831 | else
|
|---|
| 832 | {
|
|---|
| 833 | // Build disapproved posts log
|
|---|
| 834 | $disapprove_log_posts[] = array(
|
|---|
| 835 | 'type' => 'post',
|
|---|
| 836 | 'post_subject' => $post_info[$post_id]['post_subject'],
|
|---|
| 837 | 'forum_id' => $post_info[$post_id]['forum_id'],
|
|---|
| 838 | 'topic_id' => $post_info[$post_id]['topic_id'],
|
|---|
| 839 | );
|
|---|
| 840 |
|
|---|
| 841 | }
|
|---|
| 842 | }
|
|---|
| 843 |
|
|---|
| 844 | // Get disapproved posts/topics counts separately
|
|---|
| 845 | $num_disapproved_topics = sizeof($disapprove_log_topics);
|
|---|
| 846 | $num_disapproved_posts = sizeof($disapprove_log_posts);
|
|---|
| 847 |
|
|---|
| 848 | // Build the whole log
|
|---|
| 849 | $disapprove_log = array_merge($disapprove_log_topics, $disapprove_log_posts);
|
|---|
| 850 |
|
|---|
| 851 | // Unset unneeded arrays
|
|---|
| 852 | unset($post_data, $disapprove_log_topics, $disapprove_log_posts);
|
|---|
| 853 |
|
|---|
| 854 | // Let's do the job - delete disapproved posts
|
|---|
| 855 | if (sizeof($post_disapprove_list))
|
|---|
| 856 | {
|
|---|
| 857 | if (!function_exists('delete_posts'))
|
|---|
| 858 | {
|
|---|
| 859 | include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
|
|---|
| 860 | }
|
|---|
| 861 |
|
|---|
| 862 | // We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts
|
|---|
| 863 | // Note: function delete_posts triggers related forums/topics sync,
|
|---|
| 864 | // so we don't need to call update_post_information later and to adjust real topic replies or forum topics count manually
|
|---|
| 865 | delete_posts('post_id', array_keys($post_disapprove_list));
|
|---|
| 866 |
|
|---|
| 867 | foreach ($disapprove_log as $log_data)
|
|---|
| 868 | {
|
|---|
| 869 | add_log('mod', $log_data['forum_id'], $log_data['topic_id'], ($log_data['type'] == 'topic') ? 'LOG_TOPIC_DISAPPROVED' : 'LOG_POST_DISAPPROVED', $log_data['post_subject'], $disapprove_reason);
|
|---|
| 870 | }
|
|---|
| 871 | }
|
|---|
| 872 |
|
|---|
| 873 | $messenger = new messenger();
|
|---|
| 874 |
|
|---|
| 875 | // Notify Poster?
|
|---|
| 876 | if ($notify_poster)
|
|---|
| 877 | {
|
|---|
| 878 | $lang_reasons = array();
|
|---|
| 879 |
|
|---|
| 880 | foreach ($post_info as $post_id => $post_data)
|
|---|
| 881 | {
|
|---|
| 882 | if ($post_data['poster_id'] == ANONYMOUS)
|
|---|
| 883 | {
|
|---|
| 884 | continue;
|
|---|
| 885 | }
|
|---|
| 886 |
|
|---|
| 887 | if (isset($disapprove_reason_lang))
|
|---|
| 888 | {
|
|---|
| 889 | // Okay we need to get the reason from the posters language
|
|---|
| 890 | if (!isset($lang_reasons[$post_data['user_lang']]))
|
|---|
| 891 | {
|
|---|
| 892 | // Assign the current users translation as the default, this is not ideal but getting the board default adds another layer of complexity.
|
|---|
| 893 | $lang_reasons[$post_data['user_lang']] = $user->lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang];
|
|---|
| 894 |
|
|---|
| 895 | // Only load up the language pack if the language is different to the current one
|
|---|
| 896 | if ($post_data['user_lang'] != $user->lang_name && file_exists($phpbb_root_path . '/language/' . $post_data['user_lang'] . '/mcp.' . $phpEx))
|
|---|
| 897 | {
|
|---|
| 898 | // Load up the language pack
|
|---|
| 899 | $lang = array();
|
|---|
| 900 | @include($phpbb_root_path . '/language/' . basename($post_data['user_lang']) . '/mcp.' . $phpEx);
|
|---|
| 901 |
|
|---|
| 902 | // If we find the reason in this language pack use it
|
|---|
| 903 | if (isset($lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang]))
|
|---|
| 904 | {
|
|---|
| 905 | $lang_reasons[$post_data['user_lang']] = $lang['report_reasons']['DESCRIPTION'][$disapprove_reason_lang];
|
|---|
| 906 | }
|
|---|
| 907 |
|
|---|
| 908 | unset($lang); // Free memory
|
|---|
| 909 | }
|
|---|
| 910 | }
|
|---|
| 911 |
|
|---|
| 912 | $email_disapprove_reason = $lang_reasons[$post_data['user_lang']];
|
|---|
| 913 | $email_disapprove_reason .= ($reason) ? "\n\n" . $reason : '';
|
|---|
| 914 | }
|
|---|
| 915 |
|
|---|
| 916 | $email_template = ($post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id']) ? 'topic_disapproved' : 'post_disapproved';
|
|---|
| 917 |
|
|---|
| 918 | $messenger->template($email_template, $post_data['user_lang']);
|
|---|
| 919 |
|
|---|
| 920 | $messenger->to($post_data['user_email'], $post_data['username']);
|
|---|
| 921 | $messenger->im($post_data['user_jabber'], $post_data['username']);
|
|---|
| 922 |
|
|---|
| 923 | $messenger->assign_vars(array(
|
|---|
| 924 | 'USERNAME' => htmlspecialchars_decode($post_data['username']),
|
|---|
| 925 | 'REASON' => htmlspecialchars_decode($email_disapprove_reason),
|
|---|
| 926 | 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_data['post_subject'])),
|
|---|
| 927 | 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_data['topic_title'])))
|
|---|
| 928 | );
|
|---|
| 929 |
|
|---|
| 930 | $messenger->send($post_data['user_notify_type']);
|
|---|
| 931 | }
|
|---|
| 932 |
|
|---|
| 933 | unset($lang_reasons);
|
|---|
| 934 | }
|
|---|
| 935 | unset($post_info, $disapprove_reason, $email_disapprove_reason, $disapprove_reason_lang);
|
|---|
| 936 |
|
|---|
| 937 | $messenger->save_queue();
|
|---|
| 938 |
|
|---|
| 939 | if ($num_disapproved_topics)
|
|---|
| 940 | {
|
|---|
| 941 | $success_msg = ($num_disapproved_topics == 1) ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS';
|
|---|
| 942 | }
|
|---|
| 943 | else
|
|---|
| 944 | {
|
|---|
| 945 | $success_msg = ($num_disapproved_posts == 1) ? 'POST_DISAPPROVED_SUCCESS' : 'POSTS_DISAPPROVED_SUCCESS';
|
|---|
| 946 | }
|
|---|
| 947 | }
|
|---|
| 948 | else
|
|---|
| 949 | {
|
|---|
| 950 | include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
|---|
| 951 |
|
|---|
| 952 | display_reasons($reason_id);
|
|---|
| 953 |
|
|---|
| 954 | $show_notify = false;
|
|---|
| 955 |
|
|---|
| 956 | foreach ($post_info as $post_data)
|
|---|
| 957 | {
|
|---|
| 958 | if ($post_data['poster_id'] == ANONYMOUS)
|
|---|
| 959 | {
|
|---|
| 960 | continue;
|
|---|
| 961 | }
|
|---|
| 962 | else
|
|---|
| 963 | {
|
|---|
| 964 | $show_notify = true;
|
|---|
| 965 | break;
|
|---|
| 966 | }
|
|---|
| 967 | }
|
|---|
| 968 |
|
|---|
| 969 | $template->assign_vars(array(
|
|---|
| 970 | 'S_NOTIFY_POSTER' => $show_notify,
|
|---|
| 971 | 'S_APPROVE' => false,
|
|---|
| 972 | 'REASON' => $reason,
|
|---|
| 973 | 'ADDITIONAL_MSG' => $additional_msg)
|
|---|
| 974 | );
|
|---|
| 975 |
|
|---|
| 976 | confirm_box(false, 'DISAPPROVE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html');
|
|---|
| 977 | }
|
|---|
| 978 |
|
|---|
| 979 | $redirect = request_var('redirect', "index.$phpEx");
|
|---|
| 980 | $redirect = reapply_sid($redirect);
|
|---|
| 981 |
|
|---|
| 982 | if (!$success_msg)
|
|---|
| 983 | {
|
|---|
| 984 | redirect($redirect);
|
|---|
| 985 | }
|
|---|
| 986 | else
|
|---|
| 987 | {
|
|---|
| 988 | meta_refresh(3, $redirect);
|
|---|
| 989 | trigger_error($user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], "<a href=\"$redirect\">", '</a>'));
|
|---|
| 990 | }
|
|---|
| 991 | }
|
|---|
| 992 |
|
|---|
| 993 | ?>
|
|---|