Passed
Push — release-2.1 ( 0c2197...207d2d )
by Jeremy
05:47
created

template_edit_options()   F

Complexity

Conditions 48
Paths > 20000

Size

Total Lines 217
Code Lines 107

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 48
eloc 107
c 0
b 0
f 0
nop 0
dl 0
loc 217
rs 0
nc 2482176

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * Simple Machines Forum (SMF)
4
 *
5
 * @package SMF
6
 * @author Simple Machines http://www.simplemachines.org
7
 * @copyright 2018 Simple Machines and individual contributors
8
 * @license http://www.simplemachines.org/about/smf/license.php BSD
9
 *
10
 * @version 2.1 Beta 4
11
 */
12
13
/**
14
 * Minor stuff shown above the main profile - mostly used for error messages and showing that the profile update was successful.
15
 */
16
function template_profile_above()
17
{
18
	global $context;
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
Bug introduced by
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
			echo '
109
			<div class="unread">
110
				', !empty($details['sender']) ? $details['sender']['avatar']['image'] : '', '
111
				<div class="details">
112
					', !empty($details['icon']) ? $details['icon'] : '', '<span>', $details['text'], '</span> - ', $details['time'], '
113
				</div>
114
			</div>';
115
	}
116
117
	echo '
118
		</div><!-- .alerts_unread -->
119
		<script>
120
			function markAlertsRead(obj) {
121
				ajax_indicator(true);
122
				$.get(
123
					obj.href,
124
					function(data) {
125
						ajax_indicator(false);
126
						$("#alerts_menu_top span.amt").remove();
127
						$("#alerts_menu div.alerts_unread").html(data);
128
					}
129
				);
130
				return false;
131
			}
132
		</script>';
133
}
134
135
/**
136
 * A simple template to say "You don't have any unread alerts".
137
 */
138
function template_alerts_all_read()
139
{
140
	global $txt;
141
142
	echo '<div class="no_unread">', $txt['alerts_no_unread'], '</div>';
143
}
144
145
/**
146
 * This template displays a user's details without any option to edit them.
147
 */
148
function template_summary()
149
{
150
	global $context, $settings, $scripturl, $modSettings, $txt;
151
152
	// Display the basic information about the user
153
	echo '
154
	<div id="profileview" class="roundframe flow_auto">
155
		<div id="basicinfo">';
156
157
	// Are there any custom profile fields for above the name?
158
	if (!empty($context['print_custom_fields']['above_member']))
159
	{
160
		$fields = '';
161
		foreach ($context['print_custom_fields']['above_member'] as $field)
162
			if (!empty($field['output_html']))
163
				$fields .= '
164
					<li>' . $field['output_html'] . '</li>';
165
166
		if (!empty($fields))
167
			echo '
168
			<div class="custom_fields_above_name">
169
				<ul>', $fields, '
170
				</ul>
171
			</div>';
172
	}
173
174
	echo '
175
			<div class="username clear">
176
				<h4>';
177
178
	if (!empty($context['print_custom_fields']['before_member']))
179
		foreach ($context['print_custom_fields']['before_member'] as $field)
180
			if (!empty($field['output_html']))
181
				echo '
182
					<span>', $field['output_html'], '</span>';
183
184
	echo '
185
					', $context['member']['name'];
186
187
	if (!empty($context['print_custom_fields']['after_member']))
188
		foreach ($context['print_custom_fields']['after_member'] as $field)
189
			if (!empty($field['output_html']))
190
				echo '
191
					<span>', $field['output_html'], '</span>';
192
193
194
	echo '
195
					<span class="position">', (!empty($context['member']['group']) ? $context['member']['group'] : $context['member']['post_group']), '</span>
196
				</h4>
197
			</div>
198
			', $context['member']['avatar']['image'];
199
200
	// Are there any custom profile fields for below the avatar?
201
	if (!empty($context['print_custom_fields']['below_avatar']))
202
	{
203
		$fields = '';
204
		foreach ($context['print_custom_fields']['below_avatar'] as $field)
205
			if (!empty($field['output_html']))
206
				$fields .= '
207
					<li>' . $field['output_html'] . '</li>';
208
209
		if (!empty($fields))
210
			echo '
211
			<div class="custom_fields_below_avatar">
212
				<ul>', $fields, '
213
				</ul>
214
			</div>';
215
	}
216
217
	echo '
218
			<ul class="icon_fields clear">';
219
220
	// Email is only visible if it's your profile or you have the moderate_forum permission
221
	if ($context['member']['show_email'])
222
		echo '
223
				<li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>';
224
225
	// Don't show an icon if they haven't specified a website.
226
	if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website']))
227
		echo '
228
				<li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank" rel="noopener">', ($settings['use_image_buttons'] ? '<span class="generic_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
229
230
	// Are there any custom profile fields as icons?
231
	if (!empty($context['print_custom_fields']['icons']))
232
	{
233
		foreach ($context['print_custom_fields']['icons'] as $field)
234
			if (!empty($field['output_html']))
235
				echo '
236
				<li class="custom_field">', $field['output_html'], '</li>';
237
	}
238
239
	echo '
240
			</ul>
241
			<span id="userstatus">
242
				', $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>' : '';
243
244
	// Can they add this member as a buddy?
245
	if (!empty($context['can_have_buddy']) && !$context['user']['is_owner'])
246
		echo '
247
				<br>
248
				<a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], '</a>';
249
250
	echo '
251
			</span>';
252
253
	if (!$context['user']['is_owner'] && $context['can_send_pm'])
254
		echo '
255
			<a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>';
256
257
	echo '
258
			<a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>';
259
260
	if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled']))
261
		echo '
262
			<a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>';
263
264
	echo '
265
			<a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>';
266
267
	// Are there any custom profile fields for bottom?
268
	if (!empty($context['print_custom_fields']['bottom_poster']))
269
	{
270
		$fields = '';
271
		foreach ($context['print_custom_fields']['bottom_poster'] as $field)
272
			if (!empty($field['output_html']))
273
				$fields .= '
274
					<li>' . $field['output_html'] . '</li>';
275
276
		if (!empty($fields))
277
			echo '
278
			<div class="custom_fields_bottom">
279
				<ul class="nolist">', $fields, '
280
				</ul>
281
			</div>';
282
	}
283
284
	echo '
285
		</div><!-- #basicinfo -->
286
287
		<div id="detailedinfo">
288
			<dl class="settings">';
289
290
	if ($context['user']['is_owner'] || $context['user']['is_admin'])
291
		echo '
292
				<dt>', $txt['username'], ': </dt>
293
				<dd>', $context['member']['username'], '</dd>';
294
295
	if (!isset($context['disabled_fields']['posts']))
296
		echo '
297
				<dt>', $txt['profile_posts'], ': </dt>
298
				<dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>';
299
300
	if ($context['member']['show_email'])
301
		echo '
302
				<dt>', $txt['email'], ': </dt>
303
				<dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>';
304
305
	if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title']))
306
		echo '
307
				<dt>', $txt['custom_title'], ': </dt>
308
				<dd>', $context['member']['title'], '</dd>';
309
310
	if (!empty($context['member']['blurb']))
311
		echo '
312
				<dt>', $txt['personal_text'], ': </dt>
313
				<dd>', $context['member']['blurb'], '</dd>';
314
315
	echo '
316
				<dt>', $txt['age'], ':</dt>
317
				<dd>', $context['member']['age'] . ($context['member']['today_is_birthday'] ? ' &nbsp; <img src="' . $settings['images_url'] . '/cake.png" alt="">' : ''), '</dd>';
318
319
	echo '
320
			</dl>';
321
322
	// Any custom fields for standard placement?
323
	if (!empty($context['print_custom_fields']['standard']))
324
	{
325
		$fields = array();
326
327
		foreach ($context['print_custom_fields']['standard'] as $field)
328
			if (!empty($field['output_html']))
329
				$fields[] = $field;
330
331
		if (count($fields) > 0)
332
		{
333
			echo '
334
			<dl class="settings">';
335
336
			foreach ($fields as $field)
337
				echo '
338
				<dt>', $field['name'], ':</dt>
339
				<dd>', $field['output_html'], '</dd>';
340
341
			echo '
342
			</dl>';
343
		}
344
	}
345
346
	echo '
347
			<dl class="settings noborder">';
348
349
	// Can they view/issue a warning?
350
	if ($context['can_view_warning'] && $context['member']['warning'])
351
	{
352
		echo '
353
				<dt>', $txt['profile_warning_level'], ': </dt>
354
				<dd>
355
					<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>';
356
357
		// Can we provide information on what this means?
358
		if (!empty($context['warning_status']))
359
			echo '
360
					<span class="smalltext">(', $context['warning_status'], ')</span>';
361
362
		echo '
363
				</dd>';
364
	}
365
366
	// Is this member requiring activation and/or banned?
367
	if (!empty($context['activate_message']) || !empty($context['member']['bans']))
368
	{
369
		// If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves.
370
		if (!empty($context['activate_message']))
371
			echo '
372
				<dt class="clear">
373
					<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>)
374
				</dt>';
375
376
		// If the current member is banned, show a message and possibly a link to the ban.
377
		if (!empty($context['member']['bans']))
378
		{
379
			echo '
380
				<dt class="clear">
381
					<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>]
382
				</dt>
383
				<dt class="clear hidden" id="ban_info">
384
					<strong>', $txt['user_banned_by_following'], ':</strong>';
385
386
			foreach ($context['member']['bans'] as $ban)
387
				echo '
388
					<br>
389
					<span class="smalltext">', $ban['explanation'], '</span>';
390
391
			echo '
392
				</dt>';
393
		}
394
	}
395
396
	echo '
397
				<dt>', $txt['date_registered'], ': </dt>
398
				<dd>', $context['member']['registered'], '</dd>';
399
400
	// If the person looking is allowed, they can check the members IP address and hostname.
401
	if ($context['can_see_ip'])
402
	{
403
		if (!empty($context['member']['ip']))
404
		echo '
405
				<dt>', $txt['ip'], ': </dt>
406
				<dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>';
407
408
		if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip']))
409
			echo '
410
				<dt>', $txt['hostname'], ': </dt>
411
				<dd>', $context['member']['hostname'], '</dd>';
412
	}
413
414
	echo '
415
				<dt>', $txt['local_time'], ':</dt>
416
				<dd>', $context['member']['local_time'], '</dd>';
417
418
	if (!empty($modSettings['userLanguage']) && !empty($context['member']['language']))
419
		echo '
420
				<dt>', $txt['language'], ':</dt>
421
				<dd>', $context['member']['language'], '</dd>';
422
423
	if ($context['member']['show_last_login'])
424
		echo '
425
				<dt>', $txt['lastLoggedIn'], ': </dt>
426
				<dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>';
427
428
	echo '
429
			</dl>';
430
431
	// Are there any custom profile fields for above the signature?
432
	if (!empty($context['print_custom_fields']['above_signature']))
433
	{
434
		$fields = '';
435
		foreach ($context['print_custom_fields']['above_signature'] as $field)
436
			if (!empty($field['output_html']))
437
				$fields .= '
438
					<li>' . $field['output_html'] . '</li>';
439
440
		if (!empty($fields))
441
			echo '
442
			<div class="custom_fields_above_signature">
443
				<ul class="nolist">', $fields, '
444
				</ul>
445
			</div>';
446
	}
447
448
	// Show the users signature.
449
	if ($context['signature_enabled'] && !empty($context['member']['signature']))
450
		echo '
451
			<div class="signature">
452
				<h5>', $txt['signature'], ':</h5>
453
				', $context['member']['signature'], '
454
			</div>';
455
456
	// Are there any custom profile fields for below the signature?
457
	if (!empty($context['print_custom_fields']['below_signature']))
458
	{
459
		$fields = '';
460
		foreach ($context['print_custom_fields']['below_signature'] as $field)
461
			if (!empty($field['output_html']))
462
				$fields .=  '
463
					<li>' . $field['output_html'] . '</li>';
464
465
		if (!empty($fields))
466
			echo '
467
			<div class="custom_fields_below_signature">
468
				<ul class="nolist">', $fields, '
469
				</ul>
470
			</div>';
471
	}
472
473
	echo '
474
		</div><!-- #detailedinfo -->
475
	</div><!-- #profileview -->';
476
}
477
478
/**
479
 * Template for showing all the posts of the user, in chronological order.
480
 */
