Completed
Push — release-2.1 ( e9ccf0...3d75db )
by Michael
08:23
created

Profile.template.php ➔ template_profile_theme_settings()   F

Complexity

Conditions 51
Paths 205

Size

Total Lines 124
Code Lines 69

Duplication

Lines 39
Ratio 31.45 %

Importance

Changes 0
Metric Value
cc 51
eloc 69
nc 205
nop 0
dl 39
loc 124
rs 3.9333
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

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

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

Commonly applied refactorings include:

1
<?php
2
/**
3
 * Simple Machines Forum (SMF)
4
 *
5
 * @package SMF
6
 * @author Simple Machines http://www.simplemachines.org
7
 * @copyright 2017 Simple Machines and individual contributors
8
 * @license http://www.simplemachines.org/about/smf/license.php BSD
9
 *
10
 * @version 2.1 Beta 3
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>';
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
	{
104
		template_alerts_all_read();
105
	}
106
	else
107
	{
108
		foreach ($context['unread_alerts'] as $id_alert => $details)
109
		{
110
			echo '
111
			<div class="unread">
112
				', !empty($details['sender']) ? $details['sender']['avatar']['image'] : '', '
113
				<div class="details">
114
					', !empty($details['icon']) ? $details['icon'] : '', '<span>', $details['text'], '</span> - ', $details['time'], '
115
				</div>
116
			</div>';
117
		}
118
	}
119
120
	echo '
121
		</div>
122
		<script>
123
		function markAlertsRead(obj) {
124
			ajax_indicator(true);
125
			$.get(
126
				obj.href,
127
				function(data) {
128
					ajax_indicator(false);
129
					$("#alerts_menu_top span.amt").remove();
130
					$("#alerts_menu div.alerts_unread").html(data);
131
				}
132
			);
133
			return false;
134
		}
135
		</script>';
136
}
137
138
/**
139
 * A simple template to say "You don't have any unread alerts".
140
 */
141
function template_alerts_all_read()
142
{
143
	global $txt;
144
145
	echo '<div class="no_unread">', $txt['alerts_no_unread'], '</div>';
146
}
147
148
/**
149
 * This template displays a user's details without any option to edit them.
150
 */
151
function template_summary()
152
{
153
	global $context, $settings, $scripturl, $modSettings, $txt;
154
155
	// Display the basic information about the user
156
	echo '
157
	<div id="profileview" class="roundframe flow_auto noup">
158
		<div id="basicinfo">';
159
160
	// Are there any custom profile fields for above the name?
161 View Code Duplication
	if (!empty($context['print_custom_fields']['above_member']))
162
	{
163
		echo '
164
			<div class="custom_fields_above_name">
165
				<ul >';
166
167
		foreach ($context['print_custom_fields']['above_member'] as $field)
168
			if (!empty($field['output_html']))
169
				echo '
170
					<li>', $field['output_html'], '</li>';
171
172
		echo '
173
				</ul>
174
			</div>
175
			<br>';
176
	}
177
178
	echo '
179
			<div class="username clear">
180
				<h4>', $context['member']['name'], '<span class="position">', (!empty($context['member']['group']) ? $context['member']['group'] : $context['member']['post_group']), '</span></h4>
181
			</div>
182
			', $context['member']['avatar']['image'];
183
184
	// Are there any custom profile fields for below the avatar?
185 View Code Duplication
	if (!empty($context['print_custom_fields']['below_avatar']))
186
	{
187
		echo '
188
			<div class="custom_fields_below_avatar">
189
				<ul >';
190
191
		foreach ($context['print_custom_fields']['below_avatar'] as $field)
192
			if (!empty($field['output_html']))
193
				echo '
194
					<li>', $field['output_html'], '</li>';
195
196
		echo '
197
				</ul>
198
			</div>
199
			<br>';
200
	}
201
202
		echo '
203
			<ul class="clear">';
204
	// Email is only visible if it's your profile or you have the moderate_forum permission
205 View Code Duplication
	if ($context['member']['show_email'])
206
		echo '
207
				<li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>';
208
209
	// Don't show an icon if they haven't specified a website.
210 View Code Duplication
	if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website']))
211
		echo '
212
				<li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<span class="generic_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
213
214
	// Are there any custom profile fields as icons?
215
	if (!empty($context['print_custom_fields']['icons']))
216
	{
217
		foreach ($context['print_custom_fields']['icons'] as $field)
218
			if (!empty($field['output_html']))
219
				echo '
220
					<li class="custom_field">', $field['output_html'], '</li>';
221
	}
222
223
	echo '
224
			</ul>
225
			<span id="userstatus">', $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>' : '';
226
227
	// Can they add this member as a buddy?
228
	if (!empty($context['can_have_buddy']) && !$context['user']['is_owner'])
229
		echo '
230
				<br><a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a>';
231
232
	echo '
233
			</span>';
234
235
	if (!$context['user']['is_owner'] && $context['can_send_pm'])
236
		echo '
237
			<a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>';
238
239
	echo '
240
			<a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>';
241
242
	if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled']))
243
		echo '
244
			<a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>';
245
246
	echo '
247
			<a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>';
248
249
	// Are there any custom profile fields for bottom?
250 View Code Duplication
	if (!empty($context['print_custom_fields']['bottom_poster']))
251
	{
252
		echo '
253
			<div class="custom_fields_bottom">
254
				<ul class="nolist">';
255
256
		foreach ($context['print_custom_fields']['bottom_poster'] as $field)
257
			if (!empty($field['output_html']))
258
				echo '
259
					<li>', $field['output_html'], '</li>';
260
261
		echo '
262
				</ul>
263
			</div>';
264
	}
265
266
	echo '
267
		</div>';
268
269
	echo '
270
		<div id="detailedinfo">
271
			<dl class="settings">';
272
273
	if ($context['user']['is_owner'] || $context['user']['is_admin'])
274
		echo '
275
				<dt>', $txt['username'], ': </dt>
276
				<dd>', $context['member']['username'], '</dd>';
277
278
	if (!isset($context['disabled_fields']['posts']))
279
		echo '
280
				<dt>', $txt['profile_posts'], ': </dt>
281
				<dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>';
282
283 View Code Duplication
	if ($context['member']['show_email'])
284
	{
285
		echo '
286
				<dt>', $txt['email'], ': </dt>
287
				<dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>';
288
	}
289
290
	if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title']))
291
		echo '
292
				<dt>', $txt['custom_title'], ': </dt>
293
				<dd>', $context['member']['title'], '</dd>';
294
295
	if (!empty($context['member']['blurb']))
296
		echo '
297
				<dt>', $txt['personal_text'], ': </dt>
298
				<dd>', $context['member']['blurb'], '</dd>';
299
300
	echo '
301
				<dt>', $txt['age'], ':</dt>
302
				<dd>', $context['member']['age'] . ($context['member']['today_is_birthday'] ? ' &nbsp; <img src="' . $settings['images_url'] . '/cake.png" alt="">' : ''), '</dd>';
303
304
	echo '
305
			</dl>';
306
307
	// Any custom fields for standard placement?
308 View Code Duplication
	if (!empty($context['print_custom_fields']['standard']))
309
	{
310
		echo '
311
				<dl class="settings">';
312
313
		foreach ($context['print_custom_fields']['standard'] as $field)
314
			if (!empty($field['output_html']))
315
				echo '
316
					<dt>', $field['name'], ':</dt>
317
					<dd>', $field['output_html'], '</dd>';
318
319
		echo '
320
				</dl>';
321
	}
322
323
	echo '
324
				<dl class="settings noborder">';
325
326
	// Can they view/issue a warning?
327
	if ($context['can_view_warning'] && $context['member']['warning'])
328
	{
329
		echo '
330
					<dt>', $txt['profile_warning_level'], ': </dt>
331
					<dd>
332
						<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>';
333
334
		// Can we provide information on what this means?
335
		if (!empty($context['warning_status']))
336
			echo '
337
						<span class="smalltext">(', $context['warning_status'], ')</span>';
338
339
		echo '
340
					</dd>';
341
	}
342
343
	// Is this member requiring activation and/or banned?
344
	if (!empty($context['activate_message']) || !empty($context['member']['bans']))
345
	{
346
347
		// If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves.
348
		if (!empty($context['activate_message']))
349
			echo '
350
					<dt class="clear"><span class="alert">', $context['activate_message'], '</span>&nbsp;(<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="' . $txt['profileConfirm'] . '"' : ''), '>', $context['activate_link_text'], '</a>)</dt>';
351
352
		// If the current member is banned, show a message and possibly a link to the ban.
353
		if (!empty($context['member']['bans']))
354
		{
355
			echo '
356
					<dt class="clear"><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>]</dt>
357
					<dt class="clear" id="ban_info" style="display: none;">
358
						<strong>', $txt['user_banned_by_following'], ':</strong>';
359
360
			foreach ($context['member']['bans'] as $ban)
361
				echo '
362
						<br><span class="smalltext">', $ban['explanation'], '</span>';
363
364
			echo '
365
					</dt>';
366
		}
367
	}
368
369
	echo '
370
					<dt>', $txt['date_registered'], ': </dt>
371
					<dd>', $context['member']['registered'], '</dd>';
372
373
	// If the person looking is allowed, they can check the members IP address and hostname.
374
	if ($context['can_see_ip'])
375
	{
376
		if (!empty($context['member']['ip']))
377
		echo '
378
					<dt>', $txt['ip'], ': </dt>
379
					<dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>';
380
381
		if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip']))
382
			echo '
383
					<dt>', $txt['hostname'], ': </dt>
384
					<dd>', $context['member']['hostname'], '</dd>';
385
	}
386
387
	echo '
388
					<dt>', $txt['local_time'], ':</dt>
389
					<dd>', $context['member']['local_time'], '</dd>';
390
391
	if (!empty($modSettings['userLanguage']) && !empty($context['member']['language']))
392
		echo '
393
					<dt>', $txt['language'], ':</dt>
394
					<dd>', $context['member']['language'], '</dd>';
395
396
	if ($context['member']['show_last_login'])
397
		echo '
398
					<dt>', $txt['lastLoggedIn'], ': </dt>
399
					<dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>';
400
401
	echo '
402
				</dl>';
403
404
	// Are there any custom profile fields for above the signature?
405 View Code Duplication
	if (!empty($context['print_custom_fields']['above_signature']))
406
	{
407
		echo '
408
				<div class="custom_fields_above_signature">
409
					<ul class="nolist">';
410
411
		foreach ($context['print_custom_fields']['above_signature'] as $field)
412
			if (!empty($field['output_html']))
413
				echo '
414
						<li>', $field['output_html'], '</li>';
415
416
		echo '
417
					</ul>
418
				</div>';
419
	}
420
421
	// Show the users signature.
422 View Code Duplication
	if ($context['signature_enabled'] && !empty($context['member']['signature']))
423
		echo '
424
				<div class="signature">
425
					<h5>', $txt['signature'], ':</h5>
426
					', $context['member']['signature'], '
427
				</div>';
428
429
	// Are there any custom profile fields for below the signature?
430 View Code Duplication
	if (!empty($context['print_custom_fields']['below_signature']))
431
	{
432
		echo '
433
				<div class="custom_fields_below_signature">
434
					<ul class="nolist">';
435
436
		foreach ($context['print_custom_fields']['below_signature'] as $field)
437
			if (!empty($field['output_html']))
438
				echo '
439
						<li>', $field['output_html'], '</li>';
440
441
		echo '
442
					</ul>
443
				</div>';
444
	}
445
446
	echo '
447
		</div>
448
	</div>
449
<div class="clear"></div>';
450
}
451
452
/**
453
 * Template for showing all the posts of the user, in chronological order.
454
 */
455
function template_showPosts()
456
{
457
	global $context, $scripturl, $txt;
458
459
	echo '
460
		<div class="cat_bar">
461
			<h3 class="catbg">
462
				', (!isset($context['attachments']) && empty($context['is_topics']) ? $txt['showMessages'] : (!empty($context['is_topics']) ? $txt['showTopics'] : $txt['showAttachments'])), ' - ', $context['member']['name'], '
463
			</h3>
464
		</div>', !empty($context['page_index']) ? '
465
		<div class="pagesection">
466
			<div class="pagelinks">' . $context['page_index'] . '</div>
467
		</div>' : '';
468
469
	// Are we displaying posts or attachments?
470
	if (!isset($context['attachments']))
471
	{
472
		// For every post to be displayed, give it its own div, and show the important details of the post.
473
		foreach ($context['posts'] as $post)
474
		{
475
			echo '
476
			<div class="', $post['css_class'], '">
477
				<div class="counter">', $post['counter'], '</div>
478
				<div class="topic_details">
479
					<h5><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></h5>
480
					<span class="smalltext">', $post['time'], '</span>
481
				</div>
482
				<div class="list_posts">';
483
484
			if (!$post['approved'])
485
				echo '
486
					<div class="approve_post">
487
						<em>', $txt['post_awaiting_approval'], '</em>
488
					</div>';
489
490
			echo '
491
					', $post['body'], '
492
				</div>';
493
494
			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
495
				echo '
496
				<div class="floatright">
497
					<ul class="quickbuttons">';
498
499
			// If they *can* reply?
500 View Code Duplication
			if ($post['can_reply'])
501
				echo '
502
						<li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>';
503
504
			// If they *can* quote?
505 View Code Duplication
			if ($post['can_quote'])
506
				echo '
507
						<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>';
508
509
			// How about... even... remove it entirely?!
510 View Code Duplication
			if ($post['can_delete'])
511
				echo '
512
						<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>';
513
514
			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
515
				echo '
516
					</ul>
517
				</div>';
518
519
			echo '
520
			</div>';
521
		}
522
	}
523
	else
524
		template_show_list('attachments');
525
526
	// No posts? Just end with a informative message.
527
	if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts'])))
528
		echo '
529
			<div class="windowbg2">
530
				', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), '
531
			</div>';
532
533
	// Show more page numbers.
534
	if (!empty($context['page_index']))
535
		echo '
536
		<div class="pagesection">
537
			<div class="pagelinks">', $context['page_index'], '</div>
538
		</div>';
539
}
540
541
/**
542
 * Template for showing alerts within the alerts popup
543
 */
