Changeset 702 for trunk/forum/report.php
- Timestamp:
- Mar 31, 2010, 6:32:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/forum/report.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : report.php 8479 2008-03-29 00:22:48Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 25 25 $forum_id = request_var('f', 0); 26 26 $post_id = request_var('p', 0); 27 $pm_id = request_var('pm', 0); 27 28 $reason_id = request_var('reason_id', 0); 28 29 $report_text = utf8_normalize_nfc(request_var('report_text', '', true)); … … 31 32 $submit = (isset($_POST['submit'])) ? true : false; 32 33 33 if (!$post_id )34 if (!$post_id && (!$pm_id || !$config['allow_pm_report'])) 34 35 { 35 36 trigger_error('NO_POST_SELECTED'); 36 37 } 37 38 38 $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&p=$post_id") . "#p$post_id"; 39 if ($post_id) 40 { 41 $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&p=$post_id") . "#p$post_id"; 42 $pm_id = 0; 43 } 44 else 45 { 46 $redirect_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&mode=view&p=$pm_id"); 47 $post_id = 0; 48 $forum_id = 0; 49 } 39 50 40 51 // Has the report been cancelled? … … 44 55 } 45 56 46 // Grab all relevant data 47 $sql = 'SELECT t.*, p.* 48 FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t 49 WHERE p.post_id = $post_id 50 AND p.topic_id = t.topic_id"; 51 $result = $db->sql_query($sql); 52 $report_data = $db->sql_fetchrow($result); 53 $db->sql_freeresult($result); 54 55 if (!$report_data) 56 { 57 trigger_error('POST_NOT_EXIST'); 58 } 59 60 $forum_id = (int) ($report_data['forum_id']) ? $report_data['forum_id'] : $forum_id; 61 $topic_id = (int) $report_data['topic_id']; 62 63 $sql = 'SELECT * 64 FROM ' . FORUMS_TABLE . ' 65 WHERE forum_id = ' . $forum_id; 66 $result = $db->sql_query($sql); 67 $forum_data = $db->sql_fetchrow($result); 68 $db->sql_freeresult($result); 69 70 if (!$forum_data) 71 { 72 trigger_error('FORUM_NOT_EXIST'); 73 } 74 75 // Check required permissions 76 $acl_check_ary = array('f_list' => 'POST_NOT_EXIST', 'f_read' => 'USER_CANNOT_READ', 'f_report' => 'USER_CANNOT_REPORT'); 77 78 foreach ($acl_check_ary as $acl => $error) 79 { 80 if (!$auth->acl_get($acl, $forum_id)) 81 { 82 trigger_error($error); 83 } 84 } 85 unset($acl_check_ary); 86 87 if ($report_data['post_reported']) 88 { 89 $message = $user->lang['ALREADY_REPORTED']; 90 $message .= '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>'); 91 trigger_error($message); 57 if ($post_id) 58 { 59 // Grab all relevant data 60 $sql = 'SELECT t.*, p.* 61 FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t 62 WHERE p.post_id = $post_id 63 AND p.topic_id = t.topic_id"; 64 $result = $db->sql_query($sql); 65 $report_data = $db->sql_fetchrow($result); 66 $db->sql_freeresult($result); 67 68 if (!$report_data) 69 { 70 trigger_error('POST_NOT_EXIST'); 71 } 72 73 $forum_id = (int) ($report_data['forum_id']) ? $report_data['forum_id'] : $forum_id; 74 $topic_id = (int) $report_data['topic_id']; 75 76 $sql = 'SELECT * 77 FROM ' . FORUMS_TABLE . ' 78 WHERE forum_id = ' . $forum_id; 79 $result = $db->sql_query($sql); 80 $forum_data = $db->sql_fetchrow($result); 81 $db->sql_freeresult($result); 82 83 if (!$forum_data) 84 { 85 trigger_error('FORUM_NOT_EXIST'); 86 } 87 88 // Check required permissions 89 $acl_check_ary = array('f_list' => 'POST_NOT_EXIST', 'f_read' => 'USER_CANNOT_READ', 'f_report' => 'USER_CANNOT_REPORT'); 90 91 foreach ($acl_check_ary as $acl => $error) 92 { 93 if (!$auth->acl_get($acl, $forum_id)) 94 { 95 trigger_error($error); 96 } 97 } 98 unset($acl_check_ary); 99 100 if ($report_data['post_reported']) 101 { 102 $message = $user->lang['ALREADY_REPORTED']; 103 $message .= '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>'); 104 trigger_error($message); 105 } 106 } 107 else 108 { 109 // Grab all relevant data 110 $sql = 'SELECT p.*, pt.* 111 FROM ' . PRIVMSGS_TABLE . ' p, ' . PRIVMSGS_TO_TABLE . " pt 112 WHERE p.msg_id = $pm_id 113 AND p.msg_id = pt.msg_id 114 AND (p.author_id = " . $user->data['user_id'] . " OR pt.user_id = " . $user->data['user_id'] . ")"; 115 $result = $db->sql_query($sql); 116 $report_data = $db->sql_fetchrow($result); 117 $db->sql_freeresult($result); 118 119 if (!$report_data) 120 { 121 $user->add_lang('ucp'); 122 trigger_error('NO_MESSAGE'); 123 } 124 125 if ($report_data['message_reported']) 126 { 127 $message = $user->lang['ALREADY_REPORTED_PM']; 128 $message .= '<br /><br />' . sprintf($user->lang['RETURN_PM'], '<a href="' . $redirect_url . '">', '</a>'); 129 trigger_error($message); 130 } 92 131 } 93 132 … … 110 149 'reason_id' => (int) $reason_id, 111 150 'post_id' => $post_id, 151 'pm_id' => $pm_id, 112 152 'user_id' => (int) $user->data['user_id'], 113 153 'user_notify' => (int) $user_notify, … … 121 161 $report_id = $db->sql_nextid(); 122 162 123 if ( !$report_data['post_reported'])163 if ($post_id) 124 164 { 125 165 $sql = 'UPDATE ' . POSTS_TABLE . ' … … 127 167 WHERE post_id = ' . $post_id; 128 168 $db->sql_query($sql); 129 } 130 131 if (!$report_data['topic_reported']) 132 { 133 $sql = 'UPDATE ' . TOPICS_TABLE . ' 134 SET topic_reported = 1 135 WHERE topic_id = ' . $report_data['topic_id'] . ' 136 OR topic_moved_id = ' . $report_data['topic_id']; 169 170 if (!$report_data['topic_reported']) 171 { 172 $sql = 'UPDATE ' . TOPICS_TABLE . ' 173 SET topic_reported = 1 174 WHERE topic_id = ' . $report_data['topic_id'] . ' 175 OR topic_moved_id = ' . $report_data['topic_id']; 176 $db->sql_query($sql); 177 } 178 179 $lang_return = $user->lang['RETURN_TOPIC']; 180 $lang_success = $user->lang['POST_REPORTED_SUCCESS']; 181 } 182 else 183 { 184 $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' 185 SET message_reported = 1 186 WHERE msg_id = ' . $pm_id; 137 187 $db->sql_query($sql); 188 189 $sql_ary = array( 190 'msg_id' => $pm_id, 191 'user_id' => ANONYMOUS, 192 'author_id' => (int) $report_data['author_id'], 193 'pm_deleted' => 0, 194 'pm_new' => 0, 195 'pm_unread' => 0, 196 'pm_replied' => 0, 197 'pm_marked' => 0, 198 'pm_forwarded' => 0, 199 'folder_id' => PRIVMSGS_INBOX, 200 ); 201 202 $sql = 'INSERT INTO ' . PRIVMSGS_TO_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); 203 $db->sql_query($sql); 204 205 $lang_return = $user->lang['RETURN_PM']; 206 $lang_success = $user->lang['PM_REPORTED_SUCCESS']; 138 207 } 139 208 140 209 meta_refresh(3, $redirect_url); 141 210 142 $message = $ user->lang['POST_REPORTED_SUCCESS'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>');211 $message = $lang_success . '<br /><br />' . sprintf($lang_return, '<a href="' . $redirect_url . '">', '</a>'); 143 212 trigger_error($message); 144 213 } … … 147 216 display_reasons($reason_id); 148 217 218 $page_title = ($pm_id) ? $user->lang['REPORT_MESSAGE'] : $user->lang['REPORT_POST']; 219 149 220 $template->assign_vars(array( 221 'S_REPORT_POST' => ($pm_id) ? false : true, 150 222 'REPORT_TEXT' => $report_text, 151 'S_REPORT_ACTION' => append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $post_id ),223 'S_REPORT_ACTION' => append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $post_id . '&pm=' . $pm_id), 152 224 153 225 'S_NOTIFY' => $user_notify, … … 158 230 159 231 // Start output of page 160 page_header($ user->lang['REPORT_POST']);232 page_header($page_title); 161 233 162 234 $template->set_filenames(array(
Note:
See TracChangeset
for help on using the changeset viewer.