481
function template_showPosts()
482
{
483
	global $context, $scripturl, $txt;
484
485
	echo '
486
		<div class="cat_bar">
487
			<h3 class="catbg">
488
				', (!isset($context['attachments']) && empty($context['is_topics']) ? $txt['showMessages'] : (!empty($context['is_topics']) ? $txt['showTopics'] : $txt['showAttachments'])), ' - ', $context['member']['name'], '
489
			</h3>
490
		</div>', !empty($context['page_index']) ? '
491
		<div class="pagesection">
492
			<div class="pagelinks">' . $context['page_index'] . '</div>
493
		</div>' : '';
494
495
	// Are we displaying posts or attachments?
496
	if (!isset($context['attachments']))
497
	{
498
		// For every post to be displayed, give it its own div, and show the important details of the post.
499
		foreach ($context['posts'] as $post)
500
		{
501
			echo '
502
		<div class="', $post['css_class'], '">
503
			<div class="counter">', $post['counter'], '</div>
504
			<div class="topic_details">
505
				<h5>
506
					<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>
507
				</h5>
508
				<span class="smalltext">', $post['time'], '</span>
509
			</div>
510
			<div class="list_posts">';
511
512
			if (!$post['approved'])
513
				echo '
514
				<div class="approve_post">
515
					<em>', $txt['post_awaiting_approval'], '</em>
516
				</div>';
517
518
			echo '
519
				', $post['body'], '
520
			</div>';
521
522
			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
523
				echo '
524
			<div class="floatright">
525
				<ul class="quickbuttons">';
526
527
			// If they *can* reply?
528
			if ($post['can_reply'])
529
				echo '
530
					<li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>';
531
532
			// If they *can* quote?
533
			if ($post['can_quote'])
534
				echo '
535
					<li><a href="', $scripturl . '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>';
536
537
			// How about... even... remove it entirely?!
538
			if ($post['can_delete'])
539
				echo '
540
					<li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';profile;u=', $context['member']['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
541
542
			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
543
				echo '
544
				</ul>
545
			</div><!-- .floatright -->';
546
547
			echo '
548
		</div><!-- $post[css_class] -->';
549
		}
550
	}
551
	else
552
		template_show_list('attachments');
553
554
	// No posts? Just end with a informative message.
555
	if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts'])))
556
		echo '
557
		<div class="windowbg">
558
			', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), '
559
		</div>';
560
561
	// Show more page numbers.
562
	if (!empty($context['page_index']))
563
		echo '
564
		<div class="pagesection">
565
			<div class="pagelinks">', $context['page_index'], '</div>
566
		</div>';
567
}
568
569
/**
570
 * Template for showing alerts within the alerts popup
571
 */
572
function template_showAlerts()
573
{
574
	global $context, $txt, $scripturl;
575
576
	// Do we have an update message?
577
	if (!empty($context['update_message']))
578
		echo '
579
		<div class="infobox">
580
			', $context['update_message'], '
581
		</div>';
582
583
	echo '
584
		<div class="cat_bar">
585
			<h3 class="catbg">
586
			', $txt['alerts'], ' - ', $context['member']['name'], '
587
			</h3>
588
		</div>';
589
590
	if (empty($context['alerts']))
591
		echo '
592
		<div class="information">
593
			', $txt['alerts_none'], '
594
		</div>';
595
596
	else
597
	{
598
		// Start the form if checkboxes are in use
599
		if ($context['showCheckboxes'])
600
			echo '
601
		<form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;save" method="post" accept-charset="', $context['character_set'], '" id="mark_all">';
602
603
		echo '
604
			<table id="alerts" class="table_grid">';
605
606
		foreach ($context['alerts'] as $id => $alert)
607
		{
608
			echo '
609
				<tr class="windowbg">
610
					<td class="alert_text">
611
						', $alert['text'], '
612
						<span class="alert_inline_time"><span class="generic_icons time_online"></span> ', $alert['time'], '</span>
613
					</td>
614
					<td class="alert_time">', $alert['time'], '</td>
615
					<td class="alert_buttons">
616
						<ul class="quickbuttons">
617
							<li><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;do=remove;aid=', $id, ';', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['delete'], '</a></li>
618
							<li><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;do=', ($alert['is_read'] != 0 ? 'unread' : 'read'), ';aid=', $id, ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons ', $alert['is_read'] != 0 ? 'unread_button' : 'read_button', '"></span>', ($alert['is_read'] != 0 ? $txt['mark_unread'] : $txt['mark_read_short']), '</a></li>';
619
620
					if ($context['showCheckboxes'])
621
						echo '
622
							<li><input type="checkbox" name="mark[', $id, ']" value="', $id, '"></li>';
623
624
			echo '
625
						</ul>
626
					</td>
627
				</tr>';
628
		}
629
630
		echo '
631
			</table>
632
			<div class="pagesection">
633
				<div class="floatleft">
634
					', $context['pagination'], '
635
				</div>';
636
637
		if ($context['showCheckboxes'])
638
			echo '
639
				<div class="floatright">
640
					', $txt['check_all'], ': <input type="checkbox" name="select_all" id="select_all">
641
					<select name="mark_as">
642
						<option value="read">', $txt['quick_mod_markread'], '</option>
643
						<option value="unread">', $txt['quick_mod_markunread'], '</option>
644
						<option value="remove">', $txt['quick_mod_remove'], '</option>
645
					</select>
646
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
647
					<input type="submit" name="req" value="', $txt['quick_mod_go'], '" class="button you_sure">
648
				</div>';
649
650
	echo '
651
			</div>';
652
653
	if ($context['showCheckboxes'])
654
		echo '
655
		</form>';
656
	}
657
}
658
659
/**
660
 * Template for showing all of a user's drafts
661
 */
662
function template_showDrafts()
663
{
664
	global $context, $scripturl, $txt;
665
666
	echo '
667
		<div class="cat_bar">
668
			<h3 class="catbg">
669
				', $txt['drafts'], ' - ', $context['member']['name'], '
670
			</h3>
671
		</div>', !empty($context['page_index']) ? '
672
		<div class="pagesection">
673
			<div class="pagelinks">' . $context['page_index'] . '</div>
674
		</div>' : '';
675
676
	// No drafts? Just show an informative message.
677
	if (empty($context['drafts']))
678
		echo '
679
		<div class="windowbg centertext">
680
			', $txt['draft_none'], '
681
		</div>';
682
	else
683
	{
684
		// For every draft to be displayed, give it its own div, and show the important details of the draft.
685
		foreach ($context['drafts'] as $draft)
686
		{
687
			echo '
688
		<div class="windowbg">
689
			<div class="counter">', $draft['counter'], '</div>
690
			<div class="topic_details">
691
				<h5>
692
					<strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> &nbsp; &nbsp;';
693
694
			if (!empty($draft['sticky']))
695
				echo '
696
					<span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>';
697
698
			if (!empty($draft['locked']))
699
				echo '
700
					<span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>';
701
702
			echo '
703
				</h5>
704
				<span class="smalltext">&#171;&nbsp;<strong>', $txt['on'], ':</strong> ', $draft['time'], '&nbsp;&#187;</span>
705
			</div><!-- .topic_details -->
706
			<div class="list_posts">
707
				', $draft['body'], '
708
			</div>
709
			<div class="floatright">
710
				<ul class="quickbuttons">
711
						<li><a href="', $scripturl, '?action=post;', (empty($draft['topic']['id']) ? 'board=' . $draft['board']['id'] : 'topic=' . $draft['topic']['id']), '.0;id_draft=', $draft['id_draft'], '"><span class="generic_icons reply_button"></span>', $txt['draft_edit'], '</a></li>
712
						<li><a href="', $scripturl, '?action=profile;u=', $context['member']['id'], ';area=showdrafts;delete=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['draft_remove'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['draft_delete'], '</a></li>
713
				</ul>
714
			</div><!-- .floatright -->
715
		</div><!-- .windowbg -->';
716
		}
717
	}
718
719
	// Show page numbers.
720
	echo '
721
		<div class="pagesection">
722
			<div class="pagelinks">', $context['page_index'], '</div>
723
		</div>';
724
}
725
726
/**
727
 * Template for showing and managing the buddy list.
728
 */
729
function template_editBuddies()
730
{
731
	global $context, $scripturl, $txt;
732
733
	if (!empty($context['saved_successful']))
734
		echo '
735
	<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
736
737
	elseif (!empty($context['saved_failed']))
738
		echo '
739
	<div class="errorbox">', $context['saved_failed'], '</div>';
740
741
	echo '
742
	<div id="edit_buddies">
743
		<div class="cat_bar">
744
			<h3 class="catbg">
745
				<span class="generic_icons people icon"></span> ', $txt['editBuddies'], '
746
			</h3>
747
		</div>
748
		<table class="table_grid">
749
			<thead>
750
				<tr class="title_bar">
751
					<th scope="col" class="quarter_table buddy_link">', $txt['name'], '</th>
752
					<th scope="col" class="buddy_status">', $txt['status'], '</th>';
753
754
	if ($context['can_moderate_forum'])
755
		echo '
756
					<th scope="col" class="buddy_email">', $txt['email'], '</th>';
757
758
	if (!empty($context['custom_pf']))
759
		foreach ($context['custom_pf'] as $column)
760
				echo '
761
					<th scope="col" class="buddy_custom_fields">', $column['label'], '</th>';
762
763
	echo '
764
					<th scope="col" class="buddy_remove">', $txt['remove'], '</th>
765
				</tr>
766
			</thead>
767
			<tbody>';
768
769
	// If they don't have any buddies don't list them!
770
	if (empty($context['buddies']))
771
		echo '
772
				<tr class="windowbg">
773
					<td colspan="', $context['can_moderate_forum'] ? '10' : '9', '">
774
						<strong>', $txt['no_buddies'], '</strong>
775
					</td>
776
				</tr>';
777
778
		// Now loop through each buddy showing info on each.
779
	else
780
	{
781
		foreach ($context['buddies'] as $buddy)
782
		{
783
			echo '
784
				<tr class="windowbg">
785
					<td class="buddy_link">', $buddy['link'], '</td>
786
					<td class="centertext buddy_status">
787
						<a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a>
788
					</td>';
789
790
			if ($buddy['show_email'])
791
				echo '
792
					<td class="buddy_email centertext">
793
						<a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a>
794
					</td>';
795
796
			// Show the custom profile fields for this user.
797
			if (!empty($context['custom_pf']))
798
				foreach ($context['custom_pf'] as $key => $column)
799
					echo '
800
					<td class="lefttext buddy_custom_fields">', $buddy['options'][$key], '</td>';
801
802
			echo '
803
					<td class="centertext buddy_remove">
804
						<a href="', $scripturl, '?action=profile;area=lists;sa=buddies;u=', $context['id_member'], ';remove=', $buddy['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['buddy_remove'], '"></span></a>
805
					</td>
806
				</tr>';
807
		}
808
	}
809
810
	echo '
811
			</tbody>
812
		</table>
813
	</div><!-- #edit_buddies -->';
814
815
	// Add a new buddy?
816
	echo '
817
	<form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=buddies" method="post" accept-charset="', $context['character_set'], '">
818
		<div class="cat_bar">
819
			<h3 class="catbg">', $txt['buddy_add'], '</h3>
820
		</div>
821
		<div class="information">
822
			<dl class="settings">
823
				<dt>
824
					<label for="new_buddy"><strong>', $txt['who_member'], ':</strong></label>
825
				</dt>
826
				<dd>
827
					<input type="text" name="new_buddy" id="new_buddy" size="30">
828
					<input type="submit" value="', $txt['buddy_add_button'], '" class="button floatnone">
829
				</dd>
830
			</dl>
831
		</div>';
832
833
	if (!empty($context['token_check']))
834
		echo '
835
		<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
836
837
	echo '
838
		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
839
	</form>
840
	<script>
841
		var oAddBuddySuggest = new smc_AutoSuggest({
842
			sSelf: \'oAddBuddySuggest\',
843
			sSessionId: smf_session_id,
844
			sSessionVar: smf_session_var,
845
			sSuggestId: \'new_buddy\',
846
			sControlId: \'new_buddy\',
847
			sSearchType: \'member\',
848
			sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
849
			bItemList: false
850
		});
851
	</script>';
852
}
853
854
/**
855
 * Template for showing the ignore list of the current user.
856
 */
857
function template_editIgnoreList()
858
{
859
	global $context, $scripturl, $txt;
860
861
	if (!empty($context['saved_successful']))
862
		echo '
863
	<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
864
865
	elseif (!empty($context['saved_failed']))
866
		echo '
867
	<div class="errorbox">', $context['saved_failed'], '</div>';
868
869
	echo '
870
	<div id="edit_buddies">
871
		<div class="cat_bar">
872
			<h3 class="catbg profile_hd">
873
				', $txt['editIgnoreList'], '
874
			</h3>
875
		</div>
876
		<table class="table_grid">
877
			<thead>
878
				<tr class="title_bar">
879
					<th scope="col" class="quarter_table buddy_link">', $txt['name'], '</th>
880
					<th scope="col" class="buddy_status">', $txt['status'], '</th>';
881
882
	if ($context['can_moderate_forum'])
883
		echo '
884
					<th scope="col" class="buddy_email">', $txt['email'], '</th>';
885
886
	echo '
887
					<th scope="col" class="buddy_remove">', $txt['ignore_remove'], '</th>
888
				</tr>
889
			</thead>
890
			<tbody>';
891
892
	// If they don't have anyone on their ignore list, don't list it!
893
	if (empty($context['ignore_list']))
894
		echo '
895
				<tr class="windowbg">
896
					<td colspan="', $context['can_moderate_forum'] ? '4' : '3', '">
897
						<strong>', $txt['no_ignore'], '</strong>
898
					</td>
899
				</tr>';
900
901
	// Now loop through each buddy showing info on each.
902
	foreach ($context['ignore_list'] as $member)
903
	{
904
		echo '
905
				<tr class="windowbg">
906
					<td class="buddy_link">', $member['link'], '</td>
907
					<td class="centertext buddy_status">
908
						<a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a>
909
					</td>';
910
911
		if ($context['can_moderate_forum'])
912
			echo '
913
					<td class="centertext buddy_email">
914
						<a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a>
915
					</td>';
916
		echo '
917
					<td class="centertext buddy_remove">
918
						<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore;remove=', $member['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['ignore_remove'], '"></span></a>
919
					</td>
920
				</tr>';
921
	}
922
923
	echo '
924
			</tbody>
925
		</table>
926
	</div><!-- #edit_buddies -->';
927
928
	// Add to the ignore list?
929
	echo '
930
	<form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore" method="post" accept-charset="', $context['character_set'], '">
931
		<div class="cat_bar">
932
			<h3 class="catbg">', $txt['ignore_add'], '</h3>
933
		</div>
934
		<div class="information">
935
			<dl class="settings">
936
				<dt>
937
					<label for="new_buddy"><strong>', $txt['who_member'], ':</strong></label>
938
				</dt>
939
				<dd>
940
					<input type="text" name="new_ignore" id="new_ignore" size="30">
941
                    <input type="submit" value="', $txt['ignore_add_button'], '" class="button">
942
				</dd>
943
			</dl>
944
		</div>';
945
946
	if (!empty($context['token_check']))
947
		echo '
948
		<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
949
950
	echo '
951
		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
952
	</form>
953
	<script>
954
		var oAddIgnoreSuggest = new smc_AutoSuggest({
955
			sSelf: \'oAddIgnoreSuggest\',
956
			sSessionId: \'', $context['session_id'], '\',
957
			sSessionVar: \'', $context['session_var'], '\',
958
			sSuggestId: \'new_ignore\',
959
			sControlId: \'new_ignore\',
960
			sSearchType: \'member\',
961
			sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
962
			bItemList: false
963
		});
964
	</script>';
965
}
966
967
/**
968
 * This template shows an admin information on a users IP addresses used and errors attributed to them.
969
 */
970
function template_trackActivity()
971
{
972
	global $context, $scripturl, $txt;
973
974
	// The first table shows IP information about the user.
975
	echo '
976
		<div class="cat_bar">
977
			<h3 class="catbg">', $txt['view_ips_by'], ' ', $context['member']['name'], '</h3>
978
		</div>';
979
980
	// The last IP the user used.
981
	echo '
982
		<div id="tracking" class="windowbg">
983
			<dl class="settings noborder">
984
				<dt>
985
					', $txt['most_recent_ip'], ':
986
					', (empty($context['last_ip2']) ? '' : '<br>
987
					<span class="smalltext">(<a href="' . $scripturl . '?action=helpadmin;help=whytwoip" onclick="return reqOverlayDiv(this.href);">' . $txt['why_two_ip_address'] . '</a>)</span>'), '
988
				</dt>
989
				<dd>
990
					<a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>';
991
992
	// Second address detected?
993
	if (!empty($context['last_ip2']))
994
		echo '
995
					, <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>';
996
997
	echo '
998
				</dd>';
999
1000
	// Lists of IP addresses used in messages / error messages.
1001
	echo '
1002
				<dt>', $txt['ips_in_messages'], ':</dt>
1003
				<dd>
1004
					', (count($context['ips']) > 0 ? implode(', ', $context['ips']) : '(' . $txt['none'] . ')'), '
1005
				</dd>
1006
				<dt>', $txt['ips_in_errors'], ':</dt>
1007
				<dd>
1008
					', (count($context['error_ips']) > 0 ? implode(', ', $context['error_ips']) : '(' . $txt['none'] . ')'), '
1009
				</dd>';
1010
1011
	// List any members that have used the same IP addresses as the current member.
1012
	echo '
1013
				<dt>', $txt['members_in_range'], ':</dt>
1014
				<dd>
1015
					', (count($context['members_in_range']) > 0 ? implode(', ', $context['members_in_range']) : '(' . $txt['none'] . ')'), '
1016
				</dd>
1017
			</dl>
1018
		</div><!-- #tracking -->';
1019
1020
	// Show the track user list.
1021
	template_show_list('track_user_list');
1022
}
1023
1024
/**
1025
 * The template for trackIP, allowing the admin to see where/who a certain IP has been used.
1026
 */
1027
function template_trackIP()
1028
{
1029
	global $context, $txt;
1030
1031
	// This function always defaults to the last IP used by a member but can be set to track any IP.
1032
	// The first table in the template gives an input box to allow the admin to enter another IP to track.
1033
	echo '
1034
		<div class="cat_bar">
1035
			<h3 class="catbg">', $txt['trackIP'], '</h3>
1036
		</div>
1037
		<div class="windowbg">
1038
			<form action="', $context['base_url'], '" method="post" accept-charset="', $context['character_set'], '">
1039
				<dl class="settings">
1040
					<dt>
1041
						<label for="searchip"><strong>', $txt['enter_ip'], ':</strong></label>
1042
					</dt>
1043
					<dd>
1044
						<input type="text" name="searchip" value="', $context['ip'], '">
1045
					</dd>
1046
				</dl>
1047
				<input type="submit" value="', $txt['trackIP'], '" class="button">
1048
			</form>
1049
		</div>
1050
		<br>';
1051
1052
	// The table inbetween the first and second table shows links to the whois server for every region.
1053
	if ($context['single_ip'])
1054
	{
1055
		echo '
1056
		<div class="cat_bar">
1057
			<h3 class="catbg">', $txt['whois_title'], ' ', $context['ip'], '</h3>
1058
		</div>
1059
		<div class="windowbg">';
1060
1061
		foreach ($context['whois_servers'] as $server)
1062
			echo '
1063
			<a href="', $server['url'], '" target="_blank" rel="noopener"', '>', $server['name'], '</a><br>';
1064
		echo '
1065
		</div>
1066
		<br>';
1067
	}
1068
1069
	// The second table lists all the members who have been logged as using this IP address.
1070
	echo '
1071
		<div class="cat_bar">
1072
			<h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3>
1073
		</div>';
1074
1075
	if (empty($context['ips']))
1076
		echo '
1077
		<p class="windowbg description">
1078
			<em>', $txt['no_members_from_ip'], '</em>
1079
		</p>';
1080
1081
	else
1082
	{
1083
		echo '
1084
		<table class="table_grid">
1085
			<thead>
1086
				<tr class="title_bar">
1087
					<th scope="col">', $txt['ip_address'], '</th>
1088
					<th scope="col">', $txt['display_name'], '</th>
1089
				</tr>
1090
			</thead>
1091
			<tbody>';
1092
1093
		// Loop through each of the members and display them.
1094
		foreach ($context['ips'] as $ip => $memberlist)
1095
			echo '
1096
				<tr class="windowbg">
1097
					<td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td>
1098
					<td>', implode(', ', $memberlist), '</td>
1099
				</tr>';
1100
1101
		echo '
1102
			</tbody>
1103
		</table>';
1104
	}
1105
1106
	echo '
1107
		<br>';
1108
1109
	template_show_list('track_message_list');
1110
1111
	echo '<br>';
1112
1113
	template_show_list('track_user_list');
1114
1115
	// 3rd party integrations may have added additional tracking.
1116
	if (!empty($context['additional_track_lists']))
1117
	{
1118
		foreach ($context['additional_track_lists'] as $list)
1119
		{
1120
			echo '<br>';
1121
1122
			template_show_list($list);
1123
		}
1124
	}
1125
}
1126
1127
/**
1128
 * This template shows an admin which permissions a user have and which group(s) give them each permission.
1129
 */
1130
function template_showPermissions()
1131
{
1132
	global $context, $scripturl, $txt;
1133
1134
	echo '
1135
		<div class="cat_bar">
1136
			<h3 class="catbg profile_hd">
1137
				', $txt['showPermissions'], '
1138
			</h3>
1139
		</div>';
1140
1141
	if ($context['member']['has_all_permissions'])
1142
		echo '
1143
		<div class="information">', $txt['showPermissions_all'], '</div>';
1144
1145
	else
1146
	{
1147
		echo '
1148
		<div class="information">',$txt['showPermissions_help'], '</div>
1149
		<div id="permissions" class="flow_hidden">';
1150
1151
		if (!empty($context['no_access_boards']))
1152
		{
1153
			echo '
1154
			<div class="cat_bar">
1155
				<h3 class="catbg">', $txt['showPermissions_restricted_boards'], '</h3>
1156
			</div>
1157
			<div class="windowbg smalltext">
1158
				', $txt['showPermissions_restricted_boards_desc'], ':<br>';
1159
1160
			foreach ($context['no_access_boards'] as $no_access_board)
1161
				echo '
1162
				<a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', ';
1163
			echo '
1164
			</div>';
1165
		}
1166
1167
		// General Permissions section.
1168
		echo '
1169
			<div class="tborder">
1170
				<div class="cat_bar">
1171
					<h3 class="catbg">', $txt['showPermissions_general'], '</h3>
1172
				</div>';
1173
		if (!empty($context['member']['permissions']['general']))
1174
		{
1175
			echo '
1176
				<table class="table_grid">
1177
					<thead>
1178
						<tr class="title_bar">
1179
							<th class="lefttext half_table">', $txt['showPermissions_permission'], '</th>
1180
							<th class="lefttext half_table">', $txt['showPermissions_status'], '</th>
1181
						</tr>
1182
					</thead>
1183
					<tbody>';
1184
1185
			foreach ($context['member']['permissions']['general'] as $permission)
1186
			{
1187
				echo '
1188
						<tr class="windowbg">
1189
							<td title="', $permission['id'], '">
1190
								', $permission['is_denied'] ? '<del>' . $permission['name'] . '</del>' : $permission['name'], '
1191
							</td>
1192
							<td class="smalltext">';
1193
1194
				if ($permission['is_denied'])
1195
					echo '
1196
								<span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>';
1197
				else
1198
					echo '
1199
								', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']);
1200
1201
				echo '
1202
							</td>
1203
						</tr>';
1204
			}
1205
			echo '
1206
					</tbody>
1207
				</table>
1208
			</div><!-- .tborder -->
1209
			<br>';
1210
		}
1211
		else
1212
			echo '
1213
			<p class="windowbg">', $txt['showPermissions_none_general'], '</p>';
1214
1215
		// Board permission section.
1216
		echo '
1217
			<form action="' . $scripturl . '?action=profile;u=', $context['id_member'], ';area=permissions#board_permissions" method="post" accept-charset="', $context['character_set'], '">
1218
				<div class="cat_bar">
1219
					<h3 class="catbg">
1220
						<a id="board_permissions"></a>', $txt['showPermissions_select'], ':
1221
						<select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();">
1222
							<option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], '</option>';
1223
1224
		if (!empty($context['boards']))
1225
			echo '
1226
							<option value="" disabled>---------------------------</option>';
1227
1228
		// Fill the box with any local permission boards.
1229
		foreach ($context['boards'] as $board)
1230
			echo '
1231
							<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>';
1232
1233
		echo '
1234
						</select>
1235
					</h3>
1236
				</div><!-- .cat_bar -->
1237
			</form>';
1238
1239
		if (!empty($context['member']['permissions']['board']))
1240
		{
1241
			echo '
1242
			<table class="table_grid">
1243
				<thead>
1244
					<tr class="title_bar">
1245
						<th class="lefttext half_table">', $txt['showPermissions_permission'], '</th>
1246
						<th class="lefttext half_table">', $txt['showPermissions_status'], '</th>
1247
					</tr>
1248
				</thead>
1249
				<tbody>';
1250
1251
			foreach ($context['member']['permissions']['board'] as $permission)
1252
			{
1253
				echo '
1254
					<tr class="windowbg">
1255
						<td title="', $permission['id'], '">
1256
							', $permission['is_denied'] ? '<del>' . $permission['name'] . '</del>' : $permission['name'], '
1257
						</td>
1258
						<td class="smalltext">';
1259
1260
				if ($permission['is_denied'])
1261
					echo '
1262
							<span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>';
1263
1264
				else
1265
					echo '
1266
							', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']);
1267
1268
				echo '
1269
						</td>
1270
					</tr>';
1271
			}
1272
			echo '
1273
				</tbody>
1274
			</table>';
1275
		}
1276
		else
1277
			echo '
1278
			<p class="windowbg">', $txt['showPermissions_none_board'], '</p>';
1279
	echo '
1280
		</div><!-- #permissions -->';
1281
	}
1282
}
1283
1284
/**
1285
 * Template for user statistics, showing graphs and the like.
1286
 */
1287
function template_statPanel()
1288
{
1289
	global $context, $txt;
1290
1291
	// First, show a few text statistics such as post/topic count.
1292
	echo '
1293
	<div id="profileview" class="roundframe noup">
1294
		<div id="generalstats">
1295
			<dl class="stats">';
1296
1297
	foreach ($context['text_stats'] as $key => $stat)
1298
	{
1299
		echo '
1300
				<dt>', $txt['statPanel_' . $key], '</dt>';
1301
1302
		if (!empty($stat['url']))
1303
			echo '
1304
				<dd><a href="', $stat['url'], '">', $stat['text'], '</a></dd>';
1305
		else
1306
			echo '
1307
				<dd>', $stat['text'], '</dd>';
1308
	}
1309
1310
	echo '
1311
			</dl>
1312
		</div>';
1313
1314
	// This next section draws a graph showing what times of day they post the most.
1315
	echo '
1316
		<div id="activitytime" class="flow_hidden">
1317
			<div class="title_bar">
1318
				<h3 class="titlebg">
1319
					<span class="generic_icons history"></span> ', $txt['statPanel_activityTime'], '
1320
				</h3>
1321
			</div>';
1322
1323
	// If they haven't post at all, don't draw the graph.
1324
	if (empty($context['posts_by_time']))
1325
		echo '
1326
			<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1327
1328
	// Otherwise do!
1329
	else
1330
	{
1331
		echo '
1332
			<ul class="activity_stats flow_hidden">';
1333
1334
		// The labels.
1335
		foreach ($context['posts_by_time'] as $time_of_day)
1336
			echo '
1337
				<li>
1338
					<div class="generic_bar vertical">
1339
						<div class="bar" style="height: ', (int) $time_of_day['relative_percent'], '%;">
1340
							<span>', sprintf($txt['statPanel_activityTime_posts'], $time_of_day['posts'], $time_of_day['posts_percent']), '</span>
1341
						</div>
1342
					</div>
1343
					<span class="stats_hour">', $time_of_day['hour_format'], '</span>
1344
				</li>';
1345
1346
		echo '
1347
			</ul>';
1348
	}
1349
1350
	echo '
1351
		</div><!-- #activitytime -->';
1352
1353
	// Two columns with the most popular boards by posts and activity (activity = users posts / total posts).
1354
	echo '
1355
		<div class="flow_hidden">
1356
			<div class="half_content">
1357
				<div class="title_bar">
1358
					<h3 class="titlebg">
1359
						<span class="generic_icons replies"></span> ', $txt['statPanel_topBoards'], '
1360
					</h3>
1361
				</div>';
1362
1363
	if (empty($context['popular_boards']))
1364
		echo '
1365
				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1366
1367
	else
1368
	{
1369
		echo '
1370
				<dl class="stats">';
1371
1372
		// Draw a bar for every board.
1373
		foreach ($context['popular_boards'] as $board)
1374
		{
1375
			echo '
1376
					<dt>', $board['link'], '</dt>
1377
					<dd>
1378
						<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']), '">
1379
							', sprintf($txt['statPanel_topBoards_memberposts'], $board['posts'], $board['total_posts_member'], $board['posts_percent']), '
1380
						</div>
1381
						', empty($context['hide_num_posts']) ? $board['posts'] : '', '
1382
					</dd>';
1383
		}
1384
1385
		echo '
1386
				</dl>';
1387
	}
1388
	echo '
1389
			</div><!-- .half_content -->
1390
			<div class="half_content">
1391
				<div class="title_bar">
1392
					<h3 class="titlebg">
1393
						<span class="generic_icons replies"></span> ', $txt['statPanel_topBoardsActivity'], '
1394
					</h3>
1395
				</div>';
1396
1397
	if (empty($context['board_activity']))
1398
		echo '
1399
				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1400
	else
1401
	{
1402
		echo '
1403
				<dl class="stats">';
1404
1405
		// Draw a bar for every board.
1406
		foreach ($context['board_activity'] as $activity)
1407
		{
1408
			echo '
1409
					<dt>', $activity['link'], '</dt>
1410
					<dd>
1411
						<div class="profile_pie" style="background-position: -', ((int) ($activity['percent'] / 5) * 20), 'px 0;" title="', sprintf($txt['statPanel_topBoards_posts'], $activity['posts'], $activity['total_posts'], $activity['posts_percent']), '">
1412
							', sprintf($txt['statPanel_topBoards_posts'], $activity['posts'], $activity['total_posts'], $activity['posts_percent']), '
1413
						</div>
1414
						', $activity['percent'], '%
1415
					</dd>';
1416
		}
1417
1418
		echo '
1419
				</dl>';
1420
	}
1421
	echo '
1422
			</div><!-- .half_content -->
1423
		</div><!-- .flow_hidden -->';
1424
1425
	echo '
1426
	</div><!-- #profileview -->';
1427
}
1428
1429
/**
1430
 * Template for editing profile options.
1431
 */
1432
function template_edit_options()
1433
{
1434
	global $context, $scripturl, $txt, $modSettings;
1435
1436
	// The main header!
1437
	// because some browsers ignore autocomplete=off and fill username in display name and/ or email field, fake them out.
1438
	$url = !empty($context['profile_custom_submit_url']) ? $context['profile_custom_submit_url'] : $scripturl . '?action=profile;area=' . $context['menu_item_selected'] . ';u=' . $context['id_member'];
1439
	$url = $context['require_password'] && !empty($modSettings['force_ssl']) ? strtr($url, array('http://' => 'https://')) : $url;
1440
1441
	echo '
1442
		<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"' : ''), '>
1443
			<div style="position:absolute; left:-3000px;">
1444
				<input type="text" id="autocompleteFakeName">
1445
				<input type="password" id="autocompleteFakePassword">
1446
			</div>
1447
			<div class="cat_bar">
1448
				<h3 class="catbg profile_hd">';
1449
1450
		// Don't say "Profile" if this isn't the profile...
1451
		if (!empty($context['profile_header_text']))
1452
			echo '
1453
					', $context['profile_header_text'];
1454
		else
1455
			echo '
1456
					', $txt['profile'];
1457
1458
		echo '
1459
				</h3>
1460
			</div>';
1461
1462
	// Have we some description?
1463
	if ($context['page_desc'])
1464
		echo '
1465
			<p class="information">', $context['page_desc'], '</p>';
1466
1467
	echo '
1468
			<div class="roundframe">';
1469
1470
	// Any bits at the start?
1471
	if (!empty($context['profile_prehtml']))
1472
		echo '
1473
				<div>', $context['profile_prehtml'], '</div>';
1474
1475
	if (!empty($context['profile_fields']))
1476
		echo '
1477
				<dl class="settings">';
1478
1479
	// Start the big old loop 'of love.
1480
	$lastItem = 'hr';
1481
	foreach ($context['profile_fields'] as $key => $field)
1482
	{
1483
		// We add a little hack to be sure we never get more than one hr in a row!
1484
		if ($lastItem == 'hr' && $field['type'] == 'hr')
1485
			continue;
1486
1487
		$lastItem = $field['type'];
1488
		if ($field['type'] == 'hr')
1489
			echo '
1490
				</dl>
1491
				<hr>
1492
				<dl class="settings">';
1493
1494
		elseif ($field['type'] == 'callback')
1495
		{
1496
			if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func']))
1497
			{
1498
				$callback_func = 'template_profile_' . $field['callback_func'];
1499
				$callback_func();
1500
			}
1501
		}
1502
		else
1503
		{
1504
			echo '
1505
					<dt>
1506
						<strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>';
1507
1508
			// Does it have any subtext to show?
1509
			if (!empty($field['subtext']))
1510
				echo '
1511
						<br>
1512
						<span class="smalltext">', $field['subtext'], '</span>';
1513
1514
			echo '
1515
					</dt>
1516
					<dd>';
1517
1518
			// Want to put something infront of the box?
1519
			if (!empty($field['preinput']))
1520
				echo '
1521
						', $field['preinput'];
1522
1523
			// What type of data are we showing?
1524
			if ($field['type'] == 'label')
1525
				echo '
1526
						', $field['value'];
1527
1528
			// Maybe it's a text box - very likely!
1529
			elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url')))
1530
			{
1531
				if ($field['type'] == 'int' || $field['type'] == 'float')
1532
					$type = 'number';
1533
				else
1534
					$type = $field['type'];
1535
				$step = $field['type'] == 'float' ? ' step="0.1"' : '';
1536
1537
1538
				echo '
1539
						<input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' ', $step, '>';
1540
			}
1541
			// You "checking" me out? ;)
1542
			elseif ($field['type'] == 'check')
1543
				echo '
1544
						<input type="hidden" name="', $key, '" value="0">
1545
						<input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" ', $field['input_attr'], '>';
1546
1547
			// Always fun - select boxes!
1548
			elseif ($field['type'] == 'select')
1549
			{
1550
				echo '
1551
						<select name="', $key, '" id="', $key, '">';
1552
1553
				if (isset($field['options']))
1554
				{
1555
					// Is this some code to generate the options?
1556
					if (!is_array($field['options']))
1557
						$field['options'] = $field['options']();
1558
1559
					// Assuming we now have some!
1560
					if (is_array($field['options']))
1561
						foreach ($field['options'] as $value => $name)
1562
							echo '
1563
							<option', is_numeric($value) ? ' value="" disabled' : ' value="' . $value . '"', $value === $field['value'] ? ' selected' : '', '>', $name, '</option>';
1564
				}
1565
1566
				echo '
1567
						</select>';
1568
			}
1569
1570
			// Something to end with?
1571
			if (!empty($field['postinput']))
1572
				echo '
1573
						', $field['postinput'];
1574
1575
			echo '
1576
					</dd>';
1577
		}
1578
	}
1579
1580
	if (!empty($context['profile_fields']))
1581
		echo '
1582
				</dl>';
1583
1584
	// Are there any custom profile fields - if so print them!
1585
	if (!empty($context['custom_fields']))
1586
	{
1587
		if ($lastItem != 'hr')
1588
			echo '
1589
				<hr>';
1590
1591
		echo '
1592
				<dl class="settings">';
1593
1594
		foreach ($context['custom_fields'] as $field)
1595
			echo '
1596
					<dt>
1597
						<strong>', $field['name'], ': </strong><br>
1598
						<span class="smalltext">', $field['desc'], '</span>
1599
					</dt>
1600
					<dd>
1601
						', $field['input_html'], '
1602
					</dd>';
1603
1604
		echo '
1605
				</dl>';
1606
	}
1607
1608
	// Any closing HTML?
1609
	if (!empty($context['profile_posthtml']))
1610
		echo '
1611
				<div>', $context['profile_posthtml'], '</div>';
1612
1613
	// Only show the password box if it's actually needed.
1614
	if ($context['require_password'])
1615
		echo '
1616
				<dl class="settings">
1617
					<dt>
1618
						<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br>
1619
						<span class="smalltext">', $txt['required_security_reasons'], '</span>
1620
					</dt>
1621
					<dd>
1622
						<input type="password" name="oldpasswrd" id="oldpasswrd" size="20">
1623
					</dd>
1624
				</dl>';
1625
1626
	// The button shouldn't say "Change profile" unless we're changing the profile...
1627
	if (!empty($context['submit_button_text']))
1628
		echo '
1629
				<input type="submit" name="save" value="', $context['submit_button_text'], '" class="button floatright">';
1630
	else
1631
		echo '
1632
				<input type="submit" name="save" value="', $txt['change_profile'], '" class="button floatright">';
1633
1634
	if (!empty($context['token_check']))
1635
		echo '
1636
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
1637
1638
	echo '
1639
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1640
				<input type="hidden" name="u" value="', $context['id_member'], '">
1641
				<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
1642
			</div><!-- .roundframe -->
1643
		</form>';
1644
1645
	// Any final spellchecking stuff?
1646
	if (!empty($context['show_spellchecking']))
1647
		echo '
1648
		<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>';
1649
}
1650
1651
/**
1652
 * Personal Message settings.
1653
 */
1654
function template_profile_pm_settings()
1655
{
1656
	global $context, $modSettings, $txt;
1657
1658
	echo '
1659
					<dt>
1660
						<label for="pm_prefs">', $txt['pm_display_mode'], ':</label>
1661
					</dt>
1662
					<dd>
1663
						<select name="pm_prefs" id="pm_prefs">
1664
							<option value="0"', $context['display_mode'] == 0 ? ' selected' : '', '>', $txt['pm_display_mode_all'], '</option>
1665
							<option value="1"', $context['display_mode'] == 1 ? ' selected' : '', '>', $txt['pm_display_mode_one'], '</option>
1666
							<option value="2"', $context['display_mode'] == 2 ? ' selected' : '', '>', $txt['pm_display_mode_linked'], '</option>
1667
						</select>
1668
					</dd>
1669
					<dt>
1670
						<label for="view_newest_pm_first">', $txt['recent_pms_at_top'], '</label>
1671
					</dt>
1672
					<dd>
1673
						<input type="hidden" name="default_options[view_newest_pm_first]" value="0">
1674
						<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' : '', '>
1675
					</dd>
1676
				</dl>
1677
				<hr>
1678
				<dl class="settings">
1679
					<dt>
1680
						<label for="pm_receive_from">', $txt['pm_receive_from'], '</label>
1681
					</dt>
1682
					<dd>
1683
						<select name="pm_receive_from" id="pm_receive_from">
1684
							<option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>';
1685
1686
	if (!empty($modSettings['enable_buddylist']))
1687
		echo '
1688
							<option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option>
1689
							<option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>';
1690
1691
	echo '
1692
							<option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option>
1693
						</select>
1694
					</dd>
1695
					<dt>
1696
						<label for="popup_messages">', $txt['popup_messages'], '</label>
1697
					</dt>
1698
					<dd>
1699
						<input type="hidden" name="default_options[popup_messages]" value="0">
1700
						<input type="checkbox" name="default_options[popup_messages]" id="popup_messages" value="1"', !empty($context['member']['options']['popup_messages']) ? ' checked' : '', '>
1701
					</dd>
1702
				</dl>
1703
				<hr>
1704
				<dl class="settings">
1705
					<dt>
1706
						<label for="pm_remove_inbox_label">', $txt['pm_remove_inbox_label'], '</label>
1707
					</dt>
1708
					<dd>
1709
						<input type="hidden" name="default_options[pm_remove_inbox_label]" value="0">
1710
						<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' : '', '>
1711
					</dd>';
1712
1713
}
1714
1715
/**
1716
 * Template for showing theme settings. Note: template_options() actually adds the theme specific options.
1717
 */
1718
function template_profile_theme_settings()
1719
{
1720
	global $context, $modSettings;
1721
1722
	$skeys = array_keys($context['theme_options']);
1723
	$first_option_key = array_shift($skeys);
1724
	$titled_section = false;
1725
1726
	foreach ($context['theme_options'] as $i => $setting)
1727
	{
1728
		// Just spit out separators and move on
1729
		if (empty($setting) || !is_array($setting))
1730
		{
1731
			// Insert a separator (unless this is the first item in the list)
1732
			if ($i !== $first_option_key)
1733
				echo '
1734
				</dl>
1735
				<hr>
1736
				<dl class="settings">';
1737
1738
			// Should we give a name to this section?
1739
			if (is_string($setting) && !empty($setting))
1740
			{
1741
				$titled_section = true;
1742
				echo '
1743
					<dt><strong>' . $setting . '</strong></dt>
1744
					<dd></dd>';
1745
			}
1746
			else
1747
				$titled_section = false;
1748
1749
			continue;
1750
		}
1751
1752
		// Is this disabled?
1753
		if (isset($setting['enabled']) && $setting['enabled'] === false)
1754
			continue;
1755
1756
		// Some of these may not be set...  Set to defaults here
1757
		$opts = array('calendar_start_day', 'topics_per_page', 'messages_per_page', 'display_quick_mod');
1758
		if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']]))
1759
			$context['member']['options'][$setting['id']] = 0;
1760
1761
		if (!isset($setting['type']) || $setting['type'] == 'bool')
1762
			$setting['type'] = 'checkbox';
1763
1764
		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
1765
			$setting['type'] = 'number';
1766
1767
		elseif ($setting['type'] == 'string')
1768
			$setting['type'] = 'text';
1769
1770
		if (isset($setting['options']))
1771
			$setting['type'] = 'list';
1772
1773
		echo '
1774
					<dt>
1775
						<label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>';
1776
1777
		if (isset($setting['description']))
1778
			echo '
1779
						<br>
1780
						<span class="smalltext">', $setting['description'], '</span>';
1781
		echo '
1782
					</dt>
1783
					<dd>';
1784
1785
		// Display checkbox options
1786
		if ($setting['type'] == 'checkbox')
1787
			echo '
1788
						<input type="hidden" name="default_options[' . $setting['id'] . ']" value="0">
1789
						<input type="checkbox" name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', !empty($context['member']['options'][$setting['id']]) ? ' checked' : '', ' value="1">';
1790
1791
		// How about selection lists, we all love them
1792
		elseif ($setting['type'] == 'list')
1793
		{
1794
			echo '
1795
						<select name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', '>';
1796
1797
			foreach ($setting['options'] as $value => $label)
1798
				echo '
1799
							<option value="', $value, '"', $value == $context['member']['options'][$setting['id']] ? ' selected' : '', '>', $label, '</option>';
1800
1801
			echo '
1802
						</select>';
1803
		}
1804
		// A textbox it is then
1805
		else
1806
		{
1807
			if (isset($setting['type']) && $setting['type'] == 'number')
1808
			{
1809
				$min = isset($setting['min']) ? ' min="' . $setting['min'] . '"' : ' min="0"';
1810
				$max = isset($setting['max']) ? ' max="' . $setting['max'] . '"' : '';
1811
				$step = isset($setting['step']) ? ' step="' . $setting['step'] . '"' : '';
1812
1813
				echo '
1814
						<input type="number"', $min . $max . $step;
1815
			}
1816
			elseif (isset($setting['type']) && $setting['type'] == 'url')
1817
				echo'
1818
						<input type="url"';
1819
1820
			else
1821
				echo '
1822
						<input type="text"';
1823
1824
			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"' : '', '>';
1825
		}
1826
1827
		// end of this defintion
1828
		echo '
1829
					</dd>';
1830
	}
1831
}
1832
1833
/**
1834
 * The template for configuring alerts
1835
 */
1836
function template_alert_configuration()
1837
{
1838
	global $context, $txt, $scripturl, $modSettings;
1839
1840
	echo '
1841
		<div class="cat_bar">
1842
			<h3 class="catbg">
1843
				', $txt['alert_prefs'], '
1844
			</h3>
1845
		</div>
1846
		<p class="information">
1847
			', (empty($context['description']) ? $txt['alert_prefs_desc'] : $context['description']), '
1848
		</p>
1849
		<form action="', $scripturl, '?', $context['action'], '" method="post" accept-charset="', $context['character_set'], '" id="notify_options" class="flow_hidden">
1850
			<div class="cat_bar">
1851
				<h3 class="catbg">
1852
					', $txt['notification_general'], '
1853
				</h3>
1854
			</div>
1855
			<div class="windowbg">
1856
				<dl class="settings">';
1857
1858
	// Allow notification on announcements to be disabled?
1859
	if (!empty($modSettings['allow_disableAnnounce']))
1860
		echo '
1861
					<dt>
1862
						<label for="notify_announcements">', $txt['notify_important_email'], '</label>
1863
					</dt>
1864
					<dd>
1865
						<input type="hidden" name="notify_announcements" value="0">
1866
						<input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', '>
1867
					</dd>';
1868
1869
	if (!empty($modSettings['enable_ajax_alerts']))
1870
		echo '
1871
					<dt>
1872
						<label for="notify_send_body">', $txt['notify_alert_timeout'], '</label>
1873
					</dt>
1874
					<dd>
1875
						<input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '">
1876
					</dd>';
1877
1878
	echo '
1879
				</dl>
1880
			</div><!-- .windowbg -->
1881
			<div class="cat_bar">
1882
				<h3 class="catbg">
1883
					', $txt['notify_what_how'], '
1884
				</h3>
1885
			</div>
1886
			<table class="table_grid">';
1887
1888
	foreach ($context['alert_types'] as $alert_group => $alerts)
1889
	{
1890
		echo '
1891
				<tr class="title_bar">
1892
					<th>', $txt['alert_group_' . $alert_group], '</th>
1893
					<th>', $txt['receive_alert'], '</th>
1894
					<th>', $txt['receive_mail'], '</th>
1895
				</tr>
1896
				<tr class="windowbg">';
1897
1898
		if (isset($context['alert_group_options'][$alert_group]))
1899
		{
1900
			foreach ($context['alert_group_options'][$alert_group] as $opts)
1901
			{
1902
				echo '
1903
				<tr class="windowbg">
1904
					<td colspan="3">';
1905
1906
				$label = $txt['alert_opt_' . $opts[1]];
1907
				$label_pos = isset($opts['label']) ? $opts['label'] : '';
1908
				if ($label_pos == 'before')
1909
					echo '
1910
						<label for="opt_', $opts[1], '">', $label, '</label>';
1911
1912
				$this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0;
1913
				switch ($opts[0])
1914
				{
1915
					case 'check':
1916
						echo '
1917
						<input type="checkbox" name="opt_', $opts[1], '" id="opt_', $opts[1], '"', $this_value ? ' checked' : '', '>';
1918
						break;
1919
1920
					case 'select':
1921
						echo '
1922
						<select name="opt_', $opts[1], '" id="opt_', $opts[1], '">';
1923
1924
						foreach ($opts['opts'] as $k => $v)
1925
							echo '
1926
							<option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>';
1927
						echo '
1928
						</select>';
1929
						break;
1930
				}
1931
1932
				if ($label_pos == 'after')
1933
					echo '
1934
						<label for="opt_', $opts[1], '">', $label, '</label>';
1935
1936
				echo '
1937
					</td>
1938
				</tr>';
1939
			}
1940
		}
1941
1942
		foreach ($alerts as $alert_id => $alert_details)
1943
		{
1944
			echo '
1945
				<tr class="windowbg">
1946
					<td>
1947
						', $txt['alert_' . $alert_id], isset($alert_details['help']) ? '<a href="' . $scripturl . '?action=helpadmin;help=' . $alert_details['help'] . '" onclick="return reqOverlayDiv(this.href);" class="help floatright"><span class="generic_icons help" title="' . $txt['help'] . '"></span></a>' : '', '
1948
					</td>';
1949
1950
			foreach ($context['alert_bits'] as $type => $bitmask)
1951
			{
1952
				echo '
1953
					<td class="centercol">';
1954
1955
				$this_value = isset($context['alert_prefs'][$alert_id]) ? $context['alert_prefs'][$alert_id] : 0;
1956
				switch ($alert_details[$type])
1957
				{
1958
					case 'always':
1959
						echo '
1960
						<input type="checkbox" checked disabled>';
1961
						break;
1962
					case 'yes':
1963
						echo '
1964
						<input type="checkbox" name="', $type, '_', $alert_id, '"', ($this_value & $bitmask) ? ' checked' : '', '>';
1965
						break;
1966
					case 'never':
1967
						echo '
1968
						<input type="checkbox" disabled>';
1969
						break;
1970
				}
1971
				echo '
1972
					</td>';
1973
			}
1974
1975
			echo '
1976
				</tr>';
1977
		}
1978
	}
1979
1980
	echo '
1981
			</table>
1982
			<br>
1983
			<div>
1984
				<input id="notify_submit" type="submit" name="notify_submit" value="', $txt['notify_save'], '" class="button">
1985
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">', !empty($context['token_check']) ? '
1986
				<input type="hidden" name="' . $context[$context['token_check'] . '_token_var'] . '" value="' . $context[$context['token_check'] . '_token'] . '">' : '', '
1987
				<input type="hidden" name="u" value="', $context['id_member'], '">
1988
				<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
1989
			</div>
1990
		</form>
1991
		<br>';
1992
}
1993
1994
/**
1995
 * Template for showing which topics you're subscribed to
1996
 */
1997
function template_alert_notifications_topics()
1998
{
1999
	global $txt;
2000
2001
	// The main containing header.
2002
	echo '
2003
		<div class="cat_bar">
2004
			<h3 class="catbg">
2005
				', $txt['watched_topics'], '
2006
			</h3>
2007
		</div>
2008
		<p class="information">', $txt['watched_topics_desc'], '</p>
2009
		<br>';
2010
2011
	template_show_list('topic_notification_list');
2012
}
2013
2014
/**
2015
 * Template for showing which boards you're subscribed to
2016
 */
2017
function template_alert_notifications_boards()
2018
{
2019
	global $txt;
2020
2021
	echo '
2022
		<div class="cat_bar">
2023
			<h3 class="catbg">
2024
				', $txt['watched_boards'], '
2025
			</h3>
2026
		</div>
2027
		<p class="information">', $txt['watched_boards_desc'], '</p>
2028
		<br>';
2029
2030
	template_show_list('board_notification_list');
2031
}
2032
2033
/**
2034
 * Template for choosing group membership.
2035
 */
2036
function template_groupMembership()
2037
{
2038
	global $context, $scripturl, $txt;
2039
2040
	// The main containing header.
2041
	echo '
2042
		<form action="', $scripturl, '?action=profile;area=groupmembership;save" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
2043
			<div class="cat_bar">
2044
				<h3 class="catbg profile_hd">
2045
					', $txt['profile'], '
2046
				</h3>
2047
			</div>
2048
			<p class="information">', $txt['groupMembership_info'], '</p>';
2049
2050
	// Do we have an update message?
2051
	if (!empty($context['update_message']))
2052
		echo '
2053
			<div class="infobox">
2054
				', $context['update_message'], '.
2055
			</div>';
2056
2057
	echo '
2058
			<div id="groups">';
2059
2060
	// Requesting membership to a group?
2061
	if (!empty($context['group_request']))
2062
	{
2063
		echo '
2064
			<div class="groupmembership">
2065
				<div class="cat_bar">
2066
					<h3 class="catbg">', $txt['request_group_membership'], '</h3>
2067
				</div>
2068
				<div class="roundframe">
2069
					', $txt['request_group_membership_desc'], ':
2070
					<textarea name="reason" rows="4"></textarea>
2071
					<div class="righttext">
2072
						<input type="hidden" name="gid" value="', $context['group_request']['id'], '">
2073
						<input type="submit" name="req" value="', $txt['submit_request'], '" class="button">
2074
						</div>
2075
					</div>
2076
				</div><!-- .groupmembership -->';
2077
	}
2078
	else
2079
	{
2080
		echo '
2081
				<div class="title_bar">
2082
					<h3 class="titlebg">', $txt['current_membergroups'], '</h3>
2083
				</div>';
2084
2085
		foreach ($context['groups']['member'] as $group)
2086
		{
2087
			echo '
2088
				<div class="windowbg" id="primdiv_', $group['id'], '">';
2089
2090
				if ($context['can_edit_primary'])
2091
					echo '
2092
					<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', '>';
2093
2094
				echo '
2095
					<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>';
2096
2097
				// Can they leave their group?
2098
				if ($group['can_leave'])
2099
					echo '
2100
					<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>';
2101
2102
				echo '
2103
				</div><!-- .windowbg -->';
2104
		}
2105
2106
		if ($context['can_edit_primary'])
2107
			echo '
2108
				<div class="padding righttext">
2109
					<input type="submit" value="', $txt['make_primary'], '" class="button">
2110
				</div>';
2111
2112
		// Any groups they can join?
2113
		if (!empty($context['groups']['available']))
2114
		{
2115
			echo '
2116
				<div class="title_bar">
2117
					<h3 class="titlebg">', $txt['available_groups'], '</h3>
2118
				</div>';
2119
2120
			foreach ($context['groups']['available'] as $group)
2121
			{
2122
				echo '
2123
				<div class="windowbg">
2124
					<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>' : ''), '';
2125
2126
				if ($group['type'] == 3)
2127
					echo '
2128
					<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>';
2129
2130
				elseif ($group['type'] == 2 && $group['pending'])
2131
					echo '
2132
					<span class="floatright">', $txt['approval_pending'], '</span>';
2133
2134
				elseif ($group['type'] == 2)
2135
					echo '
2136
					<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>';
2137
2138
				echo '
2139
				</div><!-- .windowbg -->';
2140
			}
2141
		}
2142
2143
		// Javascript for the selector stuff.
2144
		echo '
2145
				<script>
2146
					var prevClass = "";
2147
					var prevDiv = "";
2148
					function highlightSelected(box)
2149
					{
2150
						if (prevClass != "")
2151
						{
2152
							prevDiv.className = prevClass;
2153
						}
2154
						prevDiv = document.getElementById(box);
2155
						prevClass = prevDiv.className;
2156
2157
						prevDiv.className = "windowbg";
2158
					}';
2159
		if (isset($context['groups']['member'][$context['primary_group']]))
2160
			echo '
2161
					highlightSelected("primdiv_' . $context['primary_group'] . '");';
2162
2163
		echo '
2164
				</script>';
2165
	}
2166
2167
	echo '
2168
			</div><!-- #groups -->';
2169
2170
	if (!empty($context['token_check']))
2171
		echo '
2172
			<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2173
2174
	echo '
2175
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2176
			<input type="hidden" name="u" value="', $context['id_member'], '">
2177
		</form>';
2178
}
2179
2180
/**
2181
 * Template for managing ignored boards
2182
 */
