Issues (1027)

Themes/default/Profile.template.php (4 issues)

1
<?php
2
/**
3
 * Simple Machines Forum (SMF)
4
 *
5
 * @package SMF
6
 * @author Simple Machines http://www.simplemachines.org
7
 * @copyright 2019 Simple Machines and individual contributors
8
 * @license http://www.simplemachines.org/about/smf/license.php BSD
9
 *
10
 * @version 2.1 RC2
11
 */
12
13
/**
14
 * 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;
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();
0 ignored issues
show
Are you sure the usage of template_error_message() is correct as it seems to always return null.

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

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

}

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

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

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

Loading history...
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;
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;
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
		template_alerts_all_read();
104
105
	else
106
	{
107
		foreach ($context['unread_alerts'] as $id_alert => $details)
108
		{
109
			echo '
110
			<', !$details['show_links'] ? 'a href="' . $scripturl . '?action=profile;area=showalerts;alert=' . $id_alert . '" onclick="this.classList.add(\'alert_read\')"' : 'div', ' class="unread_notify">
111
				<div class="unread_notify_image">
112
					', empty($details['sender']['avatar']['image']) ? '' : $details['sender']['avatar']['image'] . '
113
					', $details['icon'], '
114
				</div>
115
				<div class="details">
116
					<span class="alert_text">', $details['text'], '</span> - <span class="alert_time">', $details['time'], '</span>
117
				</div>
118
			</', !$details['show_links'] ? 'a' : 'div', '>';
119
		}
120
	}
121
122
	echo '
123
		</div><!-- .alerts_unread -->
124
		<script>
125
			function markAlertsRead(obj) {
126
				ajax_indicator(true);
127
				$.get(
128
					obj.href,
129
					function(data) {
130
						ajax_indicator(false);
131
						$("#alerts_menu_top span.amt").remove();
132
						$("#alerts_menu div.alerts_unread").html(data);
133
						if (typeof localStorage != "undefined")
134
							localStorage.setItem("alertsCounter", 0);
135
					}
136
				);
137
				return false;
138
			}
139
		</script>';
140
}
141
142
/**
143
 * A simple template to say "You don't have any unread alerts".
144
 */
145
function template_alerts_all_read()
146
{
147
	global $txt;
148
149
	echo '<div class="no_unread">', $txt['alerts_no_unread'], '</div>';
150
}
151
152
/**
153
 * This template displays a user's details without any option to edit them.
154
 */
155
function template_summary()
156
{
157
	global $context, $settings, $scripturl, $modSettings, $txt;
158
159
	// Display the basic information about the user
160
	echo '
161
	<div id="profileview" class="roundframe flow_auto">
162
		<div id="basicinfo">';
163
164
	// Are there any custom profile fields for above the name?
165
	if (!empty($context['print_custom_fields']['above_member']))
166
	{
167
		$fields = '';
168
		foreach ($context['print_custom_fields']['above_member'] as $field)
169
			if (!empty($field['output_html']))
170
				$fields .= '
171
					<li>' . $field['output_html'] . '</li>';
172
173
		if (!empty($fields))
174
			echo '
175
			<div class="custom_fields_above_name">
176
				<ul>', $fields, '
177
				</ul>
178
			</div>';
179
	}
180
181
	echo '
182
			<div class="username clear">
183
				<h4>';
184
185
	if (!empty($context['print_custom_fields']['before_member']))
186
		foreach ($context['print_custom_fields']['before_member'] as $field)
187
			if (!empty($field['output_html']))
188
				echo '
189
					<span>', $field['output_html'], '</span>';
190
191
	echo '
192
					', $context['member']['name'];
193
194
	if (!empty($context['print_custom_fields']['after_member']))
195
		foreach ($context['print_custom_fields']['after_member'] as $field)
196
			if (!empty($field['output_html']))
197
				echo '
198
					<span>', $field['output_html'], '</span>';
199
200
	echo '
201
					<span class="position">', (!empty($context['member']['group']) ? $context['member']['group'] : $context['member']['post_group']), '</span>
202
				</h4>
203
			</div>
204
			', $context['member']['avatar']['image'];
205
206
	// Are there any custom profile fields for below the avatar?
207
	if (!empty($context['print_custom_fields']['below_avatar']))
208
	{
209
		$fields = '';
210
		foreach ($context['print_custom_fields']['below_avatar'] as $field)
211
			if (!empty($field['output_html']))
212
				$fields .= '
213
					<li>' . $field['output_html'] . '</li>';
214
215
		if (!empty($fields))
216
			echo '
217
			<div class="custom_fields_below_avatar">
218
				<ul>', $fields, '
219
				</ul>
220
			</div>';
221
	}
222
223
	echo '
224
			<ul class="icon_fields clear">';
225
226
	// Email is only visible if it's your profile or you have the moderate_forum permission
227
	if ($context['member']['show_email'])
228
		echo '
229
				<li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="main_icons mail" title="' . $txt['email'] . '"></span></a></li>';
230
231
	// Don't show an icon if they haven't specified a website.
232
	if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website']))
233
		echo '
234
				<li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank" rel="noopener">', ($settings['use_image_buttons'] ? '<span class="main_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
235
236
	// Are there any custom profile fields as icons?
237
	if (!empty($context['print_custom_fields']['icons']))
238
	{
239
		foreach ($context['print_custom_fields']['icons'] as $field)
240
			if (!empty($field['output_html']))
241
				echo '
242
				<li class="custom_field">', $field['output_html'], '</li>';
243
	}
244
245
	echo '
246
			</ul>
247
			<span id="userstatus">
248
				', $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>' : '';
249
250
	// Can they add this member as a buddy?
251
	if (!empty($context['can_have_buddy']) && !$context['user']['is_owner'])
252
		echo '
253
				<br>
254
				<a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], '</a>';
255
256
	echo '
257
			</span>';
258
259
	if (!$context['user']['is_owner'] && $context['can_send_pm'])
260
		echo '
261
			<a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>';
262
263
	echo '
264
			<a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>';
265
266
	if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled']))
267
		echo '
268
			<a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>';
269
270
	echo '
271
			<a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>';
272
273
	// Are there any custom profile fields for bottom?
274
	if (!empty($context['print_custom_fields']['bottom_poster']))
275
	{
276
		$fields = '';
277
		foreach ($context['print_custom_fields']['bottom_poster'] as $field)
278
			if (!empty($field['output_html']))
279
				$fields .= '
280
					<li>' . $field['output_html'] . '</li>';
281
282
		if (!empty($fields))
283
			echo '
284
			<div class="custom_fields_bottom">
285
				<ul class="nolist">', $fields, '
286
				</ul>
287
			</div>';
288
	}
289
290
	echo '
291
		</div><!-- #basicinfo -->
292
293
		<div id="detailedinfo">
294
			<dl class="settings">';
295
296
	if ($context['user']['is_owner'] || $context['user']['is_admin'])
297
		echo '
298
				<dt>', $txt['username'], ': </dt>
299
				<dd>', $context['member']['username'], '</dd>';
300
301
	if (!isset($context['disabled_fields']['posts']))
302
		echo '
303
				<dt>', $txt['profile_posts'], ': </dt>
304
				<dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>';
305
306
	if ($context['member']['show_email'])
307
		echo '
308
				<dt>', $txt['email'], ': </dt>
309
				<dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>';
310
311
	if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title']))
312
		echo '
313
				<dt>', $txt['custom_title'], ': </dt>
314
				<dd>', $context['member']['title'], '</dd>';
315
316
	if (!empty($context['member']['blurb']))
317
		echo '
318
				<dt>', $txt['personal_text'], ': </dt>
319
				<dd>', $context['member']['blurb'], '</dd>';
320
321
	echo '
322
				<dt>', $txt['age'], ':</dt>
323
				<dd>', $context['member']['age'] . ($context['member']['today_is_birthday'] ? ' &nbsp; <img src="' . $settings['images_url'] . '/cake.png" alt="">' : ''), '</dd>';
324
325
	echo '
326
			</dl>';
327
328
	// Any custom fields for standard placement?
329
	if (!empty($context['print_custom_fields']['standard']))
330
	{
331
		$fields = array();
332
333
		foreach ($context['print_custom_fields']['standard'] as $field)
334
			if (!empty($field['output_html']))
335
				$fields[] = $field;
336
337
		if (count($fields) > 0)
338
		{
339
			echo '
340
			<dl class="settings">';
341
342
			foreach ($fields as $field)
343
				echo '
344
				<dt>', $field['name'], ':</dt>
345
				<dd>', $field['output_html'], '</dd>';
346
347
			echo '
348
			</dl>';
349
		}
350
	}
351
352
	echo '
353
			<dl class="settings noborder">';
354
355
	// Can they view/issue a warning?
356
	if ($context['can_view_warning'] && $context['member']['warning'])
357
	{
358
		echo '
359
				<dt>', $txt['profile_warning_level'], ': </dt>
360
				<dd>
361
					<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>';
362
363
		// Can we provide information on what this means?
364
		if (!empty($context['warning_status']))
365
			echo '
366
					<span class="smalltext">(', $context['warning_status'], ')</span>';
367
368
		echo '
369
				</dd>';
370
	}
371
372
	// Is this member requiring activation and/or banned?
373
	if (!empty($context['activate_message']) || !empty($context['member']['bans']))
374
	{
375
		// If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves.
376
		if (!empty($context['activate_message']))
377
			echo '
378
				<dt class="clear">
379
					<span class="alert">', $context['activate_message'], '</span> (<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="' . $txt['profileConfirm'] . '"' : ''), '>', $context['activate_link_text'], '</a>)
380
				</dt>';
381
382
		// If the current member is banned, show a message and possibly a link to the ban.
383
		if (!empty($context['member']['bans']))
384
		{
385
			echo '
386
				<dt class="clear">
387
					<span class="alert">', $txt['user_is_banned'], '</span>&nbsp;[<a href="#" onclick="document.getElementById(\'ban_info\').classList.toggle(\'hidden\');return false;">' . $txt['view_ban'] . '</a>]
388
				</dt>
389
				<dt class="clear hidden" id="ban_info">
390
					<strong>', $txt['user_banned_by_following'], ':</strong>';
391
392
			foreach ($context['member']['bans'] as $ban)
393
				echo '
394
					<br>
395
					<span class="smalltext">', $ban['explanation'], '</span>';
396
397
			echo '
398
				</dt>';
399
		}
400
	}
401
402
	echo '
403
				<dt>', $txt['date_registered'], ': </dt>
404
				<dd>', $context['member']['registered'], '</dd>';
405
406
	// If the person looking is allowed, they can check the members IP address and hostname.
407
	if ($context['can_see_ip'])
408
	{
409
		if (!empty($context['member']['ip']))
410
			echo '
411
				<dt>', $txt['ip'], ': </dt>
412
				<dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>';
413
414
		if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip']))
415
			echo '
416
				<dt>', $txt['hostname'], ': </dt>
417
				<dd>', $context['member']['hostname'], '</dd>';
418
	}
419
420
	echo '
421
				<dt>', $txt['local_time'], ':</dt>
422
				<dd>', $context['member']['local_time'], '</dd>';
423
424
	if (!empty($modSettings['userLanguage']) && !empty($context['member']['language']))
425
		echo '
426
				<dt>', $txt['language'], ':</dt>
427
				<dd>', $context['member']['language'], '</dd>';
428
429
	if ($context['member']['show_last_login'])
430
		echo '
431
				<dt>', $txt['lastLoggedIn'], ': </dt>
432
				<dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>';
433
434
	echo '
435
			</dl>';
436
437
	// Are there any custom profile fields for above the signature?
438
	if (!empty($context['print_custom_fields']['above_signature']))
439
	{
440
		$fields = '';
441
		foreach ($context['print_custom_fields']['above_signature'] as $field)
442
			if (!empty($field['output_html']))
443
				$fields .= '
444
					<li>' . $field['output_html'] . '</li>';
445
446
		if (!empty($fields))
447
			echo '
448
			<div class="custom_fields_above_signature">
449
				<ul class="nolist">', $fields, '
450
				</ul>
451
			</div>';
452
	}
453
454
	// Show the users signature.
455
	if ($context['signature_enabled'] && !empty($context['member']['signature']))
456
		echo '
457
			<div class="signature">
458
				<h5>', $txt['signature'], ':</h5>
459
				', $context['member']['signature'], '
460
			</div>';
461
462
	// Are there any custom profile fields for below the signature?
463
	if (!empty($context['print_custom_fields']['below_signature']))
464
	{
465
		$fields = '';
466
		foreach ($context['print_custom_fields']['below_signature'] as $field)
467
			if (!empty($field['output_html']))
468
				$fields .= '
469
					<li>' . $field['output_html'] . '</li>';
470
471
		if (!empty($fields))
472
			echo '
473
			<div class="custom_fields_below_signature">
474
				<ul class="nolist">', $fields, '
475
				</ul>
476
			</div>';
477
	}
478
479
	echo '
480
		</div><!-- #detailedinfo -->
481
	</div><!-- #profileview -->';
482
}
483
484
/**
485
 * Template for showing all the posts of the user, in chronological order.
486
 */
