template_edit_comment()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nop 0
dl 0
loc 20
rs 10
c 0
b 0
f 0
nc 1
1
<?php
2
/**
3
 * Simple Machines Forum (SMF)
4
 *
5
 * @package SMF
6
 * @author Simple Machines http://www.simplemachines.org
7
 * @copyright 2019 Simple Machines and individual contributors
8
 * @license http://www.simplemachines.org/about/smf/license.php BSD
9
 *
10
 * @version 2.1 RC2
11
 */
12
13
/**
14
 * Displays all reported posts.
15
 */
16
function template_reported_posts()
17
{
18
	global $context, $txt, $scripturl;
19
20
	// Let them know the action was a success.
21
	if (!empty($context['report_post_action']))
22
		echo '
23
	<div class="infobox">
24
		', $txt['report_action_' . $context['report_post_action']], '
25
	</div>';
26
27
	echo '
28
	<form id="reported_posts" action="', $scripturl, '?action=moderate;area=reportedposts;sa=show', $context['view_closed'] ? ';closed' : '', ';start=', $context['start'], '" method="post" accept-charset="', $context['character_set'], '">
29
		<div class="cat_bar">
30
			<h3 class="catbg">
31
				', $context['view_closed'] ? $txt['mc_reportedp_closed'] : $txt['mc_reportedp_active'], '
32
			</h3>
33
		</div>';
34
35
	foreach ($context['reports'] as $report)
36
	{
37
		echo '
38
		<div class="windowbg">
39
			<h5>
40
				<strong>', !empty($report['topic']['board_name']) ? '<a href="' . $scripturl . '?board=' . $report['topic']['id_board'] . '.0">' . $report['topic']['board_name'] . '</a>' : '??', ' / <a href="', $report['topic']['href'], '">', $report['subject'], '</a></strong> ', $txt['mc_reportedp_by'], ' <strong>', $report['author']['link'], '</strong>
41
			</h5>
42
			<div class="smalltext">
43
				', $txt['mc_reportedp_last_reported'], ': ', $report['last_updated'], '&nbsp;-&nbsp;';
44
45
		// Prepare the comments...
46
		$comments = array();
47
		foreach ($report['comments'] as $comment)
48
			$comments[$comment['member']['id']] = $comment['member']['link'];
49
50
		echo '
51
				', $txt['mc_reportedp_reported_by'], ': ', implode(', ', $comments), '
52
			</div>
53
			<hr>
54
			', $report['body'], '
55
			<br>';
56
57
		// Reported post options
58
		template_quickbuttons($report['quickbuttons'], 'reported_posts');
59
60
		echo '
61
		</div><!-- .windowbg -->';
62
	}
63
64
	// Were none found?
65
	if (empty($context['reports']))
66
		echo '
67
		<div class="windowbg">
68
			<p class="centertext">', $txt['mc_reportedp_none_found'], '</p>
69
		</div>';
70
71
	echo '
72
		<div class="pagesection">';
73
74
	if (!empty($context['total_reports']) && $context['total_reports'] >= $context['reports_how_many'])
75
		echo '
76
			<div class="pagelinks floatleft">' . $context['page_index'] . '</div>';
77
78
	echo '
79
			<div class="floatright">', !$context['view_closed'] ? '
80
				<input type="hidden" name="' . $context['mod-report-close-all_token_var'] . '" value="' . $context['mod-report-close-all_token'] . '">
81
				<input type="submit" name="close_selected" value="' . $txt['mc_reportedp_close_selected'] . '" class="button">' : '', '
82
			</div>
83
		</div>
84
		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
85
	</form>';
86
}
87
88
/**
89
 * A block to show the current top reported posts.
90
 */
