Changeset 702 for trunk/forum/includes/mcp/mcp_reports.php
- Timestamp:
- Mar 31, 2010, 6:32:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/forum/includes/mcp/mcp_reports.php
r400 r702 3 3 * 4 4 * @package mcp 5 * @version $Id : mcp_reports.php 9015 2008-10-14 18:29:50Z toonarmy$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 78 78 AND rr.reason_id = r.reason_id 79 79 AND r.user_id = u.user_id 80 AND r.pm_id = 0 80 81 ORDER BY report_closed ASC'; 81 82 $result = $db->sql_query_limit($sql, 1); … … 116 117 $template->assign_vars(array( 117 118 'S_TOPIC_REVIEW' => true, 119 'S_BBCODE_ALLOWED' => $post_info['enable_bbcode'], 118 120 'TOPIC_TITLE' => $post_info['topic_title']) 119 121 ); … … 150 152 if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) 151 153 { 152 $extensions = $cache->obtain_attach_extensions($post_info['forum_id']);153 154 154 $sql = 'SELECT * 155 155 FROM ' . ATTACHMENTS_TABLE . ' 156 156 WHERE post_msg_id = ' . $post_id . ' 157 157 AND in_message = 0 158 ORDER BY filetime DESC , post_msg_id ASC';158 ORDER BY filetime DESC'; 159 159 $result = $db->sql_query($sql); 160 160 … … 259 259 unset($forum_list_read); 260 260 261 if ($topic_id && $forum_id)261 if ($topic_id) 262 262 { 263 263 $topic_info = get_topic_data(array($topic_id)); … … 268 268 } 269 269 270 $topic_info = $topic_info[$topic_id]; 271 $forum_id = $topic_info['forum_id']; 272 } 273 else if ($topic_id && !$forum_id) 274 { 275 $topic_id = 0; 270 if ($forum_id != $topic_info[$topic_id]['forum_id']) 271 { 272 $topic_id = 0; 273 } 274 else 275 { 276 $topic_info = $topic_info[$topic_id]; 277 $forum_id = (int) $topic_info['forum_id']; 278 } 276 279 } 277 280 … … 330 333 331 334 $forum_topics = ($total == -1) ? $forum_info['forum_topics'] : $total; 332 $limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : '';335 $limit_time_sql = ($sort_days) ? 'AND r.report_time >= ' . (time() - ($sort_days * 86400)) : ''; 333 336 334 337 if ($mode == 'reports') … … 347 350 AND r.post_id = p.post_id 348 351 " . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . ' 349 ' . (($sort_order_sql[0] == 'r') ? 'AND ru.user_id = p.poster_id' : '') . '352 ' . (($sort_order_sql[0] == 'r') ? 'AND ru.user_id = r.user_id' : '') . ' 350 353 ' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . " 351 354 AND t.topic_id = p.topic_id 355 AND r.pm_id = 0 352 356 $limit_time_sql 353 357 ORDER BY $sort_order_sql"; … … 372 376 AND u.user_id = p.poster_id 373 377 AND ru.user_id = r.user_id 378 AND r.pm_id = 0 374 379 ORDER BY ' . $sort_order_sql; 375 380 $result = $db->sql_query($sql); … … 426 431 'TOPIC_ID' => $topic_id, 427 432 'TOTAL' => $total, 428 'TOTAL_REPORTS' => ($total == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $total), 433 'TOTAL_REPORTS' => ($total == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $total), 429 434 ) 430 435 ); … … 439 444 * Closes a report 440 445 */ 441 function close_report($report_id_list, $mode, $action )446 function close_report($report_id_list, $mode, $action, $pm = false) 442 447 { 443 global $db, $template, $user, $config ;448 global $db, $template, $user, $config, $auth; 444 449 global $phpEx, $phpbb_root_path; 445 450 446 $sql = 'SELECT r.post_id 447 FROM ' . REPORTS_TABLE . ' r 448 WHERE ' . $db->sql_in_set('r.report_id', $report_id_list); 451 $pm_where = ($pm) ? ' AND r.post_id = 0 ' : ' AND r.pm_id = 0 '; 452 $id_column = ($pm) ? 'pm_id' : 'post_id'; 453 $module = ($pm) ? 'pm_reports' : 'reports'; 454 $pm_prefix = ($pm) ? 'PM_' : ''; 455 456 $sql = "SELECT r.$id_column 457 FROM " . REPORTS_TABLE . ' r 458 WHERE ' . $db->sql_in_set('r.report_id', $report_id_list) . $pm_where; 449 459 $result = $db->sql_query($sql); 450 460 … … 452 462 while ($row = $db->sql_fetchrow($result)) 453 463 { 454 $post_id_list[] = $row[ 'post_id'];464 $post_id_list[] = $row[$id_column]; 455 465 } 456 466 $post_id_list = array_unique($post_id_list); 457 467 458 if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_report'))) 459 { 460 trigger_error('NOT_AUTHORISED'); 468 if ($pm) 469 { 470 if (!$auth->acl_getf_global('m_report')) 471 { 472 trigger_error('NOT_AUTHORISED'); 473 } 474 } 475 else 476 { 477 if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_report'))) 478 { 479 trigger_error('NOT_AUTHORISED'); 480 } 461 481 } 462 482 … … 465 485 $redirect = request_var('redirect', build_url(array('mode', 'r', 'quickmod')) . '&mode=reports'); 466 486 } 487 elseif ($action == 'delete' && strpos($user->data['session_page'], 'mode=pm_report_details') !== false) 488 { 489 $redirect = request_var('redirect', build_url(array('mode', 'r', 'quickmod')) . '&mode=pm_reports'); 490 } 467 491 else if ($action == 'close' && !request_var('r', 0)) 468 492 { 469 $redirect = request_var('redirect', build_url(array('mode', 'p', 'quickmod')) . '&mode= reports');493 $redirect = request_var('redirect', build_url(array('mode', 'p', 'quickmod')) . '&mode=' . $module); 470 494 } 471 495 else … … 478 502 479 503 $s_hidden_fields = build_hidden_fields(array( 480 'i' => 'reports',504 'i' => $module, 481 505 'mode' => $mode, 482 506 'report_id_list' => $report_id_list, … … 487 511 if (confirm_box(true)) 488 512 { 489 $post_info = get_post_data($post_id_list, 'm_report');490 491 $sql = 'SELECT r.report_id, r.post_id, 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_type492 FROM '. REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u513 $post_info = ($pm) ? get_pm_data($post_id_list) : get_post_data($post_id_list, 'm_report'); 514 515 $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 516 FROM " . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u 493 517 WHERE ' . $db->sql_in_set('r.report_id', $report_id_list) . ' 494 518 ' . (($action == 'close') ? 'AND r.report_closed = 0' : '') . ' 495 AND r.user_id = u.user_id' ;519 AND r.user_id = u.user_id' . $pm_where; 496 520 $result = $db->sql_query($sql); 497 521 … … 504 528 if (!$report['report_closed']) 505 529 { 506 $close_report_posts[] = $report['post_id']; 507 $close_report_topics[] = $post_info[$report['post_id']]['topic_id']; 530 $close_report_posts[] = $report[$id_column]; 531 532 if (!$pm) 533 { 534 $close_report_topics[] = $post_info[$report['post_id']]['topic_id']; 535 } 508 536 } 509 537 … … 520 548 $close_report_topics = array_unique($close_report_topics); 521 549 522 if ( sizeof($close_report_posts))550 if (!$pm && sizeof($close_report_posts)) 523 551 { 524 552 // Get a list of topics that still contain reported posts … … 559 587 if (sizeof($close_report_posts)) 560 588 { 561 $sql = 'UPDATE ' . POSTS_TABLE . ' 562 SET post_reported = 0 563 WHERE ' . $db->sql_in_set('post_id', $close_report_posts); 564 $db->sql_query($sql); 565 566 if (sizeof($close_report_topics)) 567 { 568 $sql = 'UPDATE ' . TOPICS_TABLE . ' 569 SET topic_reported = 0 570 WHERE ' . $db->sql_in_set('topic_id', $close_report_topics) . ' 571 OR ' . $db->sql_in_set('topic_moved_id', $close_report_topics); 589 if ($pm) 590 { 591 $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' 592 SET message_reported = 0 593 WHERE ' . $db->sql_in_set('msg_id', $close_report_posts); 572 594 $db->sql_query($sql); 595 596 if ($action == 'delete') 597 { 598 delete_pm(ANONYMOUS, $close_report_posts, PRIVMSGS_INBOX); 599 } 600 } 601 else 602 { 603 $sql = 'UPDATE ' . POSTS_TABLE . ' 604 SET post_reported = 0 605 WHERE ' . $db->sql_in_set('post_id', $close_report_posts); 606 $db->sql_query($sql); 607 608 if (sizeof($close_report_topics)) 609 { 610 $sql = 'UPDATE ' . TOPICS_TABLE . ' 611 SET topic_reported = 0 612 WHERE ' . $db->sql_in_set('topic_id', $close_report_topics) . ' 613 OR ' . $db->sql_in_set('topic_moved_id', $close_report_topics); 614 $db->sql_query($sql); 615 } 573 616 } 574 617 } … … 580 623 foreach ($reports as $report) 581 624 { 582 add_log('mod', $post_info[$report['post_id']]['forum_id'], $post_info[$report['post_id']]['topic_id'], 'LOG_REPORT_' . strtoupper($action) . 'D', $post_info[$report['post_id']]['post_subject']); 625 if ($pm) 626 { 627 add_log('mod', 0, 0, 'LOG_PM_REPORT_' . strtoupper($action) . 'D', $post_info[$report['pm_id']]['message_subject']); 628 } 629 else 630 { 631 add_log('mod', $post_info[$report['post_id']]['forum_id'], $post_info[$report['post_id']]['topic_id'], 'LOG_REPORT_' . strtoupper($action) . 'D', $post_info[$report['post_id']]['post_subject']); 632 } 583 633 } 584 634 … … 595 645 } 596 646 597 $post_id = $reporter[ 'post_id'];598 599 $messenger->template( 'report_'. $action . 'd', $reporter['user_lang']);647 $post_id = $reporter[$id_column]; 648 649 $messenger->template((($pm) ? 'pm_report_' : 'report_') . $action . 'd', $reporter['user_lang']); 600 650 601 651 $messenger->to($reporter['user_email'], $reporter['username']); 602 652 $messenger->im($reporter['user_jabber'], $reporter['username']); 603 653 604 $messenger->assign_vars(array( 605 'USERNAME' => htmlspecialchars_decode($reporter['username']), 606 'CLOSER_NAME' => htmlspecialchars_decode($user->data['username']), 607 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_info[$post_id]['post_subject'])), 608 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_info[$post_id]['topic_title']))) 609 ); 654 if ($pm) 655 { 656 $messenger->assign_vars(array( 657 'USERNAME' => htmlspecialchars_decode($reporter['username']), 658 'CLOSER_NAME' => htmlspecialchars_decode($user->data['username']), 659 'PM_SUBJECT' => htmlspecialchars_decode(censor_text($post_info[$post_id]['message_subject'])), 660 )); 661 } 662 else 663 { 664 $messenger->assign_vars(array( 665 'USERNAME' => htmlspecialchars_decode($reporter['username']), 666 'CLOSER_NAME' => htmlspecialchars_decode($user->data['username']), 667 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_info[$post_id]['post_subject'])), 668 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_info[$post_id]['topic_title']))) 669 ); 670 } 610 671 611 672 $messenger->send($reporter['user_notify_type']); 612 673 } 613 674 } 614 615 foreach ($post_info as $post) 616 { 617 $forum_ids[$post['forum_id']] = $post['forum_id']; 618 $topic_ids[$post['topic_id']] = $post['topic_id']; 619 } 620 675 676 if (!$pm) 677 { 678 foreach ($post_info as $post) 679 { 680 $forum_ids[$post['forum_id']] = $post['forum_id']; 681 $topic_ids[$post['topic_id']] = $post['topic_id']; 682 } 683 } 684 621 685 unset($notify_reporters, $post_info, $reports); 622 686 623 687 $messenger->save_queue(); 624 688 625 $success_msg = (sizeof($report_id_list) == 1) ? 'REPORT_' . strtoupper($action) . 'D_SUCCESS' : 'REPORTS_'. strtoupper($action) . 'D_SUCCESS';689 $success_msg = (sizeof($report_id_list) == 1) ? "{$pm_prefix}REPORT_" . strtoupper($action) . 'D_SUCCESS' : "{$pm_prefix}REPORTS_" . strtoupper($action) . 'D_SUCCESS'; 626 690 } 627 691 else 628 692 { 629 confirm_box(false, $user->lang[strtoupper($action) . '_REPORT'. ((sizeof($report_id_list) == 1) ? '' : 'S') . '_CONFIRM'], $s_hidden_fields);693 confirm_box(false, $user->lang[strtoupper($action) . "_{$pm_prefix}REPORT" . ((sizeof($report_id_list) == 1) ? '' : 'S') . '_CONFIRM'], $s_hidden_fields); 630 694 } 631 695 … … 640 704 { 641 705 meta_refresh(3, $redirect); 706 642 707 $return_forum = ''; 643 if (sizeof($forum_ids == 1))644 {645 $return_forum = sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . current($forum_ids)) . '">', '</a>') . '<br /><br />';646 }647 708 $return_topic = ''; 648 if (sizeof($topic_ids == 1)) 649 { 650 $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 />'; 651 } 652 709 710 if (!$pm) 711 { 712 if (sizeof($forum_ids) === 1) 713 { 714 $return_forum = sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . current($forum_ids)) . '">', '</a>') . '<br /><br />'; 715 } 716 717 if (sizeof($topic_ids) === 1) 718 { 719 $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 />'; 720 } 721 } 722 653 723 trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_forum . $return_topic . sprintf($user->lang['RETURN_PAGE'], "<a href=\"$redirect\">", '</a>')); 654 724 }
Note:
See TracChangeset
for help on using the changeset viewer.