2183
function template_ignoreboards()
2184
{
2185
    global $context, $txt, $scripturl;
2186
2187
    // The main containing header.
2188
    echo '
2189
	<form action="', $scripturl, '?action=profile;area=ignoreboards;save" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
2190
		<div class="cat_bar">
2191
			<h3 class="catbg profile_hd">
2192
				', $txt['profile'], '
2193
			</h3>
2194
		</div>
2195
		<p class="information">', $txt['ignoreboards_info'], '</p>
2196
		<div class="windowbg">
2197
			<div class="flow_hidden boardslist">
2198
				<ul>';
2199
2200
    foreach ($context['categories'] as $category)
2201
    {
2202
        echo '
2203
					<li>
2204
						<a href="javascript:void(0);" onclick="selectBoards([', implode(', ', $category['child_ids']), '], \'creator\'); return false;">', $category['name'], '</a>
2205
            			<ul>';
2206
2207
        foreach ($category['boards'] as $board)
2208
        {
2209
            echo '
2210
							<li style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">
2211
								<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>
2212
							</li>';
2213
        }
2214
2215
        echo '
2216
						</ul>
2217
					</li>';
2218
    }
2219
2220
    echo '
2221
				</ul>
2222
    		</div><!-- .flow_hidden boardslist -->';
2223
2224
    // Show the standard "Save Settings" profile button.
2225
    template_profile_save();
2226
2227
    echo '
2228
		</div><!-- .windowbg -->
2229
	</form>
2230
	<br>';
2231
}
2232
2233
/**
2234
 * Simply loads some theme variables common to several warning templates.
2235
 */