91
function template_reported_posts_block()
92
{
93
	global $context, $txt, $scripturl;
94
95
	echo '
96
		<div class="cat_bar">
97
			<h3 class="catbg">
98
				<span id="reported_posts_toggle" class="', !empty($context['admin_prefs']['mcrp']) ? 'toggle_down' : 'toggle_up', ' floatright" style="display: none;"></span>
99
				<a href="', $scripturl, '?action=moderate;area=reportedposts" id="reported_posts_link">', $txt['mc_recent_reports'], '</a>
100
			</h3>
101
		</div>
102
		<div class="windowbg" id="reported_posts_panel">
103
			<div class="modbox">
104
				<ul>';
105
106
	foreach ($context['reported_posts'] as $report)
107
		echo '
108
					<li class="smalltext">
109
						<a href="', $report['report_href'], '">', $report['subject'], '</a> ', $txt['mc_reportedp_by'], ' ', $report['author']['link'], '
110
					</li>';
111
112
	// Don't have any watched users right now?
113
	if (empty($context['reported_posts']))
114
		echo '
115
					<li>
116
						<strong class="smalltext">', $txt['mc_recent_reports_none'], '</strong>
117
					</li>';
118
119
	echo '
120
				</ul>
121
			</div><!-- .modbox -->
122
		</div><!-- #reported_posts_panel -->
123
124
		<script>
125
			var oReportedPostsPanelToggle = new smc_Toggle({
126
				bToggleEnabled: true,
127
				bCurrentlyCollapsed: ', !empty($context['admin_prefs']['mcrp']) ? 'true' : 'false', ',
128
				aSwappableContainers: [
129
					\'reported_posts_panel\'
130
				],
131
				aSwapImages: [
132
					{
133
						sId: \'reported_posts_toggle\',
134
						altExpanded: ', JavaScriptEscape($txt['hide']), ',
135
						altCollapsed: ', JavaScriptEscape($txt['show']), '
136
					}
137
				],
138
				aSwapLinks: [
139
					{
140
						sId: \'reported_posts_link\',
141
						msgExpanded: ', JavaScriptEscape($txt['mc_recent_reports']), ',
142
						msgCollapsed: ', JavaScriptEscape($txt['mc_recent_reports']), '
143
					}
144
				],
145
				oThemeOptions: {
146
					bUseThemeSettings: true,
147
					sOptionName: \'admin_preferences\',
148
					sSessionVar: smf_session_var,
149
					sSessionId: smf_session_id,
150
					sThemeId: \'1\',
151
					sAdditionalVars: \';admin_key=mcrp\'
152
				}
153
			});
154
		</script>';
155
}
156
157
/**
158
 * Handles viewing details of and managing a specific report
159
 */