487
function template_showPosts()
488
{
489
	global $context, $scripturl, $txt;
490
491
	echo '
492
		<div class="cat_bar">
493
			<h3 class="catbg">
494
				', (!isset($context['attachments']) && empty($context['is_topics']) ? $txt['showMessages'] : (!empty($context['is_topics']) ? $txt['showTopics'] : $txt['showAttachments'])), ' - ', $context['member']['name'], '
495
			</h3>
496
		</div>', !empty($context['page_index']) ? '
497
		<div class="pagesection">
498
			<div class="pagelinks">' . $context['page_index'] . '</div>
499
		</div>' : '';
500
501
	// Are we displaying posts or attachments?
502
	if (!isset($context['attachments']))
503
	{
504
		// For every post to be displayed, give it its own div, and show the important details of the post.
505
		foreach ($context['posts'] as $post)
506
		{
507
			echo '
508
		<div class="', $post['css_class'], '">
509
			<div class="counter">', $post['counter'], '</div>
510
			<div class="topic_details">
511
				<h5>
512
					<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>
513
				</h5>
514
				<span class="smalltext">', $post['time'], '</span>
515
			</div>';
516
517
			if (!$post['approved'])
518
				echo '
519
			<div class="noticebox">
520
				', $txt['post_awaiting_approval'], '
521
			</div>';
522
523
			echo '
524
			<div class="post">
525
				<div class="inner">
526
					', $post['body'], '
527
				</div>
528
			</div><!-- .post -->';
529
530
			// Post options
531
			template_quickbuttons($post['quickbuttons'], 'profile_showposts');
532
533
			echo '
534
		</div><!-- .', $post['css_class'], ' -->';
535
		}
536
	}
537
	else
538
		template_show_list('attachments');
539
540
	// No posts? Just end with a informative message.
541
	if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts'])))
542
		echo '
543
		<div class="windowbg">
544
			', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), '
545
		</div>';
546
547
	// Show more page numbers.
548
	if (!empty($context['page_index']))
549
		echo '
550
		<div class="pagesection">
551
			<div class="pagelinks">', $context['page_index'], '</div>
552
		</div>';
553
}
554
555
/**
556
 * Template for showing all alerts
557
 */
558
function template_showAlerts()
559
{
560
	global $context, $txt, $scripturl;
561
562
	// Do we have an update message?
563
	if (!empty($context['update_message']))
564
		echo '
565
		<div class="infobox">
566
			', $context['update_message'], '
567
		</div>';
568
569
	echo '
570
		<div class="cat_bar">
571
			<h3 class="catbg">
572
			', $txt['alerts'], ' - ', $context['member']['name'], '
573
			</h3>
574
		</div>';
575
576
	if (empty($context['alerts']))
577
		echo '
578
		<div class="information">
579
			', $txt['alerts_none'], '
580
		</div>';
581
582
	else
583
	{
584
		// Start the form if checkboxes are in use
585
		if ($context['showCheckboxes'])
586
			echo '
587
		<form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;save" method="post" accept-charset="', $context['character_set'], '" id="mark_all">';
588
589
		echo '
590
			<table id="alerts" class="table_grid">';
591
592
		foreach ($context['alerts'] as $id => $alert)
593
		{
594
			echo '
595
				<tr class="windowbg">
596
					<td class="alert_image">
597
						<div>
598
							', empty($alert['sender']['avatar']['image']) ? '' : $alert['sender']['avatar']['image'] . '
599
							', $alert['icon'], '
600
						</div>
601
					</td>
602
					<td class="alert_text">
603
						<div>', $alert['text'], '</div>
604
						<time class="alert_inline_time" datetime="', $alert['alert_time'], '">', $alert['time'], '</time>
605
					</td>
606
					<td class="alert_time">
607
						<time datetime="', $alert['alert_time'], '">', $alert['time'], '</time>
608
					</td>
609
					<td class="alert_buttons">';
610
611
			// Alert options
612
			template_quickbuttons($alert['quickbuttons'], 'profile_alerts');
613
614
			echo '
615
					</td>
616
				</tr>';
617
		}
618
619
		echo '
620
			</table>
621
			<div class="pagesection">
622
				<div class="floatleft">
623
					', $context['pagination'], '
624
				</div>';
625
626
		if ($context['showCheckboxes'])
627
			echo '
628
				<div class="floatright">
629
					', $txt['check_all'], ': <input type="checkbox" name="select_all" id="select_all">
630
					<select name="mark_as">
631
						<option value="read">', $txt['quick_mod_markread'], '</option>
632
						<option value="unread">', $txt['quick_mod_markunread'], '</option>
633
						<option value="remove">', $txt['quick_mod_remove'], '</option>
634
					</select>
635
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
636
					<input type="hidden" name="start" value="', $context['start'], '">
637
					<input type="submit" name="req" value="', $txt['quick_mod_go'], '" class="button you_sure">
638
				</div>';
639
640
		echo '
641
			</div>';
642
643
		if ($context['showCheckboxes'])
644
			echo '
645
		</form>';
646
	}
647
}
648
649
/**
650
 * Template for showing all of a user's drafts
651
 */
652
function template_showDrafts()
653
{
654
	global $context, $scripturl, $txt;
655
656
	echo '
657
		<div class="cat_bar">
658
			<h3 class="catbg">
659
				', $txt['drafts'], ' - ', $context['member']['name'], '
660
			</h3>
661
		</div>', !empty($context['page_index']) ? '
662
		<div class="pagesection">
663
			<div class="pagelinks">' . $context['page_index'] . '</div>
664
		</div>' : '';
665
666
	// No drafts? Just show an informative message.
667
	if (empty($context['drafts']))
668
		echo '
669
		<div class="windowbg centertext">
670
			', $txt['draft_none'], '
671
		</div>';
672
	else
673
	{
674
		// For every draft to be displayed, give it its own div, and show the important details of the draft.
675
		foreach ($context['drafts'] as $draft)
676
		{
677
			echo '
678
		<div class="windowbg">
679
			<div class="counter">', $draft['counter'], '</div>
680
			<div class="topic_details">
681
				<h5>
682
					<strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> &nbsp; &nbsp;';
683
684
			if (!empty($draft['sticky']))
685
				echo '
686
					<span class="main_icons sticky" title="', $txt['sticky_topic'], '"></span>';
687
688
			if (!empty($draft['locked']))
689
				echo '
690
					<span class="main_icons lock" title="', $txt['locked_topic'], '"></span>';
691
692
			echo '
693
				</h5>
694
				<span class="smalltext">&#171;&nbsp;<strong>', $txt['on'], ':</strong> ', $draft['time'], '&nbsp;&#187;</span>
695
			</div><!-- .topic_details -->
696
			<div class="list_posts">
697
				', $draft['body'], '
698
			</div>
699
			<div class="floatright">';
700
701
			// Draft buttons
702
			template_quickbuttons($draft['quickbuttons'], 'profile_drafts');
703
704
			echo '
705
			</div><!-- .floatright -->
706
		</div><!-- .windowbg -->';
707
		}
708
	}
709
710
	// Show page numbers.
711
	echo '
712
		<div class="pagesection">
713
			<div class="pagelinks">', $context['page_index'], '</div>
714
		</div>';
715
}
716
717
/**
718
 * Template for showing and managing the buddy list.
719
 */
720
function template_editBuddies()
721
{
722
	global $context, $scripturl, $txt;
723
724
	if (!empty($context['saved_successful']))
725
		echo '
726
	<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
727
728
	elseif (!empty($context['saved_failed']))
729
		echo '
730
	<div class="errorbox">', $context['saved_failed'], '</div>';
731
732
	echo '
733
	<div id="edit_buddies">
734
		<div class="cat_bar">
735
			<h3 class="catbg">
736
				<span class="main_icons people icon"></span> ', $txt['editBuddies'], '
737
			</h3>
738
		</div>
739
		<table class="table_grid">
740
			<thead>
741
				<tr class="title_bar">
742
					<th scope="col" class="quarter_table buddy_link">', $txt['name'], '</th>
743
					<th scope="col" class="buddy_status">', $txt['status'], '</th>';
744
745
	if ($context['can_moderate_forum'])
746
		echo '
747
					<th scope="col" class="buddy_email">', $txt['email'], '</th>';
748
749
	if (!empty($context['custom_pf']))
750
		foreach ($context['custom_pf'] as $column)
751
			echo '
752
					<th scope="col" class="buddy_custom_fields">', $column['label'], '</th>';
753
754
	echo '
755
					<th scope="col" class="buddy_remove">', $txt['remove'], '</th>
756
				</tr>
757
			</thead>
758
			<tbody>';
759
760
	// If they don't have any buddies don't list them!
761
	if (empty($context['buddies']))
762
		echo '
763
				<tr class="windowbg">
764
					<td colspan="', $context['can_moderate_forum'] ? '10' : '9', '">
765
						<strong>', $txt['no_buddies'], '</strong>
766
					</td>
767
				</tr>';
768
769
	// Now loop through each buddy showing info on each.
770
	else
771
	{
772
		foreach ($context['buddies'] as $buddy)
773
		{
774
			echo '
775
				<tr class="windowbg">
776
					<td class="buddy_link">', $buddy['link'], '</td>
777
					<td class="centertext buddy_status">
778
						<a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a>
779
					</td>';
780
781
			if ($buddy['show_email'])
782
				echo '
783
					<td class="buddy_email centertext">
784
						<a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="main_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a>
785
					</td>';
786
787
			// Show the custom profile fields for this user.
788
			if (!empty($context['custom_pf']))
789
				foreach ($context['custom_pf'] as $key => $column)
790
					echo '
791
					<td class="lefttext buddy_custom_fields">', $buddy['options'][$key], '</td>';
792
793
			echo '
794
					<td class="centertext buddy_remove">
795
						<a href="', $scripturl, '?action=profile;area=lists;sa=buddies;u=', $context['id_member'], ';remove=', $buddy['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="main_icons delete" title="', $txt['buddy_remove'], '"></span></a>
796
					</td>
797
				</tr>';
798
		}
799
	}
800
801
	echo '
802
			</tbody>
803
		</table>
804
	</div><!-- #edit_buddies -->';
805
806
	// Add a new buddy?
807
	echo '
808
	<form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=buddies" method="post" accept-charset="', $context['character_set'], '">
809
		<div class="cat_bar">
810
			<h3 class="catbg">', $txt['buddy_add'], '</h3>
811
		</div>
812
		<div class="information">
813
			<dl class="settings">
814
				<dt>
815
					<label for="new_buddy"><strong>', $txt['who_member'], ':</strong></label>
816
				</dt>
817
				<dd>
818
					<input type="text" name="new_buddy" id="new_buddy" size="30">
819
					<input type="submit" value="', $txt['buddy_add_button'], '" class="button floatnone">
820
				</dd>
821
			</dl>
822
		</div>';
823
824
	if (!empty($context['token_check']))
825
		echo '
826
		<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
827
828
	echo '
829
		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
830
	</form>
831
	<script>
832
		var oAddBuddySuggest = new smc_AutoSuggest({
833
			sSelf: \'oAddBuddySuggest\',
834
			sSessionId: smf_session_id,
835
			sSessionVar: smf_session_var,
836
			sSuggestId: \'new_buddy\',
837
			sControlId: \'new_buddy\',
838
			sSearchType: \'member\',
839
			sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
840
			bItemList: false
841
		});
842
	</script>';
843
}
844
845
/**
846
 * Template for showing the ignore list of the current user.
847
 */
848
function template_editIgnoreList()
849
{
850
	global $context, $scripturl, $txt;
851
852
	if (!empty($context['saved_successful']))
853
		echo '
854
	<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
855
856
	elseif (!empty($context['saved_failed']))
857
		echo '
858
	<div class="errorbox">', $context['saved_failed'], '</div>';
859
860
	echo '
861
	<div id="edit_buddies">
862
		<div class="cat_bar">
863
			<h3 class="catbg profile_hd">
864
				', $txt['editIgnoreList'], '
865
			</h3>
866
		</div>
867
		<table class="table_grid">
868
			<thead>
869
				<tr class="title_bar">
870
					<th scope="col" class="quarter_table buddy_link">', $txt['name'], '</th>
871
					<th scope="col" class="buddy_status">', $txt['status'], '</th>';
872
873
	if ($context['can_moderate_forum'])
874
		echo '
875
					<th scope="col" class="buddy_email">', $txt['email'], '</th>';
876
877
	echo '
878
					<th scope="col" class="buddy_remove">', $txt['ignore_remove'], '</th>
879
				</tr>
880
			</thead>
881
			<tbody>';
882
883
	// If they don't have anyone on their ignore list, don't list it!
884
	if (empty($context['ignore_list']))
885
		echo '
886
				<tr class="windowbg">
887
					<td colspan="', $context['can_moderate_forum'] ? '4' : '3', '">
888
						<strong>', $txt['no_ignore'], '</strong>
889
					</td>
890
				</tr>';
891
892
	// Now loop through each buddy showing info on each.
893
	foreach ($context['ignore_list'] as $member)
894
	{
895
		echo '
896
				<tr class="windowbg">
897
					<td class="buddy_link">', $member['link'], '</td>
898
					<td class="centertext buddy_status">
899
						<a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a>
900
					</td>';
901
902
		if ($context['can_moderate_forum'])
903
			echo '
904
					<td class="centertext buddy_email">
905
						<a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="main_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a>
906
					</td>';
907
		echo '
908
					<td class="centertext buddy_remove">
909
						<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore;remove=', $member['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="main_icons delete" title="', $txt['ignore_remove'], '"></span></a>
910
					</td>
911
				</tr>';
912
	}
913
914
	echo '
915
			</tbody>
916
		</table>
917
	</div><!-- #edit_buddies -->';
918
919
	// Add to the ignore list?
920
	echo '
921
	<form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore" method="post" accept-charset="', $context['character_set'], '">
922
		<div class="cat_bar">
923
			<h3 class="catbg">', $txt['ignore_add'], '</h3>
924
		</div>
925
		<div class="information">
926
			<dl class="settings">
927
				<dt>
928
					<label for="new_buddy"><strong>', $txt['who_member'], ':</strong></label>
929
				</dt>
930
				<dd>
931
					<input type="text" name="new_ignore" id="new_ignore" size="30">
932
					<input type="submit" value="', $txt['ignore_add_button'], '" class="button">
933
				</dd>
934
			</dl>
935
		</div>';
936
937
	if (!empty($context['token_check']))
938
		echo '
939
		<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
940
941
	echo '
942
		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
943
	</form>
944
	<script>
945
		var oAddIgnoreSuggest = new smc_AutoSuggest({
946
			sSelf: \'oAddIgnoreSuggest\',
947
			sSessionId: \'', $context['session_id'], '\',
948
			sSessionVar: \'', $context['session_var'], '\',
949
			sSuggestId: \'new_ignore\',
950
			sControlId: \'new_ignore\',
951
			sSearchType: \'member\',
952
			sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
953
			bItemList: false
954
		});
955
	</script>';
956
}
957
958
/**
959
 * This template shows an admin information on a users IP addresses used and errors attributed to them.
960
 */
