Ignore:
Timestamp:
Mar 31, 2010, 6:32:40 PM (14 years ago)
Author:
george
Message:
  • Upraveno: Aktualizace fóra.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/forum/includes/mcp/mcp_reports.php

    r400 r702  
    33*
    44* @package mcp
    5 * @version $Id: mcp_reports.php 9015 2008-10-14 18:29:50Z toonarmy $
     5* @version $Id$
    66* @copyright (c) 2005 phpBB Group
    77* @license http://opensource.org/licenses/gpl-license.php GNU Public License
     
    7878                                                AND rr.reason_id = r.reason_id
    7979                                                AND r.user_id = u.user_id
     80                                                AND r.pm_id = 0
    8081                                        ORDER BY report_closed ASC';
    8182                                $result = $db->sql_query_limit($sql, 1);
     
    116117                                        $template->assign_vars(array(
    117118                                                'S_TOPIC_REVIEW'        => true,
     119                                                'S_BBCODE_ALLOWED'      => $post_info['enable_bbcode'],
    118120                                                'TOPIC_TITLE'           => $post_info['topic_title'])
    119121                                        );
     
    150152                                if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id']))
    151153                                {
    152                                         $extensions = $cache->obtain_attach_extensions($post_info['forum_id']);
    153 
    154154                                        $sql = 'SELECT *
    155155                                                FROM ' . ATTACHMENTS_TABLE . '
    156156                                                WHERE post_msg_id = ' . $post_id . '
    157157                                                        AND in_message = 0
    158                                                 ORDER BY filetime DESC, post_msg_id ASC';
     158                                                ORDER BY filetime DESC';
    159159                                        $result = $db->sql_query($sql);
    160160
     
    259259                                unset($forum_list_read);
    260260
    261                                 if ($topic_id && $forum_id)
     261                                if ($topic_id)
    262262                                {
    263263                                        $topic_info = get_topic_data(array($topic_id));
     
    268268                                        }
    269269
    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                                        }
    276279                                }
    277280
     
    330333
    331334                                $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)) : '';
    333336
    334337                                if ($mode == 'reports')
     
    347350                                                AND r.post_id = p.post_id
    348351                                                " . (($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' : '') . '
    350353                                                ' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . "
    351354                                                AND t.topic_id = p.topic_id
     355                                                AND r.pm_id = 0
    352356                                                $limit_time_sql
    353357                                        ORDER BY $sort_order_sql";
     
    372376                                                        AND u.user_id = p.poster_id
    373377                                                        AND ru.user_id = r.user_id
     378                                                        AND r.pm_id = 0
    374379                                                ORDER BY ' . $sort_order_sql;
    375380                                        $result = $db->sql_query($sql);
     
    426431                                        'TOPIC_ID'                              => $topic_id,
    427432                                        '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),
    429434                                        )
    430435                                );
     
    439444* Closes a report
    440445*/
    441 function close_report($report_id_list, $mode, $action)
     446function close_report($report_id_list, $mode, $action, $pm = false)
    442447{
    443         global $db, $template, $user, $config;
     448        global $db, $template, $user, $config, $auth;
    444449        global $phpEx, $phpbb_root_path;
    445450
    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;
    449459        $result = $db->sql_query($sql);
    450460
     
    452462        while ($row = $db->sql_fetchrow($result))
    453463        {
    454                 $post_id_list[] = $row['post_id'];
     464                $post_id_list[] = $row[$id_column];
    455465        }
    456466        $post_id_list = array_unique($post_id_list);
    457467
    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                }
    461481        }
    462482
     
    465485                $redirect = request_var('redirect', build_url(array('mode', 'r', 'quickmod')) . '&mode=reports');
    466486        }
     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        }
    467491        else if ($action == 'close' && !request_var('r', 0))
    468492        {
    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);
    470494        }
    471495        else
     
    478502
    479503        $s_hidden_fields = build_hidden_fields(array(
    480                 'i'                                     => 'reports',
     504                'i'                                     => $module,
    481505                'mode'                          => $mode,
    482506                'report_id_list'        => $report_id_list,
     
    487511        if (confirm_box(true))
    488512        {
    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_type
    492                         FROM ' . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u
     513                $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
    493517                        WHERE ' . $db->sql_in_set('r.report_id', $report_id_list) . '
    494518                                ' . (($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;
    496520                $result = $db->sql_query($sql);
    497521
     
    504528                        if (!$report['report_closed'])
    505529                        {
    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                                }
    508536                        }
    509537
     
    520548                        $close_report_topics = array_unique($close_report_topics);
    521549
    522                         if (sizeof($close_report_posts))
     550                        if (!$pm && sizeof($close_report_posts))
    523551                        {
    524552                                // Get a list of topics that still contain reported posts
     
    559587                        if (sizeof($close_report_posts))
    560588                        {
    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);
    572594                                        $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                                        }
    573616                                }
    574617                        }
     
    580623                foreach ($reports as $report)
    581624                {
    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                        }
    583633                }
    584634
     
    595645                                }
    596646
    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']);
    600650
    601651                                $messenger->to($reporter['user_email'], $reporter['username']);
    602652                                $messenger->im($reporter['user_jabber'], $reporter['username']);
    603653
    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                                }
    610671
    611672                                $messenger->send($reporter['user_notify_type']);
    612673                        }
    613674                }
    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
    621685                unset($notify_reporters, $post_info, $reports);
    622686
    623687                $messenger->save_queue();
    624688
    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';
    626690        }
    627691        else
    628692        {
    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);
    630694        }
    631695
     
    640704        {
    641705                meta_refresh(3, $redirect);
     706
    642707                $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                 }
    647708                $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) . '&amp;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) . '&amp;f=' . current($forum_ids)) . '">', '</a>') . '<br /><br />';
     720                        }
     721                }
     722
    653723                trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_forum . $return_topic . sprintf($user->lang['RETURN_PAGE'], "<a href=\"$redirect\">", '</a>'));
    654724        }
Note: See TracChangeset for help on using the changeset viewer.