Completed
Pull Request — release-2.1 (#4892)
by Mathias
08:19
created

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

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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

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

1. Pass all data via parameters

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

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

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

    public function myFunction() {
        // Do something
    }
}
Loading history...
3267
3268
	// The main containing header.
3269
	echo '
3270
		<div class="cat_bar">
3271
			<h3 class="catbg profile_hd">
3272
				', $txt['profileDataCenter'], '
3273
			</h3>
3274
		</div>
3275
		',( !empty($context['pdc']['nofound']) ? '<p class="information">' . $txt['profileDataNotFound'] . '</p>' : ''),'<div class="windowbg">
3276
		<div>
3277
			<form action="', $scripturl, '?action=profile;area=getprofiledata;activity=profile" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
3278
				<p',  '', '>', (!empty($context['pdc']['own']) ? $txt['profileDownloadProfile_own'] : sprintf($txt['profileDownloadProfile_any'], $context['pdc']['name'])), ': </p>
3279
				<input type="submit" value="', $txt['profileDownload'], '" class="button">
3280
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
3281
				<input type="hidden" name="u" value="', $context['id_member'], '">
3282
				<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
3283
			</form>
3284
		</div>
3285
		<div>
3286
			<form action="', $scripturl, '?action=profile;area=getprofiledata;activity=messages" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
3287
				<p',  '', '>', (!empty($context['pdc']['own']) ? $txt['profileDownloadMessages_own'] : sprintf($txt['profileDownloadMessages_any'], $context['pdc']['name'])), ': </p>
3288
				<input type="submit" value="', $txt['profileDownload'], '" class="button">
3289
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
3290
				<input type="hidden" name="u" value="', $context['id_member'], '">
3291
				<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
3292
			</form>
3293
		</div>
3294
		<div>
3295
			<form action="', $scripturl, '?action=profile;area=getprofiledata;activity=pmessages" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
3296
				<p',  '', '>', (!empty($context['pdc']['own']) ? $txt['profileDownloadPMessages_own'] : sprintf($txt['profileDownloadPMessages_any'], $context['pdc']['name'])), ': </p>
3297
				<input type="submit" value="', $txt['profileDownload'], '" class="button">
3298
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
3299
				<input type="hidden" name="u" value="', $context['id_member'], '">
3300
				<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
3301
			</form>
3302
		</div>
3303
		<br>
3304
';
3305
}
3306
3307
/**
3308
 * Template to view policy data
3309
 */
3310
function template_getPolicyData()
3311
{
3312
	global $context, $scripturl, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

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

1. Pass all data via parameters

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

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

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

    public function myFunction() {
        // Do something
    }
}
Loading history...
3313
3314
	// The main containing header.
3315
	echo '
3316
		<div class="cat_bar">
3317
			<h3 class="catbg profile_hd">
3318
				', $txt['policyOvervie'], '
3319
			</h3>
3320
		</div>
3321
		<div class="windowbg">';
3322
	if (empty($context['poc']['approved_text']) && empty($context['poc']['newVersionText']))
3323
		echo '
3324
			</div>
3325
				<p class="information">', $txt['policyNoApprved'], '</p><div class="windowbg">
3326
			<div>';
3327
	
3328
	if (!empty($context['poc']['approved_text']))
3329
		echo '
3330
			<div>
3331
				<div class="title_bar">
3332
					<h3 class="titlebg">', $txt['policy_approved'], '</h3>
3333
				</div>
3334
				<p>' ,$context['poc']['approved_text'] , '</p>
3335
			</div>';
3336
	if (!empty($context['poc']['newVersionText']))
3337
		echo '
3338
			<div>
3339
				<div class="title_bar">
3340
					<h3 class="titlebg">', $txt['policy_new'], '</h3>
3341
				</div>
3342
				<p>' ,$context['poc']['newVersionText'] , '</p>
3343
			</div>';
3344
	
3345
	if (!empty($context['poc']['showAccept']))
3346
		echo '
3347
			<div>
3348
				<form action="', $scripturl, '?action=profile;area=getpolicydata;activity=save" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
3349
					<input type="submit" value="', $txt['policyAccept'], '" class="button">
3350
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
3351
					<input type="hidden" name="u" value="', $context['id_member'], '">
3352
					<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
3353
				</form>
3354
			</div>';
3355
3356
	echo '
3357
		</div><!-- .windowbg -->
3358
		<br>
3359
';
3360
}
3361
3362
?>