961
function template_trackActivity()
962
{
963
	global $context, $scripturl, $txt;
964
965
	// The first table shows IP information about the user.
966
	echo '
967
		<div class="cat_bar">
968
			<h3 class="catbg">', $txt['view_ips_by'], ' ', $context['member']['name'], '</h3>
969
		</div>';
970
971
	// The last IP the user used.
972
	echo '
973
		<div id="tracking" class="windowbg">
974
			<dl class="settings noborder">
975
				<dt>
976
					', $txt['most_recent_ip'], ':
977
					', (empty($context['last_ip2']) ? '' : '<br>
978
					<span class="smalltext">(<a href="' . $scripturl . '?action=helpadmin;help=whytwoip" onclick="return reqOverlayDiv(this.href);">' . $txt['why_two_ip_address'] . '</a>)</span>'), '
979
				</dt>
980
				<dd>
981
					<a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>';
982
983
	// Second address detected?
984
	if (!empty($context['last_ip2']))
985
		echo '
986
					, <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>';
987
988
	echo '
989
				</dd>';
990
991
	// Lists of IP addresses used in messages / error messages.
992
	echo '
993
				<dt>', $txt['ips_in_messages'], ':</dt>
994
				<dd>
995
					', (count($context['ips']) > 0 ? implode(', ', $context['ips']) : '(' . $txt['none'] . ')'), '
996
				</dd>
997
				<dt>', $txt['ips_in_errors'], ':</dt>
998
				<dd>
999
					', (count($context['error_ips']) > 0 ? implode(', ', $context['error_ips']) : '(' . $txt['none'] . ')'), '
1000
				</dd>';
1001
1002
	// List any members that have used the same IP addresses as the current member.
1003
	echo '
1004
				<dt>', $txt['members_in_range'], ':</dt>
1005
				<dd>
1006
					', (count($context['members_in_range']) > 0 ? implode(', ', $context['members_in_range']) : '(' . $txt['none'] . ')'), '
1007
				</dd>
1008
			</dl>
1009
		</div><!-- #tracking -->';
1010
1011
	// Show the track user list.
1012
	template_show_list('track_user_list');
1013
}
1014
1015
/**
1016
 * The template for trackIP, allowing the admin to see where/who a certain IP has been used.
1017
 */
1018
function template_trackIP()
1019
{
1020
	global $context, $txt;
1021
1022
	// This function always defaults to the last IP used by a member but can be set to track any IP.
1023
	// The first table in the template gives an input box to allow the admin to enter another IP to track.
1024
	echo '
1025
		<div class="cat_bar">
1026
			<h3 class="catbg">', $txt['trackIP'], '</h3>
1027
		</div>
1028
		<div class="windowbg">
1029
			<form action="', $context['base_url'], '" method="post" accept-charset="', $context['character_set'], '">
1030
				<dl class="settings">
1031
					<dt>
1032
						<label for="searchip"><strong>', $txt['enter_ip'], ':</strong></label>
1033
					</dt>
1034
					<dd>
1035
						<input type="text" name="searchip" value="', $context['ip'], '">
1036
					</dd>
1037
				</dl>
1038
				<input type="submit" value="', $txt['trackIP'], '" class="button">
1039
			</form>
1040
		</div>
1041
		<br>';
1042
1043
	// The table inbetween the first and second table shows links to the whois server for every region.
1044
	if ($context['single_ip'])
1045
	{
1046
		echo '
1047
		<div class="cat_bar">
1048
			<h3 class="catbg">', $txt['whois_title'], ' ', $context['ip'], '</h3>
1049
		</div>
1050
		<div class="windowbg">';
1051
1052
		foreach ($context['whois_servers'] as $server)
1053
			echo '
1054
			<a href="', $server['url'], '" target="_blank" rel="noopener"', '>', $server['name'], '</a><br>';
1055
		echo '
1056
		</div>
1057
		<br>';
1058
	}
1059
1060
	// The second table lists all the members who have been logged as using this IP address.
1061
	echo '
1062
		<div class="cat_bar">
1063
			<h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3>
1064
		</div>';
1065
1066
	if (empty($context['ips']))
1067
		echo '
1068
		<p class="windowbg description">
1069
			<em>', $txt['no_members_from_ip'], '</em>
1070
		</p>';
1071
1072
	else
1073
	{
1074
		echo '
1075
		<table class="table_grid">
1076
			<thead>
1077
				<tr class="title_bar">
1078
					<th scope="col">', $txt['ip_address'], '</th>
1079
					<th scope="col">', $txt['display_name'], '</th>
1080
				</tr>
1081
			</thead>
1082
			<tbody>';
1083
1084
		// Loop through each of the members and display them.
1085
		foreach ($context['ips'] as $ip => $memberlist)
1086
			echo '
1087
				<tr class="windowbg">
1088
					<td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td>
1089
					<td>', implode(', ', $memberlist), '</td>
1090
				</tr>';
1091
1092
		echo '
1093
			</tbody>
1094
		</table>';
1095
	}
1096
1097
	echo '
1098
		<br>';
1099
1100
	template_show_list('track_message_list');
1101
1102
	echo '<br>';
1103
1104
	template_show_list('track_user_list');
1105
1106
	// 3rd party integrations may have added additional tracking.
1107
	if (!empty($context['additional_track_lists']))
1108
	{
1109
		foreach ($context['additional_track_lists'] as $list)
1110
		{
1111
			echo '<br>';
1112
1113
			template_show_list($list);
1114
		}
1115
	}
1116
}
1117
1118
/**
1119
 * This template shows an admin which permissions a user have and which group(s) give them each permission.
1120
 */
1121
function template_showPermissions()
1122
{
1123
	global $context, $scripturl, $txt;
1124
1125
	echo '
1126
		<div class="cat_bar">
1127
			<h3 class="catbg profile_hd">
1128
				', $txt['showPermissions'], '
1129
			</h3>
1130
		</div>';
1131
1132
	if ($context['member']['has_all_permissions'])
1133
		echo '
1134
		<div class="information">', $txt['showPermissions_all'], '</div>';
1135
1136
	else
1137
	{
1138
		echo '
1139
		<div class="information">', $txt['showPermissions_help'], '</div>
1140
		<div id="permissions" class="flow_hidden">';
1141
1142
		if (!empty($context['no_access_boards']))
1143
		{
1144
			echo '
1145
			<div class="cat_bar">
1146
				<h3 class="catbg">', $txt['showPermissions_restricted_boards'], '</h3>
1147
			</div>
1148
			<div class="windowbg smalltext">
1149
				', $txt['showPermissions_restricted_boards_desc'], ':<br>';
1150
1151
			foreach ($context['no_access_boards'] as $no_access_board)
1152
				echo '
1153
				<a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', ';
1154
			echo '
1155
			</div>';
1156
		}
1157
1158
		// General Permissions section.
1159
		echo '
1160
			<div class="tborder">
1161
				<div class="cat_bar">
1162
					<h3 class="catbg">', $txt['showPermissions_general'], '</h3>
1163
				</div>';
1164
		if (!empty($context['member']['permissions']['general']))
1165
		{
1166
			echo '
1167
				<table class="table_grid">
1168
					<thead>
1169
						<tr class="title_bar">
1170
							<th class="lefttext half_table">', $txt['showPermissions_permission'], '</th>
1171
							<th class="lefttext half_table">', $txt['showPermissions_status'], '</th>
1172
						</tr>
1173
					</thead>
1174
					<tbody>';
1175
1176
			foreach ($context['member']['permissions']['general'] as $permission)
1177
			{
1178
				echo '
1179
						<tr class="windowbg">
1180
							<td title="', $permission['id'], '">
1181
								', $permission['is_denied'] ? '<del>' . $permission['name'] . '</del>' : $permission['name'], '
1182
							</td>
1183
							<td class="smalltext">';
1184
1185
				if ($permission['is_denied'])
1186
					echo '
1187
								<span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>';
1188
				else
1189
					echo '
1190
								', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']);
1191
1192
				echo '
1193
							</td>
1194
						</tr>';
1195
			}
1196
			echo '
1197
					</tbody>
1198
				</table>
1199
			</div><!-- .tborder -->
1200
			<br>';
1201
		}
1202
		else
1203
			echo '
1204
			<p class="windowbg">', $txt['showPermissions_none_general'], '</p>';
1205
1206
		// Board permission section.
1207
		echo '
1208
			<form action="' . $scripturl . '?action=profile;u=', $context['id_member'], ';area=permissions#board_permissions" method="post" accept-charset="', $context['character_set'], '">
1209
				<div class="cat_bar">
1210
					<h3 class="catbg">
1211
						<a id="board_permissions"></a>', $txt['showPermissions_select'], ':
1212
						<select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();">
1213
							<option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], '</option>';
1214
1215
		if (!empty($context['boards']))
1216
			echo '
1217
							<option value="" disabled>---------------------------</option>';
1218
1219
		// Fill the box with any local permission boards.
1220
		foreach ($context['boards'] as $board)
1221
			echo '
1222
							<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>';
1223
1224
		echo '
1225
						</select>
1226
					</h3>
1227
				</div><!-- .cat_bar -->
1228
			</form>';
1229
1230
		if (!empty($context['member']['permissions']['board']))
1231
		{
1232
			echo '
1233
			<table class="table_grid">
1234
				<thead>
1235
					<tr class="title_bar">
1236
						<th class="lefttext half_table">', $txt['showPermissions_permission'], '</th>
1237
						<th class="lefttext half_table">', $txt['showPermissions_status'], '</th>
1238
					</tr>
1239
				</thead>
1240
				<tbody>';
1241
1242
			foreach ($context['member']['permissions']['board'] as $permission)
1243
			{
1244
				echo '
1245
					<tr class="windowbg">
1246
						<td title="', $permission['id'], '">
1247
							', $permission['is_denied'] ? '<del>' . $permission['name'] . '</del>' : $permission['name'], '
1248
						</td>
1249
						<td class="smalltext">';
1250
1251
				if ($permission['is_denied'])
1252
					echo '
1253
							<span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>';
1254
1255
				else
1256
					echo '
1257
							', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']);
1258
1259
				echo '
1260
						</td>
1261
					</tr>';
1262
			}
1263
			echo '
1264
				</tbody>
1265
			</table>';
1266
		}
1267
		else
1268
			echo '
1269
			<p class="windowbg">', $txt['showPermissions_none_board'], '</p>';
1270
		echo '
1271
		</div><!-- #permissions -->';
1272
	}
1273
}
1274
1275
/**
1276
 * Template for user statistics, showing graphs and the like.
1277
 */