2236
function template_load_warning_variables()
2237
{
2238
	global $modSettings, $context;
2239
2240
	// Setup the warning mode
2241
	$context['warning_mode'] = array(
2242
		0 => 'none',
2243
		$modSettings['warning_watch'] => 'watched',
2244
		$modSettings['warning_moderate'] => 'moderated',
2245
		$modSettings['warning_mute'] => 'muted',
2246
	);
2247
2248
	// Work out the starting warning.
2249
	$context['current_warning_mode'] = $context['warning_mode'][0];
2250
	foreach ($context['warning_mode'] as $limit => $warning)
2251
		if ($context['member']['warning'] >= $limit)
2252
			$context['current_warning_mode'] = $warning;
2253
}
2254
2255
// Show all warnings of a user?
2256
function template_viewWarning()
2257
{
2258
	global $context, $txt;
2259
2260
	template_load_warning_variables();
2261
2262
	echo '
2263
		<div class="cat_bar">
2264
			<h3 class="catbg profile_hd">
2265
				', sprintf($txt['profile_viewwarning_for_user'], $context['member']['name']), '
2266
			</h3>
2267
		</div>
2268
		<p class="information">', $txt['viewWarning_help'], '</p>
2269
		<div class="windowbg">
2270
			<dl class="settings">
2271
				<dt>
2272
					<strong>', $txt['profile_warning_name'], ':</strong>
2273
				</dt>
2274
				<dd>
2275
					', $context['member']['name'], '
2276
				</dd>
2277
				<dt>
2278
					<strong>', $txt['profile_warning_level'], ':</strong>
2279
				</dt>
2280
				<dd>
2281
					<div class="generic_bar warning_level ', $context['current_warning_mode'], '">
2282
						<div class="bar" style="width: ', $context['member']['warning'], '%;"></div>
2283
						<span>', $context['member']['warning'], '%</span>
2284
					</div>
2285
				</dd>';
2286
2287
	// There's some impact of this?
2288
	if (!empty($context['level_effects'][$context['current_level']]))
2289
		echo '
2290
				<dt>
2291
					<strong>', $txt['profile_viewwarning_impact'], ':</strong>
2292
				</dt>
2293
				<dd>
2294
					', $context['level_effects'][$context['current_level']], '
2295
				</dd>';
2296
2297
	echo '
2298
			</dl>
2299
		</div><!-- .windowbg -->';
2300
2301
	template_show_list('view_warnings');
2302
}
2303
2304
// Show a lovely interface for issuing warnings.
2305
function template_issueWarning()
2306
{
2307
	global $context, $scripturl, $txt;
2308
2309
	template_load_warning_variables();
2310
2311
	echo '
2312
	<script>
2313
		// Disable notification boxes as required.
2314
		function modifyWarnNotify()
2315
		{
2316
			disable = !document.getElementById(\'warn_notify\').checked;
2317
			document.getElementById(\'warn_sub\').disabled = disable;
2318
			document.getElementById(\'warn_body\').disabled = disable;
2319
			document.getElementById(\'warn_temp\').disabled = disable;
2320
			document.getElementById(\'new_template_link\').style.display = disable ? \'none\' : \'\';
2321
			document.getElementById(\'preview_button\').style.display = disable ? \'none\' : \'\';
2322
		}
2323
2324
		// Warn template.
2325
		function populateNotifyTemplate()
2326
		{
2327
			index = document.getElementById(\'warn_temp\').value;
2328
			if (index == -1)
2329
				return false;
2330
2331
			// Otherwise see what we can do...';
2332
2333
	foreach ($context['notification_templates'] as $k => $type)
2334
		echo '
2335
			if (index == ', $k, ')
2336
				document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";';
2337
2338
	echo '
2339
		}
2340
2341
		function updateSlider(slideAmount)
2342
		{
2343
			// Also set the right effect.
2344
			effectText = "";';
2345
2346
	foreach ($context['level_effects'] as $limit => $text)
2347
		echo '
2348
			if (slideAmount >= ', $limit, ')
2349
				effectText = "', $text, '";';
2350
2351
	echo '
2352
			setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\');
2353
		}
2354
	</script>';
2355
2356
	echo '
2357
	<form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=issuewarning" method="post" class="flow_hidden" accept-charset="', $context['character_set'], '">
2358
		<div class="cat_bar">
2359
			<h3 class="catbg profile_hd">
2360
				', $context['user']['is_owner'] ? $txt['profile_warning_level'] : $txt['profile_issue_warning'], '
2361
			</h3>
2362
		</div>';
2363
2364
	if (!$context['user']['is_owner'])
2365
		echo '
2366
		<p class="information">', $txt['profile_warning_desc'], '</p>';
2367
2368
	echo '
2369
		<div class="windowbg">
2370
			<dl class="settings">';
2371
2372
	if (!$context['user']['is_owner'])
2373
		echo '
2374
				<dt>
2375
					<strong>', $txt['profile_warning_name'], ':</strong>
2376
				</dt>
2377
				<dd>
2378
					<strong>', $context['member']['name'], '</strong>
2379
				</dd>';
2380
2381
	echo '
2382
				<dt>
2383
					<strong>', $txt['profile_warning_level'], ':</strong>';
2384
2385
	// Is there only so much they can apply?
2386
	if ($context['warning_limit'])
2387
		echo '
2388
					<br>
2389
					<span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>';
2390
2391
	echo '
2392
				</dt>
2393
				<dd>
2394
					0% <input name="warning_level" id="warning_level" type="range" min="0" max="100" step="5" value="', $context['member']['warning'], '" onchange="updateSlider(this.value)"> 100%
2395
					<div class="clear_left">
2396
						', $txt['profile_warning_impact'], ': <span id="cur_level_div">', $context['member']['warning'], '% (', $context['level_effects'][$context['current_level']], ')</span>
2397
					</div>
2398
				</dd>';
2399
2400
	if (!$context['user']['is_owner'])
2401
	{
2402
		echo '
2403
				<dt>
2404
					<strong>', $txt['profile_warning_reason'], ':</strong><br>
2405
					<span class="smalltext">', $txt['profile_warning_reason_desc'], '</span>
2406
				</dt>
2407
				<dd>
2408
					<input type="text" name="warn_reason" id="warn_reason" value="', $context['warning_data']['reason'], '" size="50">
2409
				</dd>
2410
			</dl>
2411
			<hr>
2412
			<div id="box_preview"', !empty($context['warning_data']['body_preview']) ? '' : ' style="display:none"', '>
2413
				<dl class="settings">
2414
					<dt>
2415
						<strong>', $txt['preview'], '</strong>
2416
					</dt>
2417
					<dd id="body_preview">
2418
						', !empty($context['warning_data']['body_preview']) ? $context['warning_data']['body_preview'] : '', '
2419
					</dd>
2420
				</dl>
2421
				<hr>
2422
			</div>
2423
			<dl class="settings">
2424
				<dt>
2425
					<strong><label for="warn_notify">', $txt['profile_warning_notify'], ':</label></strong>
2426
				</dt>
2427
				<dd>
2428
					<input type="checkbox" name="warn_notify" id="warn_notify" onclick="modifyWarnNotify();"', $context['warning_data']['notify'] ? ' checked' : '', '>
2429
				</dd>
2430
				<dt>
2431
					<strong><label for="warn_sub">', $txt['profile_warning_notify_subject'], ':</label></strong>
2432
				</dt>
2433
				<dd>
2434
					<input type="text" name="warn_sub" id="warn_sub" value="', empty($context['warning_data']['notify_subject']) ? $txt['profile_warning_notify_template_subject'] : $context['warning_data']['notify_subject'], '" size="50">
2435
				</dd>
2436
				<dt>
2437
					<strong><label for="warn_temp">', $txt['profile_warning_notify_body'], ':</label></strong>
2438
				</dt>
2439
				<dd>
2440
					<select name="warn_temp" id="warn_temp" disabled onchange="populateNotifyTemplate();">
2441
						<option value="-1">', $txt['profile_warning_notify_template'], '</option>
2442
						<option value="-1" disabled>------------------------------</option>';
2443
2444
		foreach ($context['notification_templates'] as $id_template => $template)
2445
			echo '
2446
						<option value="', $id_template, '">', $template['title'], '</option>';
2447
2448
		echo '
2449
					</select>
2450
					<span class="smalltext" id="new_template_link" style="display: none;">[<a href="', $scripturl, '?action=moderate;area=warnings;sa=templateedit;tid=0" target="_blank" rel="noopener">', $txt['profile_warning_new_template'], '</a>]</span>
2451
					<br>
2452
					<textarea name="warn_body" id="warn_body" cols="40" rows="8">', $context['warning_data']['notify_body'], '</textarea>
2453
				</dd>';
2454
	}
2455
	echo '
2456
			</dl>
2457
			<div class="righttext">';
2458
2459
	if (!empty($context['token_check']))
2460
		echo '
2461
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2462
2463
	echo '
2464
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2465
				<input type="button" name="preview" id="preview_button" value="', $txt['preview'], '" class="button">
2466
				<input type="submit" name="save" value="', $context['user']['is_owner'] ? $txt['change_profile'] : $txt['profile_warning_issue'], '" class="button">
2467
			</div><!-- .righttext -->
2468
		</div><!-- .windowbg -->
2469
	</form>';
2470
2471
	// Previous warnings?
2472
	template_show_list('view_warnings');
2473
2474
	echo '
2475
	<script>';
2476
2477
	if (!$context['user']['is_owner'])
2478
		echo '
2479
		modifyWarnNotify();
2480
		$(document).ready(function() {
2481
			$("#preview_button").click(function() {
2482
				return ajax_getTemplatePreview();
2483
			});
2484
		});
2485
2486
		function ajax_getTemplatePreview ()
2487
		{
2488
			$.ajax({
2489
				type: "POST",
2490
				url: "' . $scripturl . '?action=xmlhttp;sa=previews;xml",
2491
				data: {item: "warning_preview", title: $("#warn_sub").val(), body: $("#warn_body").val(), issuing: true},
2492
				context: document.body,
2493
				success: function(request){
2494
					$("#box_preview").css({display:""});
2495
					$("#body_preview").html($(request).find(\'body\').text());
2496
					if ($(request).find("error").text() != \'\')
2497
					{
2498
						$("#profile_error").css({display:""});
2499
						var errors_html = \'<ul class="list_errors">\';
2500
						var errors = $(request).find(\'error\').each(function() {
2501
							errors_html += \'<li>\' + $(this).text() + \'</li>\';
2502
						});
2503
						errors_html += \'</ul>\';
2504
2505
						$("#profile_error").html(errors_html);
2506
					}
2507
					else
2508
					{
2509
						$("#profile_error").css({display:"none"});
2510
						$("#error_list").html(\'\');
2511
					}
2512
				return false;
2513
				},
2514
			});
2515
			return false;
2516
		}';
2517
2518
	echo '
2519
	</script>';
2520
}
2521
2522
/**
2523
 * Template to show for deleting a user's account - now with added delete post capability!
2524
 */
2525
function template_deleteAccount()
2526
{
2527
	global $context, $scripturl, $txt;
2528
2529
	// The main containing header.
2530
	echo '
2531
		<form action="', $scripturl, '?action=profile;area=deleteaccount;save" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
2532
			<div class="cat_bar">
2533
				<h3 class="catbg profile_hd">
2534
					', $txt['deleteAccount'], '
2535
				</h3>
2536
			</div>';
2537
2538
	// If deleting another account give them a lovely info box.
2539
	if (!$context['user']['is_owner'])
2540
		echo '
2541
			<p class="information">', $txt['deleteAccount_desc'], '</p>';
2542
2543
	echo '
2544
			<div class="windowbg">';
2545
2546
	// If they are deleting their account AND the admin needs to approve it - give them another piece of info ;)
2547
	if ($context['needs_approval'])
2548
		echo '
2549
				<div class="errorbox">', $txt['deleteAccount_approval'], '</div>';
2550
2551
	// If the user is deleting their own account warn them first - and require a password!
2552
	if ($context['user']['is_owner'])
2553
	{
2554
		echo '
2555
				<div class="alert">', $txt['own_profile_confirm'], '</div>
2556
				<div>
2557
					<strong', (isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : ''), '>', $txt['current_password'], ': </strong>
2558
					<input type="password" name="oldpasswrd" size="20">
2559
					<input type="submit" value="', $txt['yes'], '" class="button">';
2560
2561
		if (!empty($context['token_check']))
2562
			echo '
2563
					<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2564
2565
		echo '
2566
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2567
					<input type="hidden" name="u" value="', $context['id_member'], '">
2568
					<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
2569
				</div>';
2570
	}
2571
	// Otherwise an admin doesn't need to enter a password - but they still get a warning - plus the option to delete lovely posts!
2572
	else
2573
	{
2574
		echo '
2575
				<div class="alert">', $txt['deleteAccount_warning'], '</div>';
2576
2577
		// Only actually give these options if they are kind of important.
2578
		if ($context['can_delete_posts'])
2579
		{
2580
			echo '
2581
				<div>
2582
					<label for="deleteVotes">
2583
						<input type="checkbox" name="deleteVotes" id="deleteVotes" value="1"> ', $txt['deleteAccount_votes'], ':
2584
					</label><br>
2585
					<label for="deletePosts">
2586
						<input type="checkbox" name="deletePosts" id="deletePosts" value="1"> ', $txt['deleteAccount_posts'], ':
2587
					</label>
2588
					<select name="remove_type">
2589
						<option value="posts">', $txt['deleteAccount_all_posts'], '</option>
2590
						<option value="topics">', $txt['deleteAccount_topics'], '</option>
2591
					</select>';
2592
2593
			if ($context['show_perma_delete'])
2594
				echo '
2595
					<br>
2596
					<label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1">', $txt['deleteAccount_permanent'], ':</label>';
2597
2598
			echo '
2599
				</div>';
2600
		}
2601
2602
		echo '
2603
				<div>
2604
					<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>
2605
				</div>
2606
				<div>
2607
					<input type="submit" value="', $txt['delete'], '" class="button">';
2608
2609
		if (!empty($context['token_check']))
2610
			echo '
2611
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2612
2613
		echo '
2614
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2615
					<input type="hidden" name="u" value="', $context['id_member'], '">
2616
					<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
2617
				</div>';
2618
	}
2619
	echo '
2620
			</div><!-- .windowbg -->
2621
			<br>
2622
		</form>';
2623
}
2624
2625
/**
2626
 * Template for the password box/save button stuck at the bottom of every profile page.
2627
 */
2628
function template_profile_save()
2629
{
2630
	global $context, $txt;
2631
2632
	echo '
2633
2634
					<hr>';
2635
2636
	// Only show the password box if it's actually needed.
2637
	if ($context['require_password'])
2638
		echo '
2639
					<dl class="settings">
2640
						<dt>
2641
							<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br>
2642
							<span class="smalltext">', $txt['required_security_reasons'], '</span>
2643
						</dt>
2644
						<dd>
2645
							<input type="password" name="oldpasswrd" size="20">
2646
						</dd>
2647
					</dl>';
2648
2649
	echo '
2650
					<div class="righttext">';
2651
2652
	if (!empty($context['token_check']))
2653
		echo '
2654
						<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2655
2656
	echo '
2657
						<input type="submit" value="', $txt['change_profile'], '" class="button">
2658
						<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2659
						<input type="hidden" name="u" value="', $context['id_member'], '">
2660
						<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
2661
					</div>';
2662
}
2663
2664
/**
2665
 * Small template for showing an error message upon a save problem in the profile.
2666
 */
2667
function template_error_message()
2668
{
2669
	global $context, $txt;
2670
2671
	echo '
2672
		<div class="errorbox" ', empty($context['post_errors']) ? 'style="display:none" ' : '', 'id="profile_error">';
2673
2674
	if (!empty($context['post_errors']))
2675
	{
2676
		echo '
2677
			<span>', !empty($context['custom_error_title']) ? $context['custom_error_title'] : $txt['profile_errors_occurred'], ':</span>
2678
			<ul id="list_errors">';
2679
2680
		// Cycle through each error and display an error message.
2681
		foreach ($context['post_errors'] as $error)
2682
			echo '
2683
				<li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>';
2684
2685
		echo '
2686
			</ul>';
2687
	}
2688
2689
	echo '
2690
		</div><!-- #profile_error -->';
2691
}
2692
2693
/**
2694
 * Display a load of drop down selectors for allowing the user to change group.
2695
 */
2696
function template_profile_group_manage()
2697
{
2698
	global $context, $txt, $scripturl;
2699
2700
	echo '
2701
							<dt>
2702
								<strong>', $txt['primary_membergroup'], ': </strong><br>
2703
								<span class="smalltext"><a href="', $scripturl, '?action=helpadmin;help=moderator_why_missing" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help"></span> ', $txt['moderator_why_missing'], '</a></span>
2704
							</dt>
2705
							<dd>
2706
								<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;"' : ''), '>';
2707
2708
	// Fill the select box with all primary member groups that can be assigned to a member.
2709
	foreach ($context['member_groups'] as $member_group)
2710
		if (!empty($member_group['can_be_primary']))
2711
			echo '
2712
									<option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '>
2713
										', $member_group['name'], '
2714
									</option>';
2715
2716
	echo '
2717
								</select>
2718
							</dd>
2719
							<dt>
2720
								<strong>', $txt['additional_membergroups'], ':</strong>
2721
							</dt>
2722
							<dd>
2723
								<span id="additional_groupsList">
2724
									<input type="hidden" name="additional_groups[]" value="0">';
2725
2726
	// For each membergroup show a checkbox so members can be assigned to more than one group.
2727
	foreach ($context['member_groups'] as $member_group)
2728
		if ($member_group['can_be_additional'])
2729
			echo '
2730
									<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>';
2731
2732
	echo '
2733
								</span>
2734
								<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>
2735
								<script>
2736
									document.getElementById("additional_groupsList").style.display = "none";
2737
									document.getElementById("additional_groupsLink").style.display = "";
2738
								</script>
2739
							</dd>';
2740
2741
}
2742
2743
/**
2744
 * Callback function for entering a birthdate!
2745
 */
2746
function template_profile_birthdate()
2747
{
2748
	global $txt, $context;
2749
2750
	// Just show the pretty box!
2751
	echo '
2752
							<dt>
2753
								<strong>', $txt['dob'], ':</strong><br>
2754
								<span class="smalltext">', $txt['dob_year'], ' - ', $txt['dob_month'], ' - ', $txt['dob_day'], '</span>
2755
							</dt>
2756
							<dd>
2757
								<input type="text" name="bday3" size="4" maxlength="4" value="', $context['member']['birth_date']['year'], '"> -
2758
								<input type="text" name="bday1" size="2" maxlength="2" value="', $context['member']['birth_date']['month'], '"> -
2759
								<input type="text" name="bday2" size="2" maxlength="2" value="', $context['member']['birth_date']['day'], '">
2760
							</dd>';
2761
}
2762
2763
/**
2764
 * Show the signature editing box?
2765
 */
2766
function template_profile_signature_modify()
2767
{
2768
	global $txt, $context;
2769
2770
	echo '
2771
							<dt id="current_signature" style="display:none">
2772
								<strong>', $txt['current_signature'], ':</strong>
2773
							</dt>
2774
							<dd id="current_signature_display" style="display:none">
2775
								<hr>
2776
							</dd>
2777
2778
							<dt id="preview_signature" style="display:none">
2779
								<strong>', $txt['signature_preview'], ':</strong>
2780
							</dt>
2781
							<dd id="preview_signature_display" style="display:none">
2782
								<hr>
2783
							</dd>
2784
2785
							<dt>
2786
								<strong>', $txt['signature'], ':</strong><br>
2787
								<span class="smalltext">', $txt['sig_info'], '</span><br>
2788
								<br>';
2789
2790
	if ($context['show_spellchecking'])
2791
		echo '
2792
								<input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button">';
2793
2794
	echo '
2795
							</dt>
2796
							<dd>
2797
								<textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50">', $context['member']['signature'], '</textarea><br>';
2798
2799
	// If there is a limit at all!
2800
	if (!empty($context['signature_limits']['max_length']))
2801
		echo '
2802
								<span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>';
2803
2804
	if (!empty($context['show_preview_button']))
2805
		echo '
2806
								<input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button floatright">';
2807
2808
	if ($context['signature_warning'])
2809
		echo '
2810
								<span class="smalltext">', $context['signature_warning'], '</span>';
2811
2812
	// Some javascript used to count how many characters have been used so far in the signature.
2813
	echo '
2814
								<script>
2815
									var maxLength = ', $context['signature_limits']['max_length'], ';
2816
2817
									$(document).ready(function() {
2818
										calcCharLeft();
2819
										$("#preview_button").click(function() {
2820
											return ajax_getSignaturePreview(true);
2821
										});
2822
									});
2823
								</script>
2824
							</dd>';
2825
}
2826
2827
/**
2828
 * Template for selecting an avatar
2829
 */
2830
function template_profile_avatar_select()
2831
{
2832
	global $context, $txt, $modSettings;
2833
2834
	// Start with the upper menu
2835
	echo '
2836
							<dt>
2837
								<strong id="personal_picture">
2838
									<label for="avatar_upload_box">', $txt['personal_picture'], '</label>
2839
								</strong>';
2840
2841
	if (empty($modSettings['gravatarOverride']))
2842
		echo '
2843
								<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"' : '') . '>
2844
								<label for="avatar_choice_none"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>
2845
									' . $txt['no_avatar'] . '
2846
								</label><br>';
2847
2848
	if (!empty($context['member']['avatar']['allow_server_stored']))
2849
		echo '
2850
								<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"' : '') . '>
2851
								<label for="avatar_choice_server_stored"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>
2852
									', $txt['choose_avatar_gallery'], '
2853
								</label><br>';
2854
2855
	if (!empty($context['member']['avatar']['allow_external']))
2856
		echo '
2857
								<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"' : '') . '>
2858
								<label for="avatar_choice_external"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>
2859
									', $txt['my_own_pic'], '
2860
								</label><br>';
2861
2862
	if (!empty($context['member']['avatar']['allow_upload']))
2863
		echo '
2864
								<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"' : '') . '>
2865
								<label for="avatar_choice_upload"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>
2866
									', $txt['avatar_will_upload'], '
2867
								</label><br>';
2868
2869
	if (!empty($context['member']['avatar']['allow_gravatar']))
2870
		echo '
2871
								<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"' : '') . '>
2872
								<label for="avatar_choice_gravatar"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>' . $txt['use_gravatar'] . '</label>';
2873
2874
	echo '
2875
							</dt>
2876
							<dd>';
2877
2878
	// If users are allowed to choose avatars stored on the server show selection boxes to choice them from.
2879
	if (!empty($context['member']['avatar']['allow_server_stored']))
2880
	{
2881
		echo '
2882
								<div id="avatar_server_stored">
2883
									<div>
2884
										<select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">';
2885
2886
		// This lists all the file categories.
2887
		foreach ($context['avatars'] as $avatar)
2888
			echo '
2889
											<option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>';
2890
2891
		echo '
2892
										</select>
2893
									</div>
2894
									<div>
2895
										<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>
2896
									</div>
2897
									<div>
2898
										<img id="avatar" src="', !empty($context['member']['avatar']['allow_external']) && $context['member']['avatar']['choice'] == 'external' ? $context['member']['avatar']['external'] : $modSettings['avatar_url'] . '/blank.png', '" alt="Do Nothing">
2899
									</div>
2900
									<script>
2901
										var files = ["' . implode('", "', $context['avatar_list']) . '"];
2902
										var avatar = document.getElementById("avatar");
2903
										var cat = document.getElementById("cat");
2904
										var selavatar = "' . $context['avatar_selected'] . '";
2905
										var avatardir = "' . $modSettings['avatar_url'] . '/";
2906
										var size = avatar.alt.substr(3, 2) + " " + avatar.alt.substr(0, 2) + String.fromCharCode(117, 98, 116);
2907
										var file = document.getElementById("file");
2908
										var maxHeight = ', !empty($modSettings['avatar_max_height_external']) ? $modSettings['avatar_max_height_external'] : 0, ';
2909
										var maxWidth = ', !empty($modSettings['avatar_max_width_external']) ? $modSettings['avatar_max_width_external'] : 0, ';
2910
2911
										if (avatar.src.indexOf("blank.png") > -1)
2912
											changeSel(selavatar);
2913
										else
2914
											previewExternalAvatar(avatar.src)
2915
2916
									</script>
2917
								</div><!-- #avatar_server_stored -->';
2918
	}
2919
2920
	// If the user can link to an off server avatar, show them a box to input the address.
2921
	if (!empty($context['member']['avatar']['allow_external']))
2922
		echo '
2923
								<div id="avatar_external">
2924
									<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
Bug introduced by
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...
2925
									<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);">
2926
								</div>';
2927
2928
	// If the user is able to upload avatars to the server show them an upload box.
2929
	if (!empty($context['member']['avatar']['allow_upload']))
2930
		echo '
2931
								<div id="avatar_upload">
2932
									<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
Bug introduced by
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...
2933
									', (!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'] . '">' : ''), '
2934
								</div>';
2935
2936
	// if the user is able to use Gravatar avatars show then the image preview
2937
	if (!empty($context['member']['avatar']['allow_gravatar']))
2938
	{
2939
		echo '
2940
								<div id="avatar_gravatar">
2941
									<img src="' . $context['member']['avatar']['href'] . '" alt="">';
2942
2943
		if (empty($modSettings['gravatarAllowExtraEmail']))
2944
			echo '
2945
									<div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>';
2946
		else
2947
		{
2948
			// Depending on other stuff, the stored value here might have some odd things in it from other areas.
2949
			if ($context['member']['avatar']['external'] == $context['member']['email'])
2950
				$textbox_value = '';
2951
			else
2952
				$textbox_value = $context['member']['avatar']['external'];
2953
2954
			echo '
2955
									<div class="smalltext">', $txt['gravatar_alternateEmail'], '</div>
2956
									<input type="text" name="gravatarEmail" id="gravatarEmail" size="45" value="', $textbox_value, '">';
2957
		}
2958
		echo '
2959
								</div><!-- #avatar_gravatar -->';
2960
	}
2961
2962
	echo '
2963
								<script>
2964
									', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "' . ($context['member']['avatar']['choice'] == 'server_stored' ? '' : 'none') . '";' : '', '
2965
									', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "' . ($context['member']['avatar']['choice'] == 'external' ? '' : 'none') . '";' : '', '
2966
									', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "' . ($context['member']['avatar']['choice'] == 'upload' ? '' : 'none') . '";' : '', '
2967
									', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "' . ($context['member']['avatar']['choice'] == 'gravatar' ? '' : 'none') . '";' : '', '
2968
2969
									function swap_avatar(type)
2970
									{
2971
										switch(type.id)
2972
										{
2973
											case "avatar_choice_server_stored":
2974
												', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "";' : '', '
2975
												', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "none";' : '', '
2976
												', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "none";' : '', '
2977
												', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "none";' : '', '
2978
												break;
2979
											case "avatar_choice_external":
2980
												', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "none";' : '', '
2981
												', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "";' : '', '
2982
												', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "none";' : '', '
2983
												', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "none";' : '', '
2984
												break;
2985
											case "avatar_choice_upload":
2986
												', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "none";' : '', '
2987
												', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "none";' : '', '
2988
												', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "";' : '', '
2989
												', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "none";' : '', '
2990
												break;
2991
											case "avatar_choice_none":
2992
												', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "none";' : '', '
2993
												', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "none";' : '', '
2994
												', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "none";' : '', '
2995
												', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "none";' : '', '
2996
												break;
2997
											case "avatar_choice_gravatar":
2998
												', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "none";' : '', '
2999
												', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "none";' : '', '
3000
												', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "none";' : '', '
3001
												', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "";' : '', '
3002
												', ($context['member']['avatar']['external'] == $context['member']['email'] || strstr($context['member']['avatar']['external'], 'http://')) ?
3003
												'document.getElementById("gravatarEmail").value = "";' : '', '
3004
												break;
3005
										}
3006
									}
3007
								</script>
3008
							</dd>';
3009
}
3010
3011
/**
3012
 * This is just a really little helper to avoid duplicating code unnecessarily
3013
 *
3014
 * @param string $type The type of avatar
3015
 */
3016
function template_max_size($type)
3017
{
3018
	global $modSettings, $txt;
3019
3020
	$w = !empty($modSettings['avatar_max_width_' . $type]) ? comma_format($modSettings['avatar_max_width_' . $type]) : 0;
3021
	$h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0;
3022
3023
	$suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : '');
3024
	if (empty($suffix))
3025
		return;
3026
3027
	echo '
3028
								<div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>';
3029
}
3030
3031
/**
3032
 * Select the time format!
3033
 */
3034
function template_profile_timeformat_modify()
3035
{
3036
	global $context, $txt, $scripturl;
3037
3038
	echo '
3039
							<dt>
3040
								<strong><label for="easyformat">', $txt['time_format'], ':</label></strong><br>
3041
								<a href="', $scripturl, '?action=helpadmin;help=time_format" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>
3042
								<span class="smalltext">
3043
									<label for="time_format">', $txt['date_format'], '</label>
3044
								</span>
3045
							</dt>
3046
							<dd>
3047
								<select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;">';
3048
3049
	// Help the user by showing a list of common time formats.
3050
	foreach ($context['easy_timeformats'] as $time_format)
3051
		echo '
3052
									<option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>';
3053
3054
	echo '
3055
								</select>
3056
								<input type="text" name="time_format" id="time_format" value="', $context['member']['time_format'], '" size="30">
3057
							</dd>';
3058
}
3059
3060
/**
3061
 * Template for picking a theme
3062
 */
3063
function template_profile_theme_pick()
3064
{
3065
	global $txt, $context, $scripturl;
3066
3067
	echo '
3068
							<dt>
3069
								<strong>', $txt['current_theme'], ':</strong>
3070
							</dt>
3071
							<dd>
3072
								', $context['member']['theme']['name'], ' [<a href="', $scripturl, '?action=theme;sa=pick;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['change'], '</a>]
3073
							</dd>';
3074
}
3075
3076
/**
3077
 * Smiley set picker.
3078
 */
3079
function template_profile_smiley_pick()
3080
{
3081
	global $txt, $context, $modSettings, $settings;
3082
3083
	echo '
3084
							<dt>
3085
								<strong><label for="smiley_set">', $txt['smileys_current'], ':</label></strong>
3086
							</dt>
3087
							<dd>
3088
								<select name="smiley_set" id="smiley_set">';
3089
3090
	foreach ($context['smiley_sets'] as $set)
3091
		echo '
3092
									<option value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>';
3093
3094
	echo '
3095
								</select>
3096
								<img id="smileypr" class="centericon" src="', $context['member']['smiley_set']['id'] != 'none' ? $modSettings['smileys_url'] . '/' . ($context['member']['smiley_set']['id'] != '' ? $context['member']['smiley_set']['id'] . '/smiley' . $context['user']['smiley_set_ext'] : (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) . '/smiley' . $context['user']['smiley_set_default_ext']) : $settings['images_url'] . '/blank.png', '" alt=":)">
3097
							</dd>';
3098
}
3099
3100
/**
3101
 * Template for setting up and managing Two-Factor Authentication.
3102
 */
3103
function template_tfasetup()
3104
{
3105
	global $txt, $context, $scripturl, $modSettings;
3106
3107
	echo '
3108
			<div class="cat_bar">
3109
				<h3 class="catbg">', $txt['tfa_title'], '</h3>
3110
			</div>
3111
			<div class="roundframe">
3112
				<div>';
3113
3114
	if (!empty($context['tfa_backup']))
3115
		echo '
3116
					<div class="smalltext error">
3117
						', $txt['tfa_backup_used_desc'], '
3118
					</div>';
3119
3120
	elseif ($modSettings['tfa_mode'] == 2)
3121
		echo '
3122
					<div class="smalltext">
3123
						<strong>', $txt['tfa_forced_desc'], '</strong>
3124
					</div>';
3125
3126
	echo '
3127
					<div class="smalltext">
3128
						', $txt['tfa_desc'], '
3129
					</div>
3130
					<div class="floatleft">
3131
						<form action="', $scripturl, '?action=profile;area=tfasetup" method="post">
3132
							<div class="block">
3133
								<strong>', $txt['tfa_step1'], '</strong><br>';
3134
3135
	if (!empty($context['tfa_pass_error']))
3136
		echo '
3137
								<div class="error smalltext">
3138
									', $txt['tfa_pass_invalid'], '
3139
								</div>';
3140
3141
	echo '
3142
								<input type="password" name="passwd" size="25"', !empty($context['tfa_pass_error']) ? ' class="error"' : '', !empty($context['tfa_pass_value']) ? ' value="' . $context['tfa_pass_value'] . '"' : '', '>
3143
							</div>
3144
							<div class="block">
3145
								<strong>', $txt['tfa_step2'], '</strong>
3146
								<div class="smalltext">', $txt['tfa_step2_desc'], '</div>
3147
								<div class="tfacode">', $context['tfa_secret'], '</div>
3148
							</div>
3149
							<div class="block">
3150
								<strong>', $txt['tfa_step3'], '</strong><br>';
3151
3152
	if (!empty($context['tfa_error']))
3153
		echo '
3154
								<div class="error smalltext">
3155
									', $txt['tfa_code_invalid'], '
3156
								</div>';
3157
3158
	echo '
3159
								<input type="text" name="tfa_code" size="25"', !empty($context['tfa_error']) ? ' class="error"' : '', !empty($context['tfa_value']) ? ' value="' . $context['tfa_value'] . '"' : '', '>
3160
								<input type="submit" name="save" value="', $txt['tfa_enable'], '" class="button">
3161
							</div>
3162
							<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">
3163
							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
3164
						</form>
3165
					</div>
3166
					<div class="floatright tfa_qrcode">
3167
						<img src="', $context['tfa_qr_url'], '" alt="">
3168
					</div>';
3169
3170
	if (!empty($context['from_ajax']))
3171
		echo '
3172
					<br>
3173
					<a href="javascript:self.close();"></a>';
3174
3175
	echo '
3176
				</div>
3177
			</div><!-- .roundframe -->';
3178
}
3179
3180
/**
3181
 * Template for setting up 2FA backup code
3182
 */
3183
function template_tfasetup_backup()
3184
{
3185
	global $context, $txt;
3186
3187
	echo '
3188
			<div class="cat_bar">
3189
				<h3 class="catbg">', $txt['tfa_backup_title'], '</h3>
3190
			</div>
3191
			<div class="roundframe">
3192
				<div>
3193
					<div class="smalltext">', $txt['tfa_backup_desc'], '</div>
3194
					<div class="bbc_code" style="resize: none; border: none;">', $context['tfa_backup'], '</div>
3195
				</div>
3196
			</div>';
3197
}
3198
3199
/**
3200
 * Simple template for showing the 2FA area when editing a profile.
3201
 */
3202
function template_profile_tfa()
3203
{
3204
	global $context, $txt, $scripturl, $modSettings;
3205
3206
	echo '
3207
							<dt>
3208
								<strong>', $txt['tfa_profile_label'], ':</strong><br>
3209
								<div class="smalltext">', $txt['tfa_profile_desc'], '</div>
3210
							</dt>
3211
							<dd>';
3212
3213
	if (!$context['tfa_enabled'] && $context['user']['is_owner'])
3214
		echo '
3215
								<a href="', !empty($modSettings['force_ssl']) ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>';
3216
3217
	elseif (!$context['tfa_enabled'])
3218
		echo '
3219
								', $txt['tfa_profile_disabled'];
3220
3221
	else
3222
		echo '
3223
								', sprintf($txt['tfa_profile_enabled'], $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=tfasetup;disable');
3224
3225
	echo '
3226
							</dd>';
3227
}
3228
3229
?>