544
function template_showAlerts()
545
{
546
	global $context, $txt, $scripturl;
547
548
	// Do we have an update message?
549
	if (!empty($context['update_message']))
550
		echo '
551
		<div class="infobox">
552
			', $context['update_message'], '.
553
		</div>';
554
555
	echo '
556
		<div class="cat_bar">
557
			<h3 class="catbg">
558
			', $txt['alerts'], ' - ', $context['member']['name'], '
559
			</h3>
560
		</div>';
561
562
	if (empty($context['alerts']))
563
		echo '
564
		<div class="information">
565
			', $txt['alerts_none'], '
566
		</div>';
567
568
	else
569
	{
570
		// Start the form.
571
		echo '
572
		<form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;save" method="post" accept-charset="', $context['character_set'], '" id="mark_all">
573
			<table id="alerts" class="table_grid">';
574
575
		foreach ($context['alerts'] as $id => $alert)
576
		{
577
			echo '
578
				<tr class="windowbg">
579
					<td>', $alert['text'], '</td>
580
					<td>', $alert['time'], '</td>
581
					<td>
582
						<ul class="quickbuttons">
583
							<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>
584
							<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>
585
							<li><input type="checkbox" name="mark[', $id, ']" value="', $id, '"></li>
586
						</ul>
587
					</td>
588
				</tr>';
589
		}
590
591
		echo '
592
			</table>
593
			<div class="pagesection">
594
				<div class="floatleft">
595
					', $context['pagination'], '
596
				</div>
597
				<div class="floatright">
598
					', $txt['check_all'], ': <input type="checkbox" name="select_all" id="select_all">
599
					<select name="mark_as">
600
						<option value="read">', $txt['quick_mod_markread'], '</option>
601
						<option value="unread">', $txt['quick_mod_markunread'], '</option>
602
						<option value="remove">', $txt['quick_mod_remove'], '</option>
603
					</select>
604
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
605
					<input type="submit" name="req" value="', $txt['quick_mod_go'], '" class="button_submit you_sure">
606
				</div>
607
			</div>
608
		</form>';
609
	}
610
}
611
612
/**
613
 * Template for showing all of a user's drafts
614
 */
615
function template_showDrafts()
616
{
617
	global $context, $scripturl, $txt;
618
619
	echo '
620
		<div class="cat_bar">
621
			<h3 class="catbg">
622
				', $txt['drafts'], ' - ', $context['member']['name'], '
623
			</h3>
624
		</div>', !empty($context['page_index']) ? '
625
		<div class="pagesection">
626
			<div class="pagelinks">' . $context['page_index'] . '</div>
627
		</div>' : '';
628
629
	// No drafts? Just show an informative message.
630
	if (empty($context['drafts']))
631
		echo '
632
		<div class="windowbg2 centertext">
633
			', $txt['draft_none'], '
634
		</div>';
635
	else
636
	{
637
		// For every draft to be displayed, give it its own div, and show the important details of the draft.
638
		foreach ($context['drafts'] as $draft)
639
		{
640
			echo '
641
				<div class="windowbg">
642
					<div class="counter">', $draft['counter'], '</div>
643
					<div class="topic_details">
644
						<h5><strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> &nbsp; &nbsp;';
645
646
			if (!empty($draft['sticky']))
647
				echo '<span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>';
648
649
			if (!empty($draft['locked']))
650
				echo '<span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>';
651
652
			echo '
653
						</h5>
654
						<span class="smalltext">&#171;&nbsp;<strong>', $txt['on'], ':</strong> ', $draft['time'], '&nbsp;&#187;</span>
655
					</div>
656
					<div class="list_posts">
657
						', $draft['body'], '
658
					</div>
659
				<div class="floatright">
660
					<ul class="quickbuttons">
661
						<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>
662
						<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>
663
					</ul>
664
				</div>
665
			</div>';
666
		}
667
	}
668
669
	// Show page numbers.
670
	echo '
671
		<div class="pagesection">
672
			<div class="pagelinks">', $context['page_index'], '</div>
673
		</div>';
674
}
675
676
/**
677
 * Template for showing and managing the buddy list.
678
 */
679
function template_editBuddies()
680
{
681
	global $context, $scripturl, $txt;
682
683 View Code Duplication
	if (!empty($context['saved_successful']))
684
		echo '
685
					<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
686
	elseif (!empty($context['saved_failed']))
687
		echo '
688
					<div class="errorbox">', $context['saved_failed'], '</div>';
689
690
	echo '
691
	<div id="edit_buddies">
692
		<div class="cat_bar">
693
			<h3 class="catbg">
694
				<span class="generic_icons people icon"></span> ', $txt['editBuddies'], '
695
			</h3>
696
		</div>
697
		<table class="table_grid">
698
			<tr class="title_bar">
699
				<th scope="col" class="quarter_table">', $txt['name'], '</th>
700
				<th scope="col">', $txt['status'], '</th>';
701
702
	if (allowedTo('moderate_forum'))
703
		echo '
704
				<th scope="col">', $txt['email'], '</th>';
705
706 View Code Duplication
	if (!empty($context['custom_pf']))
707
		foreach ($context['custom_pf'] as $column)
708
				echo '<th scope="col">', $column['label'], '</th>';
709
710
	echo '
711
				<th scope="col">', $txt['remove'], '</th>
712
			</tr>';
713
714
	// If they don't have any buddies don't list them!
715
	if (empty($context['buddies']))
716
		echo '
717
			<tr class="windowbg">
718
				<td colspan="', allowedTo('moderate_forum') ? '10' : '9', '"><strong>', $txt['no_buddies'], '</strong></td>
719
			</tr>';
720
721
		// Now loop through each buddy showing info on each.
722
	else
723
	{
724
		foreach ($context['buddies'] as $buddy)
725
		{
726
			echo '
727
				<tr class="windowbg">
728
					<td>', $buddy['link'], '</td>
729
					<td><a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a></td>';
730
731 View Code Duplication
			if ($buddy['show_email'])
732
				echo '
733
					<td><a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a></td>';
734
735
			// Show the custom profile fields for this user.
736 View Code Duplication
			if (!empty($context['custom_pf']))
737
				foreach ($context['custom_pf'] as $key => $column)
738
					echo '
739
						<td class="lefttext">', $buddy['options'][$key], '</td>';
740
741
			echo '
742
					<td><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></td>
743
				</tr>';
744
		}
745
	}
746
747
	echo '
748
		</table>
749
	</div>';
750
751
	// Add a new buddy?
752
	echo '
753
	<form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=buddies" method="post" accept-charset="', $context['character_set'], '">
754
		<div class="cat_bar">
755
			<h3 class="catbg">', $txt['buddy_add'], '</h3>
756
		</div>
757
		<div class="information">
758
			<dl class="settings">
759
				<dt>
760
					<label for="new_buddy"><strong>', $txt['who_member'], ':</strong></label>
761
				</dt>
762
				<dd>
763
					<input type="text" name="new_buddy" id="new_buddy" size="30" class="input_text">
764
					<input type="submit" value="', $txt['buddy_add_button'], '" class="button_submit floatnone">
765
				</dd>
766
			</dl>
767
		</div>';
768
769 View Code Duplication
	if (!empty($context['token_check']))
770
		echo '
771
			<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
772
773
	echo '
774
		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
775
	</form>
776
	<script>
777
		var oAddBuddySuggest = new smc_AutoSuggest({
778
			sSelf: \'oAddBuddySuggest\',
779
			sSessionId: smf_session_id,
780
			sSessionVar: smf_session_var,
781
			sSuggestId: \'new_buddy\',
782
			sControlId: \'new_buddy\',
783
			sSearchType: \'member\',
784
			sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
785
			bItemList: false
786
		});
787
	</script>';
788
}
789
790
/**
791
 * Template for showing the ignore list of the current user.
792
 */
793
function template_editIgnoreList()
794
{
795
	global $context, $scripturl, $txt;
796
797 View Code Duplication
	if (!empty($context['saved_successful']))
798
		echo '
799
					<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
800
	elseif (!empty($context['saved_failed']))
801
		echo '
802
					<div class="errorbox">', $context['saved_failed'], '</div>';
803
804
	echo '
805
	<div id="edit_buddies">
806
		<div class="cat_bar">
807
			<h3 class="catbg profile_hd">
808
				', $txt['editIgnoreList'], '
809
			</h3>
810
		</div>
811
		<table class="table_grid">
812
			<tr class="title_bar">
813
				<th scope="col" class="quarter_table">', $txt['name'], '</th>
814
				<th scope="col">', $txt['status'], '</th>';
815
816
	if (allowedTo('moderate_forum'))
817
		echo '
818
				<th scope="col">', $txt['email'], '</th>';
819
820
	echo '
821
				<th scope="col">', $txt['ignore_remove'], '</th>
822
			</tr>';
823
824
	// If they don't have anyone on their ignore list, don't list it!
825
	if (empty($context['ignore_list']))
826
		echo '
827
			<tr class="windowbg">
828
				<td colspan="', allowedTo('moderate_forum') ? '4' : '3', '"><strong>', $txt['no_ignore'], '</strong></td>
829
			</tr>';
830
831
	// Now loop through each buddy showing info on each.
832
	foreach ($context['ignore_list'] as $member)
833
	{
834
		echo '
835
			<tr class="windowbg">
836
				<td>', $member['link'], '</td>
837
				<td><a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a></td>';
838
839 View Code Duplication
		if ($member['show_email'])
840
			echo '
841
				<td><a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a></td>';
842
		echo '
843
				<td><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></td>
844
			</tr>';
845
	}
846
847
	echo '
848
		</table>
849
	</div>';
850
851
	// Add to the ignore list?
852
	echo '
853
	<form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore" method="post" accept-charset="', $context['character_set'], '">
854
		<div class="cat_bar">
855
			<h3 class="catbg">', $txt['ignore_add'], '</h3>
856
		</div>
857
		<div class="information">
858
			<dl class="settings">
859
				<dt>
860
					<label for="new_buddy"><strong>', $txt['who_member'], ':</strong></label>
861
				</dt>
862
				<dd>
863
					<input type="text" name="new_ignore" id="new_ignore" size="25" class="input_text">
864
				</dd>
865
			</dl>
866
		</div>';
867
868 View Code Duplication
	if (!empty($context['token_check']))
869
		echo '
870
		<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
871
872
	echo '
873
		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
874
		<input type="submit" value="', $txt['ignore_add_button'], '" class="button_submit">
875
	</form>
876
	<script>
877
		var oAddIgnoreSuggest = new smc_AutoSuggest({
878
			sSelf: \'oAddIgnoreSuggest\',
879
			sSessionId: \'', $context['session_id'], '\',
880
			sSessionVar: \'', $context['session_var'], '\',
881
			sSuggestId: \'new_ignore\',
882
			sControlId: \'new_ignore\',
883
			sSearchType: \'member\',
884
			sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
885
			bItemList: false
886
		});
887
	</script>';
888
}
889
890
/**
891
 * This template shows an admin information on a users IP addresses used and errors attributed to them.
892
 */
893
function template_trackActivity()
894
{
895
	global $context, $scripturl, $txt;
896
897
	// The first table shows IP information about the user.
898
	echo '
899
		<div class="cat_bar">
900
			<h3 class="catbg">', $txt['view_ips_by'], ' ', $context['member']['name'], '</h3>
901
		</div>';
902
903
	// The last IP the user used.
904
	echo '
905
		<div id="tracking" class="windowbg2 noup">
906
			<dl class="settings noborder">
907
				<dt>', $txt['most_recent_ip'], ':
908
					', (empty($context['last_ip2']) ? '' : '<br>
909
					<span class="smalltext">(<a href="' . $scripturl . '?action=helpadmin;help=whytwoip" onclick="return reqOverlayDiv(this.href);">' . $txt['why_two_ip_address'] . '</a>)</span>'), '
910
				</dt>
911
				<dd>
912
					<a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>';
913
914
	// Second address detected?
915 View Code Duplication
	if (!empty($context['last_ip2']))
916
		echo '
917
					, <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>';
918
919
	echo '
920
				</dd>';
921
922
	// Lists of IP addresses used in messages / error messages.
923
	echo '
924
				<dt>', $txt['ips_in_messages'], ':</dt>
925
				<dd>
926
					', (count($context['ips']) > 0 ? implode(', ', $context['ips']) : '(' . $txt['none'] . ')'), '
927
				</dd>
928
				<dt>', $txt['ips_in_errors'], ':</dt>
929
				<dd>
930
					', (count($context['ips']) > 0 ? implode(', ', $context['error_ips']) : '(' . $txt['none'] . ')'), '
931
				</dd>';
932
933
	// List any members that have used the same IP addresses as the current member.
934
	echo '
935
				<dt>', $txt['members_in_range'], ':</dt>
936
				<dd>
937
					', (count($context['members_in_range']) > 0 ? implode(', ', $context['members_in_range']) : '(' . $txt['none'] . ')'), '
938
				</dd>
939
			</dl>
940
		</div>';
941
942
	// Show the track user list.
943
	template_show_list('track_user_list');
944
}
945
946
/**
947
 * The template for trackIP, allowing the admin to see where/who a certain IP has been used.
948
 */