1278
function template_statPanel()
1279
{
1280
	global $context, $txt;
1281
1282
	// First, show a few text statistics such as post/topic count.
1283
	echo '
1284
	<div id="profileview" class="roundframe noup">
1285
		<div id="generalstats">
1286
			<dl class="stats">';
1287
1288
	foreach ($context['text_stats'] as $key => $stat)
1289
	{
1290
		echo '
1291
				<dt>', $txt['statPanel_' . $key], '</dt>';
1292
1293
		if (!empty($stat['url']))
1294
			echo '
1295
				<dd><a href="', $stat['url'], '">', $stat['text'], '</a></dd>';
1296
		else
1297
			echo '
1298
				<dd>', $stat['text'], '</dd>';
1299
	}
1300
1301
	echo '
1302
			</dl>
1303
		</div>';
1304
1305
	// This next section draws a graph showing what times of day they post the most.
1306
	echo '
1307
		<div id="activitytime" class="flow_hidden">
1308
			<div class="title_bar">
1309
				<h3 class="titlebg">
1310
					<span class="main_icons history"></span> ', $txt['statPanel_activityTime'], '
1311
				</h3>
1312
			</div>';
1313
1314
	// If they haven't post at all, don't draw the graph.
1315
	if (empty($context['posts_by_time']))
1316
		echo '
1317
			<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1318
1319
	// Otherwise do!
1320
	else
1321
	{
1322
		echo '
1323
			<ul class="activity_stats flow_hidden">';
1324
1325
		// The labels.
1326
		foreach ($context['posts_by_time'] as $time_of_day)
1327
			echo '
1328
				<li>
1329
					<div class="generic_bar vertical">
1330
						<div class="bar" style="height: ', (int) $time_of_day['relative_percent'], '%;">
1331
							<span>', sprintf($txt['statPanel_activityTime_posts'], $time_of_day['posts'], $time_of_day['posts_percent']), '</span>
1332
						</div>
1333
					</div>
1334
					<span class="stats_hour">', $time_of_day['hour_format'], '</span>
1335
				</li>';
1336
1337
		echo '
1338
			</ul>';
1339
	}
1340
1341
	echo '
1342
		</div><!-- #activitytime -->';
1343
1344
	// Two columns with the most popular boards by posts and activity (activity = users posts / total posts).
1345
	echo '
1346
		<div class="flow_hidden">
1347
			<div class="half_content">
1348
				<div class="title_bar">
1349
					<h3 class="titlebg">
1350
						<span class="main_icons replies"></span> ', $txt['statPanel_topBoards'], '
1351
					</h3>
1352
				</div>';
1353
1354
	if (empty($context['popular_boards']))
1355
		echo '
1356
				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1357
1358
	else
1359
	{
1360
		echo '
1361
				<dl class="stats">';
1362
1363
		// Draw a bar for every board.
1364
		foreach ($context['popular_boards'] as $board)
1365
		{
1366
			echo '
1367
					<dt>', $board['link'], '</dt>
1368
					<dd>
1369
						<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']), '">
1370
							', sprintf($txt['statPanel_topBoards_memberposts'], $board['posts'], $board['total_posts_member'], $board['posts_percent']), '
1371
						</div>
1372
						', empty($context['hide_num_posts']) ? $board['posts'] : '', '
1373
					</dd>';
1374
		}
1375
1376
		echo '
1377
				</dl>';
1378
	}
1379
	echo '
1380
			</div><!-- .half_content -->
1381
			<div class="half_content">
1382
				<div class="title_bar">
1383
					<h3 class="titlebg">
1384
						<span class="main_icons replies"></span> ', $txt['statPanel_topBoardsActivity'], '
1385
					</h3>
1386
				</div>';
1387
1388
	if (empty($context['board_activity']))
1389
		echo '
1390
				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1391
	else
1392
	{
1393
		echo '
1394
				<dl class="stats">';
1395
1396
		// Draw a bar for every board.
1397
		foreach ($context['board_activity'] as $activity)
1398
		{
1399
			echo '
1400
					<dt>', $activity['link'], '</dt>
1401
					<dd>
1402
						<div class="profile_pie" style="background-position: -', ((int) ($activity['posts_percent'] / 5) * 20), 'px 0;" title="', sprintf($txt['statPanel_topBoards_posts'], $activity['posts'], $activity['total_posts'], $activity['posts_percent']), '">
1403
							', sprintf($txt['statPanel_topBoards_posts'], $activity['posts'], $activity['total_posts'], $activity['posts_percent']), '
1404
						</div>
1405
						', $activity['percent'], '%
1406
					</dd>';
1407
		}
1408
1409
		echo '
1410
				</dl>';
1411
	}
1412
	echo '
1413
			</div><!-- .half_content -->
1414
		</div><!-- .flow_hidden -->';
1415
1416
	echo '
1417
	</div><!-- #profileview -->';
1418
}
1419
1420
/**
1421
 * Template for editing profile options.
1422
 */
1423
function template_edit_options()
1424
{
1425
	global $context, $scripturl, $txt, $modSettings;
1426
1427
	// The main header!
1428
	// because some browsers ignore autocomplete=off and fill username in display name and/ or email field, fake them out.
1429
	$url = !empty($context['profile_custom_submit_url']) ? $context['profile_custom_submit_url'] : $scripturl . '?action=profile;area=' . $context['menu_item_selected'] . ';u=' . $context['id_member'];
1430
	$url = $context['require_password'] && !empty($modSettings['force_ssl']) ? strtr($url, array('http://' => 'https://')) : $url;
1431
1432
	echo '
1433
		<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"' : ''), '>
1434
			<div style="height:0;overflow:hidden;">
1435
				<input type="text" id="autocompleteFakeName">
1436
				<input type="password" id="autocompleteFakePassword">
1437
			</div>
1438
			<div class="cat_bar">
1439
				<h3 class="catbg profile_hd">';
1440
1441
	// Don't say "Profile" if this isn't the profile...
1442
	if (!empty($context['profile_header_text']))
1443
		echo '
1444
					', $context['profile_header_text'];
1445
	else
1446
		echo '
1447
					', $txt['profile'];
1448
1449
	echo '
1450
				</h3>
1451
			</div>';
1452
1453
	// Have we some description?
1454
	if ($context['page_desc'])
1455
		echo '
1456
			<p class="information">', $context['page_desc'], '</p>';
1457
1458
	echo '
1459
			<div class="roundframe">';
1460
1461
	// Any bits at the start?
1462
	if (!empty($context['profile_prehtml']))
1463
		echo '
1464
				<div>', $context['profile_prehtml'], '</div>';
1465
1466
	if (!empty($context['profile_fields']))
1467
		echo '
1468
				<dl class="settings">';
1469
1470
	// Start the big old loop 'of love.
1471
	$lastItem = 'hr';
1472
	foreach ($context['profile_fields'] as $key => $field)
1473
	{
1474
		// We add a little hack to be sure we never get more than one hr in a row!
1475
		if ($lastItem == 'hr' && $field['type'] == 'hr')
1476
			continue;
1477
1478
		$lastItem = $field['type'];
1479
		if ($field['type'] == 'hr')
1480
			echo '
1481
				</dl>
1482
				<hr>
1483
				<dl class="settings">';
1484
1485
		elseif ($field['type'] == 'callback')
1486
		{
1487
			if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func']))
1488
			{
1489
				$callback_func = 'template_profile_' . $field['callback_func'];
1490
				$callback_func();
1491
			}
1492
		}
1493
		else
1494
		{
1495
			echo '
1496
					<dt>
1497
						<strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>';
1498
1499
			// Does it have any subtext to show?
1500
			if (!empty($field['subtext']))
1501
				echo '
1502
						<br>
1503
						<span class="smalltext">', $field['subtext'], '</span>';
1504
1505
			echo '
1506
					</dt>
1507
					<dd>';
1508
1509
			// Want to put something infront of the box?
1510
			if (!empty($field['preinput']))
1511
				echo '
1512
						', $field['preinput'];
1513
1514
			// What type of data are we showing?
1515
			if ($field['type'] == 'label')
1516
				echo '
1517
						', $field['value'];
1518
1519
			// Maybe it's a text box - very likely!
1520
			elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url')))
1521
			{
1522
				if ($field['type'] == 'int' || $field['type'] == 'float')
1523
					$type = 'number';
1524
				else
1525
					$type = $field['type'];
1526
				$step = $field['type'] == 'float' ? ' step="0.1"' : '';
1527
1528
				echo '
1529
						<input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' ', $step, '>';
1530
			}
1531
			// You "checking" me out? ;)
1532
			elseif ($field['type'] == 'check')
1533
				echo '
1534
						<input type="hidden" name="', $key, '" value="0">
1535
						<input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" ', $field['input_attr'], '>';
1536
1537
			// Always fun - select boxes!
1538
			elseif ($field['type'] == 'select')
1539
			{
1540
				echo '
1541
						<select name="', $key, '" id="', $key, '">';
1542
1543
				if (isset($field['options']))
1544
				{
1545
					// Is this some code to generate the options?
1546
					if (!is_array($field['options']))
1547
						$field['options'] = $field['options']();
1548
1549
					// Assuming we now have some!
1550
					if (is_array($field['options']))
1551
						foreach ($field['options'] as $value => $name)
1552
							echo '
1553
							<option', (!empty($field['disabled_options']) && is_array($field['disabled_options']) && in_array($value, $field['disabled_options'], true) ? ' disabled' : ''), ' value="' . $value . '"', $value == $field['value'] ? ' selected' : '', '>', $name, '</option>';
1554
				}
1555
1556
				echo '
1557
						</select>';
1558
			}
1559
1560
			// Something to end with?
1561
			if (!empty($field['postinput']))
1562
				echo '
1563
						', $field['postinput'];
1564
1565
			echo '
1566
					</dd>';
1567
		}
1568
	}
1569
1570
	if (!empty($context['profile_fields']))
1571
		echo '
1572
				</dl>';
1573
1574
	// Are there any custom profile fields - if so print them!
1575
	if (!empty($context['custom_fields']))
1576
	{
1577
		if ($lastItem != 'hr')
1578
			echo '
1579
				<hr>';
1580
1581
		echo '
1582
				<dl class="settings">';
1583
1584
		foreach ($context['custom_fields'] as $field)
1585
			echo '
1586
					<dt>
1587
						<strong>', $field['name'], ': </strong><br>
1588
						<span class="smalltext">', $field['desc'], '</span>
1589
					</dt>
1590
					<dd>
1591
						', $field['input_html'], '
1592
					</dd>';
1593
1594
		echo '
1595
				</dl>';
1596
	}
1597
1598
	// Any closing HTML?
1599
	if (!empty($context['profile_posthtml']))
1600
		echo '
1601
				<div>', $context['profile_posthtml'], '</div>';
1602
1603
	// Only show the password box if it's actually needed.
1604
	if ($context['require_password'])
1605
		echo '
1606
				<dl class="settings">
1607
					<dt>
1608
						<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br>
1609
						<span class="smalltext">', $txt['required_security_reasons'], '</span>
1610
					</dt>
1611
					<dd>
1612
						<input type="password" name="oldpasswrd" id="oldpasswrd" size="20">
1613
					</dd>
1614
				</dl>';
1615
1616
	// The button shouldn't say "Change profile" unless we're changing the profile...
1617
	if (!empty($context['submit_button_text']))
1618
		echo '
1619
				<input type="submit" name="save" value="', $context['submit_button_text'], '" class="button floatright">';
1620
	else
1621
		echo '
1622
				<input type="submit" name="save" value="', $txt['change_profile'], '" class="button floatright">';
1623
1624
	if (!empty($context['token_check']))
1625
		echo '
1626
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
1627
1628
	echo '
1629
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1630
				<input type="hidden" name="u" value="', $context['id_member'], '">
1631
				<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
1632
			</div><!-- .roundframe -->
1633
		</form>';
1634
1635
	// Any final spellchecking stuff?
1636
	if (!empty($context['show_spellchecking']))
1637
		echo '
1638
		<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>';
1639
}
1640
1641
/**
1642
 * Personal Message settings.
1643
 */
1644
function template_profile_pm_settings()
1645
{
1646
	global $context, $modSettings, $txt;
1647
1648
	echo '
1649
					<dt>
1650
						<label for="pm_prefs">', $txt['pm_display_mode'], ':</label>
1651
					</dt>
1652
					<dd>
1653
						<select name="pm_prefs" id="pm_prefs">
1654
							<option value="0"', $context['display_mode'] == 0 ? ' selected' : '', '>', $txt['pm_display_mode_all'], '</option>
1655
							<option value="1"', $context['display_mode'] == 1 ? ' selected' : '', '>', $txt['pm_display_mode_one'], '</option>
1656
							<option value="2"', $context['display_mode'] == 2 ? ' selected' : '', '>', $txt['pm_display_mode_linked'], '</option>
1657
						</select>
1658
					</dd>
1659
					<dt>
1660
						<label for="view_newest_pm_first">', $txt['recent_pms_at_top'], '</label>
1661
					</dt>
1662
					<dd>
1663
						<input type="hidden" name="default_options[view_newest_pm_first]" value="0">
1664
						<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' : '', '>
1665
					</dd>
1666
				</dl>
1667
				<hr>
1668
				<dl class="settings">
1669
					<dt>
1670
						<label for="pm_receive_from">', $txt['pm_receive_from'], '</label>
1671
					</dt>
1672
					<dd>
1673
						<select name="pm_receive_from" id="pm_receive_from">
1674
							<option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>';
1675
1676
	if (!empty($modSettings['enable_buddylist']))
1677
		echo '
1678
							<option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option>
1679
							<option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>';
1680
1681
	echo '
1682
							<option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option>
1683
						</select>
1684
					</dd>
1685
					<dt>
1686
						<label for="popup_messages">', $txt['popup_messages'], '</label>
1687
					</dt>
1688
					<dd>
1689
						<input type="hidden" name="default_options[popup_messages]" value="0">
1690
						<input type="checkbox" name="default_options[popup_messages]" id="popup_messages" value="1"', !empty($context['member']['options']['popup_messages']) ? ' checked' : '', '>
1691
					</dd>
1692
				</dl>
1693
				<hr>
1694
				<dl class="settings">
1695
					<dt>
1696
						<label for="pm_remove_inbox_label">', $txt['pm_remove_inbox_label'], '</label>
1697
					</dt>
1698
					<dd>
1699
						<input type="hidden" name="default_options[pm_remove_inbox_label]" value="0">
1700
						<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' : '', '>
1701
					</dd>';
1702
1703
}
1704
1705
/**
1706
 * Template for showing theme settings. Note: template_options() actually adds the theme specific options.
1707
 */
