|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Handles reported members and posts, as well as moderation comments. |
|
5
|
|
|
* |
|
6
|
|
|
* Simple Machines Forum (SMF) |
|
7
|
|
|
* |
|
8
|
|
|
* @package SMF |
|
9
|
|
|
* @author Simple Machines http://www.simplemachines.org |
|
10
|
|
|
* @copyright 2019 Simple Machines and individual contributors |
|
11
|
|
|
* @license http://www.simplemachines.org/about/smf/license.php BSD |
|
12
|
|
|
* |
|
13
|
|
|
* @version 2.1 RC2 |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
if (!defined('SMF')) |
|
17
|
|
|
die('No direct access...'); |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Sets and call a function based on the given subaction. Acts as a dispatcher function. |
|
21
|
|
|
* It requires the moderate_forum permission. |
|
22
|
|
|
* |
|
23
|
|
|
* @uses ModerationCenter template. |
|
24
|
|
|
* @uses ModerationCenter language file. |
|
25
|
|
|
* |
|
26
|
|
|
*/ |
|
27
|
|
|
function ReportedContent() |
|
28
|
|
|
{ |
|
29
|
|
|
global $txt, $context, $user_info, $smcFunc; |
|
30
|
|
|
global $sourcedir, $scripturl; |
|
31
|
|
|
|
|
32
|
|
|
// First order of business - what are these reports about? |
|
33
|
|
|
// area=reported{type} |
|
34
|
|
|
$context['report_type'] = substr($_GET['area'], 8); |
|
35
|
|
|
|
|
36
|
|
|
loadLanguage('ModerationCenter'); |
|
37
|
|
|
loadTemplate('ReportedContent'); |
|
38
|
|
|
|
|
39
|
|
|
// We need this little rough gem. |
|
40
|
|
|
require_once($sourcedir . '/Subs-ReportedContent.php'); |
|
41
|
|
|
|
|
42
|
|
|
// Do we need to show a confirmation message? |
|
43
|
|
|
$context['report_post_action'] = !empty($_SESSION['rc_confirmation']) ? $_SESSION['rc_confirmation'] : array(); |
|
44
|
|
|
unset($_SESSION['rc_confirmation']); |
|
45
|
|
|
|
|
46
|
|
|
// Set up the comforting bits... |
|
47
|
|
|
$context['page_title'] = $txt['mc_reported_' . $context['report_type']]; |
|
48
|
|
|
|
|
49
|
|
|
// Put the open and closed options into tabs, because we can... |
|
50
|
|
|
$context[$context['moderation_menu_name']]['tab_data'] = array( |
|
51
|
|
|
'title' => $txt['mc_reported_' . $context['report_type']], |
|
52
|
|
|
'help' => '', |
|
53
|
|
|
'description' => $txt['mc_reported_' . $context['report_type'] . '_desc'], |
|
54
|
|
|
); |
|
55
|
|
|
|
|
56
|
|
|
// This comes under the umbrella of moderating posts. |
|
57
|
|
|
if ($context['report_type'] == 'members' || $user_info['mod_cache']['bq'] == '0=1') |
|
58
|
|
|
isAllowedTo('moderate_forum'); |
|
59
|
|
|
|
|
60
|
|
|
$subActions = array( |
|
61
|
|
|
'show' => 'ShowReports', |
|
62
|
|
|
'closed' => 'ShowClosedReports', |
|
63
|
|
|
'handle' => 'HandleReport', // Deals with closing/opening reports. |
|
64
|
|
|
'details' => 'ReportDetails', // Shows a single report and its comments. |
|
65
|
|
|
'handlecomment' => 'HandleComment', // CRUD actions for moderator comments. |
|
66
|
|
|
'editcomment' => 'EditComment', |
|
67
|
|
|
); |
|
68
|
|
|
|
|
69
|
|
|
// Go ahead and add your own sub-actions. |
|
70
|
|
|
call_integration_hook('integrate_reported_' . $context['report_type'], array(&$subActions)); |
|
71
|
|
|
|
|
72
|
|
|
// By default we call the open sub-action. |
|
73
|
|
|
if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
74
|
|
|
$context['sub_action'] = $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_REQUEST['sa']), ENT_QUOTES); |
|
75
|
|
|
|
|
76
|
|
|
else |
|
77
|
|
|
$context['sub_action'] = 'show'; |
|
78
|
|
|
|
|
79
|
|
|
// Hi Ho Silver Away! |
|
80
|
|
|
call_helper($subActions[$context['sub_action']]); |
|
81
|
|
|
|
|
82
|
|
|
// If we're showing a list of reports |
|
83
|
|
|
if ($context['sub_action'] == 'show' || $context['sub_action'] == 'closed') |
|
84
|
|
|
{ |
|
85
|
|
|
// Quickbuttons for each report |
|
86
|
|
|
foreach ($context['reports'] as $key => $report) |
|
87
|
|
|
{ |
|
88
|
|
|
$context['reports'][$key]['quickbuttons'] = array( |
|
89
|
|
|
'details' => array( |
|
90
|
|
|
'label' => $txt['mc_reportedp_details'], |
|
91
|
|
|
'href' => $report['report_href'], |
|
92
|
|
|
'icon' => 'details', |
|
93
|
|
|
), |
|
94
|
|
|
'ignore' => array( |
|
95
|
|
|
'label' => $report['ignore'] ? $txt['mc_reportedp_unignore'] : $txt['mc_reportedp_ignore'], |
|
96
|
|
|
'href' => $scripturl.'?action=moderate;area=reported'.$context['report_type'].';sa=handle;ignore='.(int)!$report['ignore'].';rid='.$report['id'].';start='.$context['start'].';'.$context['session_var'].'='.$context['session_id'].';'.$context['mod-report-ignore_token_var'].'='.$context['mod-report-ignore_token'], |
|
97
|
|
|
'javascript' => !$report['ignore'] ? ' class="you_sure" data-confirm="' . $txt['mc_reportedp_ignore_confirm'] . '"' : '', |
|
98
|
|
|
'icon' => 'ignore' |
|
99
|
|
|
), |
|
100
|
|
|
'close' => array( |
|
101
|
|
|
'label' => $context['view_closed'] ? $txt['mc_reportedp_open'] : $txt['mc_reportedp_close'], |
|
102
|
|
|
'href' => $scripturl.'?action=moderate;area=reported'.$context['report_type'].';sa=handle;closed='.(int)!$report['closed'].';rid='.$report['id'].';start='.$context['start'].';'.$context['session_var'].'='.$context['session_id'].';'.$context['mod-report-closed_token_var'].'='.$context['mod-report-closed_token'], |
|
103
|
|
|
'icon' => $context['view_closed'] ? 'folder' : 'close', |
|
104
|
|
|
), |
|
105
|
|
|
); |
|
106
|
|
|
|
|
107
|
|
|
// Only reported posts can be deleted |
|
108
|
|
|
if ($context['report_type'] == 'posts') |
|
109
|
|
|
$context['reports'][$key]['quickbuttons']['delete'] = array( |
|
110
|
|
|
'label' => $txt['mc_reportedp_delete'], |
|
111
|
|
|
'href' => $scripturl.'?action=deletemsg;topic='.$report['topic']['id'].'.0;msg='.$report['topic']['id_msg'].';modcenter;'.$context['session_var'].'='.$context['session_id'], |
|
112
|
|
|
'javascript' => 'data-confirm="'.$txt['mc_reportedp_delete_confirm'].'" class="you_sure"', |
|
113
|
|
|
'icon' => 'delete', |
|
114
|
|
|
'show' => !$report['closed'] && (is_array($context['report_remove_any_boards']) && in_array($report['topic']['id_board'], $context['report_remove_any_boards'])) |
|
115
|
|
|
); |
|
116
|
|
|
|
|
117
|
|
|
// Ban reported member/post author link |
|
118
|
|
|
if ($context['report_type'] == 'members') |
|
119
|
|
|
$ban_link = $scripturl.'?action=admin;area=ban;sa=add;u='.$report['user']['id'].';'.$context['session_var'].'='.$context['session_id']; |
|
120
|
|
|
else |
|
121
|
|
|
$ban_link = $scripturl.'?action=admin;area=ban;sa=add'.(!empty($report['author']['id']) ? ';u='.$report['author']['id'] : ';msg='.$report['topic']['id_msg']).';'.$context['session_var'].'='.$context['session_id']; |
|
122
|
|
|
|
|
123
|
|
|
$context['reports'][$key]['quickbuttons'] += array( |
|
124
|
|
|
'ban' => array( |
|
125
|
|
|
'label' => $txt['mc_reportedp_ban'], |
|
126
|
|
|
'href' => $ban_link, |
|
127
|
|
|
'icon' => 'error', |
|
128
|
|
|
'show' => !$report['closed'] && !empty($context['report_manage_bans']) && ($context['report_type'] == 'posts' || $context['report_type'] == 'members' && !empty($report['user']['id'])) |
|
129
|
|
|
), |
|
130
|
|
|
'quickmod' => array( |
|
131
|
|
|
'content' => '<input type="checkbox" name="close[]" value="'.$report['id'].'">', |
|
132
|
|
|
'show' => !$context['view_closed'] |
|
133
|
|
|
) |
|
134
|
|
|
); |
|
135
|
|
|
} |
|
136
|
|
|
} |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* Shows all currently open reported posts. |
|
141
|
|
|
* Handles closing multiple reports |
|
142
|
|
|
* |
|
143
|
|
|
*/ |
|
144
|
|
|
function ShowReports() |
|
145
|
|
|
{ |
|
146
|
|
|
global $context, $scripturl; |
|
147
|
|
|
|
|
148
|
|
|
// Showing closed or open ones? regardless, turn this to an integer for better handling. |
|
149
|
|
|
$context['view_closed'] = 0; |
|
150
|
|
|
|
|
151
|
|
|
// Call the right template. |
|
152
|
|
|
$context['sub_template'] = 'reported_' . $context['report_type']; |
|
153
|
|
|
$context['start'] = (int) isset($_GET['start']) ? $_GET['start'] : 0; |
|
154
|
|
|
|
|
155
|
|
|
// Before anything, we need to know just how many reports do we have. |
|
156
|
|
|
$context['total_reports'] = countReports($context['view_closed']); |
|
157
|
|
|
|
|
158
|
|
|
// Just how many items are we showing per page? |
|
159
|
|
|
$context['reports_how_many'] = 10; |
|
160
|
|
|
|
|
161
|
|
|
// So, that means we can have pagination, yes? |
|
162
|
|
|
$context['page_index'] = constructPageIndex($scripturl . '?action=moderate;area=reported' . $context['report_type'] . ';sa=show', $context['start'], $context['total_reports'], $context['reports_how_many']); |
|
163
|
|
|
|
|
164
|
|
|
// Get the reports at once! |
|
165
|
|
|
$context['reports'] = getReports($context['view_closed']); |
|
166
|
|
|
|
|
167
|
|
|
// Are we closing multiple reports? |
|
168
|
|
|
if (isset($_POST['close']) && isset($_POST['close_selected'])) |
|
169
|
|
|
{ |
|
170
|
|
|
checkSession('post'); |
|
171
|
|
|
validateToken('mod-report-close-all'); |
|
172
|
|
|
|
|
173
|
|
|
// All the ones to update... |
|
174
|
|
|
$toClose = array(); |
|
175
|
|
|
foreach ($_POST['close'] as $rid) |
|
176
|
|
|
$toClose[] = (int) $rid; |
|
177
|
|
|
|
|
178
|
|
|
if (!empty($toClose)) |
|
179
|
|
|
updateReport('closed', 1, $toClose); |
|
180
|
|
|
|
|
181
|
|
|
// Set the confirmation message. |
|
182
|
|
|
$_SESSION['rc_confirmation'] = 'close_all'; |
|
183
|
|
|
|
|
184
|
|
|
// Force a page refresh. |
|
185
|
|
|
redirectexit($scripturl . '?action=moderate;area=reported' . $context['report_type']); |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
createToken('mod-report-close-all'); |
|
189
|
|
|
createToken('mod-report-ignore', 'get'); |
|
190
|
|
|
createToken('mod-report-closed', 'get'); |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* Shows all currently closed reported posts. |
|
195
|
|
|
* |
|
196
|
|
|
*/ |
|
197
|
|
|
function ShowClosedReports() |
|
198
|
|
|
{ |
|
199
|
|
|
global $context, $scripturl; |
|
200
|
|
|
|
|
201
|
|
|
// Showing closed ones. |
|
202
|
|
|
$context['view_closed'] = 1; |
|
203
|
|
|
|
|
204
|
|
|
// Call the right template. |
|
205
|
|
|
$context['sub_template'] = 'reported_' . $context['report_type']; |
|
206
|
|
|
$context['start'] = (int) isset($_GET['start']) ? $_GET['start'] : 0; |
|
207
|
|
|
|
|
208
|
|
|
// Before anything, we need to know just how many reports do we have. |
|
209
|
|
|
$context['total_reports'] = countReports($context['view_closed']); |
|
210
|
|
|
|
|
211
|
|
|
// Just how many items are we showing per page? |
|
212
|
|
|
$context['reports_how_many'] = 10; |
|
213
|
|
|
|
|
214
|
|
|
// So, that means we can have pagination, yes? |
|
215
|
|
|
$context['page_index'] = constructPageIndex($scripturl . '?action=moderate;area=reported' . $context['report_type'] . ';sa=closed', $context['start'], $context['total_reports'], $context['reports_how_many']); |
|
216
|
|
|
|
|
217
|
|
|
// Get the reports at once! |
|
218
|
|
|
$context['reports'] = getReports($context['view_closed']); |
|
219
|
|
|
|
|
220
|
|
|
createToken('mod-report-ignore', 'get'); |
|
221
|
|
|
createToken('mod-report-closed', 'get'); |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
/** |
|
225
|
|
|
* Shows detailed information about a report. such as report comments and moderator comments. |
|
226
|
|
|
* Shows a list of moderation actions for the specific report. |
|
227
|
|
|
* |
|
228
|
|
|
*/ |
|
229
|
|
|
function ReportDetails() |
|
230
|
|
|
{ |
|
231
|
|
|
global $context, $sourcedir, $scripturl, $txt; |
|
232
|
|
|
|
|
233
|
|
|
// Have to at least give us something to work with. |
|
234
|
|
|
if (empty($_REQUEST['rid'])) |
|
235
|
|
|
fatal_lang_error('mc_reportedp_none_found'); |
|
236
|
|
|
|
|
237
|
|
|
// Integers only please |
|
238
|
|
|
$report_id = (int) $_REQUEST['rid']; |
|
239
|
|
|
|
|
240
|
|
|
// Get the report details. |
|
241
|
|
|
$report = getReportDetails($report_id); |
|
242
|
|
|
|
|
243
|
|
|
if (!$report) |
|
244
|
|
|
fatal_lang_error('mc_no_modreport_found'); |
|
245
|
|
|
|
|
246
|
|
|
// Build the report data - basic details first, then extra stuff based on the type |
|
247
|
|
|
$context['report'] = array( |
|
248
|
|
|
'id' => $report['id_report'], |
|
249
|
|
|
'report_href' => $scripturl . '?action=moderate;area=reported' . $context['report_type'] . ';rid=' . $report['id_report'], |
|
250
|
|
|
'comments' => array(), |
|
251
|
|
|
'mod_comments' => array(), |
|
252
|
|
|
'time_started' => timeformat($report['time_started']), |
|
253
|
|
|
'last_updated' => timeformat($report['time_updated']), |
|
254
|
|
|
'num_reports' => $report['num_reports'], |
|
255
|
|
|
'closed' => $report['closed'], |
|
256
|
|
|
'ignore' => $report['ignore_all'] |
|
257
|
|
|
); |
|
258
|
|
|
|
|
259
|
|
|
// Different reports have different "extra" data attached to them |
|
260
|
|
|
if ($context['report_type'] == 'members') |
|
261
|
|
|
{ |
|
262
|
|
|
$extraDetails = array( |
|
263
|
|
|
'user' => array( |
|
264
|
|
|
'id' => $report['id_user'], |
|
265
|
|
|
'name' => $report['user_name'], |
|
266
|
|
|
'link' => $report['id_user'] ? '<a href="' . $scripturl . '?action=profile;u=' . $report['id_user'] . '">' . $report['user_name'] . '</a>' : $report['user_name'], |
|
267
|
|
|
'href' => $scripturl . '?action=profile;u=' . $report['id_user'], |
|
268
|
|
|
), |
|
269
|
|
|
); |
|
270
|
|
|
} |
|
271
|
|
|
else |
|
272
|
|
|
{ |
|
273
|
|
|
$extraDetails = array( |
|
274
|
|
|
'topic_id' => $report['id_topic'], |
|
275
|
|
|
'board_id' => $report['id_board'], |
|
276
|
|
|
'message_id' => $report['id_msg'], |
|
277
|
|
|
'message_href' => $scripturl . '?msg=' . $report['id_msg'], |
|
278
|
|
|
'message_link' => '<a href="' . $scripturl . '?msg=' . $report['id_msg'] . '">' . $report['subject'] . '</a>', |
|
279
|
|
|
'author' => array( |
|
280
|
|
|
'id' => $report['id_author'], |
|
281
|
|
|
'name' => $report['author_name'], |
|
282
|
|
|
'link' => $report['id_author'] ? '<a href="' . $scripturl . '?action=profile;u=' . $report['id_author'] . '">' . $report['author_name'] . '</a>' : $report['author_name'], |
|
283
|
|
|
'href' => $scripturl . '?action=profile;u=' . $report['id_author'], |
|
284
|
|
|
), |
|
285
|
|
|
'subject' => $report['subject'], |
|
286
|
|
|
'body' => parse_bbc($report['body']), |
|
287
|
|
|
); |
|
288
|
|
|
} |
|
289
|
|
|
|
|
290
|
|
|
$context['report'] = array_merge($context['report'], $extraDetails); |
|
291
|
|
|
|
|
292
|
|
|
$reportComments = getReportComments($report_id); |
|
293
|
|
|
|
|
294
|
|
|
if (!empty($reportComments)) |
|
295
|
|
|
$context['report'] = array_merge($context['report'], $reportComments); |
|
296
|
|
|
|
|
297
|
|
|
// What have the other moderators done to this message? |
|
298
|
|
|
require_once($sourcedir . '/Modlog.php'); |
|
299
|
|
|
require_once($sourcedir . '/Subs-List.php'); |
|
300
|
|
|
loadLanguage('Modlog'); |
|
301
|
|
|
|
|
302
|
|
|
// Parameters are slightly different depending on what we're doing here... |
|
303
|
|
|
if ($context['report_type'] == 'members') |
|
304
|
|
|
{ |
|
305
|
|
|
// Find their ID in the serialized action string... |
|
306
|
|
|
$user_id_length = strlen((string) $context['report']['user']['id']); |
|
307
|
|
|
$member = 's:6:"member";s:' . $user_id_length . ':"' . $context['report']['user']['id'] . '";}'; |
|
308
|
|
|
|
|
309
|
|
|
$params = array( |
|
310
|
|
|
'lm.extra LIKE {raw:member} |
|
311
|
|
|
AND lm.action LIKE {raw:report}', |
|
312
|
|
|
array('member' => '\'%' . $member . '\'', 'report' => '\'%_user_report\''), |
|
313
|
|
|
1, |
|
314
|
|
|
true, |
|
315
|
|
|
); |
|
316
|
|
|
} |
|
317
|
|
|
else |
|
318
|
|
|
{ |
|
319
|
|
|
$params = array( |
|
320
|
|
|
'lm.id_topic = {int:id_topic} |
|
321
|
|
|
AND lm.id_board != {int:not_a_reported_post}', |
|
322
|
|
|
array('id_topic' => $context['report']['topic_id'], 'not_a_reported_post' => 0), |
|
323
|
|
|
1, |
|
324
|
|
|
); |
|
325
|
|
|
} |
|
326
|
|
|
|
|
327
|
|
|
// This is all the information from the moderation log. |
|
328
|
|
|
$listOptions = array( |
|
329
|
|
|
'id' => 'moderation_actions_list', |
|
330
|
|
|
'title' => $txt['mc_modreport_modactions'], |
|
331
|
|
|
'items_per_page' => 15, |
|
332
|
|
|
'no_items_label' => $txt['modlog_no_entries_found'], |
|
333
|
|
|
'base_href' => $scripturl . '?action=moderate;area=reported' . $context['report_type'] . ';sa=details;rid=' . $context['report']['id'], |
|
334
|
|
|
'default_sort_col' => 'time', |
|
335
|
|
|
'get_items' => array( |
|
336
|
|
|
'function' => 'list_getModLogEntries', |
|
337
|
|
|
'params' => $params, |
|
338
|
|
|
), |
|
339
|
|
|
'get_count' => array( |
|
340
|
|
|
'function' => 'list_getModLogEntryCount', |
|
341
|
|
|
'params' => $params, |
|
342
|
|
|
), |
|
343
|
|
|
// This assumes we are viewing by user. |
|
344
|
|
|
'columns' => array( |
|
345
|
|
|
'action' => array( |
|
346
|
|
|
'header' => array( |
|
347
|
|
|
'value' => $txt['modlog_action'], |
|
348
|
|
|
), |
|
349
|
|
|
'data' => array( |
|
350
|
|
|
'db' => 'action_text', |
|
351
|
|
|
'class' => 'smalltext', |
|
352
|
|
|
), |
|
353
|
|
|
'sort' => array( |
|
354
|
|
|
'default' => 'lm.action', |
|
355
|
|
|
'reverse' => 'lm.action DESC', |
|
356
|
|
|
), |
|
357
|
|
|
), |
|
358
|
|
|
'time' => array( |
|
359
|
|
|
'header' => array( |
|
360
|
|
|
'value' => $txt['modlog_date'], |
|
361
|
|
|
), |
|
362
|
|
|
'data' => array( |
|
363
|
|
|
'db' => 'time', |
|
364
|
|
|
'class' => 'smalltext', |
|
365
|
|
|
), |
|
366
|
|
|
'sort' => array( |
|
367
|
|
|
'default' => 'lm.log_time', |
|
368
|
|
|
'reverse' => 'lm.log_time DESC', |
|
369
|
|
|
), |
|
370
|
|
|
), |
|
371
|
|
|
'moderator' => array( |
|
372
|
|
|
'header' => array( |
|
373
|
|
|
'value' => $txt['modlog_member'], |
|
374
|
|
|
), |
|
375
|
|
|
'data' => array( |
|
376
|
|
|
'db' => 'moderator_link', |
|
377
|
|
|
'class' => 'smalltext', |
|
378
|
|
|
), |
|
379
|
|
|
'sort' => array( |
|
380
|
|
|
'default' => 'mem.real_name', |
|
381
|
|
|
'reverse' => 'mem.real_name DESC', |
|
382
|
|
|
), |
|
383
|
|
|
), |
|
384
|
|
|
'position' => array( |
|
385
|
|
|
'header' => array( |
|
386
|
|
|
'value' => $txt['modlog_position'], |
|
387
|
|
|
), |
|
388
|
|
|
'data' => array( |
|
389
|
|
|
'db' => 'position', |
|
390
|
|
|
'class' => 'smalltext', |
|
391
|
|
|
), |
|
392
|
|
|
'sort' => array( |
|
393
|
|
|
'default' => 'mg.group_name', |
|
394
|
|
|
'reverse' => 'mg.group_name DESC', |
|
395
|
|
|
), |
|
396
|
|
|
), |
|
397
|
|
|
'ip' => array( |
|
398
|
|
|
'header' => array( |
|
399
|
|
|
'value' => $txt['modlog_ip'], |
|
400
|
|
|
), |
|
401
|
|
|
'data' => array( |
|
402
|
|
|
'db' => 'ip', |
|
403
|
|
|
'class' => 'smalltext', |
|
404
|
|
|
), |
|
405
|
|
|
'sort' => array( |
|
406
|
|
|
'default' => 'lm.ip', |
|
407
|
|
|
'reverse' => 'lm.ip DESC', |
|
408
|
|
|
), |
|
409
|
|
|
), |
|
410
|
|
|
), |
|
411
|
|
|
); |
|
412
|
|
|
|
|
413
|
|
|
// Create the watched user list. |
|
414
|
|
|
createList($listOptions); |
|
415
|
|
|
|
|
416
|
|
|
// Make sure to get the correct tab selected. |
|
417
|
|
|
if ($context['report']['closed']) |
|
418
|
|
|
$context[$context['moderation_menu_name']]['current_subsection'] = 'closed'; |
|
419
|
|
|
|
|
420
|
|
|
// Finally we are done :P |
|
421
|
|
|
if ($context['report_type'] == 'members') |
|
422
|
|
|
{ |
|
423
|
|
|
$context['page_title'] = sprintf($txt['mc_viewmemberreport'], $context['report']['user']['name']); |
|
424
|
|
|
$context['sub_template'] = 'viewmemberreport'; |
|
425
|
|
|
} |
|
426
|
|
|
else |
|
427
|
|
|
{ |
|
428
|
|
|
$context['page_title'] = sprintf($txt['mc_viewmodreport'], $context['report']['subject'], $context['report']['author']['name']); |
|
429
|
|
|
$context['sub_template'] = 'viewmodreport'; |
|
430
|
|
|
} |
|
431
|
|
|
|
|
432
|
|
|
createToken('mod-reportC-add'); |
|
433
|
|
|
createToken('mod-reportC-delete', 'get'); |
|
434
|
|
|
|
|
435
|
|
|
// We can "un-ignore" and close a report from here so add their respective tokens. |
|
436
|
|
|
createToken('mod-report-ignore', 'get'); |
|
437
|
|
|
createToken('mod-report-closed', 'get'); |
|
438
|
|
|
} |
|
439
|
|
|
|
|
440
|
|
|
/** |
|
441
|
|
|
* Creates/Deletes moderator comments. |
|
442
|
|
|
* |
|
443
|
|
|
*/ |
|
444
|
|
|
function HandleComment() |
|
445
|
|
|
{ |
|
446
|
|
|
global $smcFunc, $scripturl, $user_info, $context; |
|
447
|
|
|
|
|
448
|
|
|
// The report ID is a must. |
|
449
|
|
|
if (empty($_REQUEST['rid'])) |
|
450
|
|
|
fatal_lang_error('mc_reportedp_none_found'); |
|
451
|
|
|
|
|
452
|
|
|
// Integers only please. |
|
453
|
|
|
$report_id = (int) $_REQUEST['rid']; |
|
454
|
|
|
|
|
455
|
|
|
// If they are adding a comment then... add a comment. |
|
456
|
|
|
if (isset($_POST['add_comment']) && !empty($_POST['mod_comment'])) |
|
457
|
|
|
{ |
|
458
|
|
|
checkSession(); |
|
459
|
|
|
validateToken('mod-reportC-add'); |
|
460
|
|
|
|
|
461
|
|
|
$new_comment = trim($smcFunc['htmlspecialchars']($_POST['mod_comment'])); |
|
462
|
|
|
|
|
463
|
|
|
saveModComment($report_id, array($report_id, $new_comment, time())); |
|
464
|
|
|
|
|
465
|
|
|
// Everything went better than expected! |
|
466
|
|
|
$_SESSION['rc_confirmation'] = 'message_saved'; |
|
467
|
|
|
} |
|
468
|
|
|
|
|
469
|
|
|
// Deleting a comment? |
|
470
|
|
|
if (isset($_REQUEST['delete']) && isset($_REQUEST['mid'])) |
|
471
|
|
|
{ |
|
472
|
|
|
checkSession('get'); |
|
473
|
|
|
validateToken('mod-reportC-delete', 'get'); |
|
474
|
|
|
|
|
475
|
|
|
if (empty($_REQUEST['mid'])) |
|
476
|
|
|
fatal_lang_error('mc_reportedp_comment_none_found'); |
|
477
|
|
|
|
|
478
|
|
|
$comment_id = (int) $_REQUEST['mid']; |
|
479
|
|
|
|
|
480
|
|
|
// We need to verify some data, so lets load the comment details once more! |
|
481
|
|
|
$comment = getCommentModDetails($comment_id); |
|
482
|
|
|
|
|
483
|
|
|
// Perhaps somebody else already deleted this fine gem... |
|
484
|
|
|
if (empty($comment)) |
|
485
|
|
|
fatal_lang_error('report_action_message_delete_issue'); |
|
486
|
|
|
|
|
487
|
|
|
// Can you actually do this? |
|
488
|
|
|
$comment_owner = $user_info['id'] == $comment['id_member']; |
|
489
|
|
|
|
|
490
|
|
|
// Nope! sorry. |
|
491
|
|
|
if (!allowedTo('admin_forum') && !$comment_owner) |
|
492
|
|
|
fatal_lang_error('report_action_message_delete_cannot'); |
|
493
|
|
|
|
|
494
|
|
|
// All good! |
|
495
|
|
|
deleteModComment($comment_id); |
|
496
|
|
|
|
|
497
|
|
|
// Tell them the message was deleted. |
|
498
|
|
|
$_SESSION['rc_confirmation'] = 'message_deleted'; |
|
499
|
|
|
} |
|
500
|
|
|
|
|
501
|
|
|
//Redirect to prevent double submission. |
|
502
|
|
|
redirectexit($scripturl . '?action=moderate;area=reported' . $context['report_type'] . ';sa=details;rid=' . $report_id); |
|
503
|
|
|
} |
|
504
|
|
|
|
|
505
|
|
|
/** |
|
506
|
|
|
* Shows a textarea for editing a moderator comment. |
|
507
|
|
|
* Handles the edited comment and stores it on the DB. |
|
508
|
|
|
* |
|
509
|
|
|
*/ |
|
510
|
|
|
function EditComment() |
|
511
|
|
|
{ |
|
512
|
|
|
global $smcFunc, $context, $txt, $scripturl, $user_info; |
|
513
|
|
|
|
|
514
|
|
|
checkSession(isset($_REQUEST['save']) ? 'post' : 'get'); |
|
515
|
|
|
|
|
516
|
|
|
// The report ID is a must. |
|
517
|
|
|
if (empty($_REQUEST['rid'])) |
|
518
|
|
|
fatal_lang_error('mc_reportedp_none_found'); |
|
519
|
|
|
|
|
520
|
|
|
if (empty($_REQUEST['mid'])) |
|
521
|
|
|
fatal_lang_error('mc_reportedp_comment_none_found'); |
|
522
|
|
|
|
|
523
|
|
|
// Integers only please. |
|
524
|
|
|
$context['report_id'] = (int) $_REQUEST['rid']; |
|
525
|
|
|
$context['comment_id'] = (int) $_REQUEST['mid']; |
|
526
|
|
|
|
|
527
|
|
|
$context['comment'] = getCommentModDetails($context['comment_id']); |
|
528
|
|
|
|
|
529
|
|
|
if (empty($context['comment'])) |
|
530
|
|
|
fatal_lang_error('mc_reportedp_comment_none_found'); |
|
531
|
|
|
|
|
532
|
|
|
// Set up the comforting bits... |
|
533
|
|
|
$context['page_title'] = $txt['mc_reported_posts']; |
|
534
|
|
|
$context['sub_template'] = 'edit_comment'; |
|
535
|
|
|
|
|
536
|
|
|
if (isset($_REQUEST['save']) && isset($_POST['edit_comment']) && !empty($_POST['mod_comment'])) |
|
537
|
|
|
{ |
|
538
|
|
|
validateToken('mod-reportC-edit'); |
|
539
|
|
|
|
|
540
|
|
|
// Make sure there is some data to edit on the DB. |
|
541
|
|
|
if (empty($context['comment'])) |
|
542
|
|
|
fatal_lang_error('report_action_message_edit_issue'); |
|
543
|
|
|
|
|
544
|
|
|
// Still there, good, now lets see if you can actually edit it... |
|
545
|
|
|
$comment_owner = $user_info['id'] == $context['comment']['id_member']; |
|
546
|
|
|
|
|
547
|
|
|
// So, you aren't neither an admin or the comment owner huh? that's too bad. |
|
548
|
|
|
if (!allowedTo('admin_forum') && !$comment_owner) |
|
549
|
|
|
fatal_lang_error('report_action_message_edit_cannot'); |
|
550
|
|
|
|
|
551
|
|
|
// All good! |
|
552
|
|
|
$edited_comment = trim($smcFunc['htmlspecialchars']($_POST['mod_comment'])); |
|
553
|
|
|
|
|
554
|
|
|
editModComment($context['comment_id'], $edited_comment); |
|
555
|
|
|
|
|
556
|
|
|
$_SESSION['rc_confirmation'] = 'message_edited'; |
|
557
|
|
|
|
|
558
|
|
|
redirectexit($scripturl . '?action=moderate;area=reported' . $context['report_type'] . ';sa=details;rid=' . $context['report_id']); |
|
559
|
|
|
} |
|
560
|
|
|
|
|
561
|
|
|
createToken('mod-reportC-edit'); |
|
562
|
|
|
} |
|
563
|
|
|
|
|
564
|
|
|
/** |
|
565
|
|
|
* Performs closing/ignoring actions for a given report. |
|
566
|
|
|
* |
|
567
|
|
|
*/ |
|
568
|
|
|
function HandleReport() |
|
569
|
|
|
{ |
|
570
|
|
|
global $scripturl, $context; |
|
571
|
|
|
|
|
572
|
|
|
checkSession('get'); |
|
573
|
|
|
|
|
574
|
|
|
// We need to do something! |
|
575
|
|
|
if (empty($_GET['rid']) && (!isset($_GET['ignore']) || !isset($_GET['closed']))) |
|
576
|
|
|
fatal_lang_error('mc_reportedp_none_found'); |
|
577
|
|
|
|
|
578
|
|
|
// What are we gonna do? |
|
579
|
|
|
$action = isset($_GET['ignore']) ? 'ignore' : 'closed'; |
|
580
|
|
|
|
|
581
|
|
|
validateToken('mod-report-' . $action, 'get'); |
|
582
|
|
|
|
|
583
|
|
|
// Are we ignore or "un-ignore"? "un-ignore" that's a funny word! |
|
584
|
|
|
$value = (int) $_GET[$action]; |
|
585
|
|
|
|
|
586
|
|
|
// Figuring out. |
|
587
|
|
|
$message = $action == 'ignore' ? ($value ? 'ignore' : 'unignore') : ($value ? 'close' : 'open'); |
|
588
|
|
|
|
|
589
|
|
|
// Integers only please. |
|
590
|
|
|
$report_id = (int) $_REQUEST['rid']; |
|
591
|
|
|
|
|
592
|
|
|
// Update the DB entry |
|
593
|
|
|
updateReport($action, $value, $report_id); |
|
594
|
|
|
|
|
595
|
|
|
// So, time to show a confirmation message, lets do some trickery! |
|
596
|
|
|
$_SESSION['rc_confirmation'] = $message; |
|
597
|
|
|
|
|
598
|
|
|
// Done! |
|
599
|
|
|
redirectexit($scripturl . '?action=moderate;area=reported' . $context['report_type']); |
|
600
|
|
|
} |
|
601
|
|
|
|
|
602
|
|
|
?> |