949
function template_trackIP()
950
{
951
	global $context, $txt;
952
953
	// This function always defaults to the last IP used by a member but can be set to track any IP.
954
	// The first table in the template gives an input box to allow the admin to enter another IP to track.
955
	echo '
956
		<div class="cat_bar">
957
			<h3 class="catbg">', $txt['trackIP'], '</h3>
958
		</div>
959
		<div class="windowbg2 noup">
960
			<form action="', $context['base_url'], '" method="post" accept-charset="', $context['character_set'], '">
961
				<dl class="settings">
962
					<dt>
963
						<label for="searchip"><strong>', $txt['enter_ip'], ':</strong></label>
964
					</dt>
965
					<dd>
966
						<input type="text" name="searchip" value="', $context['ip'], '" class="input_text">
967
					</dd>
968
				</dl>
969
				<input type="submit" value="', $txt['trackIP'], '" class="button_submit">
970
			</form>
971
		</div>
972
	<br>';
973
974
	// The table inbetween the first and second table shows links to the whois server for every region.
975
	if ($context['single_ip'])
976
	{
977
		echo '
978
			<div class="cat_bar">
979
				<h3 class="catbg">', $txt['whois_title'], ' ', $context['ip'], '</h3>
980
			</div>
981
			<div class="windowbg2 noup">';
982
			foreach ($context['whois_servers'] as $server)
983
			echo '
984
				<a href="', $server['url'], '" target="_blank" class="new_win"', isset($context['auto_whois_server']) && $context['auto_whois_server']['name'] == $server['name'] ? ' style="font-weight: bold;"' : '', '>', $server['name'], '</a><br>';
985
			echo '
986
			</div>
987
			<br>';
988
	}
989
990
	// The second table lists all the members who have been logged as using this IP address.
991
	echo '
992
		<div class="cat_bar">
993
			<h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3>
994
		</div>';
995
	if (empty($context['ips']))
996
		echo '
997
		<p class="windowbg2 description"><em>', $txt['no_members_from_ip'], '</em></p>';
998
	else
999
	{
1000
		echo '
1001
		<table class="table_grid">
1002
			<thead>
1003
				<tr class="title_bar">
1004
					<th scope="col">', $txt['ip_address'], '</th>
1005
					<th scope="col">', $txt['display_name'], '</th>
1006
				</tr>
1007
			</thead>
1008
			<tbody>';
1009
1010
		// Loop through each of the members and display them.
1011
		foreach ($context['ips'] as $ip => $memberlist)
1012
			echo '
1013
				<tr class="windowbg">
1014
					<td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td>
1015
					<td>', implode(', ', $memberlist), '</td>
1016
				</tr>';
1017
1018
		echo '
1019
			</tbody>
1020
		</table>';
1021
	}
1022
1023
	echo '
1024
	<br>';
1025
1026
	template_show_list('track_message_list');
1027
1028
	echo '<br>';
1029
1030
	template_show_list('track_user_list');
1031
1032
	// 3rd party integrations may have added additional tracking.
1033
	if (!empty($context['additional_track_lists']))
1034
	{
1035
		foreach ($context['additional_track_lists'] as $list)
1036
		{
1037
			echo '<br>';
1038
1039
			template_show_list($list);
1040
		}
1041
	}
1042
}
1043
1044
/**
1045
 * This template shows an admin which permissions a user have and which group(s) give them each permission.
1046
 */
1047
function template_showPermissions()
1048
{
1049
	global $context, $scripturl, $txt;
1050
1051
	echo '
1052
		<div class="cat_bar">
1053
			<h3 class="catbg profile_hd">
1054
				', $txt['showPermissions'], '
1055
			</h3>
1056
		</div>';
1057
1058
	if ($context['member']['has_all_permissions'])
1059
	{
1060
		echo '
1061
		<div class="information">', $txt['showPermissions_all'], '</div>';
1062
	}
1063
	else
1064
	{
1065
		echo '
1066
		<div class="information">',$txt['showPermissions_help'], '</div>
1067
		<div id="permissions" class="flow_hidden">';
1068
1069
		if (!empty($context['no_access_boards']))
1070
		{
1071
			echo '
1072
				<div class="cat_bar">
1073
					<h3 class="catbg">', $txt['showPermissions_restricted_boards'], '</h3>
1074
				</div>
1075
				<div class="windowbg smalltext">
1076
					', $txt['showPermissions_restricted_boards_desc'], ':<br>';
1077
				foreach ($context['no_access_boards'] as $no_access_board)
1078
					echo '
1079
						<a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', ';
1080
				echo '
1081
				</div>';
1082
		}
1083
1084
		// General Permissions section.
1085
		echo '
1086
				<div class="tborder">
1087
					<div class="cat_bar">
1088
						<h3 class="catbg">', $txt['showPermissions_general'], '</h3>
1089
					</div>';
1090 View Code Duplication
		if (!empty($context['member']['permissions']['general']))
1091
		{
1092
			echo '
1093
					<table class="table_grid">
1094
						<thead>
1095
							<tr class="title_bar">
1096
								<th class="lefttext half_table">', $txt['showPermissions_permission'], '</th>
1097
								<th class="lefttext half_table">', $txt['showPermissions_status'], '</th>
1098
							</tr>
1099
						</thead>
1100
						<tbody>';
1101
1102
			foreach ($context['member']['permissions']['general'] as $permission)
1103
			{
1104
				echo '
1105
							<tr class="windowbg">
1106
								<td title="', $permission['id'], '">
1107
									', $permission['is_denied'] ? '<del>' . $permission['name'] . '</del>' : $permission['name'], '
1108
								</td>
1109
								<td class="smalltext">';
1110
1111
				if ($permission['is_denied'])
1112
					echo '
1113
									<span class="alert">', $txt['showPermissions_denied'], ':&nbsp;', implode(', ', $permission['groups']['denied']), '</span>';
1114
				else
1115
					echo '
1116
									', $txt['showPermissions_given'], ':&nbsp;', implode(', ', $permission['groups']['allowed']);
1117
1118
					echo '
1119
								</td>
1120
							</tr>';
1121
			}
1122
			echo '
1123
						</tbody>
1124
					</table>
1125
				</div><br>';
1126
		}
1127
		else
1128
			echo '
1129
			<p class="windowbg2">', $txt['showPermissions_none_general'], '</p>';
1130
1131
		// Board permission section.
1132
		echo '
1133
			<form action="' . $scripturl . '?action=profile;u=', $context['id_member'], ';area=permissions#board_permissions" method="post" accept-charset="', $context['character_set'], '">
1134
				<div class="cat_bar">
1135
					<h3 class="catbg">
1136
						<a id="board_permissions"></a>', $txt['showPermissions_select'], ':
1137
						<select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();">
1138
							<option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], '&nbsp;</option>';
1139
				if (!empty($context['boards']))
1140
					echo '
1141
							<option value="" disabled>---------------------------</option>';
1142
1143
				// Fill the box with any local permission boards.
1144
				foreach ($context['boards'] as $board)
1145
					echo '
1146
							<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>';
1147
1148
				echo '
1149
						</select>
1150
					</h3>
1151
				</div>
1152
			</form>';
1153 View Code Duplication
		if (!empty($context['member']['permissions']['board']))
1154
		{
1155
			echo '
1156
			<table class="table_grid">
1157
				<thead>
1158
					<tr class="title_bar">
1159
						<th class="lefttext half_table">', $txt['showPermissions_permission'], '</th>
1160
						<th class="lefttext half_table">', $txt['showPermissions_status'], '</th>
1161
					</tr>
1162
				</thead>
1163
				<tbody>';
1164
			foreach ($context['member']['permissions']['board'] as $permission)
1165
			{
1166
				echo '
1167
					<tr class="windowbg">
1168
						<td title="', $permission['id'], '">
1169
							', $permission['is_denied'] ? '<del>' . $permission['name'] . '</del>' : $permission['name'], '
1170
						</td>
1171
						<td class="smalltext">';
1172
1173
				if ($permission['is_denied'])
1174
				{
1175
					echo '
1176
							<span class="alert">', $txt['showPermissions_denied'], ':&nbsp;', implode(', ', $permission['groups']['denied']), '</span>';
1177
				}
1178
				else
1179
				{
1180
					echo '
1181
							', $txt['showPermissions_given'], ': &nbsp;', implode(', ', $permission['groups']['allowed']);
1182
				}
1183
				echo '
1184
						</td>
1185
					</tr>';
1186
			}
1187
			echo '
1188
				</tbody>
1189
			</table>';
1190
		}
1191
		else
1192
			echo '
1193
			<p class="windowbg2">', $txt['showPermissions_none_board'], '</p>';
1194
	echo '
1195
			</div>
1196
		</div>';
1197
	}
1198
}
1199
1200
/**
1201
 * Template for user statistics, showing graphs and the like.
1202
 */
1203
function template_statPanel()
1204
{
1205
	global $context, $txt;
1206
1207
	// First, show a few text statistics such as post/topic count.
1208
	echo '
1209
	<div id="profileview" class="roundframe">
1210
		<div id="generalstats">
1211
			<dl class="stats">
1212
				<dt>', $txt['statPanel_total_time_online'], ':</dt>
1213
				<dd>', $context['time_logged_in'], '</dd>
1214
				<dt>', $txt['statPanel_total_posts'], ':</dt>
1215
				<dd>', $context['num_posts'], ' ', $txt['statPanel_posts'], '</dd>
1216
				<dt>', $txt['statPanel_total_topics'], ':</dt>
1217
				<dd>', $context['num_topics'], ' ', $txt['statPanel_topics'], '</dd>
1218
				<dt>', $txt['statPanel_users_polls'], ':</dt>
1219
				<dd>', $context['num_polls'], ' ', $txt['statPanel_polls'], '</dd>
1220
				<dt>', $txt['statPanel_users_votes'], ':</dt>
1221
				<dd>', $context['num_votes'], ' ', $txt['statPanel_votes'], '</dd>
1222
			</dl>
1223
		</div>';
1224
1225
	// This next section draws a graph showing what times of day they post the most.
1226
	echo '
1227
		<div id="activitytime" class="flow_hidden">
1228
			<div class="title_bar">
1229
				<h3 class="titlebg">
1230
					<span class="generic_icons history"></span> ', $txt['statPanel_activityTime'], '
1231
				</h3>
1232
			</div>';
1233
1234
	// If they haven't post at all, don't draw the graph.
1235
	if (empty($context['posts_by_time']))
1236
		echo '
1237
			<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1238
	// Otherwise do!
1239
	else
1240
	{
1241
		echo '
1242
			<ul class="activity_stats flow_hidden">';
1243
1244
		// The labels.
1245
		foreach ($context['posts_by_time'] as $time_of_day)
1246
		{
1247
			echo '
1248
				<li', $time_of_day['is_last'] ? ' class="last"' : '', '>
1249
					<div class="bar" style="padding-top: ', ((int) (100 - $time_of_day['relative_percent'])), 'px;" title="', sprintf($txt['statPanel_activityTime_posts'], $time_of_day['posts'], $time_of_day['posts_percent']), '">
1250
						<div style="height: ', (int) $time_of_day['relative_percent'], 'px;">
1251
							<span>', sprintf($txt['statPanel_activityTime_posts'], $time_of_day['posts'], $time_of_day['posts_percent']), '</span>
1252
						</div>
1253
					</div>
1254
					<span class="stats_hour">', $time_of_day['hour_format'], '</span>
1255
				</li>';
1256
		}
1257
1258
		echo '
1259
1260
			</ul>';
1261
	}
1262
1263
	echo '
1264
		</div>';
1265
1266
	// Two columns with the most popular boards by posts and activity (activity = users posts / total posts).
1267
	echo '
1268
		<div class="flow_hidden">
1269
			<div class="half_content">
1270
				<div class="title_bar">
1271
					<h3 class="titlebg">
1272
						<span class="generic_icons replies"></span> ', $txt['statPanel_topBoards'], '
1273
					</h3>
1274
				</div>';
1275
1276 View Code Duplication
	if (empty($context['popular_boards']))
1277
		echo '
1278
				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1279
1280
	else
1281
	{
1282
		echo '
1283
				<dl class="stats">';
1284
1285
		// Draw a bar for every board.
1286
		foreach ($context['popular_boards'] as $board)
1287
		{
1288
			echo '
1289
					<dt>', $board['link'], '</dt>
1290
					<dd>
1291
						<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']), '">
1292
							', sprintf($txt['statPanel_topBoards_memberposts'], $board['posts'], $board['total_posts_member'], $board['posts_percent']), '
1293
						</div>
1294
						', empty($context['hide_num_posts']) ? $board['posts'] : '', '
1295
					</dd>';
1296
		}
1297
1298
		echo '
1299
				</dl>';
1300
	}
1301
	echo '
1302
			</div>';
1303
	echo '
1304
			<div class="half_content">
1305
				<div class="title_bar">
1306
					<h3 class="titlebg">
1307
						<span class="generic_icons replies"></span> ', $txt['statPanel_topBoardsActivity'], '
1308
					</h3>
1309
				</div>';
1310
1311 View Code Duplication
	if (empty($context['board_activity']))
1312
		echo '
1313
				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1314
	else
1315
	{
1316
		echo '
1317
				<dl class="stats">';
1318
1319
		// Draw a bar for every board.
1320
		foreach ($context['board_activity'] as $activity)
1321
		{
1322
			echo '
1323
					<dt>', $activity['link'], '</dt>
1324
					<dd>
1325
						<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']), '">
1326
							', sprintf($txt['statPanel_topBoards_posts'], $activity['posts'], $activity['total_posts'], $activity['posts_percent']), '
1327
						</div>
1328
						', $activity['percent'], '%
1329
					</dd>';
1330
		}
1331
1332
		echo '
1333
				</dl>';
1334
	}
1335
	echo '
1336
			</div>
1337
		</div>';
1338
1339
	echo '
1340
	</div>';
1341
}
1342
1343
/**
1344
 * Template for editing profile options.
1345
 */