1708
function template_profile_theme_settings()
1709
{
1710
	global $context, $modSettings;
1711
1712
	$skeys = array_keys($context['theme_options']);
1713
	$first_option_key = array_shift($skeys);
1714
	$titled_section = false;
1715
1716
	foreach ($context['theme_options'] as $i => $setting)
1717
	{
1718
		// Just spit out separators and move on
1719
		if (empty($setting) || !is_array($setting))
1720
		{
1721
			// Avoid double separators and empty titled sections
1722
			$empty_section = true;
1723
			for ($j=$i+1; $j < count($context['theme_options']); $j++)
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
1724
			{
1725
				// Found another separator, so we're done
1726
				if (!is_array($context['theme_options'][$j]))
1727
					break;
1728
1729
				// Once we know there's something to show in this section, we can stop
1730
				if (!isset($context['theme_options'][$j]['enabled']) || !empty($context['theme_options'][$j]['enabled']))
1731
				{
1732
					$empty_section = false;
1733
					break;
1734
				}
1735
			}
1736
			if ($empty_section)
1737
			{
1738
				if ($i === $first_option_key)
1739
					$first_option_key = array_shift($skeys);
1740
1741
				continue;
1742
			}
1743
1744
			// Insert a separator (unless this is the first item in the list)
1745
			if ($i !== $first_option_key)
1746
				echo '
1747
				</dl>
1748
				<hr>
1749
				<dl class="settings">';
1750
1751
			// Should we give a name to this section?
1752
			if (is_string($setting) && !empty($setting))
1753
			{
1754
				$titled_section = true;
1755
				echo '
1756
					<dt><strong>' . $setting . '</strong></dt>
1757
					<dd></dd>';
1758
			}
1759
			else
1760
				$titled_section = false;
1761
1762
			continue;
1763
		}
1764
1765
		// Is this disabled?
1766
		if (isset($setting['enabled']) && $setting['enabled'] === false)
1767
		{
1768
			if ($i === $first_option_key)
1769
				$first_option_key = array_shift($skeys);
1770
1771
			continue;
1772
		}
1773
1774
		// Some of these may not be set...  Set to defaults here
1775
		$opts = array('calendar_start_day', 'topics_per_page', 'messages_per_page', 'display_quick_mod');
1776
		if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']]))
1777
			$context['member']['options'][$setting['id']] = 0;
1778
1779
		if (!isset($setting['type']) || $setting['type'] == 'bool')
1780
			$setting['type'] = 'checkbox';
1781
1782
		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
1783
			$setting['type'] = 'number';
1784
1785
		elseif ($setting['type'] == 'string')
1786
			$setting['type'] = 'text';
1787
1788
		if (isset($setting['options']))
1789
			$setting['type'] = 'list';
1790
1791
		echo '
1792
					<dt>
1793
						<label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>';
1794
1795
		if (isset($setting['description']))
1796
			echo '
1797
						<br>
1798
						<span class="smalltext">', $setting['description'], '</span>';
1799
		echo '
1800
					</dt>
1801
					<dd>';
1802
1803
		// Display checkbox options
1804
		if ($setting['type'] == 'checkbox')
1805
			echo '
1806
						<input type="hidden" name="default_options[' . $setting['id'] . ']" value="0">
1807
						<input type="checkbox" name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', !empty($context['member']['options'][$setting['id']]) ? ' checked' : '', ' value="1">';
1808
1809
		// How about selection lists, we all love them
1810
		elseif ($setting['type'] == 'list')
1811
		{
1812
			echo '
1813
						<select name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', '>';
1814
1815
			foreach ($setting['options'] as $value => $label)
1816
				echo '
1817
							<option value="', $value, '"', isset($context['member']['options'][$setting['id']]) && $value == $context['member']['options'][$setting['id']] ? ' selected' : '', '>', $label, '</option>';
1818
1819
			echo '
1820
						</select>';
1821
		}
1822
		// A textbox it is then
1823
		else
1824
		{
1825
			if (isset($setting['type']) && $setting['type'] == 'number')
1826
			{
1827
				$min = isset($setting['min']) ? ' min="' . $setting['min'] . '"' : ' min="0"';
1828
				$max = isset($setting['max']) ? ' max="' . $setting['max'] . '"' : '';
1829
				$step = isset($setting['step']) ? ' step="' . $setting['step'] . '"' : '';
1830
1831
				echo '
1832
						<input type="number"', $min . $max . $step;
1833
			}
1834
			elseif (isset($setting['type']) && $setting['type'] == 'url')
1835
				echo '
1836
						<input type="url"';
1837
1838
			else
1839
				echo '
1840
						<input type="text"';
1841
1842
			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"' : '', '>';
1843
		}
1844
1845
		// end of this defintion
1846
		echo '
1847
					</dd>';
1848
	}
1849
}
1850
1851
/**
1852
 * The template for configuring alerts
1853
 */
1854
function template_alert_configuration()
1855
{
1856
	global $context, $txt, $scripturl, $modSettings;
1857
1858
	echo '
1859
		<div class="cat_bar">
1860
			<h3 class="catbg">
1861
				', $txt['alert_prefs'], '
1862
			</h3>
1863
		</div>
1864
		<p class="information">
1865
			', (empty($context['description']) ? $txt['alert_prefs_desc'] : $context['description']), '
1866
		</p>
1867
		<form action="', $scripturl, '?', $context['action'], '" method="post" accept-charset="', $context['character_set'], '" id="notify_options" class="flow_hidden">
1868
			<div class="cat_bar">
1869
				<h3 class="catbg">
1870
					', $txt['notification_general'], '
1871
				</h3>
1872
			</div>
1873
			<div class="windowbg">
1874
				<dl class="settings">';
1875
1876
	// Allow notification on announcements to be disabled?
1877
	if ($context['can_disable_announce'])
1878
		echo '
1879
					<dt>
1880
						<label for="notify_announcements">', $txt['notify_important_email'], '</label>
1881
					</dt>
1882
					<dd>
1883
						<input type="hidden" name="notify_announcements" value="0">
1884
						<input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', '>
1885
					</dd>';
1886
1887
	if (!empty($modSettings['enable_ajax_alerts']))
1888
		echo '
1889
					<dt>
1890
						<label for="notify_send_body">', $txt['notify_alert_timeout'], '</label>
1891
					</dt>
1892
					<dd>
1893
						<input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '">
1894
					</dd>';
1895
1896
	echo '
1897
				</dl>
1898
			</div><!-- .windowbg -->
1899
			<div class="cat_bar">
1900
				<h3 class="catbg">
1901
					', $txt['notify_what_how'], '
1902
				</h3>
1903
			</div>
1904
			<table class="table_grid">';
1905
1906
	foreach ($context['alert_types'] as $alert_group => $alerts)
1907
	{
1908
		echo '
1909
				<tr class="title_bar">
1910
					<th>', $txt['alert_group_' . $alert_group], '</th>
1911
					<th>', $txt['receive_alert'], '</th>
1912
					<th>', $txt['receive_mail'], '</th>
1913
				</tr>
1914
				<tr class="windowbg">';
1915
1916
		if (isset($context['alert_group_options'][$alert_group]))
1917
		{
1918
			foreach ($context['alert_group_options'][$alert_group] as $opts)
1919
			{
1920
				echo '
1921
				<tr class="windowbg">
1922
					<td colspan="3">';
1923
1924
				$label = $txt['alert_opt_' . $opts[1]];
1925
				$label_pos = isset($opts['label']) ? $opts['label'] : '';
1926
				if ($label_pos == 'before')
1927
					echo '
1928
						<label for="opt_', $opts[1], '">', $label, '</label>';
1929
1930
				$this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0;
1931
				switch ($opts[0])
1932
				{
1933
					case 'check':
1934
						echo '
1935
						<input type="checkbox" name="opt_', $opts[1], '" id="opt_', $opts[1], '"', $this_value ? ' checked' : '', '>';
1936
						break;
1937
1938
					case 'select':
1939
						echo '
1940
						<select name="opt_', $opts[1], '" id="opt_', $opts[1], '">';
1941
1942
						foreach ($opts['opts'] as $k => $v)
1943
							echo '
1944
							<option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>';
1945
						echo '
1946
						</select>';
1947
						break;
1948
				}
1949
1950
				if ($label_pos == 'after')
1951
					echo '
1952
						<label for="opt_', $opts[1], '">', $label, '</label>';
1953
1954
				echo '
1955
					</td>
1956
				</tr>';
1957
			}
1958
		}
1959
1960
		foreach ($alerts as $alert_id => $alert_details)
1961
		{
1962
			echo '
1963
				<tr class="windowbg">
1964
					<td>
1965
						', $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="main_icons help" title="' . $txt['help'] . '"></span></a>' : '', '
1966
					</td>';
1967
1968
			foreach ($context['alert_bits'] as $type => $bitmask)
1969
			{
1970
				echo '
1971
					<td class="centercol">';
1972
1973
				$this_value = isset($context['alert_prefs'][$alert_id]) ? $context['alert_prefs'][$alert_id] : 0;
1974
				switch ($alert_details[$type])
1975
				{
1976
					case 'always':
1977
						echo '
1978
						<input type="checkbox" checked disabled>';
1979
						break;
1980
					case 'yes':
1981
						echo '
1982
						<input type="checkbox" name="', $type, '_', $alert_id, '"', ($this_value & $bitmask) ? ' checked' : '', '>';
1983
						break;
1984
					case 'never':
1985
						echo '
1986
						<input type="checkbox" disabled>';
1987
						break;
1988
				}
1989
				echo '
1990
					</td>';
1991
			}
1992
1993
			echo '
1994
				</tr>';
1995
		}
1996
	}
1997
1998
	echo '
1999
			</table>
2000
			<br>
2001
			<div>
2002
				<input id="notify_submit" type="submit" name="notify_submit" value="', $txt['notify_save'], '" class="button">
2003
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">', !empty($context['token_check']) ? '
2004
				<input type="hidden" name="' . $context[$context['token_check'] . '_token_var'] . '" value="' . $context[$context['token_check'] . '_token'] . '">' : '', '
2005
				<input type="hidden" name="u" value="', $context['id_member'], '">
2006
				<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
2007
			</div>
2008
		</form>
2009
		<br>';
2010
}
2011
2012
/**
2013
 * Template for showing which topics you're subscribed to
2014
 */
2015
function template_alert_notifications_topics()
2016
{
2017
	global $txt;
2018
2019
	// The main containing header.
2020
	echo '
2021
		<div class="cat_bar">
2022
			<h3 class="catbg">
2023
				', $txt['watched_topics'], '
2024
			</h3>
2025
		</div>
2026
		<p class="information">', $txt['watched_topics_desc'], '</p>
2027
		<br>';
2028
2029
	template_show_list('topic_notification_list');
2030
}
2031
2032
/**
2033
 * Template for showing which boards you're subscribed to
2034
 */
2035
function template_alert_notifications_boards()
2036
{
2037
	global $txt;
2038
2039
	echo '
2040
		<div class="cat_bar">
2041
			<h3 class="catbg">
2042
				', $txt['watched_boards'], '
2043
			</h3>
2044
		</div>
2045
		<p class="information">', $txt['watched_boards_desc'], '</p>
2046
		<br>';
2047
2048
	template_show_list('board_notification_list');
2049
}
2050
2051
/**
2052
 * Template for choosing group membership.
2053
 */
2054
function template_groupMembership()
2055
{
2056
	global $context, $scripturl, $txt;
2057
2058
	// The main containing header.
2059
	echo '
2060
		<form action="', $scripturl, '?action=profile;area=groupmembership;save" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
2061
			<div class="cat_bar">
2062
				<h3 class="catbg profile_hd">
2063
					', $txt['profile'], '
2064
				</h3>
2065
			</div>
2066
			<p class="information">', $txt['groupMembership_info'], '</p>';
2067
2068
	// Do we have an update message?
2069
	if (!empty($context['update_message']))
2070
		echo '
2071
			<div class="infobox">
2072
				', $context['update_message'], '.
2073
			</div>';
2074
2075
	echo '
2076
			<div id="groups">';
2077
2078
	// Requesting membership to a group?
2079
	if (!empty($context['group_request']))
2080
	{
2081
		echo '
2082
			<div class="groupmembership">
2083
				<div class="cat_bar">
2084
					<h3 class="catbg">', $txt['request_group_membership'], '</h3>
2085
				</div>
2086
				<div class="roundframe">
2087
					', $txt['request_group_membership_desc'], ':
2088
					<textarea name="reason" rows="4"></textarea>
2089
					<div class="righttext">
2090
						<input type="hidden" name="gid" value="', $context['group_request']['id'], '">
2091
						<input type="submit" name="req" value="', $txt['submit_request'], '" class="button">
2092
						</div>
2093
					</div>
2094
				</div><!-- .groupmembership -->';
2095
	}
2096
	else
2097
	{
2098
		echo '
2099
				<div class="title_bar">
2100
					<h3 class="titlebg">', $txt['current_membergroups'], '</h3>
2101
				</div>';
2102
2103
		foreach ($context['groups']['member'] as $group)
2104
		{
2105
			echo '
2106
				<div class="windowbg" id="primdiv_', $group['id'], '">';
2107
2108
			if ($context['can_edit_primary'])
2109
				echo '
2110
					<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', '>';
2111
2112
			echo '
2113
					<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>';
2114
2115
			// Can they leave their group?
2116
			if ($group['can_leave'])
2117
				echo '
2118
					<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>';
2119
2120
			echo '
2121
				</div><!-- .windowbg -->';
2122
		}
2123
2124
		if ($context['can_edit_primary'])
2125
			echo '
2126
				<div class="padding righttext">
2127
					<input type="submit" value="', $txt['make_primary'], '" class="button">
2128
				</div>';
2129
2130
		// Any groups they can join?
2131
		if (!empty($context['groups']['available']))
2132
		{
2133
			echo '
2134
				<div class="title_bar">
2135
					<h3 class="titlebg">', $txt['available_groups'], '</h3>
2136
				</div>';
2137
2138
			foreach ($context['groups']['available'] as $group)
2139
			{
2140
				echo '
2141
				<div class="windowbg">
2142
					<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>' : ''), '';
2143
2144
				if ($group['type'] == 3)
2145
					echo '
2146
					<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>';
2147
2148
				elseif ($group['type'] == 2 && $group['pending'])
2149
					echo '
2150
					<span class="floatright">', $txt['approval_pending'], '</span>';
2151
2152
				elseif ($group['type'] == 2)
2153
					echo '
2154
					<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>';
2155
2156
				echo '
2157
				</div><!-- .windowbg -->';
2158
			}
2159
		}
2160
2161
		// Javascript for the selector stuff.
2162
		echo '
2163
				<script>
2164
					var prevClass = "";
2165
					var prevDiv = "";
2166
					function highlightSelected(box)
2167
					{
2168
						if (prevClass != "")
2169
						{
2170
							prevDiv.className = prevClass;
2171
						}
2172
						prevDiv = document.getElementById(box);
2173
						prevClass = prevDiv.className;
2174
2175
						prevDiv.className = "windowbg";
2176
					}';
2177
		if (isset($context['groups']['member'][$context['primary_group']]))
2178
			echo '
2179
					highlightSelected("primdiv_' . $context['primary_group'] . '");';
2180
2181
		echo '
2182
				</script>';
2183
	}
2184
2185
	echo '
2186
			</div><!-- #groups -->';
2187
2188
	if (!empty($context['token_check']))
2189
		echo '
2190
			<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2191
2192
	echo '
2193
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2194
			<input type="hidden" name="u" value="', $context['id_member'], '">
2195
		</form>';
2196
}
2197
2198
/**
2199
 * Template for managing ignored boards
2200
 */
