5
* @version $Id: mcp_queue.php,v 1.88 2007/10/05 14:36:33 acydburn Exp $
6
* @copyright (c) 2005 phpBB Group
7
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
14
if (!defined('IN_PHPBB'))
21
* Handling the moderation queue
29
function mcp_queue(&$p_master)
31
$this->p_master = &$p_master;
34
function main($id, $mode)
36
global $auth, $db, $user, $template, $cache;
37
global $config, $phpbb_root_path, $phpEx, $action;
39
include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
41
$forum_id = request_var('f', 0);
42
$start = request_var('start', 0);
44
$this->page_title = 'MCP_QUEUE';
50
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
52
$post_id_list = request_var('post_id_list', array(0));
54
if (!sizeof($post_id_list))
56
trigger_error('NO_POST_SELECTED');
59
if ($action == 'approve')
61
approve_post($post_id_list, 'queue', $mode);
65
disapprove_post($post_id_list, 'queue', $mode);
73
case 'approve_details':
75
$this->tpl_name = 'mcp_post';
77
$user->add_lang('posting');
79
$post_id = request_var('p', 0);
80
$topic_id = request_var('t', 0);
84
$topic_info = get_topic_data(array($topic_id), 'm_approve');
85
if (isset($topic_info[$topic_id]['topic_first_post_id']))
87
$post_id = (int) $topic_info[$topic_id]['topic_first_post_id'];
95
$post_info = get_post_data(array($post_id), 'm_approve', true);
97
if (!sizeof($post_info))
99
trigger_error('NO_POST_SELECTED');
102
$post_info = $post_info[$post_id];
104
if ($post_info['topic_first_post_id'] != $post_id && topic_review($post_info['topic_id'], $post_info['forum_id'], 'topic_review', 0, false))
106
$template->assign_vars(array(
107
'S_TOPIC_REVIEW' => true,
108
'TOPIC_TITLE' => $post_info['topic_title'])
112
$extensions = $attachments = $topic_tracking_info = array();
114
// Get topic tracking info
115
if ($config['load_db_lastread'])
117
$tmp_topic_data = array($post_info['topic_id'] => $post_info);
118
$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']));
119
unset($tmp_topic_data);
123
$topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']);
126
$post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false;
128
// Process message, leave it uncensored
129
$message = $post_info['post_text'];
131
if ($post_info['bbcode_bitfield'])
133
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
134
$bbcode = new bbcode($post_info['bbcode_bitfield']);
135
$bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']);
138
$message = bbcode_nl2br($message);
139
$message = smiley_text($message);
141
if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id']))
143
$extensions = $cache->obtain_attach_extensions($post_info['forum_id']);
146
FROM ' . ATTACHMENTS_TABLE . '
147
WHERE post_msg_id = ' . $post_id . '
149
ORDER BY filetime DESC, post_msg_id ASC';
150
$result = $db->sql_query($sql);
152
while ($row = $db->sql_fetchrow($result))
154
$attachments[] = $row;
156
$db->sql_freeresult($result);
158
if (sizeof($attachments))
160
$update_count = array();
161
parse_attachments($post_info['forum_id'], $message, $attachments, $update_count);
164
// Display not already displayed Attachments for this post, we already parsed them. ;)
165
if (!empty($attachments))
167
$template->assign_var('S_HAS_ATTACHMENTS', true);
169
foreach ($attachments as $attachment)
171
$template->assign_block_vars('attachment', array(
172
'DISPLAY_ATTACHMENT' => $attachment)
178
$post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']);
179
$topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']);
181
$template->assign_vars(array(
182
'S_MCP_QUEUE' => true,
183
'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&p=$post_id&f=$forum_id"),
184
'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']),
185
'S_POST_REPORTED' => $post_info['post_reported'],
186
'S_POST_UNAPPROVED' => !$post_info['post_approved'],
187
'S_POST_LOCKED' => $post_info['post_edit_locked'],
188
'S_USER_NOTES' => true,
190
'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']}") : '',
191
'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id),
192
'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id),
193
'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $post_info['user_id']),
194
'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']) : '',
195
'U_VIEW_POST' => $post_url,
196
'U_VIEW_TOPIC' => $topic_url,
198
'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'),
200
'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>'),
201
'RETURN_POST' => sprintf($user->lang['RETURN_POST'], '<a href="' . $post_url . '">', '</a>'),
202
'RETURN_TOPIC_SIMPLE' => sprintf($user->lang['RETURN_TOPIC_SIMPLE'], '<a href="' . $topic_url . '">', '</a>'),
203
'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']),
204
'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']),
205
'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']),
207
'POST_AUTHOR_FULL' => get_username_string('full', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
208
'POST_AUTHOR_COLOUR' => get_username_string('colour', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
209
'POST_AUTHOR' => get_username_string('username', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
210
'U_POST_AUTHOR' => get_username_string('profile', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']),
212
'POST_PREVIEW' => $message,
213
'POST_SUBJECT' => $post_info['post_subject'],
214
'POST_DATE' => $user->format_date($post_info['post_time']),
215
'POST_IP' => $post_info['poster_ip'],
216
'POST_IPADDR' => ($auth->acl_get('m_info', $post_info['forum_id']) && request_var('lookup', '')) ? @gethostbyaddr($post_info['poster_ip']) : '',
217
'POST_ID' => $post_info['post_id'],
219
'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' : '',
224
case 'unapproved_topics':
225
case 'unapproved_posts':
226
$user->add_lang(array('viewtopic', 'viewforum'));
228
$topic_id = request_var('t', 0);
229
$forum_info = array();
233
$topic_info = get_topic_data(array($topic_id));
235
if (!sizeof($topic_info))
237
trigger_error('TOPIC_NOT_EXIST');
240
$topic_info = $topic_info[$topic_id];
241
$forum_id = $topic_info['forum_id'];
244
$forum_list_approve = get_forum_list('m_approve', false, true);
248
$forum_list = array();
249
foreach ($forum_list_approve as $row)
251
$forum_list[] = $row['forum_id'];
254
if (!sizeof($forum_list))
256
trigger_error('NOT_MODERATOR');
259
$global_id = $forum_list[0];
261
$forum_list = implode(', ', $forum_list);
263
$sql = 'SELECT SUM(forum_topics) as sum_forum_topics
264
FROM ' . FORUMS_TABLE . "
265
WHERE forum_id IN (0, $forum_list)";
266
$result = $db->sql_query($sql);
267
$forum_info['forum_topics'] = (int) $db->sql_fetchfield('sum_forum_topics');
268
$db->sql_freeresult($result);
272
$forum_info = get_forum_data(array($forum_id), 'm_approve');
274
if (!sizeof($forum_info))
276
trigger_error('NOT_MODERATOR');
279
$forum_info = $forum_info[$forum_id];
280
$forum_list = $forum_id;
281
$global_id = $forum_id;
284
$forum_options = '<option value="0"' . (($forum_id == 0) ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>';
285
foreach ($forum_list_approve as $row)
287
$forum_options .= '<option value="' . $row['forum_id'] . '"' . (($forum_id == $row['forum_id']) ? ' selected="selected"' : '') . '>' . str_repeat(' ', $row['padding']) . $row['forum_name'] . '</option>';
290
$sort_days = $total = 0;
291
$sort_key = $sort_dir = '';
292
$sort_by_sql = $sort_order_sql = array();
293
mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id);
295
$forum_topics = ($total == -1) ? $forum_info['forum_topics'] : $total;
296
$limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : '';
298
$forum_names = array();
300
if ($mode == 'unapproved_posts')
302
$sql = 'SELECT p.post_id
303
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . "
304
WHERE p.forum_id IN (0, $forum_list)
305
AND p.post_approved = 0
306
" . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . '
307
' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . "
308
AND t.topic_id = p.topic_id
309
AND t.topic_first_post_id <> p.post_id
311
ORDER BY $sort_order_sql";
312
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
316
while ($row = $db->sql_fetchrow($result))
318
$post_ids[] = $row['post_id'];
319
$row_num[$row['post_id']] = $i++;
321
$db->sql_freeresult($result);
323
if (sizeof($post_ids))
325
$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
326
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u
327
WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . '
328
AND t.topic_id = p.topic_id
329
AND u.user_id = p.poster_id
330
ORDER BY ' . $sort_order_sql;
331
$result = $db->sql_query($sql);
333
$post_data = $rowset = array();
334
while ($row = $db->sql_fetchrow($result))
336
if ($row['forum_id'])
338
$forum_names[] = $row['forum_id'];
340
$post_data[$row['post_id']] = $row;
342
$db->sql_freeresult($result);
344
foreach ($post_ids as $post_id)
346
$rowset[] = $post_data[$post_id];
348
unset($post_data, $post_ids);
357
$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
358
FROM ' . TOPICS_TABLE . " t
359
WHERE forum_id IN (0, $forum_list)
360
AND topic_approved = 0
362
ORDER BY $sort_order_sql";
363
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
366
while ($row = $db->sql_fetchrow($result))
368
if ($row['forum_id'])
370
$forum_names[] = $row['forum_id'];
374
$db->sql_freeresult($result);
377
if (sizeof($forum_names))
379
// Select the names for the forum_ids
380
$sql = 'SELECT forum_id, forum_name
381
FROM ' . FORUMS_TABLE . '
382
WHERE ' . $db->sql_in_set('forum_id', $forum_names);
383
$result = $db->sql_query($sql, 3600);
385
$forum_names = array();
386
while ($row = $db->sql_fetchrow($result))
388
$forum_names[$row['forum_id']] = $row['forum_name'];
390
$db->sql_freeresult($result);
393
foreach ($rowset as $row)
395
$global_topic = ($row['forum_id']) ? false : true;
398
$row['forum_id'] = $global_id;
401
if (empty($row['post_username']))
403
$row['post_username'] = $user->lang['GUEST'];
406
$template->assign_block_vars('postrow', array(
407
'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']),
408
'U_VIEWFORUM' => (!$global_topic) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : '',
409
'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . (($mode == 'unapproved_posts') ? '#p' . $row['post_id'] : ''),
410
'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']}" : '')),
412
'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
413
'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
414
'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
415
'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']),
417
'POST_ID' => $row['post_id'],
418
'FORUM_NAME' => (!$global_topic) ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'],
419
'POST_SUBJECT' => $row['post_subject'],
420
'TOPIC_TITLE' => $row['topic_title'],
421
'POST_TIME' => $user->format_date($row['post_time']))
424
unset($rowset, $forum_names);
426
// Now display the page
427
$template->assign_vars(array(
428
'L_DISPLAY_ITEMS' => ($mode == 'unapproved_posts') ? $user->lang['DISPLAY_POSTS'] : $user->lang['DISPLAY_TOPICS'],
429
'L_EXPLAIN' => ($mode == 'unapproved_posts') ? $user->lang['MCP_QUEUE_UNAPPROVED_POSTS_EXPLAIN'] : $user->lang['MCP_QUEUE_UNAPPROVED_TOPICS_EXPLAIN'],
430
'L_TITLE' => ($mode == 'unapproved_posts') ? $user->lang['MCP_QUEUE_UNAPPROVED_POSTS'] : $user->lang['MCP_QUEUE_UNAPPROVED_TOPICS'],
431
'L_ONLY_TOPIC' => ($topic_id) ? sprintf($user->lang['ONLY_TOPIC'], $topic_info['topic_title']) : '',
433
'S_FORUM_OPTIONS' => $forum_options,
434
'S_MCP_ACTION' => build_url(array('t', 'f', 'sd', 'st', 'sk')),
435
'S_TOPICS' => ($mode == 'unapproved_posts') ? false : true,
437
'PAGINATION' => generate_pagination($this->u_action . "&f=$forum_id&st=$sort_days&sk=$sort_key&sd=$sort_dir", $total, $config['topics_per_page'], $start),
438
'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start),
439
'TOPIC_ID' => $topic_id,
440
'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),
443
$this->tpl_name = 'mcp_queue';
452
function approve_post($post_id_list, $id, $mode)
454
global $db, $template, $user, $config;
455
global $phpEx, $phpbb_root_path;
457
if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve')))
459
trigger_error('NOT_AUTHORISED');
462
$redirect = request_var('redirect', build_url(array('_f_', 'quickmod')));
465
$s_hidden_fields = build_hidden_fields(array(
468
'post_id_list' => $post_id_list,
469
'action' => 'approve',
470
'redirect' => $redirect)
473
$post_info = get_post_data($post_id_list, 'm_approve');
475
if (confirm_box(true))
477
$notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false;
479
// If Topic -> total_topics = total_topics+1, total_posts = total_posts+1, forum_topics = forum_topics+1, forum_posts = forum_posts+1
480
// If Post -> total_posts = total_posts+1, forum_posts = forum_posts+1, topic_replies = topic_replies+1
482
$total_topics = $total_posts = 0;
483
$forum_topics_posts = $topic_approve_sql = $topic_replies_sql = $post_approve_sql = $topic_id_list = $forum_id_list = $approve_log = array();
485
$update_forum_information = false;
487
foreach ($post_info as $post_id => $post_data)
489
$topic_id_list[$post_data['topic_id']] = 1;
491
if ($post_data['forum_id'])
493
$forum_id_list[$post_data['forum_id']] = 1;
497
if ($post_data['topic_first_post_id'] == $post_id)
499
if ($post_data['forum_id'])
501
if (!isset($forum_topics_posts[$post_data['forum_id']]))
503
$forum_topics_posts[$post_data['forum_id']] = array(
510
$forum_topics_posts[$post_data['forum_id']]['forum_topics']++;
512
$topic_approve_sql[] = $post_data['topic_id'];
514
$approve_log[] = array(
516
'post_subject' => $post_data['post_subject'],
517
'forum_id' => $post_data['forum_id'],
518
'topic_id' => $post_data['topic_id'],
523
if (!isset($topic_replies_sql[$post_data['topic_id']]))
525
$topic_replies_sql[$post_data['topic_id']] = 0;
527
$topic_replies_sql[$post_data['topic_id']]++;
529
$approve_log[] = array(
531
'post_subject' => $post_data['post_subject'],
532
'forum_id' => $post_data['forum_id'],
533
'topic_id' => $post_data['topic_id'],
537
if ($post_data['forum_id'])
539
if (!isset($forum_topics_posts[$post_data['forum_id']]))
541
$forum_topics_posts[$post_data['forum_id']] = array(
548
$forum_topics_posts[$post_data['forum_id']]['forum_posts']++;
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'])
554
$total_posts += $post_data['topic_replies'];
555
$forum_topics_posts[$post_data['forum_id']]['forum_posts'] += $post_data['topic_replies'];
559
$post_approve_sql[] = $post_id;
561
// If the post is newer than the last post information stored we need to update the forum information
562
if ($post_data['post_time'] >= $post_data['forum_last_post_time'])
564
$update_forum_information = true;
568
if (sizeof($topic_approve_sql))
570
$sql = 'UPDATE ' . TOPICS_TABLE . '
571
SET topic_approved = 1
572
WHERE ' . $db->sql_in_set('topic_id', $topic_approve_sql);
573
$db->sql_query($sql);
576
if (sizeof($post_approve_sql))
578
$sql = 'UPDATE ' . POSTS_TABLE . '
579
SET post_approved = 1
580
WHERE ' . $db->sql_in_set('post_id', $post_approve_sql);
581
$db->sql_query($sql);
584
foreach ($approve_log as $log_data)
586
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']);
589
if (sizeof($topic_replies_sql))
591
foreach ($topic_replies_sql as $topic_id => $num_replies)
593
$sql = 'UPDATE ' . TOPICS_TABLE . "
594
SET topic_replies = topic_replies + $num_replies
595
WHERE topic_id = $topic_id";
596
$db->sql_query($sql);
600
if (sizeof($forum_topics_posts))
602
foreach ($forum_topics_posts as $forum_id => $row)
604
$sql = 'UPDATE ' . FORUMS_TABLE . '
606
$sql .= ($row['forum_topics']) ? "forum_topics = forum_topics + {$row['forum_topics']}" : '';
607
$sql .= ($row['forum_topics'] && $row['forum_posts']) ? ', ' : '';
608
$sql .= ($row['forum_posts']) ? "forum_posts = forum_posts + {$row['forum_posts']}" : '';
609
$sql .= " WHERE forum_id = $forum_id";
611
$db->sql_query($sql);
617
set_config('num_topics', $config['num_topics'] + $total_topics, true);
622
set_config('num_posts', $config['num_posts'] + $total_posts, true);
624
unset($topic_approve_sql, $topic_replies_sql, $post_approve_sql);
626
update_post_information('topic', array_keys($topic_id_list));
628
if ($update_forum_information)
630
update_post_information('forum', array_keys($forum_id_list));
632
unset($topic_id_list, $forum_id_list);
634
$messenger = new messenger();
639
foreach ($post_info as $post_id => $post_data)
641
if ($post_data['poster_id'] == ANONYMOUS)
646
$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';
648
$messenger->template($email_template, $post_data['user_lang']);
650
$messenger->to($post_data['user_email'], $post_data['username']);
651
$messenger->im($post_data['user_jabber'], $post_data['username']);
653
$messenger->assign_vars(array(
654
'USERNAME' => htmlspecialchars_decode($post_data['username']),
655
'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_data['post_subject'])),
656
'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_data['topic_title'])),
658
'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f={$post_data['forum_id']}&t={$post_data['topic_id']}&e=0",
659
'U_VIEW_POST' => generate_board_url() . "/viewtopic.$phpEx?f={$post_data['forum_id']}&t={$post_data['topic_id']}&p=$post_id&e=$post_id")
662
$messenger->send($post_data['user_notify_type']);
666
$messenger->save_queue();
668
// Send out normal user notifications
669
$email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
671
foreach ($post_info as $post_id => $post_data)
673
if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id'])
675
// Forum Notifications
676
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);
680
// Topic Notifications
681
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);
685
if (sizeof($post_id_list) == 1)
687
$post_data = $post_info[$post_id_list[0]];
688
$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'];
694
$success_msg = ($total_topics == 1) ? 'TOPIC_APPROVED_SUCCESS' : 'TOPICS_APPROVED_SUCCESS';
698
$success_msg = (sizeof($post_id_list) == 1) ? 'POST_APPROVED_SUCCESS' : 'POSTS_APPROVED_SUCCESS';
703
$show_notify = false;
705
foreach ($post_info as $post_data)
707
if ($post_data['poster_id'] == ANONYMOUS)
718
$template->assign_vars(array(
719
'S_NOTIFY_POSTER' => $show_notify,
723
confirm_box(false, 'APPROVE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html');
726
$redirect = request_var('redirect', "index.$phpEx");
727
$redirect = reapply_sid($redirect);
735
meta_refresh(3, $redirect);
737
// If approving one post, also give links back to post...
739
if (sizeof($post_id_list) == 1 && !empty($post_url))
741
$add_message = '<br /><br />' . sprintf($user->lang['RETURN_POST'], '<a href="' . $post_url . '">', '</a>');
744
trigger_error($user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], "<a href=\"$redirect\">", '</a>') . $add_message);
749
* Disapprove Post/Topic
751
function disapprove_post($post_id_list, $id, $mode)
753
global $db, $template, $user, $config;
754
global $phpEx, $phpbb_root_path;
756
if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve')))
758
trigger_error('NOT_AUTHORISED');
761
$redirect = request_var('redirect', build_url(array('t', 'mode', '_f_', 'quickmod')) . "&mode=$mode");
762
$reason = utf8_normalize_nfc(request_var('reason', '', true));
763
$reason_id = request_var('reason_id', 0);
764
$success_msg = $additional_msg = '';
766
$s_hidden_fields = build_hidden_fields(array(
769
'post_id_list' => $post_id_list,
770
'action' => 'disapprove',
771
'redirect' => $redirect)
774
$notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false;
775
$disapprove_reason = '';
779
$sql = 'SELECT reason_title, reason_description
780
FROM ' . REPORTS_REASONS_TABLE . "
781
WHERE reason_id = $reason_id";
782
$result = $db->sql_query($sql);
783
$row = $db->sql_fetchrow($result);
784
$db->sql_freeresult($result);
786
if (!$row || (!$reason && strtolower($row['reason_title']) == 'other'))
788
$additional_msg = $user->lang['NO_REASON_DISAPPROVAL'];
789
unset($_POST['confirm']);
793
// If the reason is defined within the language file, we will use the localized version, else just use the database entry...
794
$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']) : '';
795
$disapprove_reason .= ($reason) ? "\n\n" . $reason : '';
799
$post_info = get_post_data($post_id_list, 'm_approve');
801
if (confirm_box(true))
804
// If Topic -> forum_topics_real -= 1
805
// If Post -> topic_replies_real -= 1
807
$num_disapproved = 0;
808
$forum_topics_real = $topic_id_list = $forum_id_list = $topic_replies_real_sql = $post_disapprove_sql = $disapprove_log = array();
810
foreach ($post_info as $post_id => $post_data)
812
$topic_id_list[$post_data['topic_id']] = 1;
814
if ($post_data['forum_id'])
816
$forum_id_list[$post_data['forum_id']] = 1;
821
* @todo this probably is a different method than the one used by delete_posts, does this cause counter inconsistency?
823
if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_last_post_id'] == $post_id)
825
if ($post_data['forum_id'])
827
if (!isset($forum_topics_real[$post_data['forum_id']]))
829
$forum_topics_real[$post_data['forum_id']] = 0;
831
$forum_topics_real[$post_data['forum_id']]++;
835
$disapprove_log[] = array(
837
'post_subject' => $post_data['post_subject'],
838
'forum_id' => $post_data['forum_id'],
839
'topic_id' => 0, // useless to log a topic id, as it will be deleted
844
if (!isset($topic_replies_real_sql[$post_data['topic_id']]))
846
$topic_replies_real_sql[$post_data['topic_id']] = 0;
848
$topic_replies_real_sql[$post_data['topic_id']]++;
850
$disapprove_log[] = array(
852
'post_subject' => $post_data['post_subject'],
853
'forum_id' => $post_data['forum_id'],
854
'topic_id' => $post_data['topic_id'],
858
$post_disapprove_sql[] = $post_id;
863
if (sizeof($forum_topics_real))
865
foreach ($forum_topics_real as $forum_id => $topics_real)
867
$sql = 'UPDATE ' . FORUMS_TABLE . "
868
SET forum_topics_real = forum_topics_real - $topics_real
869
WHERE forum_id = $forum_id";
870
$db->sql_query($sql);
874
if (sizeof($topic_replies_real_sql))
876
foreach ($topic_replies_real_sql as $topic_id => $num_replies)
878
$sql = 'UPDATE ' . TOPICS_TABLE . "
879
SET topic_replies_real = topic_replies_real - $num_replies
880
WHERE topic_id = $topic_id";
881
$db->sql_query($sql);
885
if (sizeof($post_disapprove_sql))
887
if (!function_exists('delete_posts'))
889
include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
892
// We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts
893
delete_posts('post_id', $post_disapprove_sql);
895
foreach ($disapprove_log as $log_data)
897
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);
900
unset($post_disapprove_sql, $topic_replies_real_sql);
902
update_post_information('topic', array_keys($topic_id_list));
904
if (sizeof($forum_id_list))
906
update_post_information('forum', array_keys($forum_id_list));
908
unset($topic_id_list, $forum_id_list);
910
$messenger = new messenger();
915
foreach ($post_info as $post_id => $post_data)
917
if ($post_data['poster_id'] == ANONYMOUS)
922
$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';
924
$messenger->template($email_template, $post_data['user_lang']);
926
$messenger->to($post_data['user_email'], $post_data['username']);
927
$messenger->im($post_data['user_jabber'], $post_data['username']);
929
$messenger->assign_vars(array(
930
'USERNAME' => htmlspecialchars_decode($post_data['username']),
931
'REASON' => htmlspecialchars_decode($disapprove_reason),
932
'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_data['post_subject'])),
933
'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_data['topic_title'])))
936
$messenger->send($post_data['user_notify_type']);
939
unset($post_info, $disapprove_reason);
941
$messenger->save_queue();
943
if (sizeof($forum_topics_real))
945
$success_msg = ($num_disapproved == 1) ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS';
949
$success_msg = (sizeof($post_id_list) == 1) ? 'POST_DISAPPROVED_SUCCESS' : 'POSTS_DISAPPROVED_SUCCESS';
954
include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
956
display_reasons($reason_id);
958
$show_notify = false;
960
foreach ($post_info as $post_data)
962
if ($post_data['poster_id'] == ANONYMOUS)
973
$template->assign_vars(array(
974
'S_NOTIFY_POSTER' => $show_notify,
975
'S_APPROVE' => false,
977
'ADDITIONAL_MSG' => $additional_msg)
980
confirm_box(false, 'DISAPPROVE_POST' . ((sizeof($post_id_list) == 1) ? '' : 'S'), $s_hidden_fields, 'mcp_approve.html');
983
$redirect = request_var('redirect', "index.$phpEx");
984
$redirect = reapply_sid($redirect);
992
meta_refresh(3, $redirect);
993
trigger_error($user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], "<a href=\"$redirect\">", '</a>'));
b'\\ No newline at end of file'