1346
function template_edit_options()
1347
{
1348
	global $context, $scripturl, $txt, $modSettings;
1349
1350
	// The main header!
1351
	// because some browsers ignore autocomplete=off and fill username in display name and/ or email field, fake them out.
1352
	$url = !empty($context['profile_custom_submit_url']) ? $context['profile_custom_submit_url'] : $scripturl . '?action=profile;area=' . $context['menu_item_selected'] . ';u=' . $context['id_member'];
1353
	$url = $context['require_password'] && !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($url, array('http://' => 'https://')) : $url;
1354
1355
	echo '
1356
		<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"' : ''), '>
1357
			<div style="position:absolute; top:-100px;"><input type="text" id="autocompleteFakeName"/><input type="password" id="autocompleteFakePassword"/></div>
1358
			<div class="cat_bar">
1359
				<h3 class="catbg profile_hd">';
1360
1361
		// Don't say "Profile" if this isn't the profile...
1362
		if (!empty($context['profile_header_text']))
1363
			echo '
1364
					', $context['profile_header_text'];
1365
		else
1366
			echo '
1367
					', $txt['profile'];
1368
1369
		echo '
1370
				</h3>
1371
			</div>';
1372
1373
	// Have we some description?
1374
	if ($context['page_desc'])
1375
		echo '
1376
			<p class="information">', $context['page_desc'], '</p>';
1377
1378
	echo '
1379
			<div class="roundframe">';
1380
1381
	// Any bits at the start?
1382
	if (!empty($context['profile_prehtml']))
1383
		echo '
1384
				<div>', $context['profile_prehtml'], '</div>';
1385
1386
	if (!empty($context['profile_fields']))
1387
		echo '
1388
				<dl class="settings">';
1389
1390
	// Start the big old loop 'of love.
1391
	$lastItem = 'hr';
1392
	foreach ($context['profile_fields'] as $key => $field)
1393
	{
1394
		// We add a little hack to be sure we never get more than one hr in a row!
1395
		if ($lastItem == 'hr' && $field['type'] == 'hr')
1396
			continue;
1397
1398
		$lastItem = $field['type'];
1399
		if ($field['type'] == 'hr')
1400
		{
1401
			echo '
1402
				</dl>
1403
				<hr>
1404
				<dl class="settings">';
1405
		}
1406 View Code Duplication
		elseif ($field['type'] == 'callback')
1407
		{
1408
			if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func']))
1409
			{
1410
				$callback_func = 'template_profile_' . $field['callback_func'];
1411
				$callback_func();
1412
			}
1413
		}
1414
		else
1415
		{
1416
			echo '
1417
					<dt>
1418
						<strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>';
1419
1420
			// Does it have any subtext to show?
1421
			if (!empty($field['subtext']))
1422
				echo '
1423
						<br>
1424
						<span class="smalltext">', $field['subtext'], '</span>';
1425
1426
			echo '
1427
					</dt>
1428
					<dd>';
1429
1430
			// Want to put something infront of the box?
1431
			if (!empty($field['preinput']))
1432
				echo '
1433
						', $field['preinput'];
1434
1435
			// What type of data are we showing?
1436
			if ($field['type'] == 'label')
1437
				echo '
1438
						', $field['value'];
1439
1440
			// Maybe it's a text box - very likely!
1441
			elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url')))
1442
			{
1443
				if ($field['type'] == 'int' || $field['type'] == 'float')
1444
					$type = 'number';
1445
				else
1446
					$type = $field['type'];
1447
				$step = $field['type'] == 'float' ? ' step="0.1"' : '';
1448
1449
1450
				echo '
1451
						<input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' class="input_', $field['type'] == 'password' ? 'password' : 'text', '"', $step, '>';
1452
			}
1453
			// You "checking" me out? ;)
1454 View Code Duplication
			elseif ($field['type'] == 'check')
1455
				echo '
1456
						<input type="hidden" name="', $key, '" value="0"><input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" class="input_check" ', $field['input_attr'], '>';
1457
1458
			// Always fun - select boxes!
1459 View Code Duplication
			elseif ($field['type'] == 'select')
1460
			{
1461
				echo '
1462
						<select name="', $key, '" id="', $key, '">';
1463
1464
				if (isset($field['options']))
1465
				{
1466
					// Is this some code to generate the options?
1467
					if (!is_array($field['options']))
1468
						$field['options'] = $field['options']();
1469
					// Assuming we now have some!
1470
					if (is_array($field['options']))
1471
						foreach ($field['options'] as $value => $name)
1472
							echo '
1473
								<option value="', $value, '"', $value == $field['value'] ? ' selected' : '', '>', $name, '</option>';
1474
				}
1475
1476
				echo '
1477
						</select>';
1478
			}
1479
1480
			// Something to end with?
1481
			if (!empty($field['postinput']))
1482
				echo '
1483
							', $field['postinput'];
1484
1485
			echo '
1486
					</dd>';
1487
		}
1488
	}
1489
1490
	if (!empty($context['profile_fields']))
1491
		echo '
1492
				</dl>';
1493
1494
	// Are there any custom profile fields - if so print them!
1495
	if (!empty($context['custom_fields']))
1496
	{
1497
		if ($lastItem != 'hr')
1498
			echo '
1499
				<hr>';
1500
1501
		echo '
1502
				<dl class="settings">';
1503
1504
		foreach ($context['custom_fields'] as $field)
1505
		{
1506
			echo '
1507
					<dt>
1508
						<strong>', $field['name'], ': </strong><br>
1509
						<span class="smalltext">', $field['desc'], '</span>
1510
					</dt>
1511
					<dd>
1512
						', $field['input_html'], '
1513
					</dd>';
1514
		}
1515
1516
		echo '
1517
					</dl>';
1518
1519
	}
1520
1521
	// Any closing HTML?
1522
	if (!empty($context['profile_posthtml']))
1523
		echo '
1524
				<div>', $context['profile_posthtml'], '</div>';
1525
1526
	// Only show the password box if it's actually needed.
1527 View Code Duplication
	if ($context['require_password'])
1528
		echo '
1529
				<dl class="settings">
1530
					<dt>
1531
						<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br>
1532
						<span class="smalltext">', $txt['required_security_reasons'], '</span>
1533
					</dt>
1534
					<dd>
1535
						<input type="password" name="oldpasswrd" id="oldpasswrd" size="20" style="margin-right: 4ex;" class="input_password">
1536
					</dd>
1537
				</dl>';
1538
1539
	// The button shouldn't say "Change profile" unless we're changing the profile...
1540
	if (!empty($context['submit_button_text']))
1541
		echo '
1542
				<input type="submit" name="save" value="', $context['submit_button_text'], '" class="button_submit">';
1543
	else
1544
		echo '
1545
				<input type="submit" name="save" value="', $txt['change_profile'], '" class="button_submit">';
1546
1547 View Code Duplication
	if (!empty($context['token_check']))
1548
		echo '
1549
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
1550
1551
	echo '
1552
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1553
				<input type="hidden" name="u" value="', $context['id_member'], '">
1554
				<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
1555
			</div>
1556
		</form>';
1557
1558
	// Any final spellchecking stuff?
1559
	if (!empty($context['show_spellchecking']))
1560
		echo '
1561
		<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>';
1562
}
1563
1564
/**
1565
 * Personal Message settings.
1566
 */
1567
function template_profile_pm_settings()
1568
{
1569
	global $context, $modSettings, $txt;
1570
1571
	echo '
1572
								<dt>
1573
									<label for="pm_prefs">', $txt['pm_display_mode'], ':</label>
1574
								</dt>
1575
								<dd>
1576
									<select name="pm_prefs" id="pm_prefs">
1577
										<option value="0"', $context['display_mode'] == 0 ? ' selected' : '', '>', $txt['pm_display_mode_all'], '</option>
1578
										<option value="1"', $context['display_mode'] == 1 ? ' selected' : '', '>', $txt['pm_display_mode_one'], '</option>
1579
										<option value="2"', $context['display_mode'] == 2 ? ' selected' : '', '>', $txt['pm_display_mode_linked'], '</option>
1580
									</select>
1581
								</dd>
1582
								<dt>
1583
									<label for="view_newest_pm_first">', $txt['recent_pms_at_top'], '</label>
1584
								</dt>
1585
								<dd>
1586
										<input type="hidden" name="default_options[view_newest_pm_first]" value="0">
1587
										<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' : '', ' class="input_check">
1588
								</dd>
1589
						</dl>
1590
						<hr>
1591
						<dl class="settings">
1592
								<dt>
1593
										<label for="pm_receive_from">', $txt['pm_receive_from'], '</label>
1594
								</dt>
1595
								<dd>
1596
										<select name="pm_receive_from" id="pm_receive_from">
1597
												<option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>';
1598
1599
	if (!empty($modSettings['enable_buddylist']))
1600
		echo '
1601
												<option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option>
1602
												<option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>';
1603
1604
	echo '
1605
												<option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option>
1606
										</select>
1607
								</dd>
1608
								<dt>
1609
										<label for="popup_messages">', $txt['popup_messages'], '</label>
1610
								</dt>
1611
								<dd>
1612
										<input type="hidden" name="default_options[popup_messages]" value="0">
1613
										<input type="checkbox" name="default_options[popup_messages]" id="popup_messages" value="1"', !empty($context['member']['options']['popup_messages']) ? ' checked' : '', ' class="input_check">
1614
								</dd>
1615
						</dl>
1616
						<hr>
1617
						<dl class="settings">
1618
								<dt>
1619
										<label for="pm_remove_inbox_label">', $txt['pm_remove_inbox_label'], '</label>
1620
								</dt>
1621
								<dd>
1622
										<input type="hidden" name="default_options[pm_remove_inbox_label]" value="0">
1623
										<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' : '', ' class="input_check">
1624
								</dd>';
1625
1626
}
1627
1628
/**
1629
 * Template for showing theme settings. Note: template_options() actually adds the theme specific options.
1630
 */
1631
function template_profile_theme_settings()
1632
{
1633
	global $context, $modSettings, $txt;
1634
1635
	$first_option_key = array_shift($skeys = array_keys($context['theme_options']));
0 ignored issues
show
Bug introduced by
$skeys = array_keys($context['theme_options']) cannot be passed to array_shift() as the parameter $array expects a reference.
Loading history...
1636
	$titled_section = false;
1637
1638
	foreach ($context['theme_options'] as $i => $setting)
1639
	{
1640
		// Just spit out separators and move on
1641 View Code Duplication
		if (empty($setting) || !is_array($setting))
1642
		{
1643
			// Insert a separator (unless this is the first item in the list)
1644
			if ($i !== $first_option_key)
1645
				echo '
1646
				</dl>
1647
				<hr>
1648
				<dl class="settings">';
1649
1650
			// Should we give a name to this section?
1651
			if (is_string($setting) && !empty($setting))
1652
			{
1653
				$titled_section = true;
1654
				echo '
1655
					<dt><b>' . $setting . '</b></dt><dd></dd>';
1656
			}
1657
			else
1658
				$titled_section = false;
1659
1660
			continue;
1661
		}
1662
1663
		// Is this disabled?
1664
		if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled']))
1665
			continue;
1666
		elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage']))
1667
			continue;
1668
		elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored']))
1669
			continue;
1670
		elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist']))
1671
			continue;
1672
		elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg']))
1673
			continue;
1674
		elseif ($setting['id'] == 'topics_per_page' && !empty($modSettings['disableCustomPerPage']))
1675
			continue;
1676 View Code Duplication
		elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled']))))
1677
			continue;
1678 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']))))
1679
			continue;
1680
1681
		if (!isset($setting['type']) || $setting['type'] == 'bool')
1682
			$setting['type'] = 'checkbox';
1683
		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
1684
			$setting['type'] = 'number';
1685
		elseif ($setting['type'] == 'string')
1686
			$setting['type'] = 'text';
1687
1688
		if (isset($setting['options']))
1689
			$setting['type'] = 'list';
1690
1691
		echo '
1692
					<dt>
1693
						<label for="', $setting['id'], '">', !$titled_section ? '<b>' : '', $setting['label'], !$titled_section ? '</b>' : '', '</label>';
1694
1695
		if (isset($setting['description']))
1696
			echo '
1697
						<br><span class="smalltext">', $setting['description'], '</span>';
1698
		echo '
1699
					</dt>
1700
					<dd>';
1701
1702
		// display checkbox options
1703
		if ($setting['type'] == 'checkbox')
1704
		{
1705
			echo '
1706
						<input type="hidden" name="default_options[' . $setting['id'] . ']" value="0">
1707
						<input type="checkbox" name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', !empty($context['member']['options'][$setting['id']]) ? ' checked' : '', ' value="1" class="input_check">';
1708
		}
1709
		// how about selection lists, we all love them
1710 View Code Duplication
		elseif ($setting['type'] == 'list')
1711
		{
1712
			echo '
1713
						&nbsp;<select class="floatleft" name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', '>';
1714
1715
			foreach ($setting['options'] as $value => $label)
1716
			{
1717
				echo '
1718
							<option value="', $value, '"', $value == $context['member']['options'][$setting['id']] ? ' selected' : '', '>', $label, '</option>';
1719
			}
1720
1721
			echo '
1722
						</select>';
1723
		}
1724
		// a textbox it is then
1725
		else
1726
		{
1727
			if (isset($setting['type']) && $setting['type'] == 'number')
1728
			{
1729
				$min = isset($setting['min']) ? ' min="' . $setting['min'] . '"' : ' min="0"';
1730
				$max = isset($setting['max']) ? ' max="' . $setting['max'] . '"' : '';
1731
				$step = isset($setting['step']) ? ' step="' . $setting['step'] . '"' : '';
1732
1733
				echo '
1734
						<input type="number"', $min . $max . $step;
1735
			}
1736
			else if (isset($setting['type']) && $setting['type'] == 'url')
1737
			{
1738
				echo'
1739
						<input type="url"';
1740
			}
1741
			else
1742
			{
1743
				echo '
1744
						<input type="text"';
1745
			}
1746
1747
			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"' : '', ' class="input_text">';
1748
		}
1749
1750
		// end of this defintion
1751
		echo '
1752
					</dd>';
1753
	}
1754
}
1755
1756
/**
1757
 * The template for configuring alerts
1758
 */
1759
function template_alert_configuration()
1760
{
1761
	global $context, $settings, $txt, $scripturl, $modSettings;
1762
1763
	echo '
1764
		<div class="cat_bar">
1765
			<h3 class="catbg">
1766
				', $txt['alert_prefs'], '
1767
			</h3>
1768
		</div>
1769
		<p class="information">', (empty($context['description']) ? $txt['alert_prefs_desc'] : $context['description']), '</p>
1770
		<form action="', $scripturl, '?', $context['action'], '" id="admin_form_wrapper" method="post" accept-charset="', $context['character_set'], '" id="notify_options" class="flow_hidden">
1771
			<div class="cat_bar">
1772
				<h3 class="catbg">
1773
					', $txt['notification_general'], '
1774
				</h3>
1775
			</div>
1776
			<div class="windowbg2 noup">
1777
				<dl class="settings">';
1778
1779
	// Allow notification on announcements to be disabled?
1780
	if (!empty($modSettings['allow_disableAnnounce']))
1781
		echo '
1782
					<dt>
1783
						<label for="notify_announcements">', $txt['notify_important_email'], '</label>
1784
					</dt>
1785
					<dd>
1786
						<input type="hidden" name="notify_announcements" value="0">
1787
						<input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', ' class="input_check">
1788
					</dd>';
1789
1790
	if (!empty($modSettings['enable_ajax_alerts']))
1791
		echo '
1792
					<dt>
1793
						<label for="notify_send_body">', $txt['notify_alert_timeout'], '</label>
1794
					</dt>
1795
					<dd>
1796
						<input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '" class="input_text">
1797
					</dd>
1798
		';
1799
1800
	echo '
1801
				</dl>
1802
			</div>
1803
			<div class="cat_bar">
1804
				<h3 class="catbg">
1805
					', $txt['notify_what_how'], '
1806
				</h3>
1807
			</div>
1808
			<table class="table_grid">';
1809
1810
	foreach ($context['alert_types'] as $alert_group => $alerts)
1811
	{
1812
		echo '
1813
				<tr class="title_bar">
1814
					<th>', $txt['alert_group_' . $alert_group], '</th>
1815
					<th>', $txt['receive_alert'], '</th>
1816
					<th>', $txt['receive_mail'], '</th>
1817
				</tr>
1818
				<tr class="windowbg">';
1819
		if (isset($context['alert_group_options'][$alert_group]))
1820
		{
1821
			foreach ($context['alert_group_options'][$alert_group] as $opts)
1822
			{
1823
				echo '
1824
				<tr class="windowbg">
1825
					<td colspan="3">';
1826
				$label = $txt['alert_opt_' . $opts[1]];
1827
				$label_pos = isset($opts['label']) ? $opts['label'] : '';
1828
				if ($label_pos == 'before')
1829
					echo '
1830
					<label for="opt_', $opts[1], '">', $label, '</label>';
1831
1832
				$this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0;
1833
				switch ($opts[0])
1834
				{
1835
					case 'check':
1836
						echo '
1837
						<input type="checkbox" name="opt_', $opts[1], '" id="opt_', $opts[1], '"', $this_value ? ' checked' : '', '>';
1838
						break;
1839
					case 'select':
1840
						echo '
1841
						<select name="opt_', $opts[1], '" id="opt_', $opts[1], '">';
1842
						foreach ($opts['opts'] as $k => $v)
1843
							echo '
1844
							<option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>';
1845
						echo '
1846
						</select>';
1847
						break;
1848
				}
1849
1850
				if ($label_pos == 'after')
1851
					echo '
1852
					<label for="opt_', $opts[1], '">', $label, '</label>';
1853
1854
				echo '
1855
					</td>
1856
				</tr>';
1857
			}
1858
		}
1859
1860
		foreach ($alerts as $alert_id => $alert_details)
1861
		{
1862
			echo '
1863
				<tr class="windowbg">
1864
					<td>', $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>' : '', '</td>';
1865
1866
			foreach ($context['alert_bits'] as $type => $bitmask)
1867
			{
1868
				echo '
1869
					<td class="centercol">';
1870
				$this_value = isset($context['alert_prefs'][$alert_id]) ? $context['alert_prefs'][$alert_id] : 0;
1871
				switch ($alert_details[$type])
1872
				{
1873
					case 'always':
1874
						echo '
1875
						<input type="checkbox" checked disabled>';
1876
						break;
1877
					case 'yes':
1878
						echo '
1879
						<input type="checkbox" name="', $type, '_', $alert_id, '"', ($this_value & $bitmask) ? ' checked' : '', '>';
1880
						break;
1881
					case 'never':
1882
						echo '
1883
						<input type="checkbox" disabled>';
1884
						break;
1885
				}
1886
				echo '
1887
					</td>';
1888
			}
1889
1890
			echo '
1891
				</tr>';
1892
		}
1893
	}
1894
1895
	echo '
1896
			</table>
1897
			<br>
1898
			<div>
1899
				<input id="notify_submit" type="submit" name="notify_submit" value="', $txt['notify_save'], '" class="button_submit">
1900
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">', !empty($context['token_check']) ? '
1901
				<input type="hidden" name="' . $context[$context['token_check'] . '_token_var'] . '" value="' . $context[$context['token_check'] . '_token'] . '">' : '', '
1902
				<input type="hidden" name="u" value="', $context['id_member'], '">
1903
				<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
1904
			</div>
1905
		</form>
1906
		<br>';
1907
}
1908
1909
/**
1910
 * Template for showing which topics you're subscribed to
1911
 */
1912
function template_alert_notifications_topics()
1913
{
1914
	global $txt;
1915
1916
	// The main containing header.
1917
	echo '
1918
		<div class="cat_bar">
1919
			<h3 class="catbg">
1920
				', $txt['watched_topics'], '
1921
			</h3>
1922
		</div>
1923
		<p class="information">', $txt['watched_topics_desc'], '</p>
1924
		<br>';
1925
1926
	template_show_list('topic_notification_list');
1927
}
1928
1929
/**
1930
 * Template for showing which boards you're subscribed to
1931
 */
1932
function template_alert_notifications_boards()
1933
{
1934
	global $txt;
1935
1936
	echo '
1937
		<div class="cat_bar">
1938
			<h3 class="catbg">
1939
				', $txt['watched_boards'], '
1940
			</h3>
1941
		</div>
1942
		<p class="information">', $txt['watched_boards_desc'], '</p>
1943
		<br>';
1944
1945
	template_show_list('board_notification_list');
1946
}
1947
1948
/**
1949
 * Template for choosing group membership.
1950
 */
1951
function template_groupMembership()
1952
{
1953
	global $context, $scripturl, $txt;
1954
1955
	// The main containing header.
1956
	echo '
1957
		<form action="', $scripturl, '?action=profile;area=groupmembership;save" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
1958
			<div class="cat_bar">
1959
				<h3 class="catbg profile_hd">
1960
					', $txt['profile'], '
1961
				</h3>
1962
			</div>
1963
			<p class="information">', $txt['groupMembership_info'], '</p>';
1964
1965
	// Do we have an update message?
1966
	if (!empty($context['update_message']))
1967
		echo '
1968
			<div class="infobox">
1969
				', $context['update_message'], '.
1970
			</div>';
1971
1972
	echo '
1973
		<div id="groups">';
1974
1975
	// Requesting membership to a group?
1976
	if (!empty($context['group_request']))
1977
	{
1978
		echo '
1979
			<div class="groupmembership">
1980
				<div class="cat_bar">
1981
					<h3 class="catbg">', $txt['request_group_membership'], '</h3>
1982
				</div>
1983
				<div class="roundframe">
1984
					', $txt['request_group_membership_desc'], ':
1985
					<textarea name="reason" rows="4" style="width: 99%;"></textarea>
1986
					<div class="righttext" style="margin: 0.5em 0.5% 0 0.5%;">
1987
						<input type="hidden" name="gid" value="', $context['group_request']['id'], '">
1988
						<input type="submit" name="req" value="', $txt['submit_request'], '" class="button_submit">
1989
					</div>
1990
				</div>
1991
			</div>';
1992
	}
1993
	else
1994
	{
1995
		echo '
1996
			<div class="title_bar">
1997
				<h3 class="titlebg">', $txt['current_membergroups'], '</h3>
1998
			</div>';
1999
2000
		foreach ($context['groups']['member'] as $group)
2001
		{
2002
			echo '
2003
					<div class="windowbg" id="primdiv_', $group['id'], '">';
2004
2005
				if ($context['can_edit_primary'])
2006
					echo '
2007
						<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', ' class="input_radio">';
2008
2009
				echo '
2010
						<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>';
2011
2012
				// Can they leave their group?
2013
				if ($group['can_leave'])
2014
					echo '
2015
						<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>';
2016
2017
				echo '
2018
					</div>';
2019
		}
2020
2021
		if ($context['can_edit_primary'])
2022
			echo '
2023
			<div class="padding righttext">
2024
				<input type="submit" value="', $txt['make_primary'], '" class="button_submit">
2025
			</div>';
2026
2027
		// Any groups they can join?
2028
		if (!empty($context['groups']['available']))
2029
		{
2030
			echo '
2031
					<div class="title_bar">
2032
						<h3 class="titlebg">', $txt['available_groups'], '</h3>
2033
					</div>';
2034
2035
			foreach ($context['groups']['available'] as $group)
2036
			{
2037
				echo '
2038
					<div class="windowbg">
2039
						<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>' : ''), '';
2040
2041
				if ($group['type'] == 3)
2042
					echo '
2043
						<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>';
2044
				elseif ($group['type'] == 2 && $group['pending'])
2045
					echo '
2046
						<span class="floatright">', $txt['approval_pending'], '</span>';
2047
				elseif ($group['type'] == 2)
2048
					echo '
2049
						<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>';
2050
2051
				echo '
2052
					</div>';
2053
			}
2054
		}
2055
2056
		// Javascript for the selector stuff.
2057
		echo '
2058
		<script>
2059
		var prevClass = "";
2060
		var prevDiv = "";
2061
		function highlightSelected(box)
2062
		{
2063
			if (prevClass != "")
2064
			{
2065
				prevDiv.className = prevClass;
2066
			}
2067
			prevDiv = document.getElementById(box);
2068
			prevClass = prevDiv.className;
2069
2070
			prevDiv.className = "windowbg";
2071
		}';
2072
		if (isset($context['groups']['member'][$context['primary_group']]))
2073
			echo '
2074
		highlightSelected("primdiv_' . $context['primary_group'] . '");';
2075
		echo '
2076
	</script>';
2077
	}
2078
2079
	echo '
2080
		</div>';
2081
2082 View Code Duplication
	if (!empty($context['token_check']))
2083
		echo '
2084
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2085
2086
	echo '
2087
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2088
				<input type="hidden" name="u" value="', $context['id_member'], '">
2089
			</form>';
2090
}
2091
2092
/**
2093
 * Template for managing ignored boards
2094
 */
2095
function template_ignoreboards()
2096
{
2097
	global $context, $txt, $scripturl;
2098
	// The main containing header.
2099
	echo '
2100
	<form action="', $scripturl, '?action=profile;area=ignoreboards;save" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
2101
		<div class="cat_bar">
2102
			<h3 class="catbg profile_hd">
2103
				', $txt['profile'], '
2104
			</h3>
2105
		</div>
2106
		<p class="information">', $txt['ignoreboards_info'], '</p>
2107
		<div class="windowbg2">
2108
			<div class="flow_hidden">
2109
				<ul class="ignoreboards floatleft">';
2110
2111
	$i = 0;
2112
	$limit = ceil($context['num_boards'] / 2);
2113
	foreach ($context['categories'] as $category)
2114
	{
2115
		if ($i == $limit)
2116
		{
2117
			echo '
2118
				</ul>
2119
				<ul class="ignoreboards floatright">';
2120
2121
			$i++;
2122
		}
2123
2124
		echo '
2125
					<li class="category">
2126
						<a href="javascript:void(0);" onclick="selectBoards([', implode(', ', $category['child_ids']), '], \'creator\'); return false;">', $category['name'], '</a>
2127
						<ul>';
2128
2129 View Code Duplication
		foreach ($category['boards'] as $board)
2130
		{
2131
			if ($i == $limit)
2132
				echo '
2133
						</ul>
2134
					</li>
2135
				</ul>
2136
				<ul class="ignoreboards floatright">
2137
					<li class="category">
2138
						<ul>';
2139
2140
			echo '
2141
							<li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">
2142
								<label for="ignore_brd', $board['id'], '"><input type="checkbox" id="brd', $board['id'], '" name="ignore_brd[', $board['id'], ']" value="', $board['id'], '"', $board['selected'] ? ' checked' : '', ' class="input_check"> ', $board['name'], '</label>
2143
							</li>';
2144
2145
			$i++;
2146
		}
2147
2148
		echo '
2149
						</ul>
2150
					</li>';
2151
	}
2152
2153
	echo '
2154
				</ul>';
2155
2156
	// Show the standard "Save Settings" profile button.
2157
	template_profile_save();
2158
2159
	echo '
2160
			</div>
2161
		</div>
2162
	</form>
2163
	<br>';
2164
}
2165
2166
/**
2167
 * Simply loads some theme variables common to several warning templates.
2168
 */
