[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * This file is part of the phpBB Forum Software package. 5 * 6 * @copyright (c) phpBB Limited <https://www.phpbb.com> 7 * @license GNU General Public License, version 2 (GPL-2.0) 8 * 9 * For full copyright and license information, please see 10 * the docs/CREDITS.txt file. 11 * 12 */ 13 14 /** 15 * @ignore 16 */ 17 if (!defined('IN_PHPBB')) 18 { 19 exit; 20 } 21 22 /** 23 * mcp_reports 24 * Handling the reports queue 25 */ 26 class mcp_reports 27 { 28 var $p_master; 29 var $u_action; 30 31 function __construct($p_master) 32 { 33 $this->p_master = $p_master; 34 } 35 36 function main($id, $mode) 37 { 38 global $auth, $db, $user, $template, $request; 39 global $config, $phpbb_root_path, $phpEx, $action, $phpbb_container, $phpbb_dispatcher; 40 41 include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); 42 43 $forum_id = $request->variable('f', 0); 44 $start = $request->variable('start', 0); 45 46 $this->page_title = 'MCP_REPORTS'; 47 48 switch ($action) 49 { 50 case 'close': 51 case 'delete': 52 include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); 53 54 $report_id_list = $request->variable('report_id_list', array(0)); 55 56 if (!count($report_id_list)) 57 { 58 trigger_error('NO_REPORT_SELECTED'); 59 } 60 61 close_report($report_id_list, $mode, $action); 62 63 break; 64 } 65 66 switch ($mode) 67 { 68 case 'report_details': 69 70 $user->add_lang(array('posting', 'viewforum', 'viewtopic')); 71 72 $post_id = $request->variable('p', 0); 73 74 // closed reports are accessed by report id 75 $report_id = $request->variable('r', 0); 76 77 $sql_ary = array( 78 'SELECT' => 'r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, r.reported_post_text, r.reported_post_uid, r.reported_post_bitfield, r.reported_post_enable_magic_url, r.reported_post_enable_smilies, r.reported_post_enable_bbcode, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour', 79 80 'FROM' => array( 81 REPORTS_TABLE => 'r', 82 REPORTS_REASONS_TABLE => 'rr', 83 USERS_TABLE => 'u', 84 ), 85 86 'WHERE' => (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id") . ' 87 AND rr.reason_id = r.reason_id 88 AND r.user_id = u.user_id 89 AND r.pm_id = 0', 90 91 'ORDER_BY' => 'report_closed ASC', 92 ); 93 94 /** 95 * Allow changing the query to obtain the user-submitted report. 96 * 97 * @event core.mcp_reports_report_details_query_before 98 * @var array sql_ary The array in the format of the query builder with the query 99 * @var int forum_id The forum_id, the number in the f GET parameter 100 * @var int post_id The post_id of the report being viewed (if 0, it is meaningless) 101 * @var int report_id The report_id of the report being viewed 102 * @since 3.1.5-RC1 103 */ 104 $vars = array( 105 'sql_ary', 106 'forum_id', 107 'post_id', 108 'report_id', 109 ); 110 extract($phpbb_dispatcher->trigger_event('core.mcp_reports_report_details_query_before', compact($vars))); 111 112 $sql = $db->sql_build_query('SELECT', $sql_ary); 113 $result = $db->sql_query_limit($sql, 1); 114 $report = $db->sql_fetchrow($result); 115 $db->sql_freeresult($result); 116 117 /** 118 * Allow changing the data obtained from the user-submitted report. 119 * 120 * @event core.mcp_reports_report_details_query_after 121 * @var array sql_ary The array in the format of the query builder with the query that had been executted 122 * @var int forum_id The forum_id, the number in the f GET parameter 123 * @var int post_id The post_id of the report being viewed (if 0, it is meaningless) 124 * @var int report_id The report_id of the report being viewed 125 * @var array report The query's resulting row. 126 * @since 3.1.5-RC1 127 */ 128 $vars = array( 129 'sql_ary', 130 'forum_id', 131 'post_id', 132 'report_id', 133 'report', 134 ); 135 extract($phpbb_dispatcher->trigger_event('core.mcp_reports_report_details_query_after', compact($vars))); 136 137 if (!$report) 138 { 139 trigger_error('NO_REPORT'); 140 } 141 142 /* @var $phpbb_notifications \phpbb\notification\manager */ 143 $phpbb_notifications = $phpbb_container->get('notification_manager'); 144 145 $phpbb_notifications->mark_notifications('report_post', $post_id, $user->data['user_id']); 146 147 if (!$report_id && $report['report_closed']) 148 { 149 trigger_error('REPORT_CLOSED'); 150 } 151 152 $post_id = $report['post_id']; 153 $report_id = $report['report_id']; 154 155 $parse_post_flags = $report['reported_post_enable_bbcode'] ? OPTION_FLAG_BBCODE : 0; 156 $parse_post_flags += $report['reported_post_enable_smilies'] ? OPTION_FLAG_SMILIES : 0; 157 $parse_post_flags += $report['reported_post_enable_magic_url'] ? OPTION_FLAG_LINKS : 0; 158 159 $post_info = phpbb_get_post_data(array($post_id), 'm_report', true); 160 161 if (!count($post_info)) 162 { 163 trigger_error('NO_REPORT_SELECTED'); 164 } 165 166 $post_info = $post_info[$post_id]; 167 168 $reason = array('title' => $report['reason_title'], 'description' => $report['reason_description']); 169 if (isset($user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])])) 170 { 171 $reason['description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])]; 172 $reason['title'] = $user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]; 173 } 174 175 if (topic_review($post_info['topic_id'], $post_info['forum_id'], 'topic_review', 0, false)) 176 { 177 $template->assign_vars(array( 178 'S_TOPIC_REVIEW' => true, 179 'S_BBCODE_ALLOWED' => $post_info['enable_bbcode'], 180 'TOPIC_TITLE' => $post_info['topic_title'], 181 'REPORTED_POST_ID' => $post_id, 182 )); 183 } 184 185 $attachments = array(); 186 // Get topic tracking info 187 if ($config['load_db_lastread']) 188 { 189 $tmp_topic_data = array($post_info['topic_id'] => $post_info); 190 $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'])); 191 unset($tmp_topic_data); 192 } 193 else 194 { 195 $topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']); 196 } 197 198 $post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false; 199 $message = generate_text_for_display( 200 $report['reported_post_text'], 201 $report['reported_post_uid'], 202 $report['reported_post_bitfield'], 203 $parse_post_flags, 204 false 205 ); 206 207 $report['report_text'] = make_clickable(bbcode_nl2br($report['report_text'])); 208 209 if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) 210 { 211 $sql = 'SELECT * 212 FROM ' . ATTACHMENTS_TABLE . ' 213 WHERE post_msg_id = ' . $post_id . ' 214 AND in_message = 0 215 AND filetime <= ' . (int) $report['report_time'] . ' 216 ORDER BY filetime DESC'; 217 $result = $db->sql_query($sql); 218 219 while ($row = $db->sql_fetchrow($result)) 220 { 221 $attachments[] = $row; 222 } 223 $db->sql_freeresult($result); 224 225 if (count($attachments)) 226 { 227 $update_count = array(); 228 parse_attachments($post_info['forum_id'], $message, $attachments, $update_count); 229 } 230 231 // Display not already displayed Attachments for this post, we already parsed them. ;) 232 if (!empty($attachments)) 233 { 234 $template->assign_var('S_HAS_ATTACHMENTS', true); 235 236 foreach ($attachments as $attachment) 237 { 238 $template->assign_block_vars('attachment', array( 239 'DISPLAY_ATTACHMENT' => $attachment) 240 ); 241 } 242 } 243 } 244 245 // parse signature 246 $parse_flags = ($post_info['user_sig_bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; 247 $post_info['user_sig'] = generate_text_for_display($post_info['user_sig'], $post_info['user_sig_bbcode_uid'], $post_info['user_sig_bbcode_bitfield'], $parse_flags, true); 248 249 $topic_id = (int) $post_info['topic_id']; 250 251 // So it can be sent through the event below. 252 $report_template = array( 253 'S_MCP_REPORT' => true, 254 'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 255 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 256 'S_POST_REPORTED' => $post_info['post_reported'], 257 'S_POST_UNAPPROVED' => $post_info['post_visibility'] == ITEM_UNAPPROVED || $post_info['post_visibility'] == ITEM_REAPPROVE, 258 'S_POST_LOCKED' => $post_info['post_edit_locked'], 259 'S_REPORT_CLOSED' => $report['report_closed'], 260 'S_USER_NOTES' => true, 261 262 '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']}") : '', 263 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 264 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 265 'U_MCP_REPORTER_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $report['user_id']), 266 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $post_info['user_id']), 267 'U_MCP_WARN_REPORTER' => ($auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $report['user_id']) : '', 268 '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']) : '', 269 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $post_info['forum_id']), 270 'U_VIEW_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']), 271 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']), 272 273 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']), 274 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 275 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']), 276 277 'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports' . (($post_info['post_reported']) ? '&mode=reports' : '&mode=reports_closed') . '&start=' . $start . '&f=' . $post_info['forum_id']) . '">', '</a>'), 278 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']), 279 'REPORT_DATE' => $user->format_date($report['report_time']), 280 'REPORT_ID' => $report_id, 281 'REPORT_REASON_TITLE' => $reason['title'], 282 'REPORT_REASON_DESCRIPTION' => $reason['description'], 283 'REPORT_TEXT' => $report['report_text'], 284 285 'POST_AUTHOR_FULL' => get_username_string('full', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 286 'POST_AUTHOR_COLOUR' => get_username_string('colour', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 287 'POST_AUTHOR' => get_username_string('username', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 288 'U_POST_AUTHOR' => get_username_string('profile', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 289 290 'REPORTER_FULL' => get_username_string('full', $report['user_id'], $report['username'], $report['user_colour']), 291 'REPORTER_COLOUR' => get_username_string('colour', $report['user_id'], $report['username'], $report['user_colour']), 292 'REPORTER_NAME' => get_username_string('username', $report['user_id'], $report['username'], $report['user_colour']), 293 'U_VIEW_REPORTER_PROFILE' => get_username_string('profile', $report['user_id'], $report['username'], $report['user_colour']), 294 295 'POST_PREVIEW' => $message, 296 'POST_SUBJECT' => ($post_info['post_subject']) ? $post_info['post_subject'] : $user->lang['NO_SUBJECT'], 297 'POST_DATE' => $user->format_date($post_info['post_time']), 298 'POST_IP' => $post_info['poster_ip'], 299 'POST_IPADDR' => ($auth->acl_get('m_info', $post_info['forum_id']) && $request->variable('lookup', '')) ? @gethostbyaddr($post_info['poster_ip']) : '', 300 'POST_ID' => $post_info['post_id'], 301 'SIGNATURE' => $post_info['user_sig'], 302 303 'U_LOOKUP_IP' => ($auth->acl_get('m_info', $post_info['forum_id'])) ? $this->u_action . '&r=' . $report_id . '&p=' . $post_id . '&f=' . $forum_id . '&lookup=' . $post_info['poster_ip'] . '#ip' : '', 304 ); 305 306 /** 307 * Event to add/modify MCP report details template data. 308 * 309 * @event core.mcp_report_template_data 310 * @var int forum_id The forum_id, the number in the f GET parameter 311 * @var int topic_id The topic_id of the report being viewed 312 * @var int post_id The post_id of the report being viewed (if 0, it is meaningless) 313 * @var int report_id The report_id of the report being viewed 314 * @var array report Array with the report data 315 * @var array report_template Array with the report template data 316 * @var array post_info Array with the reported post data 317 * @since 3.2.5-RC1 318 */ 319 $vars = array( 320 'forum_id', 321 'topic_id', 322 'post_id', 323 'report_id', 324 'report', 325 'report_template', 326 'post_info', 327 ); 328 extract($phpbb_dispatcher->trigger_event('core.mcp_report_template_data', compact($vars))); 329 330 $template->assign_vars($report_template); 331 332 $this->tpl_name = 'mcp_post'; 333 334 break; 335 336 case 'reports': 337 case 'reports_closed': 338 $topic_id = $request->variable('t', 0); 339 340 if ($request->is_set_post('t')) 341 { 342 $topic_id = $request->variable('t', 0, false, \phpbb\request\request_interface::POST); 343 } 344 345 $forum_info = array(); 346 $forum_list_reports = get_forum_list('m_report', false, true); 347 $forum_list_read = array_flip(get_forum_list('f_read', true, true)); // Flipped so we can isset() the forum IDs 348 349 // Remove forums we cannot read 350 foreach ($forum_list_reports as $k => $forum_data) 351 { 352 if (!isset($forum_list_read[$forum_data['forum_id']])) 353 { 354 unset($forum_list_reports[$k]); 355 } 356 } 357 unset($forum_list_read); 358 359 if ($topic_id) 360 { 361 $topic_info = phpbb_get_topic_data(array($topic_id)); 362 363 if (!count($topic_info)) 364 { 365 trigger_error('TOPIC_NOT_EXIST'); 366 } 367 368 if ($forum_id != $topic_info[$topic_id]['forum_id']) 369 { 370 $topic_id = 0; 371 } 372 else 373 { 374 $topic_info = $topic_info[$topic_id]; 375 $forum_id = (int) $topic_info['forum_id']; 376 } 377 } 378 379 $forum_list = array(); 380 381 if (!$forum_id) 382 { 383 foreach ($forum_list_reports as $row) 384 { 385 $forum_list[] = $row['forum_id']; 386 } 387 388 if (!count($forum_list)) 389 { 390 trigger_error('NOT_MODERATOR'); 391 } 392 393 $sql = 'SELECT SUM(forum_topics_approved) as sum_forum_topics 394 FROM ' . FORUMS_TABLE . ' 395 WHERE ' . $db->sql_in_set('forum_id', $forum_list); 396 $result = $db->sql_query($sql); 397 $forum_info['forum_topics_approved'] = (int) $db->sql_fetchfield('sum_forum_topics'); 398 $db->sql_freeresult($result); 399 } 400 else 401 { 402 $forum_info = phpbb_get_forum_data(array($forum_id), 'm_report'); 403 404 if (!count($forum_info)) 405 { 406 trigger_error('NOT_MODERATOR'); 407 } 408 409 $forum_list = array($forum_id); 410 } 411 412 /* @var $pagination \phpbb\pagination */ 413 $pagination = $phpbb_container->get('pagination'); 414 $forum_list[] = 0; 415 $forum_data = array(); 416 417 $forum_options = '<option value="0"' . (($forum_id == 0) ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>'; 418 foreach ($forum_list_reports as $row) 419 { 420 $forum_options .= '<option value="' . $row['forum_id'] . '"' . (($forum_id == $row['forum_id']) ? ' selected="selected"' : '') . '>' . str_repeat(' ', $row['padding']) . truncate_string($row['forum_name'], 30, 255, false, $user->lang('ELLIPSIS')) . '</option>'; 421 $forum_data[$row['forum_id']] = $row; 422 } 423 unset($forum_list_reports); 424 425 $sort_days = $total = 0; 426 $sort_key = $sort_dir = ''; 427 $sort_by_sql = $sort_order_sql = array(); 428 phpbb_mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id); 429 430 $limit_time_sql = ($sort_days) ? 'AND r.report_time >= ' . (time() - ($sort_days * 86400)) : ''; 431 432 if ($mode == 'reports') 433 { 434 $report_state = 'AND p.post_reported = 1 AND r.report_closed = 0'; 435 } 436 else 437 { 438 $report_state = 'AND r.report_closed = 1'; 439 } 440 441 $sql = 'SELECT r.report_id 442 FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . REPORTS_TABLE . ' r ' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . (($sort_order_sql[0] == 'r') ? ', ' . USERS_TABLE . ' ru' : '') . ' 443 WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . " 444 $report_state 445 AND r.post_id = p.post_id 446 " . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . ' 447 ' . (($sort_order_sql[0] == 'r') ? 'AND ru.user_id = r.user_id' : '') . ' 448 ' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . " 449 AND t.topic_id = p.topic_id 450 AND r.pm_id = 0 451 $limit_time_sql 452 ORDER BY $sort_order_sql"; 453 454 /** 455 * Alter sql query to get report id of all reports for requested forum and topic or just forum 456 * 457 * @event core.mcp_reports_get_reports_query_before 458 * @var string sql String with the query to be executed 459 * @var array forum_list List of forums that contain the posts 460 * @var int topic_id topic_id in the page request 461 * @var string limit_time_sql String with the SQL code to limit the time interval of the post (Note: May be empty string) 462 * @var string sort_order_sql String with the ORDER BY SQL code used in this query 463 * @since 3.1.0-RC4 464 */ 465 $vars = array( 466 'sql', 467 'forum_list', 468 'topic_id', 469 'limit_time_sql', 470 'sort_order_sql', 471 ); 472 extract($phpbb_dispatcher->trigger_event('core.mcp_reports_get_reports_query_before', compact($vars))); 473 474 $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); 475 476 $i = 0; 477 $report_ids = array(); 478 while ($row = $db->sql_fetchrow($result)) 479 { 480 $report_ids[] = $row['report_id']; 481 $row_num[$row['report_id']] = $i++; 482 } 483 $db->sql_freeresult($result); 484 485 if (count($report_ids)) 486 { 487 $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, p.post_attachment, u.username, u.username_clean, u.user_colour, r.user_id as reporter_id, ru.username as reporter_name, ru.user_colour as reporter_colour, r.report_time, r.report_id 488 FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u, ' . USERS_TABLE . ' ru 489 WHERE ' . $db->sql_in_set('r.report_id', $report_ids) . ' 490 AND t.topic_id = p.topic_id 491 AND r.post_id = p.post_id 492 AND u.user_id = p.poster_id 493 AND ru.user_id = r.user_id 494 AND r.pm_id = 0 495 ORDER BY ' . $sort_order_sql; 496 $result = $db->sql_query($sql); 497 498 while ($row = $db->sql_fetchrow($result)) 499 { 500 $template->assign_block_vars('postrow', array( 501 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), 502 'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . '#p' . $row['post_id'], 503 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=reports&start=$start&mode=report_details&f={$row['forum_id']}&r={$row['report_id']}"), 504 505 'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 506 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 507 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 508 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 509 510 'REPORTER_FULL' => get_username_string('full', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 511 'REPORTER_COLOUR' => get_username_string('colour', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 512 'REPORTER' => get_username_string('username', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 513 'U_REPORTER' => get_username_string('profile', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 514 515 'FORUM_NAME' => $forum_data[$row['forum_id']]['forum_name'], 516 'POST_ID' => $row['post_id'], 517 'POST_SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 518 'POST_TIME' => $user->format_date($row['post_time']), 519 'REPORT_ID' => $row['report_id'], 520 'REPORT_TIME' => $user->format_date($row['report_time']), 521 'TOPIC_TITLE' => $row['topic_title'], 522 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 523 )); 524 } 525 $db->sql_freeresult($result); 526 unset($report_ids, $row); 527 } 528 529 $base_url = $this->u_action . "&f=$forum_id&t=$topic_id&st=$sort_days&sk=$sort_key&sd=$sort_dir"; 530 $pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start); 531 532 // Now display the page 533 $template->assign_vars(array( 534 'L_EXPLAIN' => ($mode == 'reports') ? $user->lang['MCP_REPORTS_OPEN_EXPLAIN'] : $user->lang['MCP_REPORTS_CLOSED_EXPLAIN'], 535 'L_TITLE' => ($mode == 'reports') ? $user->lang['MCP_REPORTS_OPEN'] : $user->lang['MCP_REPORTS_CLOSED'], 536 'L_ONLY_TOPIC' => ($topic_id) ? sprintf($user->lang['ONLY_TOPIC'], $topic_info['topic_title']) : '', 537 538 'S_MCP_ACTION' => $this->u_action, 539 'S_FORUM_OPTIONS' => $forum_options, 540 'S_CLOSED' => ($mode == 'reports_closed') ? true : false, 541 542 'TOPIC_ID' => $topic_id, 543 'TOTAL' => $total, 544 'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $total), 545 ) 546 ); 547 548 $this->tpl_name = 'mcp_reports'; 549 break; 550 } 551 } 552 } 553 554 /** 555 * Closes a report 556 */ 557 function close_report($report_id_list, $mode, $action, $pm = false) 558 { 559 global $db, $user, $auth, $phpbb_log, $request; 560 global $phpEx, $phpbb_root_path, $phpbb_container; 561 562 $pm_where = ($pm) ? ' AND r.post_id = 0 ' : ' AND r.pm_id = 0 '; 563 $id_column = ($pm) ? 'pm_id' : 'post_id'; 564 $module = ($pm) ? 'pm_reports' : 'reports'; 565 $pm_prefix = ($pm) ? 'PM_' : ''; 566 567 $sql = "SELECT r.$id_column 568 FROM " . REPORTS_TABLE . ' r 569 WHERE ' . $db->sql_in_set('r.report_id', $report_id_list) . $pm_where; 570 $result = $db->sql_query($sql); 571 572 $post_id_list = array(); 573 while ($row = $db->sql_fetchrow($result)) 574 { 575 $post_id_list[] = $row[$id_column]; 576 } 577 $db->sql_freeresult($result); 578 $post_id_list = array_unique($post_id_list); 579 580 if ($pm) 581 { 582 if (!$auth->acl_getf_global('m_report')) 583 { 584 send_status_line(403, 'Forbidden'); 585 trigger_error('NOT_AUTHORISED'); 586 } 587 } 588 else 589 { 590 if (!phpbb_check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_report'))) 591 { 592 send_status_line(403, 'Forbidden'); 593 trigger_error('NOT_AUTHORISED'); 594 } 595 } 596 597 if ($action == 'delete' && strpos($user->data['session_page'], 'mode=report_details') !== false) 598 { 599 $redirect = $request->variable('redirect', build_url(array('mode', 'r', 'quickmod')) . '&mode=reports'); 600 } 601 else if ($action == 'delete' && strpos($user->data['session_page'], 'mode=pm_report_details') !== false) 602 { 603 $redirect = $request->variable('redirect', build_url(array('mode', 'r', 'quickmod')) . '&mode=pm_reports'); 604 } 605 else if ($action == 'close' && !$request->variable('r', 0)) 606 { 607 $redirect = $request->variable('redirect', build_url(array('mode', 'p', 'quickmod')) . '&mode=' . $module); 608 } 609 else 610 { 611 $redirect = $request->variable('redirect', build_url(array('quickmod'))); 612 } 613 $success_msg = ''; 614 $forum_ids = array(); 615 $topic_ids = array(); 616 617 $s_hidden_fields = build_hidden_fields(array( 618 'i' => $module, 619 'mode' => $mode, 620 'report_id_list' => $report_id_list, 621 'action' => $action, 622 'redirect' => $redirect) 623 ); 624 625 if (confirm_box(true)) 626 { 627 $post_info = ($pm) ? phpbb_get_pm_data($post_id_list) : phpbb_get_post_data($post_id_list, 'm_report'); 628 629 $sql = "SELECT r.report_id, r.$id_column, r.report_closed, r.user_id, r.user_notify, u.username, u.username_clean, u.user_email, u.user_jabber, u.user_lang, u.user_notify_type 630 FROM " . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u 631 WHERE ' . $db->sql_in_set('r.report_id', $report_id_list) . ' 632 ' . (($action == 'close') ? 'AND r.report_closed = 0' : '') . ' 633 AND r.user_id = u.user_id' . $pm_where; 634 $result = $db->sql_query($sql); 635 636 $reports = $close_report_posts = $close_report_topics = $notify_reporters = $report_id_list = array(); 637 while ($report = $db->sql_fetchrow($result)) 638 { 639 $reports[$report['report_id']] = $report; 640 $report_id_list[] = $report['report_id']; 641 642 if (!$report['report_closed']) 643 { 644 $close_report_posts[] = $report[$id_column]; 645 646 if (!$pm) 647 { 648 $close_report_topics[] = $post_info[$report['post_id']]['topic_id']; 649 } 650 } 651 652 if ($report['user_notify'] && !$report['report_closed']) 653 { 654 $notify_reporters[$report['report_id']] = &$reports[$report['report_id']]; 655 } 656 } 657 $db->sql_freeresult($result); 658 659 if (count($reports)) 660 { 661 $close_report_posts = array_unique($close_report_posts); 662 $close_report_topics = array_unique($close_report_topics); 663 664 if (!$pm && count($close_report_posts)) 665 { 666 // Get a list of topics that still contain reported posts 667 $sql = 'SELECT DISTINCT topic_id 668 FROM ' . POSTS_TABLE . ' 669 WHERE ' . $db->sql_in_set('topic_id', $close_report_topics) . ' 670 AND post_reported = 1 671 AND ' . $db->sql_in_set('post_id', $close_report_posts, true); 672 $result = $db->sql_query($sql); 673 674 $keep_report_topics = array(); 675 while ($row = $db->sql_fetchrow($result)) 676 { 677 $keep_report_topics[] = $row['topic_id']; 678 } 679 $db->sql_freeresult($result); 680 681 $close_report_topics = array_diff($close_report_topics, $keep_report_topics); 682 unset($keep_report_topics); 683 } 684 685 $db->sql_transaction('begin'); 686 687 if ($action == 'close') 688 { 689 $sql = 'UPDATE ' . REPORTS_TABLE . ' 690 SET report_closed = 1 691 WHERE ' . $db->sql_in_set('report_id', $report_id_list); 692 } 693 else 694 { 695 $sql = 'DELETE FROM ' . REPORTS_TABLE . ' 696 WHERE ' . $db->sql_in_set('report_id', $report_id_list); 697 } 698 $db->sql_query($sql); 699 700 if (count($close_report_posts)) 701 { 702 if ($pm) 703 { 704 $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' 705 SET message_reported = 0 706 WHERE ' . $db->sql_in_set('msg_id', $close_report_posts); 707 $db->sql_query($sql); 708 709 if ($action == 'delete') 710 { 711 delete_pm(ANONYMOUS, $close_report_posts, PRIVMSGS_INBOX); 712 } 713 } 714 else 715 { 716 $sql = 'UPDATE ' . POSTS_TABLE . ' 717 SET post_reported = 0 718 WHERE ' . $db->sql_in_set('post_id', $close_report_posts); 719 $db->sql_query($sql); 720 721 if (count($close_report_topics)) 722 { 723 $sql = 'UPDATE ' . TOPICS_TABLE . ' 724 SET topic_reported = 0 725 WHERE ' . $db->sql_in_set('topic_id', $close_report_topics) . ' 726 OR ' . $db->sql_in_set('topic_moved_id', $close_report_topics); 727 $db->sql_query($sql); 728 } 729 } 730 } 731 732 $db->sql_transaction('commit'); 733 } 734 unset($close_report_posts, $close_report_topics); 735 736 /* @var $phpbb_notifications \phpbb\notification\manager */ 737 $phpbb_notifications = $phpbb_container->get('notification_manager'); 738 739 foreach ($reports as $report) 740 { 741 if ($pm) 742 { 743 $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_PM_REPORT_' . strtoupper($action) . 'D', false, array( 744 'forum_id' => 0, 745 'topic_id' => 0, 746 $post_info[$report['pm_id']]['message_subject'] 747 )); 748 $phpbb_notifications->delete_notifications('notification.type.report_pm', $report['pm_id']); 749 } 750 else 751 { 752 $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_REPORT_' . strtoupper($action) . 'D', false, array( 753 'forum_id' => $post_info[$report['post_id']]['forum_id'], 754 'topic_id' => $post_info[$report['post_id']]['topic_id'], 755 'post_id' => $report['post_id'], 756 $post_info[$report['post_id']]['post_subject'] 757 )); 758 $phpbb_notifications->delete_notifications('notification.type.report_post', $report['post_id']); 759 } 760 } 761 762 // Notify reporters 763 if (count($notify_reporters)) 764 { 765 foreach ($notify_reporters as $report_id => $reporter) 766 { 767 if ($reporter['user_id'] == ANONYMOUS) 768 { 769 continue; 770 } 771 772 $post_id = $reporter[$id_column]; 773 774 if ($pm) 775 { 776 $phpbb_notifications->add_notifications('notification.type.report_pm_closed', array_merge($post_info[$post_id], array( 777 'reporter' => $reporter['user_id'], 778 'closer_id' => $user->data['user_id'], 779 'from_user_id' => $post_info[$post_id]['author_id'], 780 ))); 781 } 782 else 783 { 784 $phpbb_notifications->add_notifications('notification.type.report_post_closed', array_merge($post_info[$post_id], array( 785 'reporter' => $reporter['user_id'], 786 'closer_id' => $user->data['user_id'], 787 ))); 788 } 789 } 790 } 791 792 if (!$pm) 793 { 794 foreach ($post_info as $post) 795 { 796 $forum_ids[$post['forum_id']] = $post['forum_id']; 797 $topic_ids[$post['topic_id']] = $post['topic_id']; 798 } 799 } 800 801 unset($notify_reporters, $post_info, $reports); 802 803 $success_msg = (count($report_id_list) == 1) ? "{$pm_prefix}REPORT_" . strtoupper($action) . 'D_SUCCESS' : "{$pm_prefix}REPORTS_" . strtoupper($action) . 'D_SUCCESS'; 804 } 805 else 806 { 807 confirm_box(false, $user->lang[strtoupper($action) . "_{$pm_prefix}REPORT" . ((count($report_id_list) == 1) ? '' : 'S') . '_CONFIRM'], $s_hidden_fields); 808 } 809 810 $redirect = $request->variable('redirect', "index.$phpEx"); 811 $redirect = reapply_sid($redirect); 812 813 if (!$success_msg) 814 { 815 redirect($redirect); 816 } 817 else 818 { 819 meta_refresh(3, $redirect); 820 821 $return_forum = ''; 822 $return_topic = ''; 823 824 if (!$pm) 825 { 826 if (count($forum_ids) === 1) 827 { 828 $return_forum = sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . current($forum_ids)) . '">', '</a>') . '<br /><br />'; 829 } 830 831 if (count($topic_ids) === 1) 832 { 833 $return_topic = sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . current($topic_ids) . '&f=' . current($forum_ids)) . '">', '</a>') . '<br /><br />'; 834 } 835 } 836 837 trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_forum . $return_topic . sprintf($user->lang['RETURN_PAGE'], "<a href=\"$redirect\">", '</a>')); 838 } 839 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |