Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 176 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
mcp_pm_reports | |
0.00% |
0 / 174 |
|
0.00% |
0 / 2 |
2070 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
main | |
0.00% |
0 / 173 |
|
0.00% |
0 / 1 |
1980 |
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_pm_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; |
40 | |
41 | include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); |
42 | include_once($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); |
43 | |
44 | /* @var $pagination \phpbb\pagination */ |
45 | $pagination = $phpbb_container->get('pagination'); |
46 | $start = $request->variable('start', 0); |
47 | |
48 | $this->page_title = 'MCP_PM_REPORTS'; |
49 | |
50 | switch ($action) |
51 | { |
52 | case 'close': |
53 | case 'delete': |
54 | include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); |
55 | |
56 | $report_id_list = $request->variable('report_id_list', array(0)); |
57 | |
58 | if (!count($report_id_list)) |
59 | { |
60 | trigger_error('NO_REPORT_SELECTED'); |
61 | } |
62 | |
63 | if (!function_exists('close_report')) |
64 | { |
65 | include($phpbb_root_path . 'includes/mcp/mcp_reports.' . $phpEx); |
66 | } |
67 | |
68 | close_report($report_id_list, $mode, $action, true); |
69 | |
70 | break; |
71 | } |
72 | |
73 | switch ($mode) |
74 | { |
75 | case 'pm_report_details': |
76 | |
77 | $user->add_lang(array('posting', 'viewforum', 'viewtopic', 'ucp')); |
78 | |
79 | $report_id = $request->variable('r', 0); |
80 | |
81 | $sql = 'SELECT r.pm_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour |
82 | FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u |
83 | WHERE r.report_id = ' . $report_id . ' |
84 | AND rr.reason_id = r.reason_id |
85 | AND r.user_id = u.user_id |
86 | AND r.post_id = 0 |
87 | ORDER BY report_closed ASC'; |
88 | $result = $db->sql_query_limit($sql, 1); |
89 | $report = $db->sql_fetchrow($result); |
90 | $db->sql_freeresult($result); |
91 | |
92 | if (!$report_id || !$report) |
93 | { |
94 | trigger_error('NO_REPORT'); |
95 | } |
96 | |
97 | /* @var $phpbb_notifications \phpbb\notification\manager */ |
98 | $phpbb_notifications = $phpbb_container->get('notification_manager'); |
99 | |
100 | $phpbb_notifications->mark_notifications_by_parent('report_pm', $report_id, $user->data['user_id']); |
101 | |
102 | $pm_id = $report['pm_id']; |
103 | $report_id = $report['report_id']; |
104 | |
105 | $pm_info = phpbb_get_pm_data(array($pm_id)); |
106 | |
107 | if (!count($pm_info)) |
108 | { |
109 | trigger_error('NO_REPORT_SELECTED'); |
110 | } |
111 | |
112 | $pm_info = $pm_info[$pm_id]; |
113 | |
114 | write_pm_addresses(array('to' => $pm_info['to_address'], 'bcc' => $pm_info['bcc_address']), (int) $pm_info['author_id']); |
115 | |
116 | $reason = array('title' => $report['reason_title'], 'description' => $report['reason_description']); |
117 | if (isset($user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])])) |
118 | { |
119 | $reason['description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])]; |
120 | $reason['title'] = $user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]; |
121 | } |
122 | |
123 | // Process message, leave it uncensored |
124 | $parse_flags = ($pm_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; |
125 | $message = generate_text_for_display($pm_info['message_text'], $pm_info['bbcode_uid'], $pm_info['bbcode_bitfield'], $parse_flags, false); |
126 | |
127 | $report['report_text'] = make_clickable(bbcode_nl2br($report['report_text'])); |
128 | |
129 | if ($pm_info['message_attachment'] && $auth->acl_get('u_pm_download')) |
130 | { |
131 | $sql = 'SELECT * |
132 | FROM ' . ATTACHMENTS_TABLE . ' |
133 | WHERE post_msg_id = ' . $pm_id . ' |
134 | AND in_message = 1 |
135 | ORDER BY filetime DESC'; |
136 | $result = $db->sql_query($sql); |
137 | |
138 | $attachments = []; |
139 | while ($row = $db->sql_fetchrow($result)) |
140 | { |
141 | $attachments[] = $row; |
142 | } |
143 | $db->sql_freeresult($result); |
144 | |
145 | if (count($attachments)) |
146 | { |
147 | $update_count = array(); |
148 | parse_attachments(0, $message, $attachments, $update_count); |
149 | } |
150 | |
151 | // Display not already displayed Attachments for this post, we already parsed them. ;) |
152 | if (!empty($attachments)) |
153 | { |
154 | $template->assign_var('S_HAS_ATTACHMENTS', true); |
155 | |
156 | foreach ($attachments as $attachment) |
157 | { |
158 | $template->assign_block_vars('attachment', array( |
159 | 'DISPLAY_ATTACHMENT' => $attachment) |
160 | ); |
161 | } |
162 | } |
163 | } |
164 | |
165 | $template->assign_vars(array( |
166 | 'S_MCP_REPORT' => true, |
167 | 'S_PM' => true, |
168 | 'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=pm_reports&mode=pm_report_details&r=' . $report_id), |
169 | 'S_CAN_VIEWIP' => $auth->acl_getf_global('m_info'), |
170 | 'S_POST_REPORTED' => $pm_info['message_reported'], |
171 | 'S_REPORT_CLOSED' => $report['report_closed'], |
172 | 'S_USER_NOTES' => true, |
173 | |
174 | 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=pm_reports&mode=pm_report_details&r=' . $report_id), |
175 | 'U_MCP_REPORTER_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $report['user_id']), |
176 | 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $pm_info['author_id']), |
177 | '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']) : '', |
178 | 'U_MCP_WARN_USER' => ($auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $pm_info['author_id']) : '', |
179 | |
180 | 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']), |
181 | 'MINI_POST_IMG' => $user->img('icon_post_target', 'POST'), |
182 | |
183 | 'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=pm_reports' . (($pm_info['message_reported']) ? '&mode=pm_reports' : '&mode=pm_reports_closed') . '&start=' . $start) . '">', '</a>'), |
184 | 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']), |
185 | 'REPORT_DATE' => $user->format_date($report['report_time']), |
186 | 'REPORT_ID' => $report_id, |
187 | 'REPORT_REASON_TITLE' => $reason['title'], |
188 | 'REPORT_REASON_DESCRIPTION' => $reason['description'], |
189 | 'REPORT_TEXT' => $report['report_text'], |
190 | |
191 | 'POST_AUTHOR_FULL' => get_username_string('full', $pm_info['author_id'], $pm_info['username'], $pm_info['user_colour']), |
192 | 'POST_AUTHOR_COLOUR' => get_username_string('colour', $pm_info['author_id'], $pm_info['username'], $pm_info['user_colour']), |
193 | 'POST_AUTHOR' => get_username_string('username', $pm_info['author_id'], $pm_info['username'], $pm_info['user_colour']), |
194 | 'U_POST_AUTHOR' => get_username_string('profile', $pm_info['author_id'], $pm_info['username'], $pm_info['user_colour']), |
195 | |
196 | 'REPORTER_FULL' => get_username_string('full', $report['user_id'], $report['username'], $report['user_colour']), |
197 | 'REPORTER_COLOUR' => get_username_string('colour', $report['user_id'], $report['username'], $report['user_colour']), |
198 | 'REPORTER_NAME' => get_username_string('username', $report['user_id'], $report['username'], $report['user_colour']), |
199 | 'U_VIEW_REPORTER_PROFILE' => get_username_string('profile', $report['user_id'], $report['username'], $report['user_colour']), |
200 | |
201 | 'POST_PREVIEW' => $message, |
202 | 'POST_SUBJECT' => ($pm_info['message_subject']) ? $pm_info['message_subject'] : $user->lang['NO_SUBJECT'], |
203 | 'POST_DATE' => $user->format_date($pm_info['message_time']), |
204 | 'POST_IP' => $pm_info['author_ip'], |
205 | 'POST_IPADDR' => ($auth->acl_getf_global('m_info') && $request->variable('lookup', '')) ? @gethostbyaddr($pm_info['author_ip']) : '', |
206 | 'POST_ID' => $pm_info['msg_id'], |
207 | |
208 | 'U_LOOKUP_IP' => ($auth->acl_getf_global('m_info')) ? $this->u_action . '&r=' . $report_id . '&pm=' . $pm_id . '&lookup=' . $pm_info['author_ip'] . '#ip' : '', |
209 | )); |
210 | |
211 | $this->tpl_name = 'mcp_post'; |
212 | |
213 | break; |
214 | |
215 | case 'pm_reports': |
216 | case 'pm_reports_closed': |
217 | $user->add_lang(array('ucp')); |
218 | |
219 | $sort_days = $total = 0; |
220 | $sort_key = $sort_dir = ''; |
221 | $sort_by_sql = $sort_order_sql = array(); |
222 | phpbb_mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total); |
223 | |
224 | $limit_time_sql = ($sort_days) ? 'AND r.report_time >= ' . (time() - ($sort_days * 86400)) : ''; |
225 | |
226 | if ($mode == 'pm_reports') |
227 | { |
228 | $report_state = 'p.message_reported = 1 AND r.report_closed = 0'; |
229 | } |
230 | else |
231 | { |
232 | $report_state = 'r.report_closed = 1'; |
233 | } |
234 | |
235 | $sql = 'SELECT r.report_id |
236 | FROM ' . PRIVMSGS_TABLE . ' p, ' . REPORTS_TABLE . ' r ' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . (($sort_order_sql[0] == 'r') ? ', ' . USERS_TABLE . ' ru' : '') . " |
237 | WHERE $report_state |
238 | AND r.pm_id = p.msg_id |
239 | " . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.author_id' : '') . ' |
240 | ' . (($sort_order_sql[0] == 'r') ? 'AND ru.user_id = r.user_id' : '') . " |
241 | AND r.post_id = 0 |
242 | $limit_time_sql |
243 | ORDER BY $sort_order_sql"; |
244 | $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); |
245 | |
246 | $report_ids = array(); |
247 | while ($row = $db->sql_fetchrow($result)) |
248 | { |
249 | $report_ids[] = $row['report_id']; |
250 | } |
251 | $db->sql_freeresult($result); |
252 | |
253 | if (count($report_ids)) |
254 | { |
255 | $sql = 'SELECT p.*, 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 |
256 | FROM ' . REPORTS_TABLE . ' r, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u, ' . USERS_TABLE . ' ru |
257 | WHERE ' . $db->sql_in_set('r.report_id', $report_ids) . " |
258 | AND r.pm_id = p.msg_id |
259 | AND p.author_id = u.user_id |
260 | AND ru.user_id = r.user_id |
261 | ORDER BY $sort_order_sql"; |
262 | $result = $db->sql_query($sql); |
263 | |
264 | $pm_list = $pm_by_id = array(); |
265 | while ($row = $db->sql_fetchrow($result)) |
266 | { |
267 | $pm_by_id[(int) $row['msg_id']] = $row; |
268 | $pm_list[] = (int) $row['msg_id']; |
269 | } |
270 | $db->sql_freeresult($result); |
271 | |
272 | if (count($pm_list)) |
273 | { |
274 | $address_list = get_recipient_strings($pm_by_id); |
275 | |
276 | foreach ($pm_list as $message_id) |
277 | { |
278 | $row = $pm_by_id[$message_id]; |
279 | $template->assign_block_vars('postrow', array( |
280 | 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=pm_reports&mode=pm_report_details&r={$row['report_id']}"), |
281 | |
282 | 'PM_AUTHOR_FULL' => get_username_string('full', $row['author_id'], $row['username'], $row['user_colour']), |
283 | 'PM_AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['username'], $row['user_colour']), |
284 | 'PM_AUTHOR' => get_username_string('username', $row['author_id'], $row['username'], $row['user_colour']), |
285 | 'U_PM_AUTHOR' => get_username_string('profile', $row['author_id'], $row['username'], $row['user_colour']), |
286 | |
287 | 'REPORTER_FULL' => get_username_string('full', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), |
288 | 'REPORTER_COLOUR' => get_username_string('colour', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), |
289 | 'REPORTER' => get_username_string('username', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), |
290 | 'U_REPORTER' => get_username_string('profile', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), |
291 | |
292 | 'PM_SUBJECT' => ($row['message_subject']) ? $row['message_subject'] : $user->lang['NO_SUBJECT'], |
293 | 'PM_TIME' => $user->format_date($row['message_time']), |
294 | 'REPORT_ID' => $row['report_id'], |
295 | 'REPORT_TIME' => $user->format_date($row['report_time']), |
296 | |
297 | 'RECIPIENTS' => implode($user->lang['COMMA_SEPARATOR'], $address_list[$row['msg_id']]), |
298 | 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $row['message_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', |
299 | )); |
300 | } |
301 | } |
302 | } |
303 | |
304 | $base_url = $this->u_action . "&st=$sort_days&sk=$sort_key&sd=$sort_dir"; |
305 | $pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start); |
306 | |
307 | // Now display the page |
308 | $template->assign_vars(array( |
309 | 'L_EXPLAIN' => ($mode == 'pm_reports') ? $user->lang['MCP_PM_REPORTS_OPEN_EXPLAIN'] : $user->lang['MCP_PM_REPORTS_CLOSED_EXPLAIN'], |
310 | 'L_TITLE' => ($mode == 'pm_reports') ? $user->lang['MCP_PM_REPORTS_OPEN'] : $user->lang['MCP_PM_REPORTS_CLOSED'], |
311 | |
312 | 'S_PM' => true, |
313 | 'S_MCP_ACTION' => $this->u_action, |
314 | 'S_CLOSED' => ($mode == 'pm_reports_closed') ? true : false, |
315 | |
316 | 'TOTAL' => $total, |
317 | 'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $total), |
318 | ) |
319 | ); |
320 | |
321 | $this->tpl_name = 'mcp_reports'; |
322 | break; |
323 | } |
324 | } |
325 | } |