2201
function template_ignoreboards()
2202
{
2203
	global $context, $txt, $scripturl;
2204
2205
	// The main containing header.
2206
	echo '
2207
	<form action="', $scripturl, '?action=profile;area=ignoreboards;save" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
2208
		<div class="cat_bar">
2209
			<h3 class="catbg profile_hd">
2210
				', $txt['profile'], '
2211
			</h3>
2212
		</div>
2213
		<p class="information">', $txt['ignoreboards_info'], '</p>
2214
		<div class="windowbg">
2215
			<div class="flow_hidden boardslist">
2216
				<ul>';
2217
2218
	foreach ($context['categories'] as $category)
2219
	{
2220
		echo '
2221
					<li>
2222
						<a href="javascript:void(0);" onclick="selectBoards([', implode(', ', $category['child_ids']), '], \'creator\'); return false;">', $category['name'], '</a>
2223
						<ul>';
2224
2225
		foreach ($category['boards'] as $board)
2226
		{
2227
			echo '
2228
							<li style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">
2229
								<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>
2230
							</li>';
2231
		}
2232
2233
		echo '
2234
						</ul>
2235
					</li>';
2236
	}
2237
2238
	echo '
2239
				</ul>
2240
			</div><!-- .flow_hidden boardslist -->';
2241
2242
	// Show the standard "Save Settings" profile button.
2243
	template_profile_save();
2244
2245
	echo '
2246
		</div><!-- .windowbg -->
2247
	</form>
2248
	<br>';
2249
}
2250
2251
/**
2252
 * Simply loads some theme variables common to several warning templates.
2253
 */