160
function template_viewmodreport()
161
{
162
	global $context, $scripturl, $txt;
163
164
	// Let them know the action was a success.
165
	if (!empty($context['report_post_action']))
166
		echo '
167
	<div class="infobox">
168
		', $txt['report_action_' . $context['report_post_action']], '
169
	</div>';
170
171
	echo '
172
	<div id="modcenter">
173
		<form action="', $scripturl, '?action=moderate;area=reportedposts;sa=handlecomment;rid=', $context['report']['id'], '" method="post" accept-charset="', $context['character_set'], '">
174
			<div class="cat_bar">
175
				<h3 class="catbg">
176
					', sprintf($txt['mc_viewmodreport'], $context['report']['message_link'], $context['report']['author']['link']), '
177
				</h3>
178
			</div>
179
			<div class="title_bar">
180
				<h3 class="titlebg">
181
					<span class="floatleft">
182
						', sprintf($txt['mc_modreport_summary'], $context['report']['num_reports'], $context['report']['last_updated']), '
183
					</span>';
184
185
	$report_buttons = array(
186
		'ignore' => array(
187
			'text' => !$context['report']['ignore'] ? 'mc_reportedp_ignore' : 'mc_reportedp_unignore',
188
			'url' => $scripturl.'?action=moderate;area=reportedposts;sa=handle;ignore='.(int) !$context['report']['ignore'].';rid='.$context['report']['id'].';'.$context['session_var'].'='.$context['session_id'].';'.$context['mod-report-ignore_token_var'].'='.$context['mod-report-ignore_token'],
189
			'class' => !$context['report']['ignore'] ? ' you_sure' : '',
190
			'custom' => !$context['report']['ignore'] ? ' data-confirm="' . $txt['mc_reportedp_ignore_confirm'] . '"' : '',
191
			'icon' => 'ignore'
192
		),
193
		'close' => array(
194
			'text' => $context['report']['closed'] ? 'mc_reportedp_open' : 'mc_reportedp_close',
195
			'url' => $scripturl.'?action=moderate;area=reportedposts;sa=handle;closed='.(int) !$context['report']['closed'].';rid='.$context['report']['id'].';'.$context['session_var'].'='.$context['session_id'].';'.$context['mod-report-closed_token_var'].'='.$context['mod-report-closed_token'],
196
			'icon' => 'close'
197
		)
198
	);
199
200
	// Report buttons 
201
	template_button_strip($report_buttons, 'right');
202
203
	echo '
204
				</h3>
205
			</div><!-- .title_bar -->
206
			<div class="windowbg">
207
				', $context['report']['body'], '
208
			</div>
209
			<br>
210
			<div class="cat_bar">
211
				<h3 class="catbg">', $txt['mc_modreport_whoreported_title'], '</h3>
212
			</div>';
213
214
	foreach ($context['report']['comments'] as $comment)
215
		echo '
216
			<div class="windowbg">
217
				<p class="smalltext">
218
					', sprintf($txt['mc_modreport_whoreported_data'], $comment['member']['link'] . (empty($comment['member']['id']) && !empty($comment['member']['ip']) ? ' (' . $comment['member']['ip'] . ')' : ''), $comment['time']), '
219
				</p>
220
				<p>', $comment['message'], '</p>
221
			</div>';
222
223
	echo '
224
			<br>
225
			<div class="cat_bar">
226
				<h3 class="catbg">', $txt['mc_modreport_mod_comments'], '</h3>
227
			</div>
228
			<div>';
229
230
	if (empty($context['report']['mod_comments']))
231
		echo '
232
				<div class="information">
233
					<p class="centertext">', $txt['mc_modreport_no_mod_comment'], '</p>
234
				</div>';
235
236
	foreach ($context['report']['mod_comments'] as $comment)
237
	{
238
		echo '
239
				<div class="title_bar">
240
					<h3 class="titlebg">
241
						', $comment['member']['link'], ':  <em class="smalltext">(', $comment['time'], ')</em>', ($comment['can_edit'] ? '<span class="floatright"><a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=editcomment;rid=' . $context['report']['id'] . ';mid=' . $comment['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '"  class="button">' . $txt['mc_reportedp_comment_edit'] . '</a><a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=handlecomment;rid=' . $context['report']['id'] . ';mid=' . $comment['id'] . ';delete;' . $context['session_var'] . '=' . $context['session_id'] . ';' . $context['mod-reportC-delete_token_var'] . '=' . $context['mod-reportC-delete_token'] . '"  class="button">' . $txt['mc_reportedp_comment_delete'] . '</a></span>' : ''), '
242
					</h3>
243
				</div>';
244
245
		echo '
246
				<div class="windowbg">
247
					<p>', $comment['message'], '</p>
248
				</div>';
249
	}
250
251
	echo '
252
				<div class="cat_bar">
253
					<h3 class="catbg">
254
						<span class="floatleft">
255
							', $txt['mc_reportedp_new_comment'], '
256
						</span>
257
					</h3>
258
				</div>
259
				<textarea rows="2" cols="60" style="width: 60%;" name="mod_comment"></textarea>
260
				<div class="padding">
261
					<input type="submit" name="add_comment" value="', $txt['mc_modreport_add_mod_comment'], '" class="button">
262
					<input type="hidden" name="', $context['mod-reportC-add_token_var'], '" value="', $context['mod-reportC-add_token'], '">
263
				</div>
264
			</div>
265
			<br>';
266
267
	template_show_list('moderation_actions_list');
268
269
	echo '
270
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
271
		</form>
272
	</div><!-- #modcenter -->';
273
}
274
275
/**
276
 * Template for editing a mod comment.
277
 */