2169
function template_load_warning_variables()
2170
{
2171
	global $modSettings, $context;
2172
2173
	$context['warningBarWidth'] = 200;
2174
	// Setup the colors - this is a little messy for theming.
2175
	$context['colors'] = array(
2176
		0 => 'green',
2177
		$modSettings['warning_watch'] => 'darkgreen',
2178
		$modSettings['warning_moderate'] => 'orange',
2179
		$modSettings['warning_mute'] => 'red',
2180
	);
2181
2182
	// Work out the starting color.
2183
	$context['current_color'] = $context['colors'][0];
2184
	foreach ($context['colors'] as $limit => $color)
2185
		if ($context['member']['warning'] >= $limit)
2186
			$context['current_color'] = $color;
2187
}
2188
2189
// Show all warnings of a user?
2190
function template_viewWarning()
2191
{
2192
	global $context, $txt;
2193
2194
	template_load_warning_variables();
2195
2196
	echo '
2197
		<div class="cat_bar">
2198
			<h3 class="catbg profile_hd">
2199
				', sprintf($txt['profile_viewwarning_for_user'], $context['member']['name']), '
2200
			</h3>
2201
		</div>
2202
		<p class="information">', $txt['viewWarning_help'], '</p>
2203
		<div class="windowbg">
2204
			<dl class="settings">
2205
				<dt>
2206
					<strong>', $txt['profile_warning_name'], ':</strong>
2207
				</dt>
2208
				<dd>
2209
					', $context['member']['name'], '
2210
				</dd>
2211
				<dt>
2212
					<strong>', $txt['profile_warning_level'], ':</strong>
2213
				</dt>
2214
				<dd>
2215
					<div>
2216
						<div>
2217
							<div style="font-size: 8pt; height: 12pt; width: ', $context['warningBarWidth'], 'px; border: 1px solid black; background-color: white; padding: 1px; position: relative;">
2218
								<div id="warning_text" style="padding-top: 1pt; width: 100%; z-index: 2; color: black; position: absolute; text-align: center; font-weight: bold;">', $context['member']['warning'], '%</div>
2219
								<div id="warning_progress" style="width: ', $context['member']['warning'], '%; height: 12pt; z-index: 1; background-color: ', $context['current_color'], ';">&nbsp;</div>
2220
							</div>
2221
						</div>
2222
					</div>
2223
				</dd>';
2224
2225
		// There's some impact of this?
2226
		if (!empty($context['level_effects'][$context['current_level']]))
2227
			echo '
2228
				<dt>
2229
					<strong>', $txt['profile_viewwarning_impact'], ':</strong>
2230
				</dt>
2231
				<dd>
2232
					', $context['level_effects'][$context['current_level']], '
2233
				</dd>';
2234
2235
		echo '
2236
			</dl>
2237
		</div>';
2238
2239
	template_show_list('view_warnings');
2240
}
2241
2242
// Show a lovely interface for issuing warnings.
2243
function template_issueWarning()
2244
{
2245
	global $context, $scripturl, $txt;
2246
2247
	template_load_warning_variables();
2248
2249
	echo '
2250
	<script>
2251
		// Disable notification boxes as required.
2252
		function modifyWarnNotify()
2253
		{
2254
			disable = !document.getElementById(\'warn_notify\').checked;
2255
			document.getElementById(\'warn_sub\').disabled = disable;
2256
			document.getElementById(\'warn_body\').disabled = disable;
2257
			document.getElementById(\'warn_temp\').disabled = disable;
2258
			document.getElementById(\'new_template_link\').style.display = disable ? \'none\' : \'\';
2259
			document.getElementById(\'preview_button\').style.display = disable ? \'none\' : \'\';
2260
		}
2261
2262
		// Warn template.
2263
		function populateNotifyTemplate()
2264
		{
2265
			index = document.getElementById(\'warn_temp\').value;
2266
			if (index == -1)
2267
				return false;
2268
2269
			// Otherwise see what we can do...';
2270
2271
	foreach ($context['notification_templates'] as $k => $type)
2272
		echo '
2273
			if (index == ', $k, ')
2274
				document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";';
2275
2276
	echo '
2277
		}
2278
2279
		function updateSlider(slideAmount)
2280
		{
2281
			// Also set the right effect.
2282
			effectText = "";';
2283
2284
	foreach ($context['level_effects'] as $limit => $text)
2285
		echo '
2286
			if (slideAmount >= ', $limit, ')
2287
				effectText = "', $text, '";';
2288
2289
	echo '
2290
			setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\');
2291
		}
2292
	</script>';
2293
2294
	echo '
2295
	<form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=issuewarning" method="post" class="flow_hidden" accept-charset="', $context['character_set'], '">
2296
		<div class="cat_bar">
2297
			<h3 class="catbg profile_hd">
2298
				', $context['user']['is_owner'] ? $txt['profile_warning_level'] : $txt['profile_issue_warning'], '
2299
			</h3>
2300
		</div>';
2301
2302
	if (!$context['user']['is_owner'])
2303
		echo '
2304
		<p class="information">', $txt['profile_warning_desc'], '</p>';
2305
2306
	echo '
2307
		<div class="windowbg">
2308
			<dl class="settings">';
2309
2310
	if (!$context['user']['is_owner'])
2311
		echo '
2312
				<dt>
2313
					<strong>', $txt['profile_warning_name'], ':</strong>
2314
				</dt>
2315
				<dd>
2316
					<strong>', $context['member']['name'], '</strong>
2317
				</dd>';
2318
2319
	echo '
2320
				<dt>
2321
					<strong>', $txt['profile_warning_level'], ':</strong>';
2322
2323
	// Is there only so much they can apply?
2324
	if ($context['warning_limit'])
2325
		echo '
2326
					<br><span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>';
2327
2328
	echo '
2329
				</dt>
2330
				<dd>
2331
					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%
2332
					<div class="clear_left">', $txt['profile_warning_impact'], ': <span id="cur_level_div">', $context['member']['warning'], '% (', $context['level_effects'][$context['current_level']], ')</span></div>
2333
				</dd>';
2334
2335
	if (!$context['user']['is_owner'])
2336
	{
2337
		echo '
2338
				<dt>
2339
					<strong>', $txt['profile_warning_reason'], ':</strong><br>
2340
					<span class="smalltext">', $txt['profile_warning_reason_desc'], '</span>
2341
				</dt>
2342
				<dd>
2343
					<input type="text" name="warn_reason" id="warn_reason" value="', $context['warning_data']['reason'], '" size="50" style="width: 80%;" class="input_text">
2344
				</dd>
2345
			</dl>
2346
			<hr>
2347
			<div id="box_preview"', !empty($context['warning_data']['body_preview']) ? '' : ' style="display:none"', '>
2348
				<dl class="settings">
2349
					<dt>
2350
						<strong>', $txt['preview'], '</strong>
2351
					</dt>
2352
					<dd id="body_preview">
2353
						', !empty($context['warning_data']['body_preview']) ? $context['warning_data']['body_preview'] : '', '
2354
					</dd>
2355
				</dl>
2356
				<hr>
2357
			</div>
2358
			<dl class="settings">
2359
				<dt>
2360
					<strong><label for="warn_notify">', $txt['profile_warning_notify'], ':</label></strong>
2361
				</dt>
2362
				<dd>
2363
					<input type="checkbox" name="warn_notify" id="warn_notify" onclick="modifyWarnNotify();"', $context['warning_data']['notify'] ? ' checked' : '', ' class="input_check">
2364
				</dd>
2365
				<dt>
2366
					<strong><label for="warn_sub">', $txt['profile_warning_notify_subject'], ':</label></strong>
2367
				</dt>
2368
				<dd>
2369
					<input type="text" name="warn_sub" id="warn_sub" value="', empty($context['warning_data']['notify_subject']) ? $txt['profile_warning_notify_template_subject'] : $context['warning_data']['notify_subject'], '" size="50" style="width: 80%;" class="input_text">
2370
				</dd>
2371
				<dt>
2372
					<strong><label for="warn_temp">', $txt['profile_warning_notify_body'], ':</label></strong>
2373
				</dt>
2374
				<dd>
2375
					<select name="warn_temp" id="warn_temp" disabled onchange="populateNotifyTemplate();" style="font-size: x-small;">
2376
						<option value="-1">', $txt['profile_warning_notify_template'], '</option>
2377
						<option value="-1" disabled>------------------------------</option>';
2378
2379
		foreach ($context['notification_templates'] as $id_template => $template)
2380
			echo '
2381
						<option value="', $id_template, '">', $template['title'], '</option>';
2382
2383
		echo '
2384
					</select>
2385
					<span class="smalltext" id="new_template_link" style="display: none;">[<a href="', $scripturl, '?action=moderate;area=warnings;sa=templateedit;tid=0" target="_blank" class="new_win">', $txt['profile_warning_new_template'], '</a>]</span><br>
2386
					<textarea name="warn_body" id="warn_body" cols="40" rows="8" style="min-width: 50%; max-width: 99%;">', $context['warning_data']['notify_body'], '</textarea>
2387
				</dd>';
2388
	}
2389
	echo '
2390
			</dl>
2391
			<div class="righttext">';
2392
2393 View Code Duplication
	if (!empty($context['token_check']))
2394
		echo '
2395
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2396
2397
	echo '
2398
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2399
				<input type="button" name="preview" id="preview_button" value="', $txt['preview'], '" class="button_submit">
2400
				<input type="submit" name="save" value="', $context['user']['is_owner'] ? $txt['change_profile'] : $txt['profile_warning_issue'], '" class="button_submit">
2401
			</div>
2402
		</div>
2403
	</form>';
2404
2405
	// Previous warnings?
2406
	template_show_list('view_warnings');
2407
2408
	echo '
2409
	<script>';
2410
2411
	if (!$context['user']['is_owner'])
2412
		echo '
2413
		modifyWarnNotify();
2414
		$(document).ready(function() {
2415
			$("#preview_button").click(function() {
2416
				return ajax_getTemplatePreview();
2417
			});
2418
		});
2419
2420
		function ajax_getTemplatePreview ()
2421
		{
2422
			$.ajax({
2423
				type: "POST",
2424
				url: "' . $scripturl . '?action=xmlhttp;sa=previews;xml",
2425
				data: {item: "warning_preview", title: $("#warn_sub").val(), body: $("#warn_body").val(), issuing: true},
2426
				context: document.body,
2427
				success: function(request){
2428
					$("#box_preview").css({display:""});
2429
					$("#body_preview").html($(request).find(\'body\').text());
2430
					if ($(request).find("error").text() != \'\')
2431
					{
2432
						$("#profile_error").css({display:""});
2433
						var errors_html = \'<ul class="list_errors">\';
2434
						var errors = $(request).find(\'error\').each(function() {
2435
							errors_html += \'<li>\' + $(this).text() + \'</li>\';
2436
						});
2437
						errors_html += \'</ul>\';
2438
2439
						$("#profile_error").html(errors_html);
2440
					}
2441
					else
2442
					{
2443
						$("#profile_error").css({display:"none"});
2444
						$("#error_list").html(\'\');
2445
					}
2446
				return false;
2447
				},
2448
			});
2449
			return false;
2450
		}';
2451
2452
	echo '
2453
	</script>';
2454
}
2455
2456
/**
2457
 * Template to show for deleting a user's account - now with added delete post capability!
2458
 */
2459
function template_deleteAccount()
2460
{
2461
	global $context, $scripturl, $txt;
2462
2463
	// The main containing header.
2464
	echo '
2465
		<form action="', $scripturl, '?action=profile;area=deleteaccount;save" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
2466
			<div class="cat_bar">
2467
				<h3 class="catbg profile_hd">
2468
					', $txt['deleteAccount'], '
2469
				</h3>
2470
			</div>';
2471
2472
	// If deleting another account give them a lovely info box.
2473
	if (!$context['user']['is_owner'])
2474
		echo '
2475
			<p class="information">', $txt['deleteAccount_desc'], '</p>';
2476
	echo '
2477
			<div class="windowbg2">';
2478
2479
	// If they are deleting their account AND the admin needs to approve it - give them another piece of info ;)
2480
	if ($context['needs_approval'])
2481
		echo '
2482
				<div class="errorbox">', $txt['deleteAccount_approval'], '</div>';
2483
2484
	// If the user is deleting their own account warn them first - and require a password!
2485
	if ($context['user']['is_owner'])
2486
	{
2487
		echo '
2488
				<div class="alert">', $txt['own_profile_confirm'], '</div>
2489
				<div>
2490
					<strong', (isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : ''), '>', $txt['current_password'], ': </strong>
2491
					<input type="password" name="oldpasswrd" size="20" class="input_password">&nbsp;&nbsp;&nbsp;&nbsp;
2492
					<input type="submit" value="', $txt['yes'], '" class="button_submit">';
2493
2494 View Code Duplication
		if (!empty($context['token_check']))
2495
			echo '
2496
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2497
2498
		echo '
2499
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2500
					<input type="hidden" name="u" value="', $context['id_member'], '">
2501
					<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
2502
				</div>';
2503
	}
2504
	// Otherwise an admin doesn't need to enter a password - but they still get a warning - plus the option to delete lovely posts!
2505
	else
2506
	{
2507
		echo '
2508
				<div class="alert">', $txt['deleteAccount_warning'], '</div>';
2509
2510
		// Only actually give these options if they are kind of important.
2511
		if ($context['can_delete_posts'])
2512
		{
2513
			echo '
2514
				<div>
2515
					<label for="deleteVotes"><input type="checkbox" name="deleteVotes" id="deleteVotes" value="1" class="input_check"> ', $txt['deleteAccount_votes'], ':</label><br>
2516
					<label for="deletePosts"><input type="checkbox" name="deletePosts" id="deletePosts" value="1" class="input_check"> ', $txt['deleteAccount_posts'], ':</label>
2517
					<select name="remove_type">
2518
						<option value="posts">', $txt['deleteAccount_all_posts'], '</option>
2519
						<option value="topics">', $txt['deleteAccount_topics'], '</option>
2520
					</select>';
2521
2522
			if ($context['show_perma_delete'])
2523
				echo '
2524
					<br><label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1" class="input_check">', $txt['deleteAccount_permanent'], ':</label>';
2525
2526
			echo '
2527
				</div>';
2528
		}
2529
2530
		echo '
2531
				<div>
2532
					<label for="deleteAccount"><input type="checkbox" name="deleteAccount" id="deleteAccount" value="1" class="input_check" onclick="if (this.checked) return confirm(\'', $txt['deleteAccount_confirm'], '\');"> ', $txt['deleteAccount_member'], '.</label>
2533
				</div>
2534
				<div>
2535
					<input type="submit" value="', $txt['delete'], '" class="button_submit">';
2536
2537 View Code Duplication
		if (!empty($context['token_check']))
2538
			echo '
2539
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2540
2541
		echo '
2542
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2543
					<input type="hidden" name="u" value="', $context['id_member'], '">
2544
					<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
2545
				</div>';
2546
	}
2547
	echo '
2548
			</div>
2549
			<br>
2550
		</form>';
2551
}
2552
2553
/**
2554
 * Template for the password box/save button stuck at the bottom of every profile page.
2555
 */
2556
function template_profile_save()
2557
{
2558
	global $context, $txt;
2559
2560
	echo '
2561
2562
					<hr>';
2563
2564
	// Only show the password box if it's actually needed.
2565 View Code Duplication
	if ($context['require_password'])
2566
		echo '
2567
					<dl class="settings">
2568
						<dt>
2569
							<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br>
2570
							<span class="smalltext">', $txt['required_security_reasons'], '</span>
2571
						</dt>
2572
						<dd>
2573
							<input type="password" name="oldpasswrd" size="20" style="margin-right: 4ex;" class="input_password">
2574
						</dd>
2575
					</dl>';
2576
2577
	echo '
2578
					<div class="righttext">';
2579
2580 View Code Duplication
		if (!empty($context['token_check']))
2581
			echo '
2582
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2583
2584
	echo '
2585
						<input type="submit" value="', $txt['change_profile'], '" class="button_submit">
2586
						<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2587
						<input type="hidden" name="u" value="', $context['id_member'], '">
2588
						<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
2589
					</div>';
2590
}
2591
2592
/**
2593
 * Small template for showing an error message upon a save problem in the profile.
2594
 */
2595
function template_error_message()
0 ignored issues
show
Best Practice introduced by
The function template_error_message() has been defined more than once; this definition is ignored, only the first definition in other/upgrade.php (L3504-3514) is considered.

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

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

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

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
2596
{
2597
	global $context, $txt;
2598
2599
	echo '
2600
		<div class="errorbox" ', empty($context['post_errors']) ? 'style="display:none" ' : '', 'id="profile_error">';
2601
2602
	if (!empty($context['post_errors']))
2603
	{
2604
		echo '
2605
			<span>', !empty($context['custom_error_title']) ? $context['custom_error_title'] : $txt['profile_errors_occurred'], ':</span>
2606
			<ul id="list_errors">';
2607
2608
		// Cycle through each error and display an error message.
2609
		foreach ($context['post_errors'] as $error)
2610
			echo '
2611
				<li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>';
2612
2613
		echo '
2614
			</ul>';
2615
	}
2616
2617
	echo '
2618
		</div>';
2619
}
2620
2621
/**
2622
 * Display a load of drop down selectors for allowing the user to change group.
2623
 */
2624
function template_profile_group_manage()
2625
{
2626
	global $context, $txt, $scripturl;
2627
2628
	echo '
2629
							<dt>
2630
								<strong>', $txt['primary_membergroup'], ': </strong><br>
2631
								<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>
2632
							</dt>
2633
							<dd>
2634
								<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;"' : ''), '>';
2635
2636
		// Fill the select box with all primary member groups that can be assigned to a member.
2637
		foreach ($context['member_groups'] as $member_group)
2638
			if (!empty($member_group['can_be_primary']))
2639
				echo '
2640
									<option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '>
2641
										', $member_group['name'], '
2642
									</option>';
2643
		echo '
2644
								</select>
2645
							</dd>
2646
							<dt>
2647
								<strong>', $txt['additional_membergroups'], ':</strong>
2648
							</dt>
2649
							<dd>
2650
								<span id="additional_groupsList">
2651
									<input type="hidden" name="additional_groups[]" value="0">';
2652
2653
		// For each membergroup show a checkbox so members can be assigned to more than one group.
2654
		foreach ($context['member_groups'] as $member_group)
2655
			if ($member_group['can_be_additional'])
2656
				echo '
2657
									<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' : '', ' class="input_check"> ', $member_group['name'], '</label><br>';
2658
		echo '
2659
								</span>
2660
								<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>
2661
								<script>
2662
									document.getElementById("additional_groupsList").style.display = "none";
2663
									document.getElementById("additional_groupsLink").style.display = "";
2664
								</script>
2665
							</dd>';
2666
2667
}
2668
2669
/**
2670
 * Callback function for entering a birthdate!
2671
 */
2672
function template_profile_birthdate()
2673
{
2674
	global $txt, $context;
2675
2676
	// Just show the pretty box!
2677
	echo '
2678
							<dt>
2679
								<strong>', $txt['dob'], ':</strong><br>
2680
								<span class="smalltext">', $txt['dob_year'], ' - ', $txt['dob_month'], ' - ', $txt['dob_day'], '</span>
2681
							</dt>
2682
							<dd>
2683
								<input type="text" name="bday3" size="4" maxlength="4" value="', $context['member']['birth_date']['year'], '" class="input_text"> -
2684
								<input type="text" name="bday1" size="2" maxlength="2" value="', $context['member']['birth_date']['month'], '" class="input_text"> -
2685
								<input type="text" name="bday2" size="2" maxlength="2" value="', $context['member']['birth_date']['day'], '" class="input_text">
2686
							</dd>';
2687
}
2688
2689
/**
2690
 * Show the signature editing box?
2691
 */
2692
function template_profile_signature_modify()
2693
{
2694
	global $txt, $context;
2695
2696
	echo '
2697
							<dt id="current_signature" style="display:none">
2698
								<strong>', $txt['current_signature'], ':</strong>
2699
							</dt>
2700
							<dd id="current_signature_display" style="display:none">
2701
								<hr>
2702
							</dd>';
2703
	echo '
2704
							<dt id="preview_signature" style="display:none">
2705
								<strong>', $txt['signature_preview'], ':</strong>
2706
							</dt>
2707
							<dd id="preview_signature_display" style="display:none">
2708
								<hr>
2709
							</dd>';
2710
2711
	echo '
2712
							<dt>
2713
								<strong>', $txt['signature'], ':</strong><br>
2714
								<span class="smalltext">', $txt['sig_info'], '</span><br>
2715
								<br>';
2716
2717
	if ($context['show_spellchecking'])
2718
		echo '
2719
								<input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button_submit">';
2720
2721
		echo '
2722
							</dt>
2723
							<dd>
2724
								<textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50" style="min-width: 50%; max-width: 99%;">', $context['member']['signature'], '</textarea><br>';
2725
2726
	// If there is a limit at all!
2727
	if (!empty($context['signature_limits']['max_length']))
2728
		echo '
2729
								<span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>';
2730
2731
	if (!empty($context['show_preview_button']))
2732
		echo '
2733
								<input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button_submit">';
2734
2735
	if ($context['signature_warning'])
2736
		echo '
2737
								<span class="smalltext">', $context['signature_warning'], '</span>';
2738
2739
	// Some javascript used to count how many characters have been used so far in the signature.
2740
	echo '
2741
								<script>
2742
									var maxLength = ', $context['signature_limits']['max_length'], ';
2743
2744
									$(document).ready(function() {
2745
										calcCharLeft();
2746
										$("#preview_button").click(function() {
2747
											return ajax_getSignaturePreview(true);
2748
										});
2749
									});
2750
								</script>
2751
							</dd>';
2752
}
2753
2754
/**
2755
 * Template for selecting an avatar
2756
 */
2757
function template_profile_avatar_select()
2758
{
2759
	global $context, $txt, $modSettings;
2760
2761
	// Start with the upper menu
2762
	echo '
2763
							<dt>
2764
								<strong id="personal_picture"><label for="avatar_upload_box">', $txt['personal_picture'], '</label></strong>
2765
								', empty($modSettings['gravatarOverride']) ? '<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_none" value="none"' . ($context['member']['avatar']['choice'] == 'none' ? ' checked="checked"' : '') . ' class="input_radio" /><label for="avatar_choice_none"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>' . $txt['no_avatar'] . '</label><br />' : '', '
2766
								', !empty($context['member']['avatar']['allow_server_stored']) ? '<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_server_stored" value="server_stored"' . ($context['member']['avatar']['choice'] == 'server_stored' ? ' checked="checked"' : '') . ' class="input_radio" /><label for="avatar_choice_server_stored"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>' . $txt['choose_avatar_gallery'] . '</label><br />' : '', '
2767
								', !empty($context['member']['avatar']['allow_external']) ? '<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_external" value="external"' . ($context['member']['avatar']['choice'] == 'external' ? ' checked="checked"' : '') . ' class="input_radio" /><label for="avatar_choice_external"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>' . $txt['my_own_pic'] . '</label><br />' : '', '
2768
								', !empty($context['member']['avatar']['allow_upload']) ? '<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_upload" value="upload"' . ($context['member']['avatar']['choice'] == 'upload' ? ' checked="checked"' : '') . ' class="input_radio" /><label for="avatar_choice_upload"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>' . $txt['avatar_will_upload'] . '</label><br />' : '', '
2769
								', !empty($context['member']['avatar']['allow_gravatar']) ? '<input type="radio" onclick="swap_avatar(this); return true;" name="avatar_choice" id="avatar_choice_gravatar" value="gravatar"' . ($context['member']['avatar']['choice'] == 'gravatar' ? ' checked="checked"' : '') . ' class="input_radio" /><label for="avatar_choice_gravatar"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>' . $txt['use_gravatar'] . '</label>' : '', '
2770
							</dt>
2771
							<dd>';
2772
2773
	// If users are allowed to choose avatars stored on the server show selection boxes to choice them from.
2774
	if (!empty($context['member']['avatar']['allow_server_stored']))
2775
	{
2776
		echo '
2777
								<div id="avatar_server_stored">
2778
									<div>
2779
										<select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">';
2780
		// This lists all the file categories.
2781
		foreach ($context['avatars'] as $avatar)
2782
			echo '
2783
											<option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>';
2784
		echo '
2785
										</select>
2786
									</div>
2787
									<div>
2788
										<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>
2789
									</div>
2790
									<div><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"></div>
2791
									<script>
2792
										var files = ["' . implode('", "', $context['avatar_list']) . '"];
2793
										var avatar = document.getElementById("avatar");
2794
										var cat = document.getElementById("cat");
2795
										var selavatar = "' . $context['avatar_selected'] . '";
2796
										var avatardir = "' . $modSettings['avatar_url'] . '/";
2797
										var size = avatar.alt.substr(3, 2) + " " + avatar.alt.substr(0, 2) + String.fromCharCode(117, 98, 116);
2798
										var file = document.getElementById("file");
2799
										var maxHeight = ', !empty($modSettings['avatar_max_height_external']) ? $modSettings['avatar_max_height_external'] : 0, ';
2800
										var maxWidth = ', !empty($modSettings['avatar_max_width_external']) ? $modSettings['avatar_max_width_external'] : 0, ';
2801
2802
										if (avatar.src.indexOf("blank.png") > -1)
2803
											changeSel(selavatar);
2804
										else
2805
											previewExternalAvatar(avatar.src)
2806
2807
									</script>
2808
								</div>';
2809
	}
2810
2811
	// If the user can link to an off server avatar, show them a box to input the address.
2812
	if (!empty($context['member']['avatar']['allow_external']))
2813
	{
2814
		echo '
2815
								<div id="avatar_external">
2816
									<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') : '', '
2817
									<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);" class="input_text" />
2818
								</div>';
2819
	}
2820
2821
	// If the user is able to upload avatars to the server show them an upload box.
2822
	if (!empty($context['member']['avatar']['allow_upload']))
2823
	{
2824
		echo '
2825
								<div id="avatar_upload">
2826
									<input type="file" size="44" name="attachment" id="avatar_upload_box" value="" onchange="readfromUpload(this)"  onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'upload\');" class="input_file" accept="image/gif, image/jpeg, image/jpg, image/png">', template_max_size('upload'), '
2827
									', (!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'] . '">' : ''), '
2828
								</div>';
2829
	}
2830
2831
	// if the user is able to use Gravatar avatars show then the image preview
2832
	if (!empty($context['member']['avatar']['allow_gravatar']))
2833
	{
2834
		echo '
2835
								<div id="avatar_gravatar">
2836
									<img src="' . $context['member']['avatar']['href'] . '" alt="" />';
2837
2838
		if (empty($modSettings['gravatarAllowExtraEmail']))
2839
			echo '
2840
									<div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>';
2841
		else
2842
		{
2843
			// Depending on other stuff, the stored value here might have some odd things in it from other areas.
2844
			if ($context['member']['avatar']['external'] == $context['member']['email'])
2845
				$textbox_value = '';
2846
			else
2847
				$textbox_value = $context['member']['avatar']['external'];
2848
2849
			echo '
2850
									<div class="smalltext">', $txt['gravatar_alternateEmail'], '</div>
2851
									<input type="text" name="gravatarEmail" id="gravatarEmail" size="45" value="', $textbox_value, '" class="input_text" />';
2852
		}
2853
		echo '
2854
								</div>';
2855
	}
2856
2857
	echo '
2858
								<script>
2859
									', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "' . ($context['member']['avatar']['choice'] == 'server_stored' ? '' : 'none') . '";' : '', '
2860
									', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "' . ($context['member']['avatar']['choice'] == 'external' ? '' : 'none') . '";' : '', '
2861
									', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "' . ($context['member']['avatar']['choice'] == 'upload' ? '' : 'none') . '";' : '', '
2862
									', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "' . ($context['member']['avatar']['choice'] == 'gravatar' ? '' : 'none') . '";' : '', '
2863
2864
									function swap_avatar(type)
2865
									{
2866
										switch(type.id)
2867
										{
2868
											case "avatar_choice_server_stored":
2869
												', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "";' : '', '
2870
												', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "none";' : '', '
2871
												', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "none";' : '', '
2872
												', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "none";' : '', '
2873
												break;
2874
											case "avatar_choice_external":
2875
												', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "none";' : '', '
2876
												', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "";' : '', '
2877
												', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "none";' : '', '
2878
												', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "none";' : '', '
2879
												break;
2880
											case "avatar_choice_upload":
2881
												', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "none";' : '', '
2882
												', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "none";' : '', '
2883
												', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "";' : '', '
2884
												', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "none";' : '', '
2885
												break;
2886
											case "avatar_choice_none":
2887
												', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "none";' : '', '
2888
												', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "none";' : '', '
2889
												', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "none";' : '', '
2890
												', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "none";' : '', '
2891
												break;
2892
											case "avatar_choice_gravatar":
2893
												', !empty($context['member']['avatar']['allow_server_stored']) ? 'document.getElementById("avatar_server_stored").style.display = "none";' : '', '
2894
												', !empty($context['member']['avatar']['allow_external']) ? 'document.getElementById("avatar_external").style.display = "none";' : '', '
2895
												', !empty($context['member']['avatar']['allow_upload']) ? 'document.getElementById("avatar_upload").style.display = "none";' : '', '
2896
												', !empty($context['member']['avatar']['allow_gravatar']) ? 'document.getElementById("avatar_gravatar").style.display = "";' : '', '
2897
												', ($context['member']['avatar']['external'] == $context['member']['email'] || strstr($context['member']['avatar']['external'], 'http://')) ?
2898
												'document.getElementById("gravatarEmail").value = "";' : '', '
2899
												break;
2900
										}
2901
									}
2902
								</script>
2903
							</dd>';
2904
}
2905
2906
/**
2907
 * This is just a really little helper to avoid duplicating code unnecessarily
2908
 *
2909
 * @param string $type The type of avatar
2910
 */
2911
function template_max_size($type)
2912
{
2913
	global $modSettings, $txt;
2914
2915
	$w = !empty($modSettings['avatar_max_width_' . $type]) ? comma_format($modSettings['avatar_max_width_' . $type]) : 0;
2916
	$h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0;
2917
2918
	$suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : '');
2919
	if (empty($suffix))
2920
		return;
2921
2922
	echo '
2923
									<div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>';
2924
}
2925
2926
/**
2927
 * Select the time format!
2928
 */
2929
function template_profile_timeformat_modify()
2930
{
2931
	global $context, $txt, $scripturl, $settings;
2932
2933
	echo '
2934
							<dt>
2935
								<strong><label for="easyformat">', $txt['time_format'], ':</label></strong><br>
2936
								<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>
2937
								<span class="smalltext">&nbsp;<label for="time_format">', $txt['date_format'], '</label></span>
2938
							</dt>
2939
							<dd>
2940
								<select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;" style="margin-bottom: 4px;">';
2941
	// Help the user by showing a list of common time formats.
2942
	foreach ($context['easy_timeformats'] as $time_format)
2943
		echo '
2944
									<option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>';
2945
	echo '
2946
								</select><br>
2947
								<input type="text" name="time_format" id="time_format" value="', $context['member']['time_format'], '" size="30" class="input_text">
2948
							</dd>';
2949
}
2950
2951
/**
2952
 * Template for picking a theme
2953
 */
2954
function template_profile_theme_pick()
2955
{
2956
	global $txt, $context, $scripturl;
2957
2958
	echo '
2959
							<dt>
2960
								<strong>', $txt['current_theme'], ':</strong>
2961
							</dt>
2962
							<dd>
2963
								', $context['member']['theme']['name'], ' [<a href="', $scripturl, '?action=theme;sa=pick;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['change'], '</a>]
2964
							</dd>';
2965
}
2966
2967
/**
2968
 * Smiley set picker.
2969
 */
2970
function template_profile_smiley_pick()
2971
{
2972
	global $txt, $context, $modSettings, $settings;
2973
2974
	echo '
2975
							<dt>
2976
								<strong><label for="smiley_set">', $txt['smileys_current'], ':</label></strong>
2977
							</dt>
2978
							<dd>
2979
								<select name="smiley_set" id="smiley_set" onchange="document.getElementById(\'smileypr\').src = this.selectedIndex == 0 ? \'', $settings['images_url'], '/blank.png\' : \'', $modSettings['smileys_url'], '/\' + (this.selectedIndex != 1 ? this.options[this.selectedIndex].value : \'', !empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'], '\') + \'/smiley.gif\';">';
2980
	foreach ($context['smiley_sets'] as $set)
2981
		echo '
2982
									<option value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>';
2983
	echo '
2984
								</select> <img id="smileypr" class="centericon" src="', $context['member']['smiley_set']['id'] != 'none' ? $modSettings['smileys_url'] . '/' . ($context['member']['smiley_set']['id'] != '' ? $context['member']['smiley_set']['id'] : (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'])) . '/smiley.gif' : $settings['images_url'] . '/blank.png', '" alt=":)"  style="padding-left: 20px;">
2985
							</dd>';
2986
}
2987
2988
/**
2989
 * Template for setting up and managing Two-Factor Authentication.
2990
 */
2991
function template_tfasetup()
2992
{
2993
	global $txt, $context, $scripturl, $modSettings;
2994
2995
	echo '
2996
							<div class="cat_bar">
2997
								<h3 class="catbg">', $txt['tfa_title'], '</h3>
2998
							</div>
2999
							<div class="roundframe">
3000
								<div>
3001
		', !empty($context['tfa_backup']) ? '
3002
									<div class="smalltext error">' . $txt['tfa_backup_used_desc'] . '</div>' :
3003
			($modSettings['tfa_mode'] == 2 ? '
3004
									<div class="smalltext"><strong>' . $txt['tfa_forced_desc'] . '</strong></div>' : ''), '
3005
									<div class="smalltext">', $txt['tfa_desc'], '</div>
3006
									<div id="basicinfo" style="width: 60%">
3007
										<form action="', $scripturl, '?action=profile;area=tfasetup" method="post">
3008
											<div class="title_top">
3009
												<strong>', $txt['tfa_step1'], '</strong><br />
3010
												', !empty($context['tfa_pass_error']) ? '<div class="error smalltext">' . $txt['tfa_pass_invalid'] . '</div>' : '', '
3011
												<input type="password" name="passwd" style="width: 200px;"', !empty($context['tfa_pass_error']) ? ' class="error"' : '', !empty($context['tfa_pass_value']) ? ' value="' . $context['tfa_pass_value'] . '"' : '', '>
3012
											</div>
3013
											<div class="title_top">
3014
												<strong>', $txt['tfa_step2'], '</strong>
3015
												<div class="smalltext">', $txt['tfa_step2_desc'], '</div>
3016
												<div class="tfacode">', $context['tfa_secret'], '</div>
3017
											</div>
3018
											<div class="title_top">
3019
												<strong>', $txt['tfa_step3'], '</strong><br />
3020
												', !empty($context['tfa_error']) ? '<div class="error smalltext">' . $txt['tfa_code_invalid'] . '</div>' : '', '
3021
												<input type="text" name="tfa_code" style="width: 200px;"', !empty($context['tfa_error']) ? ' class="error"' : '', !empty($context['tfa_value']) ? ' value="' . $context['tfa_value'] . '"' : '', '>
3022
												<input type="submit" name="save" value="', $txt['tfa_enable'], '" class="button_submit" style="float: none;" />
3023
											</div>
3024
											<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '" />
3025
											<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
3026
										</form>
3027
									</div>
3028
									<div id="detailedinfo" style="width: 30%;">
3029
										<img src="', $context['tfa_qr_url'], '" alt="" style="max-width: 120px;" />
3030
									</div>
3031
									<div class="clear"></div>';
3032
3033
	if (!empty($context['from_ajax']))
3034
		echo '
3035
									<br>
3036
									<a href="javascript:self.close();"></a>';
3037
3038
	echo '
3039
								</div>
3040
							</div>';
3041
}
3042
3043
/**
3044
 * Template for setting up 2FA backup code
3045
 */
3046
function template_tfasetup_backup()
3047
{
3048
	global $context, $txt;
3049
3050
	echo '
3051
							<div class="cat_bar">
3052
								<h3 class="catbg">', $txt['tfa_backup_title'], '</h3>
3053
							</div>
3054
							<div class="roundframe">
3055
								<div>
3056
									<div class="smalltext">', $txt['tfa_backup_desc'], '</div>
3057
									<div class="bbc_code" style="resize: none; border: none;">', $context['tfa_backup'], '</div>
3058
								</div>
3059
							</div>';
3060
}
3061
3062
/**
3063
 * Simple template for showing the 2FA area when editing a profile.
3064
 */
3065
function template_profile_tfa()
3066
{
3067
	global $context, $txt, $scripturl, $modSettings;
3068
3069
	echo '
3070
							<dt>
3071
								<strong>', $txt['tfa_profile_label'], ':</strong>
3072
								<br /><div class="smalltext">', $txt['tfa_profile_desc'], '</div>
3073
							</dt>
3074
							<dd>';
3075
	if (!$context['tfa_enabled'] && $context['user']['is_owner'])
3076
		echo '
3077
								<a href="', !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>';
3078
	elseif (!$context['tfa_enabled'])
3079
		echo '
3080
								', $txt['tfa_profile_disabled'];
3081
	else
3082
		echo '
3083
							', sprintf($txt['tfa_profile_enabled'], $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=tfasetup;disable');
3084
	echo '
3085
							</dd>';
3086
}
3087
3088
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...