2254
function template_load_warning_variables()
2255
{
2256
	global $modSettings, $context;
2257
2258
	// Setup the warning mode
2259
	$context['warning_mode'] = array(
2260
		0 => 'none',
2261
		$modSettings['warning_watch'] => 'watched',
2262
		$modSettings['warning_moderate'] => 'moderated',
2263
		$modSettings['warning_mute'] => 'muted',
2264
	);
2265
2266
	// Work out the starting warning.
2267
	$context['current_warning_mode'] = $context['warning_mode'][0];
2268
	foreach ($context['warning_mode'] as $limit => $warning)
2269
		if ($context['member']['warning'] >= $limit)
2270
			$context['current_warning_mode'] = $warning;
2271
}
2272
2273
// Show all warnings of a user?
2274
function template_viewWarning()
2275
{
2276
	global $context, $txt;
2277
2278
	template_load_warning_variables();
2279
2280
	echo '
2281
		<div class="cat_bar">
2282
			<h3 class="catbg profile_hd">
2283
				', sprintf($txt['profile_viewwarning_for_user'], $context['member']['name']), '
2284
			</h3>
2285
		</div>
2286
		<p class="information">', $txt['viewWarning_help'], '</p>
2287
		<div class="windowbg">
2288
			<dl class="settings">
2289
				<dt>
2290
					<strong>', $txt['profile_warning_name'], ':</strong>
2291
				</dt>
2292
				<dd>
2293
					', $context['member']['name'], '
2294
				</dd>
2295
				<dt>
2296
					<strong>', $txt['profile_warning_level'], ':</strong>
2297
				</dt>
2298
				<dd>
2299
					<div class="generic_bar warning_level ', $context['current_warning_mode'], '">
2300
						<div class="bar" style="width: ', $context['member']['warning'], '%;"></div>
2301
						<span>', $context['member']['warning'], '%</span>
2302
					</div>
2303
				</dd>';
2304
2305
	// There's some impact of this?
2306
	if (!empty($context['level_effects'][$context['current_level']]))
2307
		echo '
2308
				<dt>
2309
					<strong>', $txt['profile_viewwarning_impact'], ':</strong>
2310
				</dt>
2311
				<dd>
2312
					', $context['level_effects'][$context['current_level']], '
2313
				</dd>';
2314
2315
	echo '
2316
			</dl>
2317
		</div><!-- .windowbg -->';
2318
2319
	template_show_list('view_warnings');
2320
}
2321
2322
// Show a lovely interface for issuing warnings.
2323
function template_issueWarning()
2324
{
2325
	global $context, $scripturl, $txt;
2326
2327
	template_load_warning_variables();
2328
2329
	echo '
2330
	<script>
2331
		// Disable notification boxes as required.
2332
		function modifyWarnNotify()
2333
		{
2334
			disable = !document.getElementById(\'warn_notify\').checked;
2335
			document.getElementById(\'warn_sub\').disabled = disable;
2336
			document.getElementById(\'warn_body\').disabled = disable;
2337
			document.getElementById(\'warn_temp\').disabled = disable;
2338
			document.getElementById(\'new_template_link\').style.display = disable ? \'none\' : \'\';
2339
			document.getElementById(\'preview_button\').style.display = disable ? \'none\' : \'\';
2340
		}
2341
2342
		// Warn template.
2343
		function populateNotifyTemplate()
2344
		{
2345
			index = document.getElementById(\'warn_temp\').value;
2346
			if (index == -1)
2347
				return false;
2348
2349
			// Otherwise see what we can do...';
2350
2351
	foreach ($context['notification_templates'] as $k => $type)
2352
		echo '
2353
			if (index == ', $k, ')
2354
				document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";';
2355
2356
	echo '
2357
		}
2358
2359
		function updateSlider(slideAmount)
2360
		{
2361
			// Also set the right effect.
2362
			effectText = "";';
2363
2364
	foreach ($context['level_effects'] as $limit => $text)
2365
		echo '
2366
			if (slideAmount >= ', $limit, ')
2367
				effectText = "', $text, '";';
2368
2369
	echo '
2370
			setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\');
2371
		}
2372
	</script>';
2373
2374
	echo '
2375
	<form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=issuewarning" method="post" class="flow_hidden" accept-charset="', $context['character_set'], '">
2376
		<div class="cat_bar">
2377
			<h3 class="catbg profile_hd">
2378
				', $context['user']['is_owner'] ? $txt['profile_warning_level'] : $txt['profile_issue_warning'], '
2379
			</h3>
2380
		</div>';
2381
2382
	if (!$context['user']['is_owner'])
2383
		echo '
2384
		<p class="information">', $txt['profile_warning_desc'], '</p>';
2385
2386
	echo '
2387
		<div class="windowbg">
2388
			<dl class="settings">';
2389
2390
	if (!$context['user']['is_owner'])
2391
		echo '
2392
				<dt>
2393
					<strong>', $txt['profile_warning_name'], ':</strong>
2394
				</dt>
2395
				<dd>
2396
					<strong>', $context['member']['name'], '</strong>
2397
				</dd>';
2398
2399
	echo '
2400
				<dt>
2401
					<strong>', $txt['profile_warning_level'], ':</strong>';
2402
2403
	// Is there only so much they can apply?
2404
	if ($context['warning_limit'])
2405
		echo '
2406
					<br>
2407
					<span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>';
2408
2409
	echo '
2410
				</dt>
2411
				<dd>
2412
					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%
2413
					<div class="clear_left">
2414
						', $txt['profile_warning_impact'], ': <span id="cur_level_div">', $context['member']['warning'], '% (', $context['level_effects'][$context['current_level']], ')</span>
2415
					</div>
2416
				</dd>';
2417
2418
	if (!$context['user']['is_owner'])
2419
	{
2420
		echo '
2421
				<dt>
2422
					<strong>', $txt['profile_warning_reason'], ':</strong><br>
2423
					<span class="smalltext">', $txt['profile_warning_reason_desc'], '</span>
2424
				</dt>
2425
				<dd>
2426
					<input type="text" name="warn_reason" id="warn_reason" value="', $context['warning_data']['reason'], '" size="50">
2427
				</dd>
2428
			</dl>
2429
			<hr>
2430
			<div id="box_preview"', !empty($context['warning_data']['body_preview']) ? '' : ' style="display:none"', '>
2431
				<dl class="settings">
2432
					<dt>
2433
						<strong>', $txt['preview'], '</strong>
2434
					</dt>
2435
					<dd id="body_preview">
2436
						', !empty($context['warning_data']['body_preview']) ? $context['warning_data']['body_preview'] : '', '
2437
					</dd>
2438
				</dl>
2439
				<hr>
2440
			</div>
2441
			<dl class="settings">
2442
				<dt>
2443
					<strong><label for="warn_notify">', $txt['profile_warning_notify'], ':</label></strong>
2444
				</dt>
2445
				<dd>
2446
					<input type="checkbox" name="warn_notify" id="warn_notify" onclick="modifyWarnNotify();"', $context['warning_data']['notify'] ? ' checked' : '', '>
2447
				</dd>
2448
				<dt>
2449
					<strong><label for="warn_sub">', $txt['profile_warning_notify_subject'], ':</label></strong>
2450
				</dt>
2451
				<dd>
2452
					<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">
2453
				</dd>
2454
				<dt>
2455
					<strong><label for="warn_temp">', $txt['profile_warning_notify_body'], ':</label></strong>
2456
				</dt>
2457
				<dd>
2458
					<select name="warn_temp" id="warn_temp" disabled onchange="populateNotifyTemplate();">
2459
						<option value="-1">', $txt['profile_warning_notify_template'], '</option>
2460
						<option value="-1" disabled>------------------------------</option>';
2461
2462
		foreach ($context['notification_templates'] as $id_template => $template)
2463
			echo '
2464
						<option value="', $id_template, '">', $template['title'], '</option>';
2465
2466
		echo '
2467
					</select>
2468
					<span class="smalltext" id="new_template_link" style="display: none;">[<a href="', $scripturl, '?action=moderate;area=warnings;sa=templateedit;tid=0" target="_blank" rel="noopener">', $txt['profile_warning_new_template'], '</a>]</span>
2469
					<br>
2470
					<textarea name="warn_body" id="warn_body" cols="40" rows="8">', $context['warning_data']['notify_body'], '</textarea>
2471
				</dd>';
2472
	}
2473
	echo '
2474
			</dl>
2475
			<div class="righttext">';
2476
2477
	if (!empty($context['token_check']))
2478
		echo '
2479
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2480
2481
	echo '
2482
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2483
				<input type="button" name="preview" id="preview_button" value="', $txt['preview'], '" class="button">
2484
				<input type="submit" name="save" value="', $context['user']['is_owner'] ? $txt['change_profile'] : $txt['profile_warning_issue'], '" class="button">
2485
			</div><!-- .righttext -->
2486
		</div><!-- .windowbg -->
2487
	</form>';
2488
2489
	// Previous warnings?
2490
	template_show_list('view_warnings');
2491
2492
	echo '
2493
	<script>';
2494
2495
	if (!$context['user']['is_owner'])
2496
		echo '
2497
		modifyWarnNotify();
2498
		$(document).ready(function() {
2499
			$("#preview_button").click(function() {
2500
				return ajax_getTemplatePreview();
2501
			});
2502
		});
2503
2504
		function ajax_getTemplatePreview ()
2505
		{
2506
			$.ajax({
2507
				type: "POST",
2508
				url: "' . $scripturl . '?action=xmlhttp;sa=previews;xml",
2509
				data: {item: "warning_preview", title: $("#warn_sub").val(), body: $("#warn_body").val(), issuing: true},
2510
				context: document.body,
2511
				success: function(request){
2512
					$("#box_preview").css({display:""});
2513
					$("#body_preview").html($(request).find(\'body\').text());
2514
					if ($(request).find("error").text() != \'\')
2515
					{
2516
						$("#profile_error").css({display:""});
2517
						var errors_html = \'<ul class="list_errors">\';
2518
						var errors = $(request).find(\'error\').each(function() {
2519
							errors_html += \'<li>\' + $(this).text() + \'</li>\';
2520
						});
2521
						errors_html += \'</ul>\';
2522
2523
						$("#profile_error").html(errors_html);
2524
					}
2525
					else
2526
					{
2527
						$("#profile_error").css({display:"none"});
2528
						$("#error_list").html(\'\');
2529
					}
2530
				return false;
2531
				},
2532
			});
2533
			return false;
2534
		}';
2535
2536
	echo '
2537
	</script>';
2538
}
2539
2540
/**
2541
 * Template to show for deleting a user's account - now with added delete post capability!
2542
 */
2543
function template_deleteAccount()
2544
{
2545
	global $context, $scripturl, $txt;
2546
2547
	// The main containing header.
2548
	echo '
2549
		<form action="', $scripturl, '?action=profile;area=deleteaccount;save" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
2550
			<div class="cat_bar">
2551
				<h3 class="catbg profile_hd">
2552
					', $txt['deleteAccount'], '
2553
				</h3>
2554
			</div>';
2555
2556
	// If deleting another account give them a lovely info box.
2557
	if (!$context['user']['is_owner'])
2558
		echo '
2559
			<p class="information">', $txt['deleteAccount_desc'], '</p>';
2560
2561
	echo '
2562
			<div class="windowbg">';
2563
2564
	// If they are deleting their account AND the admin needs to approve it - give them another piece of info ;)
2565
	if ($context['needs_approval'])
2566
		echo '
2567
				<div class="errorbox">', $txt['deleteAccount_approval'], '</div>';
2568
2569
	// If the user is deleting their own account warn them first - and require a password!
2570
	if ($context['user']['is_owner'])
2571
	{
2572
		echo '
2573
				<div class="alert">', $txt['own_profile_confirm'], '</div>
2574
				<div>
2575
					<strong', (isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : ''), '>', $txt['current_password'], ': </strong>
2576
					<input type="password" name="oldpasswrd" size="20">
2577
					<input type="submit" value="', $txt['yes'], '" class="button">';
2578
2579
		if (!empty($context['token_check']))
2580
			echo '
2581
					<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2582
2583
		echo '
2584
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2585
					<input type="hidden" name="u" value="', $context['id_member'], '">
2586
					<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
2587
				</div>';
2588
	}
2589
	// Otherwise an admin doesn't need to enter a password - but they still get a warning - plus the option to delete lovely posts!
2590
	else
2591
	{
2592
		echo '
2593
				<div class="alert">', $txt['deleteAccount_warning'], '</div>';
2594
2595
		// Only actually give these options if they are kind of important.
2596
		if ($context['can_delete_posts'])
2597
		{
2598
			echo '
2599
				<div>
2600
					<label for="deleteVotes">
2601
						<input type="checkbox" name="deleteVotes" id="deleteVotes" value="1"> ', $txt['deleteAccount_votes'], ':
2602
					</label><br>
2603
					<label for="deletePosts">
2604
						<input type="checkbox" name="deletePosts" id="deletePosts" value="1"> ', $txt['deleteAccount_posts'], ':
2605
					</label>
2606
					<select name="remove_type">
2607
						<option value="posts">', $txt['deleteAccount_all_posts'], '</option>
2608
						<option value="topics">', $txt['deleteAccount_topics'], '</option>
2609
					</select>';
2610
2611
			if ($context['show_perma_delete'])
2612
				echo '
2613
					<br>
2614
					<label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1">', $txt['deleteAccount_permanent'], ':</label>';
2615
2616
			echo '
2617
				</div>';
2618
		}
2619
2620
		echo '
2621
				<div>
2622
					<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>
2623
				</div>
2624
				<div>
2625
					<input type="submit" value="', $txt['delete'], '" class="button">';
2626
2627
		if (!empty($context['token_check']))
2628
			echo '
2629
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2630
2631
		echo '
2632
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2633
					<input type="hidden" name="u" value="', $context['id_member'], '">
2634
					<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
2635
				</div>';
2636
	}
2637
	echo '
2638
			</div><!-- .windowbg -->
2639
			<br>
2640
		</form>';
2641
}
2642
2643
/**
2644
 * Template for the password box/save button stuck at the bottom of every profile page.
2645
 */
2646
function template_profile_save()
2647
{
2648
	global $context, $txt;
2649
2650
	echo '
2651
2652
					<hr>';
2653
2654
	// Only show the password box if it's actually needed.
2655
	if ($context['require_password'])
2656
		echo '
2657
					<dl class="settings">
2658
						<dt>
2659
							<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br>
2660
							<span class="smalltext">', $txt['required_security_reasons'], '</span>
2661
						</dt>
2662
						<dd>
2663
							<input type="password" name="oldpasswrd" size="20">
2664
						</dd>
2665
					</dl>';
2666
2667
	echo '
2668
					<div class="righttext">';
2669
2670
	if (!empty($context['token_check']))
2671
		echo '
2672
						<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2673
2674
	echo '
2675
						<input type="submit" value="', $txt['change_profile'], '" class="button">
2676
						<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2677
						<input type="hidden" name="u" value="', $context['id_member'], '">
2678
						<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
2679
					</div>';
2680
}
2681
2682
/**
2683
 * Small template for showing an error message upon a save problem in the profile.
2684
 */
2685
function template_error_message()
2686
{
2687
	global $context, $txt;
2688
2689
	echo '
2690
		<div class="errorbox" ', empty($context['post_errors']) ? 'style="display:none" ' : '', 'id="profile_error">';
2691
2692
	if (!empty($context['post_errors']))
2693
	{
2694
		echo '
2695
			<span>', !empty($context['custom_error_title']) ? $context['custom_error_title'] : $txt['profile_errors_occurred'], ':</span>
2696
			<ul id="list_errors">';
2697
2698
		// Cycle through each error and display an error message.
2699
		foreach ($context['post_errors'] as $error)
2700
			echo '
2701
				<li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>';
2702
2703
		echo '
2704
			</ul>';
2705
	}
2706
2707
	echo '
2708
		</div><!-- #profile_error -->';
2709
}
2710
2711
/**
2712
 * Display a load of drop down selectors for allowing the user to change group.
2713
 */
2714
function template_profile_group_manage()
2715
{
2716
	global $context, $txt, $scripturl;
2717
2718
	echo '
2719
							<dt>
2720
								<strong>', $txt['primary_membergroup'], ': </strong><br>
2721
								<span class="smalltext"><a href="', $scripturl, '?action=helpadmin;help=moderator_why_missing" onclick="return reqOverlayDiv(this.href);"><span class="main_icons help"></span> ', $txt['moderator_why_missing'], '</a></span>
2722
							</dt>
2723
							<dd>
2724
								<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;"' : ''), '>';
2725
2726
	// Fill the select box with all primary member groups that can be assigned to a member.
2727
	foreach ($context['member_groups'] as $member_group)
2728
		if (!empty($member_group['can_be_primary']))
2729
			echo '
2730
									<option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '>
2731
										', $member_group['name'], '
2732
									</option>';
2733
2734
	echo '
2735
								</select>
2736
							</dd>
2737
							<dt>
2738
								<strong>', $txt['additional_membergroups'], ':</strong>
2739
							</dt>
2740
							<dd>
2741
								<span id="additional_groupsList">
2742
									<input type="hidden" name="additional_groups[]" value="0">';
2743
2744
	// For each membergroup show a checkbox so members can be assigned to more than one group.
2745
	foreach ($context['member_groups'] as $member_group)
2746
		if ($member_group['can_be_additional'])
2747
			echo '
2748
									<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>';
2749
2750
	echo '
2751
								</span>
2752
								<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>
2753
								<script>
2754
									document.getElementById("additional_groupsList").style.display = "none";
2755
									document.getElementById("additional_groupsLink").style.display = "";
2756
								</script>
2757
							</dd>';
2758
2759
}
2760
2761
/**
2762
 * Callback function for entering a birthdate!
2763
 */
2764
function template_profile_birthdate()
2765
{
2766
	global $txt, $context;
2767
2768
	// Just show the pretty box!
2769
	echo '
2770
							<dt>
2771
								<strong>', $txt['dob'], ':</strong><br>
2772
								<span class="smalltext">', $txt['dob_year'], ' - ', $txt['dob_month'], ' - ', $txt['dob_day'], '</span>
2773
							</dt>
2774
							<dd>
2775
								<input type="text" name="bday3" size="4" maxlength="4" value="', $context['member']['birth_date']['year'], '"> -
2776
								<input type="text" name="bday1" size="2" maxlength="2" value="', $context['member']['birth_date']['month'], '"> -
2777
								<input type="text" name="bday2" size="2" maxlength="2" value="', $context['member']['birth_date']['day'], '">
2778
							</dd>';
2779
}
2780
2781
/**
2782
 * Show the signature editing box?
2783
 */
2784
function template_profile_signature_modify()
2785
{
2786
	global $txt, $context;
2787
2788
	echo '
2789
							<dt id="current_signature" style="display:none">
2790
								<strong>', $txt['current_signature'], ':</strong>
2791
							</dt>
2792
							<dd id="current_signature_display" style="display:none">
2793
								<hr>
2794
							</dd>
2795
2796
							<dt id="preview_signature" style="display:none">
2797
								<strong>', $txt['signature_preview'], ':</strong>
2798
							</dt>
2799
							<dd id="preview_signature_display" style="display:none">
2800
								<hr>
2801
							</dd>
2802
2803
							<dt>
2804
								<strong>', $txt['signature'], ':</strong><br>
2805
								<span class="smalltext">', $txt['sig_info'], '</span><br>
2806
								<br>';
2807
2808
	if ($context['show_spellchecking'])
2809
		echo '
2810
								<input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button">';
2811
2812
	echo '
2813
							</dt>
2814
							<dd>
2815
								<textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50">', $context['member']['signature'], '</textarea><br>';
2816
2817
	// If there is a limit at all!
2818
	if (!empty($context['signature_limits']['max_length']))
2819
		echo '
2820
								<span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>';
2821
2822
	if (!empty($context['show_preview_button']))
2823
		echo '
2824
								<input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button floatright">';
2825
2826
	if ($context['signature_warning'])
2827
		echo '
2828
								<span class="smalltext">', $context['signature_warning'], '</span>';
2829
2830
	// Some javascript used to count how many characters have been used so far in the signature.
2831
	echo '
2832
								<script>
2833
									var maxLength = ', $context['signature_limits']['max_length'], ';
2834
2835
									$(document).ready(function() {
2836
										calcCharLeft();
2837
										$("#preview_button").click(function() {
2838
											return ajax_getSignaturePreview(true);
2839
										});
2840
									});
2841
								</script>
2842
							</dd>';
2843
}
2844
2845
/**
2846
 * Template for selecting an avatar
2847
 */
2848
function template_profile_avatar_select()
2849
{
2850
	global $context, $txt, $modSettings;
2851
2852
	// Start with the upper menu
2853
	echo '
2854
							<dt>
2855
								<strong id="personal_picture">
2856
									<label for="avatar_upload_box">', $txt['personal_picture'], '</label>
2857
								</strong>';
2858
2859
	if (empty($modSettings['gravatarOverride']))
2860
		echo '
2861
								<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"' : '') . '>
2862
								<label for="avatar_choice_none"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>
2863
									' . $txt['no_avatar'] . '
2864
								</label><br>';
2865
2866
	if (!empty($context['member']['avatar']['allow_server_stored']))
2867
		echo '
2868
								<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"' : '') . '>
2869
								<label for="avatar_choice_server_stored"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>
2870
									', $txt['choose_avatar_gallery'], '
2871
								</label><br>';
2872
2873
	if (!empty($context['member']['avatar']['allow_external']))
2874
		echo '
2875
								<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"' : '') . '>
2876
								<label for="avatar_choice_external"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>
2877
									', $txt['my_own_pic'], '
2878
								</label><br>';
2879
2880
	if (!empty($context['member']['avatar']['allow_upload']))
2881
		echo '
2882
								<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"' : '') . '>
2883
								<label for="avatar_choice_upload"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>
2884
									', $txt['avatar_will_upload'], '
2885
								</label><br>';
2886
2887
	if (!empty($context['member']['avatar']['allow_gravatar']))
2888
		echo '
2889
								<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"' : '') . '>
2890
								<label for="avatar_choice_gravatar"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>' . $txt['use_gravatar'] . '</label>';
2891
2892
	echo '
2893
							</dt>
2894
							<dd>';
2895
2896
	// If users are allowed to choose avatars stored on the server show selection boxes to choice them from.
2897
	if (!empty($context['member']['avatar']['allow_server_stored']))
2898
	{
2899
		echo '
2900
								<div id="avatar_server_stored">
2901
									<div>
2902
										<select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">';
2903
2904
		// This lists all the file categories.
2905
		foreach ($context['avatars'] as $avatar)
2906
			echo '
2907
											<option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>';
2908
2909
		echo '
2910
										</select>
2911
									</div>
2912
									<div>
2913
										<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>
2914
									</div>
2915
									<div class="edit_avatar_img">
2916
										<img id="avatar" src="', $context['member']['avatar']['choice'] == 'server_stored' ? $context['member']['avatar']['href'] : $modSettings['avatar_url'] . '/blank.png', '" alt="">
2917
									</div>
2918
									<script>
2919
										var files = ["' . implode('", "', $context['avatar_list']) . '"];
2920
										var avatar = document.getElementById("avatar");
2921
										var cat = document.getElementById("cat");
2922
										var selavatar = "' . $context['avatar_selected'] . '";
2923
										var avatardir = "' . $modSettings['avatar_url'] . '/";
2924
										var size = avatar.alt.substr(3, 2) + " " + avatar.alt.substr(0, 2) + String.fromCharCode(117, 98, 116);
2925
										var file = document.getElementById("file");
2926
										var maxHeight = ', !empty($modSettings['avatar_max_height_external']) ? $modSettings['avatar_max_height_external'] : 0, ';
2927
										var maxWidth = ', !empty($modSettings['avatar_max_width_external']) ? $modSettings['avatar_max_width_external'] : 0, ';
2928
2929
										if (avatar.src.indexOf("blank.png") > -1)
2930
											changeSel(selavatar);
2931
										else
2932
											previewExternalAvatar(avatar.src)
2933
2934
									</script>
2935
								</div><!-- #avatar_server_stored -->';
2936
	}
2937
2938
	// If the user can link to an off server avatar, show them a box to input the address.
2939
	if (!empty($context['member']['avatar']['allow_external']))
2940
		echo '
2941
								<div id="avatar_external">
2942
									', $context['member']['avatar']['choice'] == 'external' ? '<div class="edit_avatar_img"><img src="' . $context['member']['avatar']['href'] . '" alt=""></div>' : '', '
2943
									<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') : '', '
0 ignored issues
show
Are you sure the usage of template_max_size('external') is correct as it seems to always return null.

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

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

}

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

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

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

Loading history...
2944
									<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);">
2945
								</div>';
2946
2947
	// If the user is able to upload avatars to the server show them an upload box.
2948
	if (!empty($context['member']['avatar']['allow_upload']))
2949
		echo '
2950
								<div id="avatar_upload">
2951
									', $context['member']['avatar']['choice'] == 'upload' ? '<div class="edit_avatar_img"><img src="' . $context['member']['avatar']['href'] . '" alt=""></div>' : '', '
2952
									<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'), '
0 ignored issues
show
Are you sure the usage of template_max_size('upload') is correct as it seems to always return null.

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

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

}

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

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

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

Loading history...
2953
									', (!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'] . '">' : ''), '
2954
								</div>';
2955
2956
	// if the user is able to use Gravatar avatars show then the image preview
2957
	if (!empty($context['member']['avatar']['allow_gravatar']))
2958
	{
2959
		echo '
2960
								<div id="avatar_gravatar">
2961
									', $context['member']['avatar']['choice'] == 'gravatar' ? '<div class="edit_avatar_img"><img src="' . $context['member']['avatar']['href'] . '" alt=""></div>' : '';
2962
2963
		if (empty($modSettings['gravatarAllowExtraEmail']))
2964
			echo '
2965
									<div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>';
2966
		else
2967
		{
2968
			// Depending on other stuff, the stored value here might have some odd things in it from other areas.
2969
			if ($context['member']['avatar']['external'] == $context['member']['email'])
2970
				$textbox_value = '';
2971
			else
2972
				$textbox_value = $context['member']['avatar']['external'];
2973
2974
			echo '
2975
									<div class="smalltext">', $txt['gravatar_alternateEmail'], '</div>
2976
									<input type="text" name="gravatarEmail" id="gravatarEmail" size="45" value="', $textbox_value, '">';
2977
		}
2978
		echo '
2979
								</div><!-- #avatar_gravatar -->';
2980
	}
2981
2982
	echo '
2983
								<script>
2984
									', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "' . ($context['member']['avatar']['choice'] == 'server_stored' ? '' : 'none') . '";' : '', '
2985
									', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "' . ($context['member']['avatar']['choice'] == 'external' ? '' : 'none') . '";' : '', '
2986
									', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "' . ($context['member']['avatar']['choice'] == 'upload' ? '' : 'none') . '";' : '', '
2987
									', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "' . ($context['member']['avatar']['choice'] == 'gravatar' ? '' : 'none') . '";' : '', '
2988
2989
									function swap_avatar(type)
2990
									{
2991
										switch(type.id)
2992
										{
2993
											case "avatar_choice_server_stored":
2994
												', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "";' : '', '
2995
												', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "none";' : '', '
2996
												', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "none";' : '', '
2997
												', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "none";' : '', '
2998
												break;
2999
											case "avatar_choice_external":
3000
												', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "none";' : '', '
3001
												', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "";' : '', '
3002
												', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "none";' : '', '
3003
												', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "none";' : '', '
3004
												break;
3005
											case "avatar_choice_upload":
3006
												', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "none";' : '', '
3007
												', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "none";' : '', '
3008
												', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "";' : '', '
3009
												', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "none";' : '', '
3010
												break;
3011
											case "avatar_choice_none":
3012
												', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "none";' : '', '
3013
												', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "none";' : '', '
3014
												', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "none";' : '', '
3015
												', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "none";' : '', '
3016
												break;
3017
											case "avatar_choice_gravatar":
3018
												', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "none";' : '', '
3019
												', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "none";' : '', '
3020
												', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "none";' : '', '
3021
												', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "";' : '', '
3022
												', ($context['member']['avatar']['external'] == $context['member']['email'] || strstr($context['member']['avatar']['external'], 'http://')) ?
3023
												'document.getElementById("gravatarEmail").value = "";' : '', '
3024
												break;
3025
										}
3026
									}
3027
								</script>
3028
							</dd>';
3029
}
3030
3031
/**
3032
 * This is just a really little helper to avoid duplicating code unnecessarily
3033
 *
3034
 * @param string $type The type of avatar
3035
 */
3036
function template_max_size($type)
3037
{
3038
	global $modSettings, $txt;
3039
3040
	$w = !empty($modSettings['avatar_max_width_' . $type]) ? comma_format($modSettings['avatar_max_width_' . $type]) : 0;
3041
	$h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0;
3042
3043
	$suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : '');
3044
	if (empty($suffix))
3045
		return;
3046
3047
	echo '
3048
								<div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>';
3049
}
3050
3051
/**
3052
 * Select the time format!
3053
 */
3054
function template_profile_timeformat_modify()
3055
{
3056
	global $context, $txt, $scripturl;
3057
3058
	echo '
3059
							<dt>
3060
								<strong><label for="easyformat">', $txt['time_format'], ':</label></strong><br>
3061
								<a href="', $scripturl, '?action=helpadmin;help=time_format" onclick="return reqOverlayDiv(this.href);" class="help"><span class="main_icons help" title="', $txt['help'], '"></span></a>
3062
								<span class="smalltext">
3063
									<label for="time_format">', $txt['date_format'], '</label>
3064
								</span>
3065
							</dt>
3066
							<dd>
3067
								<select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;">';
3068
3069
	// Help the user by showing a list of common time formats.
3070
	foreach ($context['easy_timeformats'] as $time_format)
3071
		echo '
3072
									<option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>';
3073
3074
	echo '
3075
								</select>
3076
								<input type="text" name="time_format" id="time_format" value="', $context['member']['time_format'], '" size="30">
3077
							</dd>';
3078
}
3079
3080
/**
3081
 * Template for picking a theme
3082
 */
3083
function template_profile_theme_pick()
3084
{
3085
	global $txt, $context, $scripturl;
3086
3087
	echo '
3088
							<dt>
3089
								<strong>', $txt['current_theme'], ':</strong>
3090
							</dt>
3091
							<dd>
3092
								', $context['member']['theme']['name'], ' <a class="button" href="', $scripturl, '?action=theme;sa=pick;u=', $context['id_member'], '">', $txt['change'], '</a>
3093
							</dd>';
3094
}
3095
3096
/**
3097
 * Smiley set picker.
3098
 */
3099
function template_profile_smiley_pick()
3100
{
3101
	global $txt, $context, $modSettings, $settings;
3102
3103
	echo '
3104
							<dt>
3105
								<strong><label for="smiley_set">', $txt['smileys_current'], ':</label></strong>
3106
							</dt>
3107
							<dd>
3108
								<select name="smiley_set" id="smiley_set">';
3109
3110
	foreach ($context['smiley_sets'] as $set)
3111
		echo '
3112
									<option data-preview="', $set['preview'], '" value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>';
3113
3114
	echo '
3115
								</select>
3116
								<img id="smileypr" class="centericon" src="', $context['member']['smiley_set']['preview'], '" alt=":)">
3117
							</dd>';
3118
}
3119
3120
/**
3121
 * Template for setting up and managing Two-Factor Authentication.
3122
 */
3123
function template_tfasetup()
3124
{
3125
	global $txt, $context, $scripturl, $modSettings;
3126
3127
	echo '
3128
			<div class="cat_bar">
3129
				<h3 class="catbg">', $txt['tfa_title'], '</h3>
3130
			</div>
3131
			<div class="roundframe">
3132
				<div>';
3133
3134
	if (!empty($context['tfa_backup']))
3135
		echo '
3136
					<div class="smalltext error">
3137
						', $txt['tfa_backup_used_desc'], '
3138
					</div>';
3139
3140
	elseif ($modSettings['tfa_mode'] == 2)
3141
		echo '
3142
					<div class="smalltext">
3143
						<strong>', $txt['tfa_forced_desc'], '</strong>
3144
					</div>';
3145
3146
	echo '
3147
					<div class="smalltext">
3148
						', $txt['tfa_desc'], '
3149
					</div>
3150
					<div class="floatleft">
3151
						<form action="', $scripturl, '?action=profile;area=tfasetup" method="post">
3152
							<div class="block">
3153
								<strong>', $txt['tfa_step1'], '</strong><br>';
3154
3155
	if (!empty($context['tfa_pass_error']))
3156
		echo '
3157
								<div class="error smalltext">
3158
									', $txt['tfa_pass_invalid'], '
3159
								</div>';
3160
3161
	echo '
3162
								<input type="password" name="oldpasswrd" size="25"', !empty($context['password_auth_failed']) ? ' class="error"' : '', !empty($context['tfa_pass_value']) ? ' value="' . $context['tfa_pass_value'] . '"' : '', '>
3163
							</div>
3164
							<div class="block">
3165
								<strong>', $txt['tfa_step2'], '</strong>
3166
								<div class="smalltext">', $txt['tfa_step2_desc'], '</div>
3167
								<div class="tfacode">', $context['tfa_secret'], '</div>
3168
							</div>
3169
							<div class="block">
3170
								<strong>', $txt['tfa_step3'], '</strong><br>';
3171
3172
	if (!empty($context['tfa_error']))
3173
		echo '
3174
								<div class="error smalltext">
3175
									', $txt['tfa_code_invalid'], '
3176
								</div>';
3177
3178
	echo '
3179
								<input type="text" name="tfa_code" size="25"', !empty($context['tfa_error']) ? ' class="error"' : '', !empty($context['tfa_value']) ? ' value="' . $context['tfa_value'] . '"' : '', '>
3180
								<input type="submit" name="save" value="', $txt['tfa_enable'], '" class="button">
3181
							</div>
3182
							<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">
3183
							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
3184
						</form>
3185
					</div>
3186
					<div class="floatright tfa_qrcode">
3187
						<div id="qrcode"></div>
3188
						<script type="text/javascript">
3189
							new QRCode(document.getElementById("qrcode"), "', $context['tfa_qr_url'], '");
3190
						</script>
3191
					</div>';
3192
3193
	if (!empty($context['from_ajax']))
3194
		echo '
3195
					<br>
3196
					<a href="javascript:self.close();"></a>';
3197
3198
	echo '
3199
				</div>
3200
			</div><!-- .roundframe -->';
3201
}
3202
3203
/**
3204
 * Template for disabling two-factor authentication.
3205
 */
3206
function template_tfadisable()
3207
{
3208
	global $txt, $context, $scripturl;
3209
3210
	echo '
3211
			<div class="cat_bar">
3212
				<h3 class="catbg">', $txt['tfadisable'], '</h3>
3213
			</div>
3214
			<div class="roundframe">
3215
				<form action="', $scripturl, '?action=profile;area=tfadisable" method="post">';
3216
3217
	if ($context['user']['is_owner'])
3218
		echo '
3219
					<div class="block">
3220
						<strong', (isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : ''), '>', $txt['current_password'], ': </strong><br>
3221
						<input type="password" name="oldpasswrd" size="20">
3222
					</div>';
3223
	else
3224
		echo '
3225
					<div class="smalltext">
3226
						', sprintf($txt['tfa_disable_for_user'], $context['user']['name']), '
3227
					</div>';
3228
3229
	echo '
3230
					<input type="submit" name="save" value="', $txt['tfa_disable'], '" class="button floatright">
3231
					<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">
3232
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
3233
					<input type="hidden" name="u" value="', $context['id_member'], '">
3234
				</form>
3235
			</div><!-- .roundframe -->';
3236
}
3237
3238
/**
3239
 * Template for setting up 2FA backup code
3240
 */
3241
function template_tfasetup_backup()
3242
{
3243
	global $context, $txt;
3244
3245
	echo '
3246
			<div class="cat_bar">
3247
				<h3 class="catbg">', $txt['tfa_backup_title'], '</h3>
3248
			</div>
3249
			<div class="roundframe">
3250
				<div>
3251
					<div class="smalltext">', $txt['tfa_backup_desc'], '</div>
3252
					<div class="bbc_code" style="resize: none; border: none;">', $context['tfa_backup'], '</div>
3253
				</div>
3254
			</div>';
3255
}
3256
3257
/**
3258
 * Simple template for showing the 2FA area when editing a profile.
3259
 */
3260
function template_profile_tfa()
3261
{
3262
	global $context, $txt, $scripturl, $modSettings;
3263
3264
	echo '
3265
							<dt>
3266
								<strong>', $txt['tfa_profile_label'], ':</strong><br>
3267
								<div class="smalltext">', $txt['tfa_profile_desc'], '</div>
3268
							</dt>
3269
							<dd>';
3270
3271
	if (!$context['tfa_enabled'] && $context['user']['is_owner'])
3272
		echo '
3273
								<a href="', !empty($modSettings['force_ssl']) ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>';
3274
3275
	elseif (!$context['tfa_enabled'])
3276
		echo '
3277
								', $txt['tfa_profile_disabled'];
3278
3279
	else
3280
		echo '
3281
								', sprintf($txt['tfa_profile_enabled'], (!empty($modSettings['force_ssl']) ? strtr($scripturl, array('http://' => 'https://')) : $scripturl) . '?action=profile;u=' . $context['id_member'] . ';area=tfadisable');
3282
3283
	echo '
3284
							</dd>';
3285
}
3286
3287
?>