278
function template_edit_comment()
279
{
280
	global $context, $scripturl, $txt;
281
282
	echo '
283
	<div id="modcenter">
284
		<form action="', $scripturl, '?action=moderate;area=reported', $context['report_type'], ';sa=editcomment;mid=', $context['comment_id'], ';rid=', $context['report_id'], ';save" method="post" accept-charset="', $context['character_set'], '">
285
			<br>
286
			<div class="cat_bar">
287
				<h3 class="catbg">', $txt['mc_modreport_edit_mod_comment'], '</h3>
288
			</div>
289
			<div class="windowbg">
290
				<textarea rows="6" cols="60" style="width: 60%;" name="mod_comment">', $context['comment']['body'], '</textarea>
291
				<div>
292
					<input type="submit" name="edit_comment" value="', $txt['mc_modreport_edit_mod_comment'], '" class="button">
293
				</div>
294
			</div>
295
			<br>
296
			<input type="hidden" name="', $context['mod-reportC-edit_token_var'], '" value="', $context['mod-reportC-edit_token'], '">
297
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
298
		</form>
299
	</div><!-- #modcenter -->';
300
}
301
302
/**
303
 * A block to show the current top reported member profiles.
304
 */
305
function template_reported_members_block()
306
{
307
	global $context, $txt, $scripturl;
308
309
	echo '
310
		<div class="cat_bar">
311
			<h3 class="catbg">
312
				<span id="reported_members_toggle" class="', !empty($context['admin_prefs']['mcru']) ? 'toggle_down' : 'toggle_up', ' floatright" style="display: none;"></span>
313
				<a href="', $scripturl, '?action=moderate;area=reportedmembers" id="reported_members_link">', $txt['mc_recent_member_reports'], '</a>
314
			</h3>
315
		</div>
316
		<div class="windowbg" id="reported_users_panel">
317
			<div class="modbox">
318
				<ul>';
319
320
	foreach ($context['reported_members'] as $report)
321
		echo '
322
					<li class="smalltext">
323
						<a href="', $report['report_href'], '">', $report['user_name'], '</a>
324
					</li>';
325
326
	// Don't have any reported members right now?
327
	if (empty($context['reported_members']))
328
		echo '
329
					<li>
330
						<strong class="smalltext">', $txt['mc_recent_reports_none'], '</strong>
331
					</li>';
332
333
	echo '
334
				</ul>
335
			</div><!-- .modbox -->
336
		</div><!-- #reported_users_panel -->
337
338
		<script>
339
			var oReportedPostsPanelToggle = new smc_Toggle({
340
				bToggleEnabled: true,
341
				bCurrentlyCollapsed: ', !empty($context['admin_prefs']['mcrm']) ? 'true' : 'false', ',
342
				aSwappableContainers: [
343
					\'reported_members_panel\'
344
				],
345
				aSwapImages: [
346
					{
347
						sId: \'reported_members_toggle\',
348
						altExpanded: ', JavaScriptEscape($txt['hide']), ',
349
						altCollapsed: ', JavaScriptEscape($txt['show']), '
350
					}
351
				],
352
				aSwapLinks: [
353
					{
354
						sId: \'reported_members_link\',
355
						msgExpanded: ', JavaScriptEscape($txt['mc_recent_member_reports']), ',
356
						msgCollapsed: ', JavaScriptEscape($txt['mc_recent_member_reports']), '
357
					}
358
				],
359
				oThemeOptions: {
360
					bUseThemeSettings: true,
361
					sOptionName: \'admin_preferences\',
362
					sSessionVar: smf_session_var,
363
					sSessionId: smf_session_id,
364
					sThemeId: \'1\',
365
					sAdditionalVars: \';admin_key=mcrm\'
366
				}
367
			});
368
		</script>';
369
}
370
371
/**
372
 * Lists all reported members
373
 */
