Completed
Push — release-2.1 ( b61572...c939ca )
by Mathias
15s
created

Profile.template.php ➔ template_profile_timeformat_modify()   B

Complexity

Conditions 3
Paths 2

Size

Total Lines 24
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 11
nc 2
nop 0
dl 0
loc 24
rs 8.9713
c 0
b 0
f 0
1
<?php
2
/**
3
 * Simple Machines Forum (SMF)
4
 *
5
 * @package SMF
6
 * @author Simple Machines http://www.simplemachines.org
7
 * @copyright 2017 Simple Machines and individual contributors
8
 * @license http://www.simplemachines.org/about/smf/license.php BSD
9
 *
10
 * @version 2.1 Beta 4
11
 */
12
13
/**
14
 * Minor stuff shown above the main profile - mostly used for error messages and showing that the profile update was successful.
15
 */
16
function template_profile_above()
17
{
18
	global $context;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
19
20
	// Prevent Chrome from auto completing fields when viewing/editing other members profiles
21
	if (isBrowser('is_chrome') && !$context['user']['is_owner'])
22
		echo '
23
			<script>
24
				disableAutoComplete();
25
			</script>';
26
27
	// If an error occurred while trying to save previously, give the user a clue!
28
	echo '
29
			', template_error_message();
30
31
	// If the profile was update successfully, let the user know this.
32
	if (!empty($context['profile_updated']))
33
		echo '
34
			<div class="infobox">
35
				', $context['profile_updated'], '
36
			</div>';
37
}
38
39
/**
40
 * Template for any HTML needed below the profile (closing off divs/tables, etc.)
41
 */
42
function template_profile_below()
43
{
44
}
45
46
/**
47
 * Template for showing off the spiffy popup of the menu
48
 */
49
function template_profile_popup()
50
{
51
	global $context, $scripturl;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
52
53
	// Unlike almost every other template, this is designed to be included into the HTML directly via $().load()
54
55
	echo '
56
		<div class="profile_user_avatar floatleft">
57
			<a href="', $scripturl, '?action=profile;u=', $context['user']['id'], '">', $context['member']['avatar']['image'], '</a>
58
		</div>
59
		<div class="profile_user_info floatleft">
60
			<span class="profile_username"><a href="', $scripturl, '?action=profile;u=', $context['user']['id'], '">', $context['user']['name'], '</a></span>
61
			<span class="profile_group">', $context['member']['group'], '</span>
62
		</div>
63
		<div class="profile_user_links">
64
			<ol>';
65
66
	$menu_context = &$context[$context['profile_menu_name']];
67
	foreach ($context['profile_items'] as $item)
68
	{
69
		$area = &$menu_context['sections'][$item['menu']]['areas'][$item['area']];
70
		$item_url = (isset($item['url']) ? $item['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $item['area'])) . $menu_context['extra_parameters'];
71
		echo '
72
				<li>
73
					', $area['icon'], '<a href="', $item_url, '">', !empty($item['title']) ? $item['title'] : $area['label'], '</a>
74
				</li>';
75
	}
76
77
	echo '
78
			</ol>
79
		</div><!-- .profile_user_links -->';
80
}
81
82
/**
83
 * The "popup" showing the user's alerts
84
 */
85
function template_alerts_popup()
86
{
87
	global $context, $txt, $scripturl;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
88
89
	// Unlike almost every other template, this is designed to be included into the HTML directly via $().load()
90
	echo '
91
		<div class="alert_bar">
92
			<div class="alerts_opts block">
93
				<a href="' . $scripturl . '?action=profile;area=notification;sa=markread;', $context['session_var'], '=', $context['session_id'], '" onclick="return markAlertsRead(this)">', $txt['mark_alerts_read'], '</a>
94
				<a href="', $scripturl, '?action=profile;area=notification;sa=alerts" class="floatright">', $txt['alert_settings'], '</a>
95
			</div>
96
			<div class="alerts_box centertext">
97
				<a href="', $scripturl, '?action=profile;area=showalerts" class="button">', $txt['all_alerts'], '</a>
98
			</div>
99
		</div>
100
		<div class="alerts_unread">';
101
102
	if (empty($context['unread_alerts']))
103
	{
104
		template_alerts_all_read();
105
	}
106
	else
107
	{
108
		foreach ($context['unread_alerts'] as $id_alert => $details)
109
		{
110
			echo '
111
			<div class="unread">
112
				', !empty($details['sender']) ? $details['sender']['avatar']['image'] : '', '
113
				<div class="details">
114
					', !empty($details['icon']) ? $details['icon'] : '', '<span>', $details['text'], '</span> - ', $details['time'], '
115
				</div>
116
			</div>';
117
		}
118
	}
119
120
	echo '
121
		</div><!-- .alerts_unread -->
122
		<script>
123
			function markAlertsRead(obj) {
124
				ajax_indicator(true);
125
				$.get(
126
					obj.href,
127
					function(data) {
128
						ajax_indicator(false);
129
						$("#alerts_menu_top span.amt").remove();
130
						$("#alerts_menu div.alerts_unread").html(data);
131
					}
132
				);
133
				return false;
134
			}
135
		</script>';
136
}
137
138
/**
139
 * A simple template to say "You don't have any unread alerts".
140
 */
141
function template_alerts_all_read()
142
{
143
	global $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
144
145
	echo '<div class="no_unread">', $txt['alerts_no_unread'], '</div>';
146
}
147
148
/**
149
 * This template displays a user's details without any option to edit them.
150
 */
151
function template_summary()
152
{
153
	global $context, $settings, $scripturl, $modSettings, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
154
155
	// Display the basic information about the user
156
	echo '
157
	<div id="profileview" class="roundframe flow_auto noup">
158
		<div id="basicinfo">';
159
160
	// Are there any custom profile fields for above the name?
161 View Code Duplication
	if (!empty($context['print_custom_fields']['above_member']))
162
	{
163
		echo '
164
			<div class="custom_fields_above_name">
165
				<ul>';
166
167
		foreach ($context['print_custom_fields']['above_member'] as $field)
168
			if (!empty($field['output_html']))
169
				echo '
170
					<li>', $field['output_html'], '</li>';
171
172
		echo '
173
				</ul>
174
			</div>
175
			<br>';
176
	}
177
178
	echo '
179
			<div class="username clear">
180
				<h4>
181
					', $context['member']['name'], '<span class="position">', (!empty($context['member']['group']) ? $context['member']['group'] : $context['member']['post_group']), '</span>
182
				</h4>
183
			</div>
184
			', $context['member']['avatar']['image'];
185
186
	// Are there any custom profile fields for below the avatar?
187 View Code Duplication
	if (!empty($context['print_custom_fields']['below_avatar']))
188
	{
189
		echo '
190
			<div class="custom_fields_below_avatar">
191
				<ul>';
192
193
		foreach ($context['print_custom_fields']['below_avatar'] as $field)
194
			if (!empty($field['output_html']))
195
				echo '
196
					<li>', $field['output_html'], '</li>';
197
198
		echo '
199
				</ul>
200
			</div>
201
			<br>';
202
	}
203
204
	echo '
205
			<ul class="clear">';
206
207
	// Email is only visible if it's your profile or you have the moderate_forum permission
208 View Code Duplication
	if ($context['member']['show_email'])
209
		echo '
210
				<li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>';
211
212
	// Don't show an icon if they haven't specified a website.
213 View Code Duplication
	if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website']))
214
		echo '
215
				<li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank">', ($settings['use_image_buttons'] ? '<span class="generic_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
216
217
	// Are there any custom profile fields as icons?
218
	if (!empty($context['print_custom_fields']['icons']))
219
	{
220
		foreach ($context['print_custom_fields']['icons'] as $field)
221
			if (!empty($field['output_html']))
222
				echo '
223
				<li class="custom_field">', $field['output_html'], '</li>';
224
	}
225
226
	echo '
227
			</ul>
228
			<span id="userstatus">
229
				', $context['can_send_pm'] ? '<a href="' . $context['member']['online']['href'] . '" title="' . $context['member']['online']['text'] . '" rel="nofollow">' : '', $settings['use_image_buttons'] ? '<span class="' . ($context['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $context['member']['online']['text'] . '"></span>' : $context['member']['online']['label'], $context['can_send_pm'] ? '</a>' : '', $settings['use_image_buttons'] ? '<span class="smalltext"> ' . $context['member']['online']['label'] . '</span>' : '';
230
231
	// Can they add this member as a buddy?
232
	if (!empty($context['can_have_buddy']) && !$context['user']['is_owner'])
233
		echo '
234
				<br>
235
				<a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a>';
236
237
	echo '
238
			</span>';
239
240
	if (!$context['user']['is_owner'] && $context['can_send_pm'])
241
		echo '
242
			<a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>';
243
244
	echo '
245
			<a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>';
246
247
	if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled']))
248
		echo '
249
			<a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>';
250
251
	echo '
252
			<a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>';
253
254
	// Are there any custom profile fields for bottom?
255 View Code Duplication
	if (!empty($context['print_custom_fields']['bottom_poster']))
256
	{
257
		echo '
258
			<div class="custom_fields_bottom">
259
				<ul class="nolist">';
260
261
		foreach ($context['print_custom_fields']['bottom_poster'] as $field)
262
			if (!empty($field['output_html']))
263
				echo '
264
					<li>', $field['output_html'], '</li>';
265
266
		echo '
267
				</ul>
268
			</div>';
269
	}
270
271
	echo '
272
		</div><!-- #basicinfo -->
273
274
		<div id="detailedinfo">
275
			<dl class="settings">';
276
277
	if ($context['user']['is_owner'] || $context['user']['is_admin'])
278
		echo '
279
				<dt>', $txt['username'], ': </dt>
280
				<dd>', $context['member']['username'], '</dd>';
281
282
	if (!isset($context['disabled_fields']['posts']))
283
		echo '
284
				<dt>', $txt['profile_posts'], ': </dt>
285
				<dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>';
286
287 View Code Duplication
	if ($context['member']['show_email'])
288
	{
289
		echo '
290
				<dt>', $txt['email'], ': </dt>
291
				<dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>';
292
	}
293
294
	if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title']))
295
		echo '
296
				<dt>', $txt['custom_title'], ': </dt>
297
				<dd>', $context['member']['title'], '</dd>';
298
299
	if (!empty($context['member']['blurb']))
300
		echo '
301
				<dt>', $txt['personal_text'], ': </dt>
302
				<dd>', $context['member']['blurb'], '</dd>';
303
304
	echo '
305
				<dt>', $txt['age'], ':</dt>
306
				<dd>', $context['member']['age'] . ($context['member']['today_is_birthday'] ? ' &nbsp; <img src="' . $settings['images_url'] . '/cake.png" alt="">' : ''), '</dd>';
307
308
	echo '
309
			</dl>';
310
311
	// Any custom fields for standard placement?
312
	if (!empty($context['print_custom_fields']['standard']))
313
	{
314
		$fields = array();
315
316
		foreach ($context['print_custom_fields']['standard'] as $field)
317
			if (!empty($field['output_html']))
318
				$fields[] = $field;
319
320
		if (count($fields) > 0)
321
		{
322
			echo '
323
			<dl class="settings">';
324
325
			foreach ($fields as $field)
326
				echo '
327
				<dt>', $field['name'], ':</dt>
328
				<dd>', $field['output_html'], '</dd>';
329
330
			echo '
331
			</dl>';
332
		}
333
		
334
	}
335
336
	echo '
337
			<dl class="settings noborder">';
338
339
	// Can they view/issue a warning?
340
	if ($context['can_view_warning'] && $context['member']['warning'])
341
	{
342
		echo '
343
				<dt>', $txt['profile_warning_level'], ': </dt>
344
				<dd>
345
					<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>';
346
347
		// Can we provide information on what this means?
348
		if (!empty($context['warning_status']))
349
			echo '
350
					<span class="smalltext">(', $context['warning_status'], ')</span>';
351
352
		echo '
353
				</dd>';
354
	}
355
356
	// Is this member requiring activation and/or banned?
357
	if (!empty($context['activate_message']) || !empty($context['member']['bans']))
358
	{
359
360
		// If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves.
361
		if (!empty($context['activate_message']))
362
			echo '
363
				<dt class="clear"><span class="alert">', $context['activate_message'], '</span>&nbsp;(<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="' . $txt['profileConfirm'] . '"' : ''), '>', $context['activate_link_text'], '</a>)</dt>';
364
365
		// If the current member is banned, show a message and possibly a link to the ban.
366
		if (!empty($context['member']['bans']))
367
		{
368
			echo '
369
				<dt class="clear">
370
					<span class="alert">', $txt['user_is_banned'], '</span>&nbsp;[<a href="#" onclick="document.getElementById(\'ban_info\').style.display = document.getElementById(\'ban_info\').style.display == \'none\' ? \'\' : \'none\';return false;">' . $txt['view_ban'] . '</a>]
371
				</dt>
372
				<dt class="clear" id="ban_info" style="display: none;">
373
					<strong>', $txt['user_banned_by_following'], ':</strong>';
374
375
			foreach ($context['member']['bans'] as $ban)
376
				echo '
377
					<br>
378
					<span class="smalltext">', $ban['explanation'], '</span>';
379
380
			echo '
381
				</dt>';
382
		}
383
	}
384
385
	echo '
386
				<dt>', $txt['date_registered'], ': </dt>
387
				<dd>', $context['member']['registered'], '</dd>';
388
389
	// If the person looking is allowed, they can check the members IP address and hostname.
390
	if ($context['can_see_ip'])
391
	{
392
		if (!empty($context['member']['ip']))
393
		echo '
394
				<dt>', $txt['ip'], ': </dt>
395
				<dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>';
396
397
		if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip']))
398
			echo '
399
				<dt>', $txt['hostname'], ': </dt>
400
				<dd>', $context['member']['hostname'], '</dd>';
401
	}
402
403
	echo '
404
				<dt>', $txt['local_time'], ':</dt>
405
				<dd>', $context['member']['local_time'], '</dd>';
406
407
	if (!empty($modSettings['userLanguage']) && !empty($context['member']['language']))
408
		echo '
409
				<dt>', $txt['language'], ':</dt>
410
				<dd>', $context['member']['language'], '</dd>';
411
412
	if ($context['member']['show_last_login'])
413
		echo '
414
				<dt>', $txt['lastLoggedIn'], ': </dt>
415
				<dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>';
416
417
	echo '
418
			</dl>';
419
420
	// Are there any custom profile fields for above the signature?
421 View Code Duplication
	if (!empty($context['print_custom_fields']['above_signature']))
422
	{
423
		echo '
424
			<div class="custom_fields_above_signature">
425
				<ul class="nolist">';
426
427
		foreach ($context['print_custom_fields']['above_signature'] as $field)
428
			if (!empty($field['output_html']))
429
				echo '
430
					<li>', $field['output_html'], '</li>';
431
432
		echo '
433
				</ul>
434
			</div>';
435
	}
436
437
	// Show the users signature.
438 View Code Duplication
	if ($context['signature_enabled'] && !empty($context['member']['signature']))
439
		echo '
440
			<div class="signature">
441
				<h5>', $txt['signature'], ':</h5>
442
				', $context['member']['signature'], '
443
			</div>';
444
445
	// Are there any custom profile fields for below the signature?
446 View Code Duplication
	if (!empty($context['print_custom_fields']['below_signature']))
447
	{
448
		echo '
449
			<div class="custom_fields_below_signature">
450
				<ul class="nolist">';
451
452
		foreach ($context['print_custom_fields']['below_signature'] as $field)
453
			if (!empty($field['output_html']))
454
				echo '
455
					<li>', $field['output_html'], '</li>';
456
457
		echo '
458
				</ul>
459
			</div>';
460
	}
461
462
	echo '
463
		</div><!-- #detailedinfo -->
464
	</div><!-- #profileview -->';
465
}
466
467
/**
468
 * Template for showing all the posts of the user, in chronological order.
469
 */
470
function template_showPosts()
471
{
472
	global $context, $scripturl, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
473
474
	echo '
475
		<div class="cat_bar">
476
			<h3 class="catbg">
477
				', (!isset($context['attachments']) && empty($context['is_topics']) ? $txt['showMessages'] : (!empty($context['is_topics']) ? $txt['showTopics'] : $txt['showAttachments'])), ' - ', $context['member']['name'], '
478
			</h3>
479
		</div>', !empty($context['page_index']) ? '
480
		<div class="pagesection">
481
			<div class="pagelinks">' . $context['page_index'] . '</div>
482
		</div>' : '';
483
484
	// Are we displaying posts or attachments?
485
	if (!isset($context['attachments']))
486
	{
487
		// For every post to be displayed, give it its own div, and show the important details of the post.
488
		foreach ($context['posts'] as $post)
489
		{
490
			echo '
491
		<div class="', $post['css_class'], '">
492
			<div class="counter">', $post['counter'], '</div>
493
			<div class="topic_details">
494
				<h5>
495
					<strong><a href="', $scripturl, '?board=', $post['board']['id'], '.0">', $post['board']['name'], '</a> / <a href="', $scripturl, '?topic=', $post['topic'], '.', $post['start'], '#msg', $post['id'], '">', $post['subject'], '</a></strong>
496
				</h5>
497
				<span class="smalltext">', $post['time'], '</span>
498
			</div>
499
			<div class="list_posts">';
500
501
			if (!$post['approved'])
502
				echo '
503
				<div class="approve_post">
504
					<em>', $txt['post_awaiting_approval'], '</em>
505
				</div>';
506
507
			echo '
508
				', $post['body'], '
509
			</div>';
510
511
			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
512
				echo '
513
			<div class="floatright">
514
				<ul class="quickbuttons">';
515
516
			// If they *can* reply?
517 View Code Duplication
			if ($post['can_reply'])
518
				echo '
519
					<li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>';
520
521
			// If they *can* quote?
522 View Code Duplication
			if ($post['can_quote'])
523
				echo '
524
					<li><a href="', $scripturl . '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>';
525
526
			// How about... even... remove it entirely?!
527 View Code Duplication
			if ($post['can_delete'])
528
				echo '
529
					<li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';profile;u=', $context['member']['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
530
531
			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
532
				echo '
533
				</ul>
534
			</div><!-- .floatright -->';
535
536
			echo '
537
		</div><!-- $post[css_class] -->';
538
		}
539
	}
540
	else
541
		template_show_list('attachments');
542
543
	// No posts? Just end with a informative message.
544
	if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts'])))
545
		echo '
546
		<div class="windowbg2">
547
			', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), '
548
		</div>';
549
550
	// Show more page numbers.
551
	if (!empty($context['page_index']))
552
		echo '
553
		<div class="pagesection">
554
			<div class="pagelinks">', $context['page_index'], '</div>
555
		</div>';
556
}
557
558
/**
559
 * Template for showing alerts within the alerts popup
560
 */
561
function template_showAlerts()
562
{
563
	global $context, $txt, $scripturl;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
564
565
	// Do we have an update message?
566
	if (!empty($context['update_message']))
567
		echo '
568
		<div class="infobox">
569
			', $context['update_message'], '.
570
		</div>';
571
572
	echo '
573
		<div class="cat_bar">
574
			<h3 class="catbg">
575
			', $txt['alerts'], ' - ', $context['member']['name'], '
576
			</h3>
577
		</div>';
578
579
	if (empty($context['alerts']))
580
		echo '
581
		<div class="information">
582
			', $txt['alerts_none'], '
583
		</div>';
584
585
	else
586
	{
587
		// Start the form.
588
		echo '
589
		<form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;save" method="post" accept-charset="', $context['character_set'], '" id="mark_all">
590
			<table id="alerts" class="table_grid">';
591
592
		foreach ($context['alerts'] as $id => $alert)
593
		{
594
			echo '
595
				<tr class="windowbg">
596
					<td>', $alert['text'], '</td>
597
					<td>', $alert['time'], '</td>
598
					<td>
599
						<ul class="quickbuttons">
600
							<li><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;do=remove;aid=', $id, ';', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['delete'], '</a></li>
601
							<li><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;do=', ($alert['is_read'] != 0 ? 'unread' : 'read'), ';aid=', $id, ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons ', $alert['is_read'] != 0 ? 'unread_button' : 'read_button', '"></span>', ($alert['is_read'] != 0 ? $txt['mark_unread'] : $txt['mark_read_short']), '</a></li>
602
							<li><input type="checkbox" name="mark[', $id, ']" value="', $id, '"></li>
603
						</ul>
604
					</td>
605
				</tr>';
606
		}
607
608
		echo '
609
			</table>
610
			<div class="pagesection">
611
				<div class="floatleft">
612
					', $context['pagination'], '
613
				</div>
614
				<div class="floatright">
615
					', $txt['check_all'], ': <input type="checkbox" name="select_all" id="select_all">
616
					<select name="mark_as">
617
						<option value="read">', $txt['quick_mod_markread'], '</option>
618
						<option value="unread">', $txt['quick_mod_markunread'], '</option>
619
						<option value="remove">', $txt['quick_mod_remove'], '</option>
620
					</select>
621
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
622
					<input type="submit" name="req" value="', $txt['quick_mod_go'], '" class="button you_sure">
623
				</div>
624
			</div>
625
		</form>';
626
	}
627
}
628
629
/**
630
 * Template for showing all of a user's drafts
631
 */
632
function template_showDrafts()
633
{
634
	global $context, $scripturl, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
635
636
	echo '
637
		<div class="cat_bar">
638
			<h3 class="catbg">
639
				', $txt['drafts'], ' - ', $context['member']['name'], '
640
			</h3>
641
		</div>', !empty($context['page_index']) ? '
642
		<div class="pagesection">
643
			<div class="pagelinks">' . $context['page_index'] . '</div>
644
		</div>' : '';
645
646
	// No drafts? Just show an informative message.
647
	if (empty($context['drafts']))
648
		echo '
649
		<div class="windowbg2 centertext">
650
			', $txt['draft_none'], '
651
		</div>';
652
	else
653
	{
654
		// For every draft to be displayed, give it its own div, and show the important details of the draft.
655
		foreach ($context['drafts'] as $draft)
656
		{
657
			echo '
658
		<div class="windowbg">
659
			<div class="counter">', $draft['counter'], '</div>
660
			<div class="topic_details">
661
				<h5>
662
					<strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> &nbsp; &nbsp;';
663
664
			if (!empty($draft['sticky']))
665
				echo '
666
					<span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>';
667
668
			if (!empty($draft['locked']))
669
				echo '
670
					<span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>';
671
672
			echo '
673
				</h5>
674
				<span class="smalltext">&#171;&nbsp;<strong>', $txt['on'], ':</strong> ', $draft['time'], '&nbsp;&#187;</span>
675
			</div><!-- .topic_details -->
676
			<div class="list_posts">
677
				', $draft['body'], '
678
			</div>
679
			<div class="floatright">
680
				<ul class="quickbuttons">
681
						<li><a href="', $scripturl, '?action=post;', (empty($draft['topic']['id']) ? 'board=' . $draft['board']['id'] : 'topic=' . $draft['topic']['id']), '.0;id_draft=', $draft['id_draft'], '"><span class="generic_icons reply_button"></span>', $txt['draft_edit'], '</a></li>
682
						<li><a href="', $scripturl, '?action=profile;u=', $context['member']['id'], ';area=showdrafts;delete=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['draft_remove'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['draft_delete'], '</a></li>
683
				</ul>
684
			</div><!-- .floatright -->
685
		</div><!-- .windowbg -->';
686
		}
687
	}
688
689
	// Show page numbers.
690
	echo '
691
		<div class="pagesection">
692
			<div class="pagelinks">', $context['page_index'], '</div>
693
		</div>';
694
}
695
696
/**
697
 * Template for showing and managing the buddy list.
698
 */
699
function template_editBuddies()
700
{
701
	global $context, $scripturl, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
702
703 View Code Duplication
	if (!empty($context['saved_successful']))
704
		echo '
705
	<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
706
707
	elseif (!empty($context['saved_failed']))
708
		echo '
709
	<div class="errorbox">', $context['saved_failed'], '</div>';
710
711
	echo '
712
	<div id="edit_buddies">
713
		<div class="cat_bar">
714
			<h3 class="catbg">
715
				<span class="generic_icons people icon"></span> ', $txt['editBuddies'], '
716
			</h3>
717
		</div>
718
		<table class="table_grid">
719
			<thead>
720
				<tr class="title_bar">
721
					<th scope="col" class="quarter_table">', $txt['name'], '</th>
722
					<th scope="col">', $txt['status'], '</th>';
723
724
	if (allowedTo('moderate_forum'))
725
		echo '
726
					<th scope="col">', $txt['email'], '</th>';
727
728 View Code Duplication
	if (!empty($context['custom_pf']))
729
		foreach ($context['custom_pf'] as $column)
730
				echo '
731
					<th scope="col">', $column['label'], '</th>';
732
733
	echo '
734
					<th scope="col">', $txt['remove'], '</th>
735
				</tr>
736
			</thead>
737
			<tbody>';
738
739
	// If they don't have any buddies don't list them!
740
	if (empty($context['buddies']))
741
		echo '
742
				<tr class="windowbg">
743
					<td colspan="', allowedTo('moderate_forum') ? '10' : '9', '">
744
						<strong>', $txt['no_buddies'], '</strong>
745
					</td>
746
				</tr>';
747
748
		// Now loop through each buddy showing info on each.
749
	else
750
	{
751
		foreach ($context['buddies'] as $buddy)
752
		{
753
			echo '
754
				<tr class="windowbg">
755
					<td>', $buddy['link'], '</td>
756
					<td>
757
						<a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a>
758
					</td>';
759
760 View Code Duplication
			if ($buddy['show_email'])
761
				echo '
762
					<td>
763
						<a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a>
764
					</td>';
765
766
			// Show the custom profile fields for this user.
767 View Code Duplication
			if (!empty($context['custom_pf']))
768
				foreach ($context['custom_pf'] as $key => $column)
769
					echo '
770
					<td class="lefttext">', $buddy['options'][$key], '</td>';
771
772
			echo '
773
					<td>
774
						<a href="', $scripturl, '?action=profile;area=lists;sa=buddies;u=', $context['id_member'], ';remove=', $buddy['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['buddy_remove'], '"></span></a>
775
					</td>
776
				</tr>';
777
		}
778
	}
779
780
	echo '
781
			</tbody>
782
		</table>
783
	</div><!-- #edit_buddies -->';
784
785
	// Add a new buddy?
786
	echo '
787
	<form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=buddies" method="post" accept-charset="', $context['character_set'], '">
788
		<div class="cat_bar">
789
			<h3 class="catbg">', $txt['buddy_add'], '</h3>
790
		</div>
791
		<div class="information">
792
			<dl class="settings">
793
				<dt>
794
					<label for="new_buddy"><strong>', $txt['who_member'], ':</strong></label>
795
				</dt>
796
				<dd>
797
					<input type="text" name="new_buddy" id="new_buddy" size="30">
798
					<input type="submit" value="', $txt['buddy_add_button'], '" class="button floatnone">
799
				</dd>
800
			</dl>
801
		</div>';
802
803 View Code Duplication
	if (!empty($context['token_check']))
804
		echo '
805
		<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
806
807
	echo '
808
		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
809
	</form>
810
	<script>
811
		var oAddBuddySuggest = new smc_AutoSuggest({
812
			sSelf: \'oAddBuddySuggest\',
813
			sSessionId: smf_session_id,
814
			sSessionVar: smf_session_var,
815
			sSuggestId: \'new_buddy\',
816
			sControlId: \'new_buddy\',
817
			sSearchType: \'member\',
818
			sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
819
			bItemList: false
820
		});
821
	</script>';
822
}
823
824
/**
825
 * Template for showing the ignore list of the current user.
826
 */
827
function template_editIgnoreList()
828
{
829
	global $context, $scripturl, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
830
831 View Code Duplication
	if (!empty($context['saved_successful']))
832
		echo '
833
	<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
834
	elseif (!empty($context['saved_failed']))
835
		echo '
836
	<div class="errorbox">', $context['saved_failed'], '</div>';
837
838
	echo '
839
	<div id="edit_buddies">
840
		<div class="cat_bar">
841
			<h3 class="catbg profile_hd">
842
				', $txt['editIgnoreList'], '
843
			</h3>
844
		</div>
845
		<table class="table_grid">
846
			<thead>
847
				<tr class="title_bar">
848
					<th scope="col" class="quarter_table">', $txt['name'], '</th>
849
					<th scope="col">', $txt['status'], '</th>';
850
851
	if (allowedTo('moderate_forum'))
852
		echo '
853
					<th scope="col">', $txt['email'], '</th>';
854
855
	echo '
856
					<th scope="col">', $txt['ignore_remove'], '</th>
857
				</tr>
858
			</thead>
859
			<tbody>';
860
861
	// If they don't have anyone on their ignore list, don't list it!
862
	if (empty($context['ignore_list']))
863
		echo '
864
				<tr class="windowbg">
865
					<td colspan="', allowedTo('moderate_forum') ? '4' : '3', '">
866
						<strong>', $txt['no_ignore'], '</strong>
867
					</td>
868
				</tr>';
869
870
	// Now loop through each buddy showing info on each.
871
	foreach ($context['ignore_list'] as $member)
872
	{
873
		echo '
874
				<tr class="windowbg">
875
					<td>', $member['link'], '</td>
876
					<td>
877
						<a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a>
878
					</td>';
879
880 View Code Duplication
		if ($member['show_email'])
881
			echo '
882
					<td>
883
						<a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a>
884
					</td>';
885
		echo '
886
					<td>
887
						<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore;remove=', $member['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['ignore_remove'], '"></span></a>
888
					</td>
889
				</tr>';
890
	}
891
892
	echo '
893
			</tbody>
894
		</table>
895
	</div><!-- #edit_buddies -->';
896
897
	// Add to the ignore list?
898
	echo '
899
	<form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore" method="post" accept-charset="', $context['character_set'], '">
900
		<div class="cat_bar">
901
			<h3 class="catbg">', $txt['ignore_add'], '</h3>
902
		</div>
903
		<div class="information">
904
			<dl class="settings">
905
				<dt>
906
					<label for="new_buddy"><strong>', $txt['who_member'], ':</strong></label>
907
				</dt>
908
				<dd>
909
					<input type="text" name="new_ignore" id="new_ignore" size="25">
910
				</dd>
911
			</dl>
912
		</div>';
913
914 View Code Duplication
	if (!empty($context['token_check']))
915
		echo '
916
		<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
917
918
	echo '
919
		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
920
		<input type="submit" value="', $txt['ignore_add_button'], '" class="button">
921
	</form>
922
	<script>
923
		var oAddIgnoreSuggest = new smc_AutoSuggest({
924
			sSelf: \'oAddIgnoreSuggest\',
925
			sSessionId: \'', $context['session_id'], '\',
926
			sSessionVar: \'', $context['session_var'], '\',
927
			sSuggestId: \'new_ignore\',
928
			sControlId: \'new_ignore\',
929
			sSearchType: \'member\',
930
			sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
931
			bItemList: false
932
		});
933
	</script>';
934
}
935
936
/**
937
 * This template shows an admin information on a users IP addresses used and errors attributed to them.
938
 */
939
function template_trackActivity()
940
{
941
	global $context, $scripturl, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
942
943
	// The first table shows IP information about the user.
944
	echo '
945
		<div class="cat_bar">
946
			<h3 class="catbg">', $txt['view_ips_by'], ' ', $context['member']['name'], '</h3>
947
		</div>';
948
949
	// The last IP the user used.
950
	echo '
951
		<div id="tracking" class="windowbg2 noup">
952
			<dl class="settings noborder">
953
				<dt>
954
					', $txt['most_recent_ip'], ':
955
					', (empty($context['last_ip2']) ? '' : '<br>
956
					<span class="smalltext">(<a href="' . $scripturl . '?action=helpadmin;help=whytwoip" onclick="return reqOverlayDiv(this.href);">' . $txt['why_two_ip_address'] . '</a>)</span>'), '
957
				</dt>
958
				<dd>
959
					<a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>';
960
961
	// Second address detected?
962 View Code Duplication
	if (!empty($context['last_ip2']))
963
		echo '
964
					, <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>';
965
966
	echo '
967
				</dd>';
968
969
	// Lists of IP addresses used in messages / error messages.
970
	echo '
971
				<dt>', $txt['ips_in_messages'], ':</dt>
972
				<dd>
973
					', (count($context['ips']) > 0 ? implode(', ', $context['ips']) : '(' . $txt['none'] . ')'), '
974
				</dd>
975
				<dt>', $txt['ips_in_errors'], ':</dt>
976
				<dd>
977
					', (count($context['ips']) > 0 ? implode(', ', $context['error_ips']) : '(' . $txt['none'] . ')'), '
978
				</dd>';
979
980
	// List any members that have used the same IP addresses as the current member.
981
	echo '
982
				<dt>', $txt['members_in_range'], ':</dt>
983
				<dd>
984
					', (count($context['members_in_range']) > 0 ? implode(', ', $context['members_in_range']) : '(' . $txt['none'] . ')'), '
985
				</dd>
986
			</dl>
987
		</div><!-- #tracking -->';
988
989
	// Show the track user list.
990
	template_show_list('track_user_list');
991
}
992
993
/**
994
 * The template for trackIP, allowing the admin to see where/who a certain IP has been used.
995
 */
996
function template_trackIP()
997
{
998
	global $context, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
999
1000
	// This function always defaults to the last IP used by a member but can be set to track any IP.
1001
	// The first table in the template gives an input box to allow the admin to enter another IP to track.
1002
	echo '
1003
		<div class="cat_bar">
1004
			<h3 class="catbg">', $txt['trackIP'], '</h3>
1005
		</div>
1006
		<div class="windowbg2 noup">
1007
			<form action="', $context['base_url'], '" method="post" accept-charset="', $context['character_set'], '">
1008
				<dl class="settings">
1009
					<dt>
1010
						<label for="searchip"><strong>', $txt['enter_ip'], ':</strong></label>
1011
					</dt>
1012
					<dd>
1013
						<input type="text" name="searchip" value="', $context['ip'], '">
1014
					</dd>
1015
				</dl>
1016
				<input type="submit" value="', $txt['trackIP'], '" class="button">
1017
			</form>
1018
		</div>
1019
		<br>';
1020
1021
	// The table inbetween the first and second table shows links to the whois server for every region.
1022
	if ($context['single_ip'])
1023
	{
1024
		echo '
1025
		<div class="cat_bar">
1026
			<h3 class="catbg">', $txt['whois_title'], ' ', $context['ip'], '</h3>
1027
		</div>
1028
		<div class="windowbg2 noup">';
1029
1030
		foreach ($context['whois_servers'] as $server)
1031
		echo '
1032
			<a href="', $server['url'], '" target="_blank"', isset($context['auto_whois_server']) && $context['auto_whois_server']['name'] == $server['name'] ? ' style="font-weight: bold;"' : '', '>', $server['name'], '</a><br>';
1033
		echo '
1034
		</div>
1035
		<br>';
1036
	}
1037
1038
	// The second table lists all the members who have been logged as using this IP address.
1039
	echo '
1040
		<div class="cat_bar">
1041
			<h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3>
1042
		</div>';
1043
	if (empty($context['ips']))
1044
		echo '
1045
		<p class="windowbg2 description"><em>', $txt['no_members_from_ip'], '</em></p>';
1046
	else
1047
	{
1048
		echo '
1049
		<table class="table_grid">
1050
			<thead>
1051
				<tr class="title_bar">
1052
					<th scope="col">', $txt['ip_address'], '</th>
1053
					<th scope="col">', $txt['display_name'], '</th>
1054
				</tr>
1055
			</thead>
1056
			<tbody>';
1057
1058
		// Loop through each of the members and display them.
1059
		foreach ($context['ips'] as $ip => $memberlist)
1060
			echo '
1061
				<tr class="windowbg">
1062
					<td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td>
1063
					<td>', implode(', ', $memberlist), '</td>
1064
				</tr>';
1065
1066
		echo '
1067
			</tbody>
1068
		</table>';
1069
	}
1070
1071
	echo '
1072
		<br>';
1073
1074
	template_show_list('track_message_list');
1075
1076
	echo '<br>';
1077
1078
	template_show_list('track_user_list');
1079
1080
	// 3rd party integrations may have added additional tracking.
1081
	if (!empty($context['additional_track_lists']))
1082
	{
1083
		foreach ($context['additional_track_lists'] as $list)
1084
		{
1085
			echo '<br>';
1086
1087
			template_show_list($list);
1088
		}
1089
	}
1090
}
1091
1092
/**
1093
 * This template shows an admin which permissions a user have and which group(s) give them each permission.
1094
 */
1095
function template_showPermissions()
1096
{
1097
	global $context, $scripturl, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
1098
1099
	echo '
1100
		<div class="cat_bar">
1101
			<h3 class="catbg profile_hd">
1102
				', $txt['showPermissions'], '
1103
			</h3>
1104
		</div>';
1105
1106
	if ($context['member']['has_all_permissions'])
1107
	{
1108
		echo '
1109
		<div class="information">', $txt['showPermissions_all'], '</div>';
1110
	}
1111
	else
1112
	{
1113
		echo '
1114
		<div class="information">',$txt['showPermissions_help'], '</div>
1115
		<div id="permissions" class="flow_hidden">';
1116
1117
		if (!empty($context['no_access_boards']))
1118
		{
1119
			echo '
1120
			<div class="cat_bar">
1121
				<h3 class="catbg">', $txt['showPermissions_restricted_boards'], '</h3>
1122
			</div>
1123
			<div class="windowbg smalltext">
1124
				', $txt['showPermissions_restricted_boards_desc'], ':<br>';
1125
			
1126
			foreach ($context['no_access_boards'] as $no_access_board)
1127
				echo '
1128
				<a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', ';
1129
			echo '
1130
			</div>';
1131
		}
1132
1133
		// General Permissions section.
1134
		echo '
1135
			<div class="tborder">
1136
				<div class="cat_bar">
1137
					<h3 class="catbg">', $txt['showPermissions_general'], '</h3>
1138
				</div>';
1139 View Code Duplication
		if (!empty($context['member']['permissions']['general']))
1140
		{
1141
			echo '
1142
				<table class="table_grid">
1143
					<thead>
1144
						<tr class="title_bar">
1145
							<th class="lefttext half_table">', $txt['showPermissions_permission'], '</th>
1146
							<th class="lefttext half_table">', $txt['showPermissions_status'], '</th>
1147
						</tr>
1148
					</thead>
1149
					<tbody>';
1150
1151
			foreach ($context['member']['permissions']['general'] as $permission)
1152
			{
1153
				echo '
1154
						<tr class="windowbg">
1155
							<td title="', $permission['id'], '">
1156
								', $permission['is_denied'] ? '<del>' . $permission['name'] . '</del>' : $permission['name'], '
1157
							</td>
1158
							<td class="smalltext">';
1159
1160
				if ($permission['is_denied'])
1161
					echo '
1162
								<span class="alert">', $txt['showPermissions_denied'], ':&nbsp;', implode(', ', $permission['groups']['denied']), '</span>';
1163
				else
1164
					echo '
1165
								', $txt['showPermissions_given'], ':&nbsp;', implode(', ', $permission['groups']['allowed']);
1166
1167
				echo '
1168
							</td>
1169
						</tr>';
1170
			}
1171
			echo '
1172
					</tbody>
1173
				</table>
1174
			</div><!-- .tborder -->
1175
			<br>';
1176
		}
1177
		else
1178
			echo '
1179
			<p class="windowbg2">', $txt['showPermissions_none_general'], '</p>';
1180
1181
		// Board permission section.
1182
		echo '
1183
			<form action="' . $scripturl . '?action=profile;u=', $context['id_member'], ';area=permissions#board_permissions" method="post" accept-charset="', $context['character_set'], '">
1184
				<div class="cat_bar">
1185
					<h3 class="catbg">
1186
						<a id="board_permissions"></a>', $txt['showPermissions_select'], ':
1187
						<select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();">
1188
							<option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], '&nbsp;</option>';
1189
		if (!empty($context['boards']))
1190
			echo '
1191
							<option value="" disabled>---------------------------</option>';
1192
1193
		// Fill the box with any local permission boards.
1194
		foreach ($context['boards'] as $board)
1195
			echo '
1196
							<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>';
1197
1198
		echo '
1199
						</select>
1200
					</h3>
1201
				</div><!-- .cat_bar -->
1202
			</form>';
1203 View Code Duplication
		if (!empty($context['member']['permissions']['board']))
1204
		{
1205
			echo '
1206
			<table class="table_grid">
1207
				<thead>
1208
					<tr class="title_bar">
1209
						<th class="lefttext half_table">', $txt['showPermissions_permission'], '</th>
1210
						<th class="lefttext half_table">', $txt['showPermissions_status'], '</th>
1211
					</tr>
1212
				</thead>
1213
				<tbody>';
1214
			foreach ($context['member']['permissions']['board'] as $permission)
1215
			{
1216
				echo '
1217
					<tr class="windowbg">
1218
						<td title="', $permission['id'], '">
1219
							', $permission['is_denied'] ? '<del>' . $permission['name'] . '</del>' : $permission['name'], '
1220
						</td>
1221
						<td class="smalltext">';
1222
1223
				if ($permission['is_denied'])
1224
				{
1225
					echo '
1226
							<span class="alert">', $txt['showPermissions_denied'], ':&nbsp;', implode(', ', $permission['groups']['denied']), '</span>';
1227
				}
1228
				else
1229
				{
1230
					echo '
1231
							', $txt['showPermissions_given'], ': &nbsp;', implode(', ', $permission['groups']['allowed']);
1232
				}
1233
				echo '
1234
						</td>
1235
					</tr>';
1236
			}
1237
			echo '
1238
				</tbody>
1239
			</table>';
1240
		}
1241
		else
1242
			echo '
1243
			<p class="windowbg2">', $txt['showPermissions_none_board'], '</p>';
1244
	echo '
1245
		</div><!-- #permissions -->';
1246
	}
1247
}
1248
1249
/**
1250
 * Template for user statistics, showing graphs and the like.
1251
 */
1252
function template_statPanel()
1253
{
1254
	global $context, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
1255
1256
	// First, show a few text statistics such as post/topic count.
1257
	echo '
1258
	<div id="profileview" class="roundframe">
1259
		<div id="generalstats">
1260
			<dl class="stats">
1261
				<dt>', $txt['statPanel_total_time_online'], ':</dt>
1262
				<dd>', $context['time_logged_in'], '</dd>
1263
				<dt>', $txt['statPanel_total_posts'], ':</dt>
1264
				<dd>', $context['num_posts'], ' ', $txt['statPanel_posts'], '</dd>
1265
				<dt>', $txt['statPanel_total_topics'], ':</dt>
1266
				<dd>', $context['num_topics'], ' ', $txt['statPanel_topics'], '</dd>
1267
				<dt>', $txt['statPanel_users_polls'], ':</dt>
1268
				<dd>', $context['num_polls'], ' ', $txt['statPanel_polls'], '</dd>
1269
				<dt>', $txt['statPanel_users_votes'], ':</dt>
1270
				<dd>', $context['num_votes'], ' ', $txt['statPanel_votes'], '</dd>
1271
			</dl>
1272
		</div>';
1273
1274
	// This next section draws a graph showing what times of day they post the most.
1275
	echo '
1276
		<div id="activitytime" class="flow_hidden">
1277
			<div class="title_bar">
1278
				<h3 class="titlebg">
1279
					<span class="generic_icons history"></span> ', $txt['statPanel_activityTime'], '
1280
				</h3>
1281
			</div>';
1282
1283
	// If they haven't post at all, don't draw the graph.
1284
	if (empty($context['posts_by_time']))
1285
		echo '
1286
			<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1287
	// Otherwise do!
1288
	else
1289
	{
1290
		echo '
1291
			<ul class="activity_stats flow_hidden">';
1292
1293
		// The labels.
1294
		foreach ($context['posts_by_time'] as $time_of_day)
1295
		{
1296
			echo '
1297
				<li', $time_of_day['is_last'] ? ' class="last"' : '', '>
1298
					<div class="bar" style="padding-top: ', ((int) (100 - $time_of_day['relative_percent'])), 'px;" title="', sprintf($txt['statPanel_activityTime_posts'], $time_of_day['posts'], $time_of_day['posts_percent']), '">
1299
						<div style="height: ', (int) $time_of_day['relative_percent'], 'px;">
1300
							<span>', sprintf($txt['statPanel_activityTime_posts'], $time_of_day['posts'], $time_of_day['posts_percent']), '</span>
1301
						</div>
1302
					</div>
1303
					<span class="stats_hour">', $time_of_day['hour_format'], '</span>
1304
				</li>';
1305
		}
1306
1307
		echo '
1308
			</ul>';
1309
	}
1310
1311
	echo '
1312
		</div><!-- #activitytime -->';
1313
1314
	// Two columns with the most popular boards by posts and activity (activity = users posts / total posts).
1315
	echo '
1316
		<div class="flow_hidden">
1317
			<div class="half_content">
1318
				<div class="title_bar">
1319
					<h3 class="titlebg">
1320
						<span class="generic_icons replies"></span> ', $txt['statPanel_topBoards'], '
1321
					</h3>
1322
				</div>';
1323
1324 View Code Duplication
	if (empty($context['popular_boards']))
1325
		echo '
1326
				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1327
1328
	else
1329
	{
1330
		echo '
1331
				<dl class="stats">';
1332
1333
		// Draw a bar for every board.
1334
		foreach ($context['popular_boards'] as $board)
1335
		{
1336
			echo '
1337
					<dt>', $board['link'], '</dt>
1338
					<dd>
1339
						<div class="profile_pie" style="background-position: -', ((int) ($board['posts_percent'] / 5) * 20), 'px 0;" title="', sprintf($txt['statPanel_topBoards_memberposts'], $board['posts'], $board['total_posts_member'], $board['posts_percent']), '">
1340
							', sprintf($txt['statPanel_topBoards_memberposts'], $board['posts'], $board['total_posts_member'], $board['posts_percent']), '
1341
						</div>
1342
						', empty($context['hide_num_posts']) ? $board['posts'] : '', '
1343
					</dd>';
1344
		}
1345
1346
		echo '
1347
				</dl>';
1348
	}
1349
	echo '
1350
			</div><!-- .half_content -->
1351
			<div class="half_content">
1352
				<div class="title_bar">
1353
					<h3 class="titlebg">
1354
						<span class="generic_icons replies"></span> ', $txt['statPanel_topBoardsActivity'], '
1355
					</h3>
1356
				</div>';
1357
1358 View Code Duplication
	if (empty($context['board_activity']))
1359
		echo '
1360
				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1361
	else
1362
	{
1363
		echo '
1364
				<dl class="stats">';
1365
1366
		// Draw a bar for every board.
1367
		foreach ($context['board_activity'] as $activity)
1368
		{
1369
			echo '
1370
					<dt>', $activity['link'], '</dt>
1371
					<dd>
1372
						<div class="profile_pie" style="background-position: -', ((int) ($activity['percent'] / 5) * 20), 'px 0;" title="', sprintf($txt['statPanel_topBoards_posts'], $activity['posts'], $activity['total_posts'], $activity['posts_percent']), '">
1373
							', sprintf($txt['statPanel_topBoards_posts'], $activity['posts'], $activity['total_posts'], $activity['posts_percent']), '
1374
						</div>
1375
						', $activity['percent'], '%
1376
					</dd>';
1377
		}
1378
1379
		echo '
1380
				</dl>';
1381
	}
1382
	echo '
1383
			</div><!-- .half_content -->
1384
		</div><!-- .flow_hidden -->';
1385
1386
	echo '
1387
	</div><!-- #profileview -->';
1388
}
1389
1390
/**
1391
 * Template for editing profile options.
1392
 */
1393
function template_edit_options()
1394
{
1395
	global $context, $scripturl, $txt, $modSettings;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
1396
1397
	// The main header!
1398
	// because some browsers ignore autocomplete=off and fill username in display name and/ or email field, fake them out.
1399
	$url = !empty($context['profile_custom_submit_url']) ? $context['profile_custom_submit_url'] : $scripturl . '?action=profile;area=' . $context['menu_item_selected'] . ';u=' . $context['id_member'];
1400
	$url = $context['require_password'] && !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($url, array('http://' => 'https://')) : $url;
1401
1402
	echo '
1403
		<form action="', $url, '" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator" enctype="multipart/form-data"', ($context['menu_item_selected'] == 'account' ? ' autocomplete="off"' : ''), '>
1404
			<div style="position:absolute; left:-3000px;">
1405
				<input type="text" id="autocompleteFakeName">
1406
				<input type="password" id="autocompleteFakePassword">
1407
			</div>
1408
			<div class="cat_bar">
1409
				<h3 class="catbg profile_hd">';
1410
1411
		// Don't say "Profile" if this isn't the profile...
1412
		if (!empty($context['profile_header_text']))
1413
			echo '
1414
					', $context['profile_header_text'];
1415
		else
1416
			echo '
1417
					', $txt['profile'];
1418
1419
		echo '
1420
				</h3>
1421
			</div>';
1422
1423
	// Have we some description?
1424
	if ($context['page_desc'])
1425
		echo '
1426
			<p class="information">', $context['page_desc'], '</p>';
1427
1428
	echo '
1429
			<div class="roundframe">';
1430
1431
	// Any bits at the start?
1432
	if (!empty($context['profile_prehtml']))
1433
		echo '
1434
				<div>', $context['profile_prehtml'], '</div>';
1435
1436
	if (!empty($context['profile_fields']))
1437
		echo '
1438
				<dl class="settings">';
1439
1440
	// Start the big old loop 'of love.
1441
	$lastItem = 'hr';
1442
	foreach ($context['profile_fields'] as $key => $field)
1443
	{
1444
		// We add a little hack to be sure we never get more than one hr in a row!
1445
		if ($lastItem == 'hr' && $field['type'] == 'hr')
1446
			continue;
1447
1448
		$lastItem = $field['type'];
1449
		if ($field['type'] == 'hr')
1450
		{
1451
			echo '
1452
				</dl>
1453
				<hr>
1454
				<dl class="settings">';
1455
		}
1456 View Code Duplication
		elseif ($field['type'] == 'callback')
1457
		{
1458
			if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func']))
1459
			{
1460
				$callback_func = 'template_profile_' . $field['callback_func'];
1461
				$callback_func();
1462
			}
1463
		}
1464
		else
1465
		{
1466
			echo '
1467
					<dt>
1468
						<strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>';
1469
1470
			// Does it have any subtext to show?
1471
			if (!empty($field['subtext']))
1472
				echo '
1473
						<br>
1474
						<span class="smalltext">', $field['subtext'], '</span>';
1475
1476
			echo '
1477
					</dt>
1478
					<dd>';
1479
1480
			// Want to put something infront of the box?
1481
			if (!empty($field['preinput']))
1482
				echo '
1483
						', $field['preinput'];
1484
1485
			// What type of data are we showing?
1486
			if ($field['type'] == 'label')
1487
				echo '
1488
						', $field['value'];
1489
1490
			// Maybe it's a text box - very likely!
1491
			elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url')))
1492
			{
1493
				if ($field['type'] == 'int' || $field['type'] == 'float')
1494
					$type = 'number';
1495
				else
1496
					$type = $field['type'];
1497
				$step = $field['type'] == 'float' ? ' step="0.1"' : '';
1498
1499
1500
				echo '
1501
						<input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' ', $step, '>';
1502
			}
1503
			// You "checking" me out? ;)
1504 View Code Duplication
			elseif ($field['type'] == 'check')
1505
				echo '
1506
						<input type="hidden" name="', $key, '" value="0">
1507
						<input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" ', $field['input_attr'], '>';
1508
1509
			// Always fun - select boxes!
1510 View Code Duplication
			elseif ($field['type'] == 'select')
1511
			{
1512
				echo '
1513
						<select name="', $key, '" id="', $key, '">';
1514
1515
				if (isset($field['options']))
1516
				{
1517
					// Is this some code to generate the options?
1518
					if (!is_array($field['options']))
1519
						$field['options'] = $field['options']();
1520
1521
					// Assuming we now have some!
1522
					if (is_array($field['options']))
1523
						foreach ($field['options'] as $value => $name)
1524
							echo '
1525
							<option value="', $value, '"', $value == $field['value'] ? ' selected' : '', '>', $name, '</option>';
1526
				}
1527
1528
				echo '
1529
						</select>';
1530
			}
1531
1532
			// Something to end with?
1533
			if (!empty($field['postinput']))
1534
				echo '
1535
						', $field['postinput'];
1536
1537
			echo '
1538
					</dd>';
1539
		}
1540
	}
1541
1542
	if (!empty($context['profile_fields']))
1543
		echo '
1544
				</dl>';
1545
1546
	// Are there any custom profile fields - if so print them!
1547
	if (!empty($context['custom_fields']))
1548
	{
1549
		if ($lastItem != 'hr')
1550
			echo '
1551
				<hr>';
1552
1553
		echo '
1554
				<dl class="settings">';
1555
1556
		foreach ($context['custom_fields'] as $field)
1557
		{
1558
			echo '
1559
					<dt>
1560
						<strong>', $field['name'], ': </strong><br>
1561
						<span class="smalltext">', $field['desc'], '</span>
1562
					</dt>
1563
					<dd>
1564
						', $field['input_html'], '
1565
					</dd>';
1566
		}
1567
1568
		echo '
1569
				</dl>';
1570
1571
	}
1572
1573
	// Any closing HTML?
1574
	if (!empty($context['profile_posthtml']))
1575
		echo '
1576
				<div>', $context['profile_posthtml'], '</div>';
1577
1578
	// Only show the password box if it's actually needed.
1579 View Code Duplication
	if ($context['require_password'])
1580
		echo '
1581
				<dl class="settings">
1582
					<dt>
1583
						<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br>
1584
						<span class="smalltext">', $txt['required_security_reasons'], '</span>
1585
					</dt>
1586
					<dd>
1587
						<input type="password" name="oldpasswrd" id="oldpasswrd" size="20">
1588
					</dd>
1589
				</dl>';
1590
1591
	// The button shouldn't say "Change profile" unless we're changing the profile...
1592
	if (!empty($context['submit_button_text']))
1593
		echo '
1594
				<input type="submit" name="save" value="', $context['submit_button_text'], '" class="button">';
1595
	else
1596
		echo '
1597
				<input type="submit" name="save" value="', $txt['change_profile'], '" class="button">';
1598
1599 View Code Duplication
	if (!empty($context['token_check']))
1600
		echo '
1601
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
1602
1603
	echo '
1604
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1605
				<input type="hidden" name="u" value="', $context['id_member'], '">
1606
				<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
1607
			</div><!-- .roundframe -->
1608
		</form>';
1609
1610
	// Any final spellchecking stuff?
1611
	if (!empty($context['show_spellchecking']))
1612
		echo '
1613
		<form name="spell_form" id="spell_form" method="post" accept-charset="', $context['character_set'], '" target="spellWindow" action="', $scripturl, '?action=spellcheck"><input type="hidden" name="spellstring" value=""></form>';
1614
}
1615
1616
/**
1617
 * Personal Message settings.
1618
 */
1619
function template_profile_pm_settings()
1620
{
1621
	global $context, $modSettings, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
1622
1623
	echo '
1624
					<dt>
1625
						<label for="pm_prefs">', $txt['pm_display_mode'], ':</label>
1626
					</dt>
1627
					<dd>
1628
						<select name="pm_prefs" id="pm_prefs">
1629
							<option value="0"', $context['display_mode'] == 0 ? ' selected' : '', '>', $txt['pm_display_mode_all'], '</option>
1630
							<option value="1"', $context['display_mode'] == 1 ? ' selected' : '', '>', $txt['pm_display_mode_one'], '</option>
1631
							<option value="2"', $context['display_mode'] == 2 ? ' selected' : '', '>', $txt['pm_display_mode_linked'], '</option>
1632
						</select>
1633
					</dd>
1634
					<dt>
1635
						<label for="view_newest_pm_first">', $txt['recent_pms_at_top'], '</label>
1636
					</dt>
1637
					<dd>
1638
						<input type="hidden" name="default_options[view_newest_pm_first]" value="0">
1639
						<input type="checkbox" name="default_options[view_newest_pm_first]" id="view_newest_pm_first" value="1"', !empty($context['member']['options']['view_newest_pm_first']) ? ' checked' : '', '>
1640
					</dd>
1641
				</dl>
1642
				<hr>
1643
				<dl class="settings">
1644
					<dt>
1645
						<label for="pm_receive_from">', $txt['pm_receive_from'], '</label>
1646
					</dt>
1647
					<dd>
1648
						<select name="pm_receive_from" id="pm_receive_from">
1649
							<option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>';
1650
1651
	if (!empty($modSettings['enable_buddylist']))
1652
		echo '
1653
							<option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option>
1654
							<option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>';
1655
1656
	echo '
1657
							<option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option>
1658
						</select>
1659
					</dd>
1660
					<dt>
1661
						<label for="popup_messages">', $txt['popup_messages'], '</label>
1662
					</dt>
1663
					<dd>
1664
						<input type="hidden" name="default_options[popup_messages]" value="0">
1665
						<input type="checkbox" name="default_options[popup_messages]" id="popup_messages" value="1"', !empty($context['member']['options']['popup_messages']) ? ' checked' : '', '>
1666
					</dd>
1667
				</dl>
1668
				<hr>
1669
				<dl class="settings">
1670
					<dt>
1671
						<label for="pm_remove_inbox_label">', $txt['pm_remove_inbox_label'], '</label>
1672
					</dt>
1673
					<dd>
1674
						<input type="hidden" name="default_options[pm_remove_inbox_label]" value="0">
1675
						<input type="checkbox" name="default_options[pm_remove_inbox_label]" id="pm_remove_inbox_label" value="1"', !empty($context['member']['options']['pm_remove_inbox_label']) ? ' checked' : '', '>
1676
					</dd>';
1677
1678
}
1679
1680
/**
1681
 * Template for showing theme settings. Note: template_options() actually adds the theme specific options.
1682
 */
1683
function template_profile_theme_settings()
1684
{
1685
	global $context, $modSettings;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
1686
1687
	$skeys = array_keys($context['theme_options']);
1688
	$first_option_key = array_shift($skeys);
1689
	$titled_section = false;
1690
1691
	foreach ($context['theme_options'] as $i => $setting)
1692
	{
1693
		// Just spit out separators and move on
1694 View Code Duplication
		if (empty($setting) || !is_array($setting))
1695
		{
1696
			// Insert a separator (unless this is the first item in the list)
1697
			if ($i !== $first_option_key)
1698
				echo '
1699
				</dl>
1700
				<hr>
1701
				<dl class="settings">';
1702
1703
			// Should we give a name to this section?
1704
			if (is_string($setting) && !empty($setting))
1705
			{
1706
				$titled_section = true;
1707
				echo '
1708
					<dt><strong>' . $setting . '</strong></dt>
1709
					<dd></dd>';
1710
			}
1711
			else
1712
				$titled_section = false;
1713
1714
			continue;
1715
		}
1716
1717
		// Is this disabled?
1718
		if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled']))
1719
			continue;
1720
		elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage']))
1721
			continue;
1722
		elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored']))
1723
			continue;
1724
		elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist']))
1725
			continue;
1726
		elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg']))
1727
			continue;
1728 View Code Duplication
		elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled']))))
1729
			continue;
1730 View Code Duplication
		elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled']))))
1731
			continue;
1732
1733
		// Some of these may not be set...  Set to defaults here
1734
		$opts = array('topics_per_page', 'messages_per_page', 'display_quick_mod');
1735
		if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']]))
1736
			$context['member']['options'][$setting['id']] = 0;
1737
1738
		if (!isset($setting['type']) || $setting['type'] == 'bool')
1739
			$setting['type'] = 'checkbox';
1740
		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
1741
			$setting['type'] = 'number';
1742
		elseif ($setting['type'] == 'string')
1743
			$setting['type'] = 'text';
1744
1745
		if (isset($setting['options']))
1746
			$setting['type'] = 'list';
1747
1748
		echo '
1749
					<dt>
1750
						<label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>';
1751
1752
		if (isset($setting['description']))
1753
			echo '
1754
						<br>
1755
						<span class="smalltext">', $setting['description'], '</span>';
1756
		echo '
1757
					</dt>
1758
					<dd>';
1759
1760
		// Display checkbox options
1761
		if ($setting['type'] == 'checkbox')
1762
		{
1763
			echo '
1764
						<input type="hidden" name="default_options[' . $setting['id'] . ']" value="0">
1765
						<input type="checkbox" name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', !empty($context['member']['options'][$setting['id']]) ? ' checked' : '', ' value="1">';
1766
		}
1767
		// How about selection lists, we all love them
1768 View Code Duplication
		elseif ($setting['type'] == 'list')
1769
		{
1770
			echo '
1771
						&nbsp;<select class="floatleft" name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', '>';
1772
1773
			foreach ($setting['options'] as $value => $label)
1774
			{
1775
				echo '
1776
							<option value="', $value, '"', $value == $context['member']['options'][$setting['id']] ? ' selected' : '', '>', $label, '</option>';
1777
			}
1778
1779
			echo '
1780
						</select>';
1781
		}
1782
		// A textbox it is then
1783
		else
1784
		{
1785
			if (isset($setting['type']) && $setting['type'] == 'number')
1786
			{
1787
				$min = isset($setting['min']) ? ' min="' . $setting['min'] . '"' : ' min="0"';
1788
				$max = isset($setting['max']) ? ' max="' . $setting['max'] . '"' : '';
1789
				$step = isset($setting['step']) ? ' step="' . $setting['step'] . '"' : '';
1790
1791
				echo '
1792
						<input type="number"', $min . $max . $step;
1793
			}
1794
			else if (isset($setting['type']) && $setting['type'] == 'url')
1795
			{
1796
				echo'
1797
						<input type="url"';
1798
			}
1799
			else
1800
			{
1801
				echo '
1802
						<input type="text"';
1803
			}
1804
1805
			echo ' name="default_options[', $setting['id'], ']" id="', $setting['id'], '" value="', isset($context['member']['options'][$setting['id']]) ? $context['member']['options'][$setting['id']] : $setting['value'], '"', $setting['type'] == 'number' ? ' size="5"' : '', '>';
1806
		}
1807
1808
		// end of this defintion
1809
		echo '
1810
					</dd>';
1811
	}
1812
}
1813
1814
/**
1815
 * The template for configuring alerts
1816
 */
1817
function template_alert_configuration()
1818
{
1819
	global $context, $txt, $scripturl, $modSettings;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
1820
1821
	echo '
1822
		<div class="cat_bar">
1823
			<h3 class="catbg">
1824
				', $txt['alert_prefs'], '
1825
			</h3>
1826
		</div>
1827
		<p class="information">
1828
			', (empty($context['description']) ? $txt['alert_prefs_desc'] : $context['description']), '
1829
		</p>
1830
		<form action="', $scripturl, '?', $context['action'], '" id="admin_form_wrapper" method="post" accept-charset="', $context['character_set'], '" id="notify_options" class="flow_hidden">
1831
			<div class="cat_bar">
1832
				<h3 class="catbg">
1833
					', $txt['notification_general'], '
1834
				</h3>
1835
			</div>
1836
			<div class="windowbg2 noup">
1837
				<dl class="settings">';
1838
1839
	// Allow notification on announcements to be disabled?
1840
	if (!empty($modSettings['allow_disableAnnounce']))
1841
		echo '
1842
					<dt>
1843
						<label for="notify_announcements">', $txt['notify_important_email'], '</label>
1844
					</dt>
1845
					<dd>
1846
						<input type="hidden" name="notify_announcements" value="0">
1847
						<input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', '>
1848
					</dd>';
1849
1850
	if (!empty($modSettings['enable_ajax_alerts']))
1851
		echo '
1852
					<dt>
1853
						<label for="notify_send_body">', $txt['notify_alert_timeout'], '</label>
1854
					</dt>
1855
					<dd>
1856
						<input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '">
1857
					</dd>';
1858
1859
	echo '
1860
				</dl>
1861
			</div><!-- .windowbg2 -->
1862
			<div class="cat_bar">
1863
				<h3 class="catbg">
1864
					', $txt['notify_what_how'], '
1865
				</h3>
1866
			</div>
1867
			<table class="table_grid">';
1868
1869
	foreach ($context['alert_types'] as $alert_group => $alerts)
1870
	{
1871
		echo '
1872
				<tr class="title_bar">
1873
					<th>', $txt['alert_group_' . $alert_group], '</th>
1874
					<th>', $txt['receive_alert'], '</th>
1875
					<th>', $txt['receive_mail'], '</th>
1876
				</tr>
1877
				<tr class="windowbg">';
1878
		if (isset($context['alert_group_options'][$alert_group]))
1879
		{
1880
			foreach ($context['alert_group_options'][$alert_group] as $opts)
1881
			{
1882
				echo '
1883
				<tr class="windowbg">
1884
					<td colspan="3">';
1885
				$label = $txt['alert_opt_' . $opts[1]];
1886
				$label_pos = isset($opts['label']) ? $opts['label'] : '';
1887
				if ($label_pos == 'before')
1888
					echo '
1889
						<label for="opt_', $opts[1], '">', $label, '</label>';
1890
1891
				$this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0;
1892
				switch ($opts[0])
1893
				{
1894
					case 'check':
1895
						echo '
1896
						<input type="checkbox" name="opt_', $opts[1], '" id="opt_', $opts[1], '"', $this_value ? ' checked' : '', '>';
1897
						break;
1898
					case 'select':
1899
						echo '
1900
						<select name="opt_', $opts[1], '" id="opt_', $opts[1], '">';
1901
						foreach ($opts['opts'] as $k => $v)
1902
							echo '
1903
							<option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>';
1904
						echo '
1905
						</select>';
1906
						break;
1907
				}
1908
1909
				if ($label_pos == 'after')
1910
					echo '
1911
						<label for="opt_', $opts[1], '">', $label, '</label>';
1912
1913
				echo '
1914
					</td>
1915
				</tr>';
1916
			}
1917
		}
1918
1919
		foreach ($alerts as $alert_id => $alert_details)
1920
		{
1921
			echo '
1922
				<tr class="windowbg">
1923
					<td>
1924
						', $txt['alert_' . $alert_id], isset($alert_details['help']) ? '<a href="' . $scripturl . '?action=helpadmin;help=' . $alert_details['help'] . '" onclick="return reqOverlayDiv(this.href);" class="help floatright"><span class="generic_icons help" title="' . $txt['help'] . '"></span></a>' : '', '
1925
					</td>';
1926
1927
			foreach ($context['alert_bits'] as $type => $bitmask)
1928
			{
1929
				echo '
1930
					<td class="centercol">';
1931
				$this_value = isset($context['alert_prefs'][$alert_id]) ? $context['alert_prefs'][$alert_id] : 0;
1932
				switch ($alert_details[$type])
1933
				{
1934
					case 'always':
1935
						echo '
1936
						<input type="checkbox" checked disabled>';
1937
						break;
1938
					case 'yes':
1939
						echo '
1940
						<input type="checkbox" name="', $type, '_', $alert_id, '"', ($this_value & $bitmask) ? ' checked' : '', '>';
1941
						break;
1942
					case 'never':
1943
						echo '
1944
						<input type="checkbox" disabled>';
1945
						break;
1946
				}
1947
				echo '
1948
					</td>';
1949
			}
1950
1951
			echo '
1952
				</tr>';
1953
		}
1954
	}
1955
1956
	echo '
1957
			</table>
1958
			<br>
1959
			<div>
1960
				<input id="notify_submit" type="submit" name="notify_submit" value="', $txt['notify_save'], '" class="button">
1961
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">', !empty($context['token_check']) ? '
1962
				<input type="hidden" name="' . $context[$context['token_check'] . '_token_var'] . '" value="' . $context[$context['token_check'] . '_token'] . '">' : '', '
1963
				<input type="hidden" name="u" value="', $context['id_member'], '">
1964
				<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
1965
			</div>
1966
		</form>
1967
		<br>';
1968
}
1969
1970
/**
1971
 * Template for showing which topics you're subscribed to
1972
 */
1973
function template_alert_notifications_topics()
1974
{
1975
	global $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
1976
1977
	// The main containing header.
1978
	echo '
1979
		<div class="cat_bar">
1980
			<h3 class="catbg">
1981
				', $txt['watched_topics'], '
1982
			</h3>
1983
		</div>
1984
		<p class="information">', $txt['watched_topics_desc'], '</p>
1985
		<br>';
1986
1987
	template_show_list('topic_notification_list');
1988
}
1989
1990
/**
1991
 * Template for showing which boards you're subscribed to
1992
 */
1993
function template_alert_notifications_boards()
1994
{
1995
	global $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
1996
1997
	echo '
1998
		<div class="cat_bar">
1999
			<h3 class="catbg">
2000
				', $txt['watched_boards'], '
2001
			</h3>
2002
		</div>
2003
		<p class="information">', $txt['watched_boards_desc'], '</p>
2004
		<br>';
2005
2006
	template_show_list('board_notification_list');
2007
}
2008
2009
/**
2010
 * Template for choosing group membership.
2011
 */
2012
function template_groupMembership()
2013
{
2014
	global $context, $scripturl, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
2015
2016
	// The main containing header.
2017
	echo '
2018
		<form action="', $scripturl, '?action=profile;area=groupmembership;save" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
2019
			<div class="cat_bar">
2020
				<h3 class="catbg profile_hd">
2021
					', $txt['profile'], '
2022
				</h3>
2023
			</div>
2024
			<p class="information">', $txt['groupMembership_info'], '</p>';
2025
2026
	// Do we have an update message?
2027
	if (!empty($context['update_message']))
2028
		echo '
2029
			<div class="infobox">
2030
				', $context['update_message'], '.
2031
			</div>';
2032
2033
	echo '
2034
			<div id="groups">';
2035
2036
	// Requesting membership to a group?
2037
	if (!empty($context['group_request']))
2038
	{
2039
		echo '
2040
			<div class="groupmembership">
2041
				<div class="cat_bar">
2042
					<h3 class="catbg">', $txt['request_group_membership'], '</h3>
2043
				</div>
2044
				<div class="roundframe">
2045
					', $txt['request_group_membership_desc'], ':
2046
					<textarea name="reason" rows="4"></textarea>
2047
					<div class="righttext">
2048
						<input type="hidden" name="gid" value="', $context['group_request']['id'], '">
2049
						<input type="submit" name="req" value="', $txt['submit_request'], '" class="button">
2050
						</div>
2051
					</div>
2052
				</div><!-- .groupmembership -->';
2053
	}
2054
	else
2055
	{
2056
		echo '
2057
				<div class="title_bar">
2058
					<h3 class="titlebg">', $txt['current_membergroups'], '</h3>
2059
				</div>';
2060
2061
		foreach ($context['groups']['member'] as $group)
2062
		{
2063
			echo '
2064
				<div class="windowbg" id="primdiv_', $group['id'], '">';
2065
2066
				if ($context['can_edit_primary'])
2067
					echo '
2068
					<input type="radio" name="primary" id="primary_', $group['id'], '" value="', $group['id'], '"', $group['is_primary'] ? ' checked' : '', ' onclick="highlightSelected(\'primdiv_' . $group['id'] . '\');"', $group['can_be_primary'] ? '' : ' disabled', '>';
2069
2070
				echo '
2071
					<label for="primary_', $group['id'], '"><strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '</label>';
2072
2073
				// Can they leave their group?
2074
				if ($group['can_leave'])
2075
					echo '
2076
					<a href="' . $scripturl . '?action=profile;save;u=' . $context['id_member'] . ';area=groupmembership;' . $context['session_var'] . '=' . $context['session_id'] . ';gid=' . $group['id'] . ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '">' . $txt['leave_group'] . '</a>';
2077
2078
				echo '
2079
				</div><!-- .windowbg -->';
2080
		}
2081
2082
		if ($context['can_edit_primary'])
2083
			echo '
2084
				<div class="padding righttext">
2085
					<input type="submit" value="', $txt['make_primary'], '" class="button">
2086
				</div>';
2087
2088
		// Any groups they can join?
2089
		if (!empty($context['groups']['available']))
2090
		{
2091
			echo '
2092
				<div class="title_bar">
2093
					<h3 class="titlebg">', $txt['available_groups'], '</h3>
2094
				</div>';
2095
2096
			foreach ($context['groups']['available'] as $group)
2097
			{
2098
				echo '
2099
				<div class="windowbg">
2100
					<strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '';
2101
2102
				if ($group['type'] == 3)
2103
					echo '
2104
					<a href="', $scripturl, '?action=profile;save;u=', $context['id_member'], ';area=groupmembership;', $context['session_var'], '=', $context['session_id'], ';gid=', $group['id'], ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '" class="button floatright">', $txt['join_group'], '</a>';
2105
				elseif ($group['type'] == 2 && $group['pending'])
2106
					echo '
2107
					<span class="floatright">', $txt['approval_pending'], '</span>';
2108
				elseif ($group['type'] == 2)
2109
					echo '
2110
					<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>';
2111
2112
				echo '
2113
				</div><!-- .windowbg -->';
2114
			}
2115
		}
2116
2117
		// Javascript for the selector stuff.
2118
		echo '
2119
				<script>
2120
					var prevClass = "";
2121
					var prevDiv = "";
2122
					function highlightSelected(box)
2123
					{
2124
						if (prevClass != "")
2125
						{
2126
							prevDiv.className = prevClass;
2127
						}
2128
						prevDiv = document.getElementById(box);
2129
						prevClass = prevDiv.className;
2130
2131
						prevDiv.className = "windowbg";
2132
					}';
2133
		if (isset($context['groups']['member'][$context['primary_group']]))
2134
			echo '
2135
					highlightSelected("primdiv_' . $context['primary_group'] . '");';
2136
		echo '
2137
				</script>';
2138
	}
2139
2140
	echo '
2141
			</div><!-- #groups -->';
2142
2143 View Code Duplication
	if (!empty($context['token_check']))
2144
		echo '
2145
			<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2146
2147
	echo '
2148
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2149
			<input type="hidden" name="u" value="', $context['id_member'], '">
2150
		</form>';
2151
}
2152
2153
/**
2154
 * Template for managing ignored boards
2155
 */
2156
function template_ignoreboards()
2157
{
2158
	global $context, $txt, $scripturl;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
2159
2160
	// The main containing header.
2161
	echo '
2162
	<form action="', $scripturl, '?action=profile;area=ignoreboards;save" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
2163
		<div class="cat_bar">
2164
			<h3 class="catbg profile_hd">
2165
				', $txt['profile'], '
2166
			</h3>
2167
		</div>
2168
		<p class="information">', $txt['ignoreboards_info'], '</p>
2169
		<div class="windowbg2">
2170
			<div class="flow_hidden">
2171
				<ul class="ignoreboards floatleft">';
2172
2173
	$i = 0;
2174
	$limit = ceil($context['num_boards'] / 2);
2175
	foreach ($context['categories'] as $category)
2176
	{
2177
		if ($i == $limit)
2178
		{
2179
			echo '
2180
				</ul>
2181
				<ul class="ignoreboards floatright">';
2182
2183
			$i++;
2184
		}
2185
2186
		echo '
2187
					<li class="category">
2188
						<a href="javascript:void(0);" onclick="selectBoards([', implode(', ', $category['child_ids']), '], \'creator\'); return false;">', $category['name'], '</a>
2189
						<ul>';
2190
2191 View Code Duplication
		foreach ($category['boards'] as $board)
2192
		{
2193
			if ($i == $limit)
2194
				echo '
2195
						</ul>
2196
					</li>
2197
				</ul>
2198
				<ul class="ignoreboards floatright">
2199
					<li class="category">
2200
						<ul>';
2201
2202
			echo '
2203
							<li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">
2204
								<label for="ignore_brd', $board['id'], '"><input type="checkbox" id="brd', $board['id'], '" name="ignore_brd[', $board['id'], ']" value="', $board['id'], '"', $board['selected'] ? ' checked' : '', '> ', $board['name'], '</label>
2205
							</li>';
2206
2207
			$i++;
2208
		}
2209
2210
		echo '
2211
						</ul>
2212
					</li>';
2213
	}
2214
2215
	echo '
2216
				</ul>';
2217
2218
	// Show the standard "Save Settings" profile button.
2219
	template_profile_save();
2220
2221
	echo '
2222
			</div><!-- .flow_hidden -->
2223
		</div><!-- .windowbg2 -->
2224
	</form>
2225
	<br>';
2226
}
2227
2228
/**
2229
 * Simply loads some theme variables common to several warning templates.
2230
 */
2231
function template_load_warning_variables()
2232
{
2233
	global $modSettings, $context;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
2234
2235
	$context['warningBarWidth'] = 200;
2236
	// Setup the colors - this is a little messy for theming.
2237
	$context['colors'] = array(
2238
		0 => 'green',
2239
		$modSettings['warning_watch'] => 'darkgreen',
2240
		$modSettings['warning_moderate'] => 'orange',
2241
		$modSettings['warning_mute'] => 'red',
2242
	);
2243
2244
	// Work out the starting color.
2245
	$context['current_color'] = $context['colors'][0];
2246
	foreach ($context['colors'] as $limit => $color)
2247
		if ($context['member']['warning'] >= $limit)
2248
			$context['current_color'] = $color;
2249
}
2250
2251
// Show all warnings of a user?
2252
function template_viewWarning()
2253
{
2254
	global $context, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
2255
2256
	template_load_warning_variables();
2257
2258
	echo '
2259
		<div class="cat_bar">
2260
			<h3 class="catbg profile_hd">
2261
				', sprintf($txt['profile_viewwarning_for_user'], $context['member']['name']), '
2262
			</h3>
2263
		</div>
2264
		<p class="information">', $txt['viewWarning_help'], '</p>
2265
		<div class="windowbg">
2266
			<dl class="settings">
2267
				<dt>
2268
					<strong>', $txt['profile_warning_name'], ':</strong>
2269
				</dt>
2270
				<dd>
2271
					', $context['member']['name'], '
2272
				</dd>
2273
				<dt>
2274
					<strong>', $txt['profile_warning_level'], ':</strong>
2275
				</dt>
2276
				<dd>
2277
					<div>
2278
						<div>
2279
							<div style="font-size: 8pt; height: 12pt; width: ', $context['warningBarWidth'], 'px; border: 1px solid black; background-color: white; padding: 1px; position: relative;">
2280
								<div id="warning_text" style="padding-top: 1pt; width: 100%; z-index: 2; color: black; position: absolute; text-align: center; font-weight: bold;">', $context['member']['warning'], '%</div>
2281
								<div id="warning_progress" style="width: ', $context['member']['warning'], '%; height: 12pt; z-index: 1; background-color: ', $context['current_color'], ';">&nbsp;</div>
2282
							</div>
2283
						</div>
2284
					</div>
2285
				</dd>';
2286
2287
	// There's some impact of this?
2288
	if (!empty($context['level_effects'][$context['current_level']]))
2289
		echo '
2290
				<dt>
2291
					<strong>', $txt['profile_viewwarning_impact'], ':</strong>
2292
				</dt>
2293
				<dd>
2294
					', $context['level_effects'][$context['current_level']], '
2295
				</dd>';
2296
2297
	echo '
2298
			</dl>
2299
		</div><!-- .windowbg -->';
2300
2301
	template_show_list('view_warnings');
2302
}
2303
2304
// Show a lovely interface for issuing warnings.
2305
function template_issueWarning()
2306
{
2307
	global $context, $scripturl, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
2308
2309
	template_load_warning_variables();
2310
2311
	echo '
2312
	<script>
2313
		// Disable notification boxes as required.
2314
		function modifyWarnNotify()
2315
		{
2316
			disable = !document.getElementById(\'warn_notify\').checked;
2317
			document.getElementById(\'warn_sub\').disabled = disable;
2318
			document.getElementById(\'warn_body\').disabled = disable;
2319
			document.getElementById(\'warn_temp\').disabled = disable;
2320
			document.getElementById(\'new_template_link\').style.display = disable ? \'none\' : \'\';
2321
			document.getElementById(\'preview_button\').style.display = disable ? \'none\' : \'\';
2322
		}
2323
2324
		// Warn template.
2325
		function populateNotifyTemplate()
2326
		{
2327
			index = document.getElementById(\'warn_temp\').value;
2328
			if (index == -1)
2329
				return false;
2330
2331
			// Otherwise see what we can do...';
2332
2333
	foreach ($context['notification_templates'] as $k => $type)
2334
		echo '
2335
			if (index == ', $k, ')
2336
				document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";';
2337
2338
	echo '
2339
		}
2340
2341
		function updateSlider(slideAmount)
2342
		{
2343
			// Also set the right effect.
2344
			effectText = "";';
2345
2346
	foreach ($context['level_effects'] as $limit => $text)
2347
		echo '
2348
			if (slideAmount >= ', $limit, ')
2349
				effectText = "', $text, '";';
2350
2351
	echo '
2352
			setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\');
2353
		}
2354
	</script>';
2355
2356
	echo '
2357
	<form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=issuewarning" method="post" class="flow_hidden" accept-charset="', $context['character_set'], '">
2358
		<div class="cat_bar">
2359
			<h3 class="catbg profile_hd">
2360
				', $context['user']['is_owner'] ? $txt['profile_warning_level'] : $txt['profile_issue_warning'], '
2361
			</h3>
2362
		</div>';
2363
2364
	if (!$context['user']['is_owner'])
2365
		echo '
2366
		<p class="information">', $txt['profile_warning_desc'], '</p>';
2367
2368
	echo '
2369
		<div class="windowbg">
2370
			<dl class="settings">';
2371
2372
	if (!$context['user']['is_owner'])
2373
		echo '
2374
				<dt>
2375
					<strong>', $txt['profile_warning_name'], ':</strong>
2376
				</dt>
2377
				<dd>
2378
					<strong>', $context['member']['name'], '</strong>
2379
				</dd>';
2380
2381
	echo '
2382
				<dt>
2383
					<strong>', $txt['profile_warning_level'], ':</strong>';
2384
2385
	// Is there only so much they can apply?
2386
	if ($context['warning_limit'])
2387
		echo '
2388
					<br>
2389
					<span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>';
2390
2391
	echo '
2392
				</dt>
2393
				<dd>
2394
					0% <input name="warning_level" id="warning_level" type="range" min="0" max="100" step="5" value="', $context['member']['warning'], '" onchange="updateSlider(this.value)" /> 100%
2395
					<div class="clear_left">
2396
						', $txt['profile_warning_impact'], ': <span id="cur_level_div">', $context['member']['warning'], '% (', $context['level_effects'][$context['current_level']], ')</span>
2397
					</div>
2398
				</dd>';
2399
2400
	if (!$context['user']['is_owner'])
2401
	{
2402
		echo '
2403
				<dt>
2404
					<strong>', $txt['profile_warning_reason'], ':</strong><br>
2405
					<span class="smalltext">', $txt['profile_warning_reason_desc'], '</span>
2406
				</dt>
2407
				<dd>
2408
					<input type="text" name="warn_reason" id="warn_reason" value="', $context['warning_data']['reason'], '" size="50" style="width: 80%;">
2409
				</dd>
2410
			</dl>
2411
			<hr>
2412
			<div id="box_preview"', !empty($context['warning_data']['body_preview']) ? '' : ' style="display:none"', '>
2413
				<dl class="settings">
2414
					<dt>
2415
						<strong>', $txt['preview'], '</strong>
2416
					</dt>
2417
					<dd id="body_preview">
2418
						', !empty($context['warning_data']['body_preview']) ? $context['warning_data']['body_preview'] : '', '
2419
					</dd>
2420
				</dl>
2421
				<hr>
2422
			</div>
2423
			<dl class="settings">
2424
				<dt>
2425
					<strong><label for="warn_notify">', $txt['profile_warning_notify'], ':</label></strong>
2426
				</dt>
2427
				<dd>
2428
					<input type="checkbox" name="warn_notify" id="warn_notify" onclick="modifyWarnNotify();"', $context['warning_data']['notify'] ? ' checked' : '', '>
2429
				</dd>
2430
				<dt>
2431
					<strong><label for="warn_sub">', $txt['profile_warning_notify_subject'], ':</label></strong>
2432
				</dt>
2433
				<dd>
2434
					<input type="text" name="warn_sub" id="warn_sub" value="', empty($context['warning_data']['notify_subject']) ? $txt['profile_warning_notify_template_subject'] : $context['warning_data']['notify_subject'], '" size="50" style="width: 80%;">
2435
				</dd>
2436
				<dt>
2437
					<strong><label for="warn_temp">', $txt['profile_warning_notify_body'], ':</label></strong>
2438
				</dt>
2439
				<dd>
2440
					<select name="warn_temp" id="warn_temp" disabled onchange="populateNotifyTemplate();" style="font-size: x-small;">
2441
						<option value="-1">', $txt['profile_warning_notify_template'], '</option>
2442
						<option value="-1" disabled>------------------------------</option>';
2443
2444
		foreach ($context['notification_templates'] as $id_template => $template)
2445
			echo '
2446
						<option value="', $id_template, '">', $template['title'], '</option>';
2447
2448
		echo '
2449
					</select>
2450
					<span class="smalltext" id="new_template_link" style="display: none;">[<a href="', $scripturl, '?action=moderate;area=warnings;sa=templateedit;tid=0" target="_blank">', $txt['profile_warning_new_template'], '</a>]</span>
2451
					<br>
2452
					<textarea name="warn_body" id="warn_body" cols="40" rows="8">', $context['warning_data']['notify_body'], '</textarea>
2453
				</dd>';
2454
	}
2455
	echo '
2456
			</dl>
2457
			<div class="righttext">';
2458
2459 View Code Duplication
	if (!empty($context['token_check']))
2460
		echo '
2461
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2462
2463
	echo '
2464
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2465
				<input type="button" name="preview" id="preview_button" value="', $txt['preview'], '" class="button">
2466
				<input type="submit" name="save" value="', $context['user']['is_owner'] ? $txt['change_profile'] : $txt['profile_warning_issue'], '" class="button">
2467
			</div><!-- .righttext -->
2468
		</div><!-- .windowbg -->
2469
	</form>';
2470
2471
	// Previous warnings?
2472
	template_show_list('view_warnings');
2473
2474
	echo '
2475
	<script>';
2476
2477
	if (!$context['user']['is_owner'])
2478
		echo '
2479
		modifyWarnNotify();
2480
		$(document).ready(function() {
2481
			$("#preview_button").click(function() {
2482
				return ajax_getTemplatePreview();
2483
			});
2484
		});
2485
2486
		function ajax_getTemplatePreview ()
2487
		{
2488
			$.ajax({
2489
				type: "POST",
2490
				url: "' . $scripturl . '?action=xmlhttp;sa=previews;xml",
2491
				data: {item: "warning_preview", title: $("#warn_sub").val(), body: $("#warn_body").val(), issuing: true},
2492
				context: document.body,
2493
				success: function(request){
2494
					$("#box_preview").css({display:""});
2495
					$("#body_preview").html($(request).find(\'body\').text());
2496
					if ($(request).find("error").text() != \'\')
2497
					{
2498
						$("#profile_error").css({display:""});
2499
						var errors_html = \'<ul class="list_errors">\';
2500
						var errors = $(request).find(\'error\').each(function() {
2501
							errors_html += \'<li>\' + $(this).text() + \'</li>\';
2502
						});
2503
						errors_html += \'</ul>\';
2504
2505
						$("#profile_error").html(errors_html);
2506
					}
2507
					else
2508
					{
2509
						$("#profile_error").css({display:"none"});
2510
						$("#error_list").html(\'\');
2511
					}
2512
				return false;
2513
				},
2514
			});
2515
			return false;
2516
		}';
2517
2518
	echo '
2519
	</script>';
2520
}
2521
2522
/**
2523
 * Template to show for deleting a user's account - now with added delete post capability!
2524
 */
2525
function template_deleteAccount()
2526
{
2527
	global $context, $scripturl, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
2528
2529
	// The main containing header.
2530
	echo '
2531
		<form action="', $scripturl, '?action=profile;area=deleteaccount;save" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
2532
			<div class="cat_bar">
2533
				<h3 class="catbg profile_hd">
2534
					', $txt['deleteAccount'], '
2535
				</h3>
2536
			</div>';
2537
2538
	// If deleting another account give them a lovely info box.
2539
	if (!$context['user']['is_owner'])
2540
		echo '
2541
			<p class="information">', $txt['deleteAccount_desc'], '</p>';
2542
	echo '
2543
			<div class="windowbg2">';
2544
2545
	// If they are deleting their account AND the admin needs to approve it - give them another piece of info ;)
2546
	if ($context['needs_approval'])
2547
		echo '
2548
				<div class="errorbox">', $txt['deleteAccount_approval'], '</div>';
2549
2550
	// If the user is deleting their own account warn them first - and require a password!
2551
	if ($context['user']['is_owner'])
2552
	{
2553
		echo '
2554
				<div class="alert">', $txt['own_profile_confirm'], '</div>
2555
				<div>
2556
					<strong', (isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : ''), '>', $txt['current_password'], ': </strong>
2557
					<input type="password" name="oldpasswrd" size="20">&nbsp;&nbsp;&nbsp;&nbsp;
2558
					<input type="submit" value="', $txt['yes'], '" class="button">';
2559
2560 View Code Duplication
		if (!empty($context['token_check']))
2561
			echo '
2562
					<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2563
2564
		echo '
2565
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2566
					<input type="hidden" name="u" value="', $context['id_member'], '">
2567
					<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
2568
				</div>';
2569
	}
2570
	// Otherwise an admin doesn't need to enter a password - but they still get a warning - plus the option to delete lovely posts!
2571
	else
2572
	{
2573
		echo '
2574
				<div class="alert">', $txt['deleteAccount_warning'], '</div>';
2575
2576
		// Only actually give these options if they are kind of important.
2577
		if ($context['can_delete_posts'])
2578
		{
2579
			echo '
2580
				<div>
2581
					<label for="deleteVotes">
2582
						<input type="checkbox" name="deleteVotes" id="deleteVotes" value="1"> ', $txt['deleteAccount_votes'], ':
2583
					</label><br>
2584
					<label for="deletePosts">
2585
						<input type="checkbox" name="deletePosts" id="deletePosts" value="1"> ', $txt['deleteAccount_posts'], ':
2586
					</label>
2587
					<select name="remove_type">
2588
						<option value="posts">', $txt['deleteAccount_all_posts'], '</option>
2589
						<option value="topics">', $txt['deleteAccount_topics'], '</option>
2590
					</select>';
2591
2592
			if ($context['show_perma_delete'])
2593
				echo '
2594
					<br>
2595
					<label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1">', $txt['deleteAccount_permanent'], ':</label>';
2596
2597
			echo '
2598
				</div>';
2599
		}
2600
2601
		echo '
2602
				<div>
2603
					<label for="deleteAccount"><input type="checkbox" name="deleteAccount" id="deleteAccount" value="1" onclick="if (this.checked) return confirm(\'', $txt['deleteAccount_confirm'], '\');"> ', $txt['deleteAccount_member'], '.</label>
2604
				</div>
2605
				<div>
2606
					<input type="submit" value="', $txt['delete'], '" class="button">';
2607
2608 View Code Duplication
		if (!empty($context['token_check']))
2609
			echo '
2610
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2611
2612
		echo '
2613
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2614
					<input type="hidden" name="u" value="', $context['id_member'], '">
2615
					<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
2616
				</div>';
2617
	}
2618
	echo '
2619
			</div><!-- .windowbg2 -->
2620
			<br>
2621
		</form>';
2622
}
2623
2624
/**
2625
 * Template for the password box/save button stuck at the bottom of every profile page.
2626
 */
2627
function template_profile_save()
2628
{
2629
	global $context, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
2630
2631
	echo '
2632
2633
					<hr>';
2634
2635
	// Only show the password box if it's actually needed.
2636 View Code Duplication
	if ($context['require_password'])
2637
		echo '
2638
					<dl class="settings">
2639
						<dt>
2640
							<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br>
2641
							<span class="smalltext">', $txt['required_security_reasons'], '</span>
2642
						</dt>
2643
						<dd>
2644
							<input type="password" name="oldpasswrd" size="20">
2645
						</dd>
2646
					</dl>';
2647
2648
	echo '
2649
					<div class="righttext">';
2650
2651 View Code Duplication
	if (!empty($context['token_check']))
2652
		echo '
2653
						<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2654
2655
	echo '
2656
						<input type="submit" value="', $txt['change_profile'], '" class="button">
2657
						<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2658
						<input type="hidden" name="u" value="', $context['id_member'], '">
2659
						<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
2660
					</div>';
2661
}
2662
2663
/**
2664
 * Small template for showing an error message upon a save problem in the profile.
2665
 */
2666
function template_error_message()
0 ignored issues
show
Best Practice introduced by
The function template_error_message() has been defined more than once; this definition is ignored, only the first definition in other/upgrade.php (L3545-3555) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
2667
{
2668
	global $context, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
2669
2670
	echo '
2671
		<div class="errorbox" ', empty($context['post_errors']) ? 'style="display:none" ' : '', 'id="profile_error">';
2672
2673
	if (!empty($context['post_errors']))
2674
	{
2675
		echo '
2676
			<span>', !empty($context['custom_error_title']) ? $context['custom_error_title'] : $txt['profile_errors_occurred'], ':</span>
2677
			<ul id="list_errors">';
2678
2679
		// Cycle through each error and display an error message.
2680
		foreach ($context['post_errors'] as $error)
2681
			echo '
2682
				<li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>';
2683
2684
		echo '
2685
			</ul>';
2686
	}
2687
2688
	echo '
2689
		</div><!-- #profile_error -->';
2690
}
2691
2692
/**
2693
 * Display a load of drop down selectors for allowing the user to change group.
2694
 */
2695
function template_profile_group_manage()
2696
{
2697
	global $context, $txt, $scripturl;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
2698
2699
	echo '
2700
							<dt>
2701
								<strong>', $txt['primary_membergroup'], ': </strong><br>
2702
								<span class="smalltext"><a href="', $scripturl, '?action=helpadmin;help=moderator_why_missing" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help"></span> ', $txt['moderator_why_missing'], '</a></span>
2703
							</dt>
2704
							<dd>
2705
								<select name="id_group" ', ($context['user']['is_owner'] && $context['member']['group_id'] == 1 ? 'onchange="if (this.value != 1 &amp;&amp; !confirm(\'' . $txt['deadmin_confirm'] . '\')) this.value = 1;"' : ''), '>';
2706
2707
	// Fill the select box with all primary member groups that can be assigned to a member.
2708
	foreach ($context['member_groups'] as $member_group)
2709
		if (!empty($member_group['can_be_primary']))
2710
			echo '
2711
									<option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '>
2712
										', $member_group['name'], '
2713
									</option>';
2714
	echo '
2715
								</select>
2716
							</dd>
2717
							<dt>
2718
								<strong>', $txt['additional_membergroups'], ':</strong>
2719
							</dt>
2720
							<dd>
2721
								<span id="additional_groupsList">
2722
									<input type="hidden" name="additional_groups[]" value="0">';
2723
2724
	// For each membergroup show a checkbox so members can be assigned to more than one group.
2725
	foreach ($context['member_groups'] as $member_group)
2726
		if ($member_group['can_be_additional'])
2727
			echo '
2728
									<label for="additional_groups-', $member_group['id'], '"><input type="checkbox" name="additional_groups[]" value="', $member_group['id'], '" id="additional_groups-', $member_group['id'], '"', $member_group['is_additional'] ? ' checked' : '', '> ', $member_group['name'], '</label><br>';
2729
	echo '
2730
								</span>
2731
								<a href="javascript:void(0);" onclick="document.getElementById(\'additional_groupsList\').style.display = \'block\'; document.getElementById(\'additional_groupsLink\').style.display = \'none\'; return false;" id="additional_groupsLink" style="display: none;" class="toggle_down">', $txt['additional_membergroups_show'], '</a>
2732
								<script>
2733
									document.getElementById("additional_groupsList").style.display = "none";
2734
									document.getElementById("additional_groupsLink").style.display = "";
2735
								</script>
2736
							</dd>';
2737
2738
}
2739
2740
/**
2741
 * Callback function for entering a birthdate!
2742
 */
2743
function template_profile_birthdate()
2744
{
2745
	global $txt, $context;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
2746
2747
	// Just show the pretty box!
2748
	echo '
2749
							<dt>
2750
								<strong>', $txt['dob'], ':</strong><br>
2751
								<span class="smalltext">', $txt['dob_year'], ' - ', $txt['dob_month'], ' - ', $txt['dob_day'], '</span>
2752
							</dt>
2753
							<dd>
2754
								<input type="text" name="bday3" size="4" maxlength="4" value="', $context['member']['birth_date']['year'], '"> -
2755
								<input type="text" name="bday1" size="2" maxlength="2" value="', $context['member']['birth_date']['month'], '"> -
2756
								<input type="text" name="bday2" size="2" maxlength="2" value="', $context['member']['birth_date']['day'], '">
2757
							</dd>';
2758
}
2759
2760
/**
2761
 * Show the signature editing box?
2762
 */
2763
function template_profile_signature_modify()
2764
{
2765
	global $txt, $context;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
2766
2767
	echo '
2768
							<dt id="current_signature" style="display:none">
2769
								<strong>', $txt['current_signature'], ':</strong>
2770
							</dt>
2771
							<dd id="current_signature_display" style="display:none">
2772
								<hr>
2773
							</dd>';
2774
	echo '
2775
							<dt id="preview_signature" style="display:none">
2776
								<strong>', $txt['signature_preview'], ':</strong>
2777
							</dt>
2778
							<dd id="preview_signature_display" style="display:none">
2779
								<hr>
2780
							</dd>';
2781
2782
	echo '
2783
							<dt>
2784
								<strong>', $txt['signature'], ':</strong><br>
2785
								<span class="smalltext">', $txt['sig_info'], '</span><br>
2786
								<br>';
2787
2788
	if ($context['show_spellchecking'])
2789
		echo '
2790
								<input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button">';
2791
2792
		echo '
2793
							</dt>
2794
							<dd>
2795
								<textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50">', $context['member']['signature'], '</textarea><br>';
2796
2797
	// If there is a limit at all!
2798
	if (!empty($context['signature_limits']['max_length']))
2799
		echo '
2800
								<span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>';
2801
2802
	if (!empty($context['show_preview_button']))
2803
		echo '
2804
								<input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button">';
2805
2806
	if ($context['signature_warning'])
2807
		echo '
2808
								<span class="smalltext">', $context['signature_warning'], '</span>';
2809
2810
	// Some javascript used to count how many characters have been used so far in the signature.
2811
	echo '
2812
								<script>
2813
									var maxLength = ', $context['signature_limits']['max_length'], ';
2814
2815
									$(document).ready(function() {
2816
										calcCharLeft();
2817
										$("#preview_button").click(function() {
2818
											return ajax_getSignaturePreview(true);
2819
										});
2820
									});
2821
								</script>
2822
							</dd>';
2823
}
2824
2825
/**
2826
 * Template for selecting an avatar
2827
 */
2828
function template_profile_avatar_select()
2829
{
2830
	global $context, $txt, $modSettings;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
2831
2832
	// Start with the upper menu
2833
	echo '
2834
							<dt>
2835
								<strong id="personal_picture"><label for="avatar_upload_box">', $txt['personal_picture'], '</label></strong>
2836
								', empty($modSettings['gravatarOverride']) ? '<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_none" value="none"' . ($context['member']['avatar']['choice'] == 'none' ? ' checked="checked"' : '') . ' /><label for="avatar_choice_none"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>' . $txt['no_avatar'] . '</label><br>' : '', '
2837
								', !empty($context['member']['avatar']['allow_server_stored']) ? '<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_server_stored" value="server_stored"' . ($context['member']['avatar']['choice'] == 'server_stored' ? ' checked="checked"' : '') . ' /><label for="avatar_choice_server_stored"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>' . $txt['choose_avatar_gallery'] . '</label><br>' : '', '
2838
								', !empty($context['member']['avatar']['allow_external']) ? '<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_external" value="external"' . ($context['member']['avatar']['choice'] == 'external' ? ' checked="checked"' : '') . ' /><label for="avatar_choice_external"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>' . $txt['my_own_pic'] . '</label><br>' : '', '
2839
								', !empty($context['member']['avatar']['allow_upload']) ? '<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_upload" value="upload"' . ($context['member']['avatar']['choice'] == 'upload' ? ' checked="checked"' : '') . ' /><label for="avatar_choice_upload"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>' . $txt['avatar_will_upload'] . '</label><br>' : '', '
2840
								', !empty($context['member']['avatar']['allow_gravatar']) ? '<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_gravatar" value="gravatar"' . ($context['member']['avatar']['choice'] == 'gravatar' ? ' checked="checked"' : '') . ' /><label for="avatar_choice_gravatar"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>' . $txt['use_gravatar'] . '</label>' : '', '
2841
							</dt>
2842
							<dd>';
2843
2844
	// If users are allowed to choose avatars stored on the server show selection boxes to choice them from.
2845
	if (!empty($context['member']['avatar']['allow_server_stored']))
2846
	{
2847
		echo '
2848
								<div id="avatar_server_stored">
2849
									<div>
2850
										<select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">';
2851
2852
		// This lists all the file categories.
2853
		foreach ($context['avatars'] as $avatar)
2854
			echo '
2855
											<option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>';
2856
		echo '
2857
										</select>
2858
									</div>
2859
									<div>
2860
										<select name="file" id="file" size="10" style="display: none;" onchange="showAvatar()" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');" disabled><option></option></select>
2861
									</div>
2862
									<div>
2863
										<img id="avatar" src="', !empty($context['member']['avatar']['allow_external']) && $context['member']['avatar']['choice'] == 'external' ? $context['member']['avatar']['external'] : $modSettings['avatar_url'] . '/blank.png', '" alt="Do Nothing">
2864
									</div>
2865
									<script>
2866
										var files = ["' . implode('", "', $context['avatar_list']) . '"];
2867
										var avatar = document.getElementById("avatar");
2868
										var cat = document.getElementById("cat");
2869
										var selavatar = "' . $context['avatar_selected'] . '";
2870
										var avatardir = "' . $modSettings['avatar_url'] . '/";
2871
										var size = avatar.alt.substr(3, 2) + " " + avatar.alt.substr(0, 2) + String.fromCharCode(117, 98, 116);
2872
										var file = document.getElementById("file");
2873
										var maxHeight = ', !empty($modSettings['avatar_max_height_external']) ? $modSettings['avatar_max_height_external'] : 0, ';
2874
										var maxWidth = ', !empty($modSettings['avatar_max_width_external']) ? $modSettings['avatar_max_width_external'] : 0, ';
2875
2876
										if (avatar.src.indexOf("blank.png") > -1)
2877
											changeSel(selavatar);
2878
										else
2879
											previewExternalAvatar(avatar.src)
2880
2881
									</script>
2882
								</div><!-- #avatar_server_stored -->';
2883
	}
2884
2885
	// If the user can link to an off server avatar, show them a box to input the address.
2886
	if (!empty($context['member']['avatar']['allow_external']))
2887
	{
2888
		echo '
2889
								<div id="avatar_external">
2890
									<div class="smalltext">', $txt['avatar_by_url'], '</div>', !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_download_and_resize' ? template_max_size('external') : '', '
2891
									<input type="text" name="userpicpersonal" size="45" value="', ((stristr($context['member']['avatar']['external'], 'http://') || stristr($context['member']['avatar']['external'], 'https://')) ? $context['member']['avatar']['external'] : 'http://'), '" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'external\');" onchange="if (typeof(previewExternalAvatar) != \'undefined\') previewExternalAvatar(this.value);" />
2892
								</div>';
2893
	}
2894
2895
	// If the user is able to upload avatars to the server show them an upload box.
2896
	if (!empty($context['member']['avatar']['allow_upload']))
2897
	{
2898
		echo '
2899
								<div id="avatar_upload">
2900
									<input type="file" size="44" name="attachment" id="avatar_upload_box" value="" onchange="readfromUpload(this)"  onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'upload\');" accept="image/gif, image/jpeg, image/jpg, image/png">', template_max_size('upload'), '
2901
									', (!empty($context['member']['avatar']['id_attach']) ? '<br><img src="' . $context['member']['avatar']['href'] . (strpos($context['member']['avatar']['href'], '?') === false ? '?' : '&amp;') . 'time=' . time() . '" alt="" id="attached_image"><input type="hidden" name="id_attach" value="' . $context['member']['avatar']['id_attach'] . '">' : ''), '
2902
								</div>';
2903
	}
2904
2905
	// if the user is able to use Gravatar avatars show then the image preview
2906
	if (!empty($context['member']['avatar']['allow_gravatar']))
2907
	{
2908
		echo '
2909
								<div id="avatar_gravatar">
2910
									<img src="' . $context['member']['avatar']['href'] . '" alt="" />';
2911
2912
		if (empty($modSettings['gravatarAllowExtraEmail']))
2913
			echo '
2914
									<div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>';
2915
		else
2916
		{
2917
			// Depending on other stuff, the stored value here might have some odd things in it from other areas.
2918
			if ($context['member']['avatar']['external'] == $context['member']['email'])
2919
				$textbox_value = '';
2920
			else
2921
				$textbox_value = $context['member']['avatar']['external'];
2922
2923
			echo '
2924
									<div class="smalltext">', $txt['gravatar_alternateEmail'], '</div>
2925
									<input type="text" name="gravatarEmail" id="gravatarEmail" size="45" value="', $textbox_value, '" />';
2926
		}
2927
		echo '
2928
								</div><!-- #avatar_gravatar -->';
2929
	}
2930
2931
	echo '
2932
								<script>
2933
									', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "' . ($context['member']['avatar']['choice'] == 'server_stored' ? '' : 'none') . '";' : '', '
2934
									', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "' . ($context['member']['avatar']['choice'] == 'external' ? '' : 'none') . '";' : '', '
2935
									', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "' . ($context['member']['avatar']['choice'] == 'upload' ? '' : 'none') . '";' : '', '
2936
									', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "' . ($context['member']['avatar']['choice'] == 'gravatar' ? '' : 'none') . '";' : '', '
2937
2938
									function swap_avatar(type)
2939
									{
2940
										switch(type.id)
2941
										{
2942
											case "avatar_choice_server_stored":
2943
												', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "";' : '', '
2944
												', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "none";' : '', '
2945
												', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "none";' : '', '
2946
												', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "none";' : '', '
2947
												break;
2948
											case "avatar_choice_external":
2949
												', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "none";' : '', '
2950
												', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "";' : '', '
2951
												', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "none";' : '', '
2952
												', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "none";' : '', '
2953
												break;
2954
											case "avatar_choice_upload":
2955
												', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "none";' : '', '
2956
												', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "none";' : '', '
2957
												', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "";' : '', '
2958
												', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "none";' : '', '
2959
												break;
2960
											case "avatar_choice_none":
2961
												', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "none";' : '', '
2962
												', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "none";' : '', '
2963
												', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "none";' : '', '
2964
												', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "none";' : '', '
2965
												break;
2966
											case "avatar_choice_gravatar":
2967
												', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "none";' : '', '
2968
												', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "none";' : '', '
2969
												', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "none";' : '', '
2970
												', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "";' : '', '
2971
												', ($context['member']['avatar']['external'] == $context['member']['email'] || strstr($context['member']['avatar']['external'], 'http://')) ?
2972
												'document.getElementById("gravatarEmail").value = "";' : '', '
2973
												break;
2974
										}
2975
									}
2976
								</script>
2977
							</dd>';
2978
}
2979
2980
/**
2981
 * This is just a really little helper to avoid duplicating code unnecessarily
2982
 *
2983
 * @param string $type The type of avatar
2984
 */
2985
function template_max_size($type)
2986
{
2987
	global $modSettings, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
2988
2989
	$w = !empty($modSettings['avatar_max_width_' . $type]) ? comma_format($modSettings['avatar_max_width_' . $type]) : 0;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $w. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
2990
	$h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $h. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
2991
2992
	$suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : '');
2993
	if (empty($suffix))
2994
		return;
2995
2996
	echo '
2997
								<div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>';
2998
}
2999
3000
/**
3001
 * Select the time format!
3002
 */
3003
function template_profile_timeformat_modify()
3004
{
3005
	global $context, $txt, $scripturl;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
3006
3007
	echo '
3008
							<dt>
3009
								<strong><label for="easyformat">', $txt['time_format'], ':</label></strong><br>
3010
								<a href="', $scripturl, '?action=helpadmin;help=time_format" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>
3011
								<span class="smalltext">
3012
									<label for="time_format">', $txt['date_format'], '</label>
3013
								</span>
3014
							</dt>
3015
							<dd>
3016
								<select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;">';
3017
3018
	// Help the user by showing a list of common time formats.
3019
	foreach ($context['easy_timeformats'] as $time_format)
3020
		echo '
3021
									<option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>';
3022
	echo '
3023
								</select><br>
3024
								<input type="text" name="time_format" id="time_format" value="', $context['member']['time_format'], '" size="30">
3025
							</dd>';
3026
}
3027
3028
/**
3029
 * Template for picking a theme
3030
 */
3031
function template_profile_theme_pick()
3032
{
3033
	global $txt, $context, $scripturl;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
3034
3035
	echo '
3036
							<dt>
3037
								<strong>', $txt['current_theme'], ':</strong>
3038
							</dt>
3039
							<dd>
3040
								', $context['member']['theme']['name'], ' [<a href="', $scripturl, '?action=theme;sa=pick;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['change'], '</a>]
3041
							</dd>';
3042
}
3043
3044
/**
3045
 * Smiley set picker.
3046
 */
3047
function template_profile_smiley_pick()
3048
{
3049
	global $txt, $context, $modSettings, $settings;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
3050
3051
	echo '
3052
							<dt>
3053
								<strong><label for="smiley_set">', $txt['smileys_current'], ':</label></strong>
3054
							</dt>
3055
							<dd>
3056
								<select name="smiley_set" id="smiley_set" onchange="document.getElementById(\'smileypr\').src = this.selectedIndex == 0 ? \'', $settings['images_url'], '/blank.png\' : \'', $modSettings['smileys_url'], '/\' + (this.selectedIndex != 1 ? this.options[this.selectedIndex].value : \'', !empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'], '\') + \'/smiley.gif\';">';
3057
	
3058
	foreach ($context['smiley_sets'] as $set)
3059
		echo '
3060
									<option value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>';
3061
	echo '
3062
								</select>
3063
								<img id="smileypr" class="centericon" src="', $context['member']['smiley_set']['id'] != 'none' ? $modSettings['smileys_url'] . '/' . ($context['member']['smiley_set']['id'] != '' ? $context['member']['smiley_set']['id'] : (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'])) . '/smiley.gif' : $settings['images_url'] . '/blank.png', '" alt=":)">
3064
							</dd>';
3065
}
3066
3067
/**
3068
 * Template for setting up and managing Two-Factor Authentication.
3069
 */
3070
function template_tfasetup()
3071
{
3072
	global $txt, $context, $scripturl, $modSettings;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
3073
3074
	echo '
3075
			<div class="cat_bar">
3076
				<h3 class="catbg">', $txt['tfa_title'], '</h3>
3077
			</div>
3078
			<div class="roundframe">
3079
				<div>
3080
		', !empty($context['tfa_backup']) ? '
3081
					<div class="smalltext error">' . $txt['tfa_backup_used_desc'] . '</div>' :
3082
			($modSettings['tfa_mode'] == 2 ? '
3083
									<div class="smalltext"><strong>' . $txt['tfa_forced_desc'] . '</strong></div>' : ''), '
3084
									<div class="smalltext">', $txt['tfa_desc'], '</div>
3085
									<div class="floatleft">
3086
										<form action="', $scripturl, '?action=profile;area=tfasetup" method="post">
3087
											<div class="title_top">
3088
												<strong>', $txt['tfa_step1'], '</strong><br>
3089
												', !empty($context['tfa_pass_error']) ? '<div class="error smalltext">' . $txt['tfa_pass_invalid'] . '</div>' : '', '
3090
												<input type="password" name="passwd" size="25"', !empty($context['tfa_pass_error']) ? ' class="error"' : '', !empty($context['tfa_pass_value']) ? ' value="' . $context['tfa_pass_value'] . '"' : '', '>
3091
											</div>
3092
											<div class="title_top">
3093
												<strong>', $txt['tfa_step2'], '</strong>
3094
												<div class="smalltext">', $txt['tfa_step2_desc'], '</div>
3095
												<div class="tfacode">', $context['tfa_secret'], '</div>
3096
											</div>
3097
											<div class="title_top">
3098
												<strong>', $txt['tfa_step3'], '</strong><br>
3099
												', !empty($context['tfa_error']) ? '<div class="error smalltext">' . $txt['tfa_code_invalid'] . '</div>' : '', '
3100
												<input type="text" name="tfa_code" size="25"', !empty($context['tfa_error']) ? ' class="error"' : '', !empty($context['tfa_value']) ? ' value="' . $context['tfa_value'] . '"' : '', '>
3101
												<input type="submit" name="save" value="', $txt['tfa_enable'], '" class="button">
3102
											</div>
3103
											<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '" />
3104
											<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
3105
										</form>
3106
									</div>
3107
									<div class="floatright tfa_qrcode">
3108
										<img src="', $context['tfa_qr_url'], '" alt="">
3109
									</div>';
3110
3111
	if (!empty($context['from_ajax']))
3112
		echo '
3113
					<br>
3114
					<a href="javascript:self.close();"></a>';
3115
3116
	echo '
3117
				</div>
3118
			</div><!-- .roundframe -->';
3119
}
3120
3121
/**
3122
 * Template for setting up 2FA backup code
3123
 */
3124
function template_tfasetup_backup()
3125
{
3126
	global $context, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
3127
3128
	echo '
3129
			<div class="cat_bar">
3130
				<h3 class="catbg">', $txt['tfa_backup_title'], '</h3>
3131
			</div>
3132
			<div class="roundframe">
3133
				<div>
3134
					<div class="smalltext">', $txt['tfa_backup_desc'], '</div>
3135
					<div class="bbc_code" style="resize: none; border: none;">', $context['tfa_backup'], '</div>
3136
				</div>
3137
			</div>';
3138
}
3139
3140
/**
3141
 * Simple template for showing the 2FA area when editing a profile.
3142
 */
3143
function template_profile_tfa()
3144
{
3145
	global $context, $txt, $scripturl, $modSettings;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
3146
3147
	echo '
3148
							<dt>
3149
								<strong>', $txt['tfa_profile_label'], ':</strong><br>
3150
								<div class="smalltext">', $txt['tfa_profile_desc'], '</div>
3151
							</dt>
3152
							<dd>';
3153
	if (!$context['tfa_enabled'] && $context['user']['is_owner'])
3154
		echo '
3155
								<a href="', !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>';
3156
	elseif (!$context['tfa_enabled'])
3157
		echo '
3158
								', $txt['tfa_profile_disabled'];
3159
	else
3160
		echo '
3161
							', sprintf($txt['tfa_profile_enabled'], $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=tfasetup;disable');
3162
	echo '
3163
							</dd>';
3164
}
3165
3166
?>