374
function template_reported_members()
375
{
376
	global $context, $txt, $scripturl;
377
378
	// Let them know the action was a success.
379
	if (!empty($context['report_post_action']) && !empty($txt['report_action_' . $context['report_post_action']]))
380
		echo '
381
	<div class="infobox">
382
		', $txt['report_action_' . $context['report_post_action']], '
383
	</div>';
384
385
	echo '
386
	<form id="reported_members" action="', $scripturl, '?action=moderate;area=reportedmembers;sa=show', $context['view_closed'] ? ';closed' : '', ';start=', $context['start'], '" method="post" accept-charset="', $context['character_set'], '">
387
		<div class="cat_bar">
388
			<h3 class="catbg">
389
				', $context['view_closed'] ? $txt['mc_reportedp_closed'] : $txt['mc_reportedp_active'], '
390
			</h3>
391
		</div>
392
		<div class="pagesection">
393
			<div class="pagelinks">', $context['page_index'], '</div>
394
		</div>';
395
396
	foreach ($context['reports'] as $report)
397
	{
398
		echo '
399
		<div class="generic_list_wrapper windowbg">
400
			<h5>
401
				<strong><a href="', $report['user']['href'], '">', $report['user']['name'], '</a></strong>
402
			</h5>
403
			<div class="smalltext">
404
				', $txt['mc_reportedp_last_reported'], ': ', $report['last_updated'], '&nbsp;-&nbsp;';
405
406
		// Prepare the comments...
407
		$comments = array();
408
		foreach ($report['comments'] as $comment)
409
			$comments[$comment['member']['id']] = $comment['member']['link'];
410
411
		echo '
412
				', $txt['mc_reportedp_reported_by'], ': ', implode(', ', $comments), '
413
			</div>
414
			<hr>
415
			', template_quickbuttons($report['quickbuttons'], 'reported_members'), '
0 ignored issues
show
Bug introduced by
Are you sure the usage of template_quickbuttons($r...'], 'reported_members') is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
416
		</div><!-- .generic_list_wrapper -->';
417
	}
418
419
	// Were none found?
420
	if (empty($context['reports']))
421
		echo '
422
		<div class="windowbg">
423
			<p class="centertext">', $txt['mc_reportedp_none_found'], '</p>
424
		</div>';
425
426
	echo '
427
		<div class="pagesection">
428
			<div class="pagelinks floatleft">', $context['page_index'], '</div>
429
			<div class="floatright">
430
				', !$context['view_closed'] ? '<input type="submit" name="close_selected" value="' . $txt['mc_reportedp_close_selected'] . '" class="button">' : '', '
431
			</div>
432
		</div>
433
		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
434
	</form>';
435
}
436
437
/**
438
 * Template for viewing and managing a specific report about a user's profile
439
 */
440
function template_viewmemberreport()
441
{
442
	global $context, $scripturl, $txt;
443
444
	// Let them know the action was a success.
445
	if (!empty($context['report_post_action']))
446
		echo '
447
	<div class="infobox">
448
		', $txt['report_action_' . $context['report_post_action']], '
449
	</div>';
450
451
	echo '
452
	<div id="modcenter">
453
		<form action="', $scripturl, '?action=moderate;area=reportedmembers;sa=handlecomment;rid=', $context['report']['id'], '" method="post" accept-charset="', $context['character_set'], '">
454
			<div class="cat_bar">
455
				<h3 class="catbg">
456
					', sprintf($txt['mc_viewmemberreport'], $context['report']['user']['link']), '
457
				</h3>
458
			</div>
459
			<div class="title_bar">
460
				<h3 class="titlebg">
461
					<span class="floatleft">
462
						', sprintf($txt['mc_memberreport_summary'], $context['report']['num_reports'], $context['report']['last_updated']), '
463
					</span>';
464
465
	$report_buttons = array(
466
		'ignore' => array(
467
			'text' => !$context['report']['ignore'] ? 'mc_reportedp_ignore' : 'mc_reportedp_unignore',
468
			'url' => $scripturl.'?action=moderate;area=reportedmembers;sa=handle;ignore='.(int)!$context['report']['ignore'].';rid='.$context['report']['id'].';'.$context['session_var'].'='.$context['session_id'].';'.$context['mod-report-ignore_token_var'].'='.$context['mod-report-ignore_token'],
469
			'class' => !$context['report']['ignore'] ? ' you_sure' : '',
470
			'custom' => !$context['report']['ignore'] ? ' data-confirm="' . $txt['mc_reportedp_ignore_confirm'] . '"' : '',
471
			'icon' => 'ignore'
472
		),
473
		'close' => array(
474
			'text' => $context['report']['closed'] ? 'mc_reportedp_open' : 'mc_reportedp_close',
475
			'url' => $scripturl.'?action=moderate;area=reportedmembers;sa=handle;closed='.(int)!$context['report']['closed'].';rid='.$context['report']['id'].';'.$context['session_var'].'='.$context['session_id'].';'.$context['mod-report-closed_token_var'].'='.$context['mod-report-closed_token'],
476
			'icon' => 'close'
477
		)
478
	);
479
480
	// Report buttons
481
	template_button_strip($report_buttons, 'right');
482
483
	echo '
484
				</h3>
485
			</div>
486
			<br>
487
			<div class="cat_bar">
488
				<h3 class="catbg">', $txt['mc_memberreport_whoreported_title'], '</h3>
489
			</div>';
490
491
	foreach ($context['report']['comments'] as $comment)
492
		echo '
493
			<div class="windowbg">
494
				<p class="smalltext">
495
					', sprintf($txt['mc_modreport_whoreported_data'], $comment['member']['link'] . (empty($comment['member']['id']) && !empty($comment['member']['ip']) ? ' (' . $comment['member']['ip'] . ')' : ''), $comment['time']), '
496
				</p>
497
				<p>', $comment['message'], '</p>
498
			</div>';
499
500
	echo '
501
			<br>
502
			<div class="cat_bar">
503
				<h3 class="catbg">', $txt['mc_modreport_mod_comments'], '</h3>
504
			</div>
505
			<div>';
506
507
	if (empty($context['report']['mod_comments']))
508
		echo '
509
				<div class="information">
510
					<p class="centertext">', $txt['mc_modreport_no_mod_comment'], '</p>
511
				</div>';
512
513
	foreach ($context['report']['mod_comments'] as $comment)
514
	{
515
		echo '
516
				<div class="title_bar">
517
					<h3 class="titlebg">', $comment['member']['link'], ':  <em class="smalltext">(', $comment['time'], ')</em>', ($comment['can_edit'] ? '<span class="floatright"><a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=editcomment;rid=' . $context['report']['id'] . ';mid=' . $comment['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '"  class="button">' . $txt['mc_reportedp_comment_edit'] . '</a> <a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=handlecomment;rid=' . $context['report']['id'] . ';mid=' . $comment['id'] . ';delete;' . $context['session_var'] . '=' . $context['session_id'] . ';' . $context['mod-reportC-delete_token_var'] . '=' . $context['mod-reportC-delete_token'] . '"  class="button you_sure" data-confirm="' . $txt['mc_reportedp_delete_confirm'] . '">' . $txt['mc_reportedp_comment_delete'] . '</a></span>' : ''), '</h3>
518
				</div>';
519
520
		echo '
521
				<div class="windowbg">
522
					<p>', $comment['message'], '</p>
523
				</div>';
524
	}
525
526
	echo '
527
				<div class="cat_bar">
528
					<h3 class="catbg">
529
						<span class="floatleft">
530
							', $txt['mc_reportedp_new_comment'], '
531
						</span>
532
					</h3>
533
				</div>
534
				<textarea rows="2" cols="60" style="width: 60%;" name="mod_comment"></textarea>
535
				<div class="padding">
536
					<input type="submit" name="add_comment" value="', $txt['mc_modreport_add_mod_comment'], '" class="button">
537
					<input type="hidden" name="', $context['mod-reportC-add_token_var'], '" value="', $context['mod-reportC-add_token'], '">
538
				</div>
539
			</div>
540
			<br>';
541
542
	template_show_list('moderation_actions_list');
543
544
	echo '
545
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
546
		</form>
547
	</div><!-- #modcenter -->';
548
}
549
550
?>