Completed
Push — release-2.1 ( 8bc4bf...08aa48 )
by Mathias
07:00
created

Profile.template.php ➔ template_alert_configuration()   F

Complexity

Conditions 26
Paths 276

Size

Total Lines 149
Code Lines 73

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 26
eloc 73
nc 276
nop 0
dl 0
loc 149
rs 3.5303
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 2016 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']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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'])
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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>';
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'])
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
309
	{
310
		echo '
311
				<dl>';
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="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']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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'])
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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'])
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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'])
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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'])
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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'])
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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="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']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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>';
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>';
1405
		}
1406 View Code Duplication
		elseif ($field['type'] == 'callback')
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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')
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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')
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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>';
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'])
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1528
		echo '
1529
				<dl>
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']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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>
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>
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
	echo '
1636
							<dt>
1637
								<label for="show_children">', $txt['show_children'], '</label>
1638
							</dt>
1639
							<dd>
1640
								<input type="hidden" name="default_options[show_children]" value="0">
1641
								<input type="checkbox" name="default_options[show_children]" id="show_children" value="1"', !empty($context['member']['options']['show_children']) ? ' checked' : '', ' class="input_check">
1642
							</dd>
1643
							<dt>
1644
								<label for="show_no_avatars">', $txt['show_no_avatars'], '</label>
1645
							</dt>
1646
							<dd>
1647
								<input type="hidden" name="default_options[show_no_avatars]" value="0">
1648
								<input type="checkbox" name="default_options[show_no_avatars]" id="show_no_avatars" value="1"', !empty($context['member']['options']['show_no_avatars']) ? ' checked' : '', ' class="input_check">
1649
							</dd>
1650
							<dt>
1651
								<label for="show_no_signatures">', $txt['show_no_signatures'], '</label>
1652
							</dt>
1653
							<dd>
1654
								<input type="hidden" name="default_options[show_no_signatures]" value="0">
1655
								<input type="checkbox" name="default_options[show_no_signatures]" id="show_no_signatures" value="1"', !empty($context['member']['options']['show_no_signatures']) ? ' checked' : '', ' class="input_check">
1656
							</dd>';
1657
1658
	if (!empty($modSettings['allow_no_censored']))
1659
		echo '
1660
							<dt>
1661
								<label for="show_no_censored">' . $txt['show_no_censored'] . '</label>
1662
							</dt>
1663
							<dd>
1664
								<input type="hidden" name="default_options[show_no_censored]" value="0">
1665
								<input type="checkbox" name="default_options[show_no_censored]" id="show_no_censored" value="1"' . (!empty($context['member']['options']['show_no_censored']) ? ' checked' : '') . ' class="input_check">
1666
							</dd>';
1667
1668
	echo '
1669
							<dt>
1670
								<label for="return_to_post">', $txt['return_to_post'], '</label>
1671
							</dt>
1672
							<dd>
1673
								<input type="hidden" name="default_options[return_to_post]" value="0">
1674
								<input type="checkbox" name="default_options[return_to_post]" id="return_to_post" value="1"', !empty($context['member']['options']['return_to_post']) ? ' checked' : '', ' class="input_check">
1675
							</dd>';
1676
1677 View Code Duplication
	if (!empty($modSettings['enable_buddylist']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1678
		echo '
1679
							<dt>
1680
								<label for="posts_apply_ignore_list">', $txt['posts_apply_ignore_list'], '</label>
1681
							</dt>
1682
							<dd>
1683
								<input type="hidden" name="default_options[posts_apply_ignore_list]" value="0">
1684
								<input type="checkbox" name="default_options[posts_apply_ignore_list]" id="posts_apply_ignore_list" value="1"', !empty($context['member']['options']['posts_apply_ignore_list']) ? ' checked' : '', ' class="input_check">
1685
							</dd>';
1686
1687
	echo '
1688
							<dt>
1689
								<label for="view_newest_first">', $txt['recent_posts_at_top'], '</label>
1690
							</dt>
1691
							<dd>
1692
								<input type="hidden" name="default_options[view_newest_first]" value="0">
1693
								<input type="checkbox" name="default_options[view_newest_first]" id="view_newest_first" value="1"', !empty($context['member']['options']['view_newest_first']) ? ' checked' : '', ' class="input_check">
1694
							</dd>';
1695
1696
	// Choose WYSIWYG settings?
1697 View Code Duplication
	if (empty($modSettings['disable_wysiwyg']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1698
		echo '
1699
							<dt>
1700
								<label for="wysiwyg_default">', $txt['wysiwyg_default'], '</label>
1701
							</dt>
1702
							<dd>
1703
								<input type="hidden" name="default_options[wysiwyg_default]" value="0">
1704
								<input type="checkbox" name="default_options[wysiwyg_default]" id="wysiwyg_default" value="1"', !empty($context['member']['options']['wysiwyg_default']) ? ' checked' : '', ' class="input_check">
1705
							</dd>';
1706
1707
	if (empty($modSettings['disableCustomPerPage']))
1708
	{
1709
		echo '
1710
							<dt>
1711
								<label for="topics_per_page">', $txt['topics_per_page'], '</label>
1712
							</dt>
1713
							<dd>
1714
								<select name="default_options[topics_per_page]" id="topics_per_page">
1715
									<option value="0"', empty($context['member']['options']['topics_per_page']) ? ' selected' : '', '>', $txt['per_page_default'], ' (', $modSettings['defaultMaxTopics'], ')</option>
1716
									<option value="5"', !empty($context['member']['options']['topics_per_page']) && $context['member']['options']['topics_per_page'] == 5 ? ' selected' : '', '>5</option>
1717
									<option value="10"', !empty($context['member']['options']['topics_per_page']) && $context['member']['options']['topics_per_page'] == 10 ? ' selected' : '', '>10</option>
1718
									<option value="25"', !empty($context['member']['options']['topics_per_page']) && $context['member']['options']['topics_per_page'] == 25 ? ' selected' : '', '>25</option>
1719
									<option value="50"', !empty($context['member']['options']['topics_per_page']) && $context['member']['options']['topics_per_page'] == 50 ? ' selected' : '', '>50</option>
1720
								</select>
1721
							</dd>
1722
							<dt>
1723
								<label for="messages_per_page">', $txt['messages_per_page'], '</label>
1724
							</dt>
1725
							<dd>
1726
								<select name="default_options[messages_per_page]" id="messages_per_page">
1727
									<option value="0"', empty($context['member']['options']['messages_per_page']) ? ' selected' : '', '>', $txt['per_page_default'], ' (', $modSettings['defaultMaxMessages'], ')</option>
1728
									<option value="5"', !empty($context['member']['options']['messages_per_page']) && $context['member']['options']['messages_per_page'] == 5 ? ' selected' : '', '>5</option>
1729
									<option value="10"', !empty($context['member']['options']['messages_per_page']) && $context['member']['options']['messages_per_page'] == 10 ? ' selected' : '', '>10</option>
1730
									<option value="25"', !empty($context['member']['options']['messages_per_page']) && $context['member']['options']['messages_per_page'] == 25 ? ' selected' : '', '>25</option>
1731
									<option value="50"', !empty($context['member']['options']['messages_per_page']) && $context['member']['options']['messages_per_page'] == 50 ? ' selected' : '', '>50</option>
1732
								</select>
1733
							</dd>';
1734
	}
1735
1736
	if (!empty($modSettings['cal_enabled']))
1737
		echo '
1738
							<dt>
1739
								<label for="calendar_start_day">', $txt['calendar_start_day'], ':</label>
1740
							</dt>
1741
							<dd>
1742
								<select name="default_options[calendar_start_day]" id="calendar_start_day">
1743
									<option value="0"', empty($context['member']['options']['calendar_start_day']) ? ' selected' : '', '>', $txt['days'][0], '</option>
1744
									<option value="1"', !empty($context['member']['options']['calendar_start_day']) && $context['member']['options']['calendar_start_day'] == 1 ? ' selected' : '', '>', $txt['days'][1], '</option>
1745
									<option value="6"', !empty($context['member']['options']['calendar_start_day']) && $context['member']['options']['calendar_start_day'] == 6 ? ' selected' : '', '>', $txt['days'][6], '</option>
1746
								</select>
1747
							</dd>';
1748
1749 View Code Duplication
	if ((!empty($modSettings['drafts_post_enabled']) || !empty($modSettings['drafts_pm_enabled'])) && !empty($modSettings['drafts_autosave_enabled']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1750
		echo '
1751
							<dt>
1752
								<label for="drafts_autosave_enabled">', $txt['drafts_autosave_enabled'], '</label>
1753
							</dt>
1754
							<dd>
1755
								<input type="hidden" name="default_options[drafts_autosave_enabled]" value="0">
1756
								<input type="checkbox" name="default_options[drafts_autosave_enabled]" id="drafts_autosave_enabled" value="1"', !empty($context['member']['options']['drafts_autosave_enabled']) ? ' checked' : '', ' class="input_check">
1757
							</dd>';
1758 View Code Duplication
	if ((!empty($modSettings['drafts_post_enabled']) || !empty($modSettings['drafts_pm_enabled'])) && !empty($modSettings['drafts_show_saved_enabled']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1759
		echo '
1760
							<dt>
1761
								<label for="drafts_show_saved_enabled">', $txt['drafts_show_saved_enabled'], '</label>
1762
							</dt>
1763
							<dd>
1764
								<input type="hidden" name="default_options[drafts_show_saved_enabled]" value="0">
1765
								<input type="checkbox" name="default_options[drafts_show_saved_enabled]" id="drafts_show_saved_enabled" value="1"', !empty($context['member']['options']['drafts_show_saved_enabled']) ? ' checked' : '', ' class="input_check">
1766
							</dd>';
1767
1768
	echo '
1769
							<dt>
1770
								<label for="use_editor_quick_reply">', $txt['use_editor_quick_reply'], '</label>
1771
							</dt>
1772
							<dd>
1773
								<input type="hidden" name="default_options[use_editor_quick_reply]" value="0">
1774
								<input type="checkbox" name="default_options[use_editor_quick_reply]" id="use_editor_quick_reply" value="1"', !empty($context['member']['options']['use_editor_quick_reply']) ? ' checked' : '', ' class="input_check">
1775
							</dd>
1776
							<dt>
1777
								<label for="display_quick_mod">', $txt['display_quick_mod'], ':</label>
1778
							</dt>
1779
							<dd>
1780
								<select name="default_options[display_quick_mod]" id="display_quick_mod">
1781
									<option value="0"', empty($context['member']['options']['display_quick_mod']) ? ' selected' : '', '>', $txt['display_quick_mod_none'], '</option>
1782
									<option value="1"', !empty($context['member']['options']['display_quick_mod']) && $context['member']['options']['display_quick_mod'] == 1 ? ' selected' : '', '>', $txt['display_quick_mod_check'], '</option>
1783
									<option value="2"', !empty($context['member']['options']['display_quick_mod']) && $context['member']['options']['display_quick_mod'] != 1 ? ' selected' : '', '>', $txt['display_quick_mod_image'], '</option>
1784
								</select>
1785
							</dd>';
1786
}
1787
1788
/**
1789
 * The template for configuring alerts
1790
 */
1791
function template_alert_configuration()
1792
{
1793
	global $context, $settings, $txt, $scripturl, $modSettings;
1794
1795
	echo '
1796
		<div class="cat_bar">
1797
			<h3 class="catbg">
1798
				', $txt['alert_prefs'], '
1799
			</h3>
1800
		</div>
1801
		<p class="information">', (empty($context['description']) ? $txt['alert_prefs_desc'] : $context['description']), '</p>
1802
		<form action="', $scripturl, '?', $context['action'], '" id="admin_form_wrapper" method="post" accept-charset="', $context['character_set'], '" id="notify_options" class="flow_hidden">
1803
			<div class="cat_bar">
1804
				<h3 class="catbg">
1805
					', $txt['notification_general'], '
1806
				</h3>
1807
			</div>
1808
			<div class="windowbg2 noup">
1809
				<dl class="settings">';
1810
1811
	// Allow notification on announcements to be disabled?
1812
	if (!empty($modSettings['allow_disableAnnounce']))
1813
		echo '
1814
					<dt>
1815
						<label for="notify_announcements">', $txt['notify_important_email'], '</label>
1816
					</dt>
1817
					<dd>
1818
						<input type="hidden" name="notify_announcements" value="0">
1819
						<input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', ' class="input_check">
1820
					</dd>';
1821
1822
	if (!empty($modSettings['enable_ajax_alerts']))
1823
		echo '
1824
					<dt>
1825
						<label for="notify_send_body">', $txt['notify_alert_timeout'], '</label>
1826
					</dt>
1827
					<dd>
1828
						<input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '" class="input_text">
1829
					</dd>
1830
		';
1831
1832
	echo '
1833
				</dl>
1834
			</div>
1835
			<div class="cat_bar">
1836
				<h3 class="catbg">
1837
					', $txt['notify_what_how'], '
1838
				</h3>
1839
			</div>
1840
			<table class="table_grid">';
1841
1842
	foreach ($context['alert_types'] as $alert_group => $alerts)
1843
	{
1844
		echo '
1845
				<tr class="title_bar">
1846
					<th>', $txt['alert_group_' . $alert_group],'</th>
1847
					<th>', $txt['receive_alert'], '</th>
1848
					<th>', $txt['receive_mail'], '</th>
1849
				</tr>
1850
				<tr class="windowbg">';
1851
		if (isset($context['alert_group_options'][$alert_group]))
1852
		{
1853
			foreach ($context['alert_group_options'][$alert_group] as $opts)
1854
			{
1855
				echo '
1856
				<tr class="windowbg">
1857
					<td colspan="3">';
1858
				$label = $txt['alert_opt_' . $opts[1]];
1859
				$label_pos = isset($opts['label']) ? $opts['label'] : '';
1860
				if ($label_pos == 'before')
1861
					echo '
1862
					<label for="opt_', $opts[1], '">', $label, '</label>';
1863
1864
				$this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0;
1865
				switch ($opts[0])
1866
				{
1867
					case 'check':
1868
						echo '
1869
						<input type="checkbox" name="opt_', $opts[1], '" id="opt_', $opts[1], '"', $this_value ? ' checked' : '', '>';
1870
						break;
1871
					case 'select':
1872
						echo '
1873
						<select name="opt_', $opts[1], '" id="opt_', $opts[1], '">';
1874
						foreach ($opts['opts'] as $k => $v)
1875
							echo '
1876
							<option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>';
1877
						echo '
1878
						</select>';
1879
						break;
1880
				}
1881
1882
				if ($label_pos == 'after')
1883
					echo '
1884
					<label for="opt_', $opts[1], '">', $label, '</label>';
1885
1886
				echo '
1887
					</td>
1888
				</tr>';
1889
			}
1890
		}
1891
1892
		foreach ($alerts as $alert_id => $alert_details)
1893
		{
1894
			echo '
1895
				<tr class="windowbg">
1896
					<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>';
1897
1898
			foreach ($context['alert_bits'] as $type => $bitmask)
1899
			{
1900
				echo '
1901
					<td class="centercol">';
1902
				$this_value = isset($context['alert_prefs'][$alert_id]) ? $context['alert_prefs'][$alert_id] : 0;
1903
				switch ($alert_details[$type])
1904
				{
1905
					case 'always':
1906
						echo '
1907
						<input type="checkbox" checked disabled>';
1908
						break;
1909
					case 'yes':
1910
						echo '
1911
						<input type="checkbox" name="', $type, '_', $alert_id, '"', ($this_value & $bitmask) ? ' checked' : '', '>';
1912
						break;
1913
					case 'never':
1914
						echo '
1915
						<input type="checkbox" disabled>';
1916
						break;
1917
				}
1918
				echo '
1919
					</td>';
1920
			}
1921
1922
			echo '
1923
				</tr>';
1924
		}
1925
	}
1926
1927
	echo '
1928
			</table>
1929
			<br>
1930
			<div>
1931
				<input id="notify_submit" type="submit" name="notify_submit" value="', $txt['notify_save'], '" class="button_submit">
1932
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">', !empty($context['token_check']) ? '
1933
				<input type="hidden" name="' . $context[$context['token_check'] . '_token_var'] . '" value="' . $context[$context['token_check'] . '_token'] . '">' : '', '
1934
				<input type="hidden" name="u" value="', $context['id_member'], '">
1935
				<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
1936
			</div>
1937
		</form>
1938
		<br>';
1939
}
1940
1941
/**
1942
 * Template for showing which topics you're subscribed to
1943
 */
1944
function template_alert_notifications_topics()
1945
{
1946
	global $txt;
1947
1948
	// The main containing header.
1949
	echo '
1950
		<div class="cat_bar">
1951
			<h3 class="catbg">
1952
				', $txt['watched_topics'], '
1953
			</h3>
1954
		</div>
1955
		<p class="information">', $txt['watched_topics_desc'], '</p>
1956
		<br>';
1957
1958
	template_show_list('topic_notification_list');
1959
}
1960
1961
/**
1962
 * Template for showing which boards you're subscribed to
1963
 */
1964
function template_alert_notifications_boards()
1965
{
1966
	global $txt;
1967
1968
	echo '
1969
		<div class="cat_bar">
1970
			<h3 class="catbg">
1971
				', $txt['watched_boards'], '
1972
			</h3>
1973
		</div>
1974
		<p class="information">', $txt['watched_boards_desc'], '</p>
1975
		<br>';
1976
1977
	template_show_list('board_notification_list');
1978
}
1979
1980
/**
1981
 * Template for choosing group membership.
1982
 */
1983
function template_groupMembership()
1984
{
1985
	global $context, $scripturl, $txt;
1986
1987
	// The main containing header.
1988
	echo '
1989
		<form action="', $scripturl, '?action=profile;area=groupmembership;save" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
1990
			<div class="cat_bar">
1991
				<h3 class="catbg profile_hd">
1992
					', $txt['profile'], '
1993
				</h3>
1994
			</div>
1995
			<p class="information">', $txt['groupMembership_info'], '</p>';
1996
1997
	// Do we have an update message?
1998
	if (!empty($context['update_message']))
1999
		echo '
2000
			<div class="infobox">
2001
				', $context['update_message'], '.
2002
			</div>';
2003
2004
	echo '
2005
		<div id="groups">';
2006
2007
	// Requesting membership to a group?
2008
	if (!empty($context['group_request']))
2009
	{
2010
		echo '
2011
			<div class="groupmembership">
2012
				<div class="cat_bar">
2013
					<h3 class="catbg">', $txt['request_group_membership'], '</h3>
2014
				</div>
2015
				<div class="roundframe">
2016
					', $txt['request_group_membership_desc'], ':
2017
					<textarea name="reason" rows="4" style="width: 99%;"></textarea>
2018
					<div class="righttext" style="margin: 0.5em 0.5% 0 0.5%;">
2019
						<input type="hidden" name="gid" value="', $context['group_request']['id'], '">
2020
						<input type="submit" name="req" value="', $txt['submit_request'], '" class="button_submit">
2021
					</div>
2022
				</div>
2023
			</div>';
2024
	}
2025
	else
2026
	{
2027
		echo '
2028
			<div class="title_bar">
2029
				<h3 class="titlebg">', $txt['current_membergroups'], '</h3>
2030
			</div>';
2031
2032
		foreach ($context['groups']['member'] as $group)
2033
		{
2034
			echo '
2035
					<div class="windowbg" id="primdiv_', $group['id'], '">';
2036
2037
				if ($context['can_edit_primary'])
2038
					echo '
2039
						<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">';
2040
2041
				echo '
2042
						<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>';
2043
2044
				// Can they leave their group?
2045
				if ($group['can_leave'])
2046
					echo '
2047
						<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>';
2048
2049
				echo '
2050
					</div>';
2051
		}
2052
2053
		if ($context['can_edit_primary'])
2054
			echo '
2055
			<div class="padding righttext">
2056
				<input type="submit" value="', $txt['make_primary'], '" class="button_submit">
2057
			</div>';
2058
2059
		// Any groups they can join?
2060
		if (!empty($context['groups']['available']))
2061
		{
2062
			echo '
2063
					<div class="title_bar">
2064
						<h3 class="titlebg">', $txt['available_groups'], '</h3>
2065
					</div>';
2066
2067
			foreach ($context['groups']['available'] as $group)
2068
			{
2069
				echo '
2070
					<div class="windowbg">
2071
						<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>' : ''), '';
2072
2073
				if ($group['type'] == 3)
2074
					echo '
2075
						<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>';
2076
				elseif ($group['type'] == 2 && $group['pending'])
2077
					echo '
2078
						<span class="floatright">', $txt['approval_pending'],'</span>';
2079
				elseif ($group['type'] == 2)
2080
					echo '
2081
						<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>';
2082
2083
				echo '
2084
					</div>';
2085
			}
2086
		}
2087
2088
		// Javascript for the selector stuff.
2089
		echo '
2090
		<script>
2091
		var prevClass = "";
2092
		var prevDiv = "";
2093
		function highlightSelected(box)
2094
		{
2095
			if (prevClass != "")
2096
			{
2097
				prevDiv.className = prevClass;
2098
			}
2099
			prevDiv = document.getElementById(box);
2100
			prevClass = prevDiv.className;
2101
2102
			prevDiv.className = "windowbg";
2103
		}';
2104
		if (isset($context['groups']['member'][$context['primary_group']]))
2105
			echo '
2106
		highlightSelected("primdiv_' . $context['primary_group'] . '");';
2107
		echo '
2108
	</script>';
2109
	}
2110
2111
	echo '
2112
		</div>';
2113
2114 View Code Duplication
	if (!empty($context['token_check']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2115
		echo '
2116
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2117
2118
	echo '
2119
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2120
				<input type="hidden" name="u" value="', $context['id_member'], '">
2121
			</form>';
2122
}
2123
2124
/**
2125
 * Template for managing ignored boards
2126
 */
2127
function template_ignoreboards()
2128
{
2129
	global $context, $txt, $scripturl;
2130
	// The main containing header.
2131
	echo '
2132
	<form action="', $scripturl, '?action=profile;area=ignoreboards;save" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
2133
		<div class="cat_bar">
2134
			<h3 class="catbg profile_hd">
2135
				', $txt['profile'], '
2136
			</h3>
2137
		</div>
2138
		<p class="information">', $txt['ignoreboards_info'], '</p>
2139
		<div class="windowbg2">
2140
			<div class="flow_hidden">
2141
				<ul class="ignoreboards floatleft">';
2142
2143
	$i = 0;
2144
	$limit = ceil($context['num_boards'] / 2);
2145
	foreach ($context['categories'] as $category)
2146
	{
2147
		if ($i == $limit)
2148
		{
2149
			echo '
2150
				</ul>
2151
				<ul class="ignoreboards floatright">';
2152
2153
			$i++;
2154
		}
2155
2156
		echo '
2157
					<li class="category">
2158
						<a href="javascript:void(0);" onclick="selectBoards([', implode(', ', $category['child_ids']), '], \'creator\'); return false;">', $category['name'], '</a>
2159
						<ul>';
2160
2161 View Code Duplication
		foreach ($category['boards'] as $board)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2162
		{
2163
			if ($i == $limit)
2164
				echo '
2165
						</ul>
2166
					</li>
2167
				</ul>
2168
				<ul class="ignoreboards floatright">
2169
					<li class="category">
2170
						<ul>';
2171
2172
			echo '
2173
							<li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">
2174
								<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>
2175
							</li>';
2176
2177
			$i++;
2178
		}
2179
2180
		echo '
2181
						</ul>
2182
					</li>';
2183
	}
2184
2185
	echo '
2186
				</ul>';
2187
2188
	// Show the standard "Save Settings" profile button.
2189
	template_profile_save();
2190
2191
	echo '
2192
			</div>
2193
		</div>
2194
	</form>
2195
	<br>';
2196
}
2197
2198
/**
2199
 * Simply loads some theme variables common to several warning templates.
2200
 */
2201
function template_load_warning_variables()
2202
{
2203
	global $modSettings, $context;
2204
2205
	$context['warningBarWidth'] = 200;
2206
	// Setup the colors - this is a little messy for theming.
2207
	$context['colors'] = array(
2208
		0 => 'green',
2209
		$modSettings['warning_watch'] => 'darkgreen',
2210
		$modSettings['warning_moderate'] => 'orange',
2211
		$modSettings['warning_mute'] => 'red',
2212
	);
2213
2214
	// Work out the starting color.
2215
	$context['current_color'] = $context['colors'][0];
2216
	foreach ($context['colors'] as $limit => $color)
2217
		if ($context['member']['warning'] >= $limit)
2218
			$context['current_color'] = $color;
2219
}
2220
2221
// Show all warnings of a user?
2222
function template_viewWarning()
2223
{
2224
	global $context, $txt;
2225
2226
	template_load_warning_variables();
2227
2228
	echo '
2229
		<div class="cat_bar">
2230
			<h3 class="catbg profile_hd">
2231
				', sprintf($txt['profile_viewwarning_for_user'], $context['member']['name']), '
2232
			</h3>
2233
		</div>
2234
		<p class="information">', $txt['viewWarning_help'], '</p>
2235
		<div class="windowbg">
2236
			<dl class="settings">
2237
				<dt>
2238
					<strong>', $txt['profile_warning_name'], ':</strong>
2239
				</dt>
2240
				<dd>
2241
					', $context['member']['name'], '
2242
				</dd>
2243
				<dt>
2244
					<strong>', $txt['profile_warning_level'], ':</strong>
2245
				</dt>
2246
				<dd>
2247
					<div>
2248
						<div>
2249
							<div style="font-size: 8pt; height: 12pt; width: ', $context['warningBarWidth'], 'px; border: 1px solid black; background-color: white; padding: 1px; position: relative;">
2250
								<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>
2251
								<div id="warning_progress" style="width: ', $context['member']['warning'], '%; height: 12pt; z-index: 1; background-color: ', $context['current_color'], ';">&nbsp;</div>
2252
							</div>
2253
						</div>
2254
					</div>
2255
				</dd>';
2256
2257
		// There's some impact of this?
2258
		if (!empty($context['level_effects'][$context['current_level']]))
2259
			echo '
2260
				<dt>
2261
					<strong>', $txt['profile_viewwarning_impact'], ':</strong>
2262
				</dt>
2263
				<dd>
2264
					', $context['level_effects'][$context['current_level']], '
2265
				</dd>';
2266
2267
		echo '
2268
			</dl>
2269
		</div>';
2270
2271
	template_show_list('view_warnings');
2272
}
2273
2274
// Show a lovely interface for issuing warnings.
2275
function template_issueWarning()
2276
{
2277
	global $context, $scripturl, $txt;
2278
2279
	template_load_warning_variables();
2280
2281
	echo '
2282
	<script>
2283
		// Disable notification boxes as required.
2284
		function modifyWarnNotify()
2285
		{
2286
			disable = !document.getElementById(\'warn_notify\').checked;
2287
			document.getElementById(\'warn_sub\').disabled = disable;
2288
			document.getElementById(\'warn_body\').disabled = disable;
2289
			document.getElementById(\'warn_temp\').disabled = disable;
2290
			document.getElementById(\'new_template_link\').style.display = disable ? \'none\' : \'\';
2291
			document.getElementById(\'preview_button\').style.display = disable ? \'none\' : \'\';
2292
		}
2293
2294
		// Warn template.
2295
		function populateNotifyTemplate()
2296
		{
2297
			index = document.getElementById(\'warn_temp\').value;
2298
			if (index == -1)
2299
				return false;
2300
2301
			// Otherwise see what we can do...';
2302
2303
	foreach ($context['notification_templates'] as $k => $type)
2304
		echo '
2305
			if (index == ', $k, ')
2306
				document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";';
2307
2308
	echo '
2309
		}
2310
2311
		function updateSlider(slideAmount)
2312
		{
2313
			// Also set the right effect.
2314
			effectText = "";';
2315
2316
	foreach ($context['level_effects'] as $limit => $text)
2317
		echo '
2318
			if (slideAmount >= ', $limit, ')
2319
				effectText = "', $text, '";';
2320
2321
	echo '
2322
			setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\');
2323
		}
2324
	</script>';
2325
2326
	echo '
2327
	<form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=issuewarning" method="post" class="flow_hidden" accept-charset="', $context['character_set'], '">
2328
		<div class="cat_bar">
2329
			<h3 class="catbg profile_hd">
2330
				', $context['user']['is_owner'] ? $txt['profile_warning_level'] : $txt['profile_issue_warning'], '
2331
			</h3>
2332
		</div>';
2333
2334
	if (!$context['user']['is_owner'])
2335
		echo '
2336
		<p class="information">', $txt['profile_warning_desc'], '</p>';
2337
2338
	echo '
2339
		<div class="windowbg">
2340
			<dl class="settings">';
2341
2342
	if (!$context['user']['is_owner'])
2343
		echo '
2344
				<dt>
2345
					<strong>', $txt['profile_warning_name'], ':</strong>
2346
				</dt>
2347
				<dd>
2348
					<strong>', $context['member']['name'], '</strong>
2349
				</dd>';
2350
2351
	echo '
2352
				<dt>
2353
					<strong>', $txt['profile_warning_level'], ':</strong>';
2354
2355
	// Is there only so much they can apply?
2356
	if ($context['warning_limit'])
2357
		echo '
2358
					<br><span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>';
2359
2360
	echo '
2361
				</dt>
2362
				<dd>
2363
					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%
2364
					<div class="clear_left">', $txt['profile_warning_impact'], ': <span id="cur_level_div">', $context['member']['warning'], '% (', $context['level_effects'][$context['current_level']], ')</span></div>
2365
				</dd>';
2366
2367
	if (!$context['user']['is_owner'])
2368
	{
2369
		echo '
2370
				<dt>
2371
					<strong>', $txt['profile_warning_reason'], ':</strong><br>
2372
					<span class="smalltext">', $txt['profile_warning_reason_desc'], '</span>
2373
				</dt>
2374
				<dd>
2375
					<input type="text" name="warn_reason" id="warn_reason" value="', $context['warning_data']['reason'], '" size="50" style="width: 80%;" class="input_text">
2376
				</dd>
2377
			</dl>
2378
			<hr>
2379
			<div id="box_preview"', !empty($context['warning_data']['body_preview']) ? '' : ' style="display:none"', '>
2380
				<dl class="settings">
2381
					<dt>
2382
						<strong>', $txt['preview'] , '</strong>
2383
					</dt>
2384
					<dd id="body_preview">
2385
						', !empty($context['warning_data']['body_preview']) ? $context['warning_data']['body_preview'] : '', '
2386
					</dd>
2387
				</dl>
2388
				<hr>
2389
			</div>
2390
			<dl class="settings">
2391
				<dt>
2392
					<strong><label for="warn_notify">', $txt['profile_warning_notify'], ':</label></strong>
2393
				</dt>
2394
				<dd>
2395
					<input type="checkbox" name="warn_notify" id="warn_notify" onclick="modifyWarnNotify();"', $context['warning_data']['notify'] ? ' checked' : '', ' class="input_check">
2396
				</dd>
2397
				<dt>
2398
					<strong><label for="warn_sub">', $txt['profile_warning_notify_subject'], ':</label></strong>
2399
				</dt>
2400
				<dd>
2401
					<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">
2402
				</dd>
2403
				<dt>
2404
					<strong><label for="warn_temp">', $txt['profile_warning_notify_body'], ':</label></strong>
2405
				</dt>
2406
				<dd>
2407
					<select name="warn_temp" id="warn_temp" disabled onchange="populateNotifyTemplate();" style="font-size: x-small;">
2408
						<option value="-1">', $txt['profile_warning_notify_template'], '</option>
2409
						<option value="-1" disabled>------------------------------</option>';
2410
2411
		foreach ($context['notification_templates'] as $id_template => $template)
2412
			echo '
2413
						<option value="', $id_template, '">', $template['title'], '</option>';
2414
2415
		echo '
2416
					</select>
2417
					<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>
2418
					<textarea name="warn_body" id="warn_body" cols="40" rows="8" style="min-width: 50%; max-width: 99%;">', $context['warning_data']['notify_body'], '</textarea>
2419
				</dd>';
2420
	}
2421
	echo '
2422
			</dl>
2423
			<div class="righttext">';
2424
2425 View Code Duplication
	if (!empty($context['token_check']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2426
		echo '
2427
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2428
2429
	echo '
2430
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2431
				<input type="button" name="preview" id="preview_button" value="', $txt['preview'], '" class="button_submit">
2432
				<input type="submit" name="save" value="', $context['user']['is_owner'] ? $txt['change_profile'] : $txt['profile_warning_issue'], '" class="button_submit">
2433
			</div>
2434
		</div>
2435
	</form>';
2436
2437
	// Previous warnings?
2438
	template_show_list('view_warnings');
2439
2440
	echo '
2441
	<script>';
2442
2443
	if (!$context['user']['is_owner'])
2444
		echo '
2445
		modifyWarnNotify();
2446
		$(document).ready(function() {
2447
			$("#preview_button").click(function() {
2448
				return ajax_getTemplatePreview();
2449
			});
2450
		});
2451
2452
		function ajax_getTemplatePreview ()
2453
		{
2454
			$.ajax({
2455
				type: "POST",
2456
				url: "' . $scripturl . '?action=xmlhttp;sa=previews;xml",
2457
				data: {item: "warning_preview", title: $("#warn_sub").val(), body: $("#warn_body").val(), issuing: true},
2458
				context: document.body,
2459
				success: function(request){
2460
					$("#box_preview").css({display:""});
2461
					$("#body_preview").html($(request).find(\'body\').text());
2462
					if ($(request).find("error").text() != \'\')
2463
					{
2464
						$("#profile_error").css({display:""});
2465
						var errors_html = \'<ul class="list_errors">\';
2466
						var errors = $(request).find(\'error\').each(function() {
2467
							errors_html += \'<li>\' + $(this).text() + \'</li>\';
2468
						});
2469
						errors_html += \'</ul>\';
2470
2471
						$("#profile_error").html(errors_html);
2472
					}
2473
					else
2474
					{
2475
						$("#profile_error").css({display:"none"});
2476
						$("#error_list").html(\'\');
2477
					}
2478
				return false;
2479
				},
2480
			});
2481
			return false;
2482
		}';
2483
2484
	echo '
2485
	</script>';
2486
}
2487
2488
/**
2489
 * Template to show for deleting a user's account - now with added delete post capability!
2490
 */
2491
function template_deleteAccount()
2492
{
2493
	global $context, $scripturl, $txt;
2494
2495
	// The main containing header.
2496
	echo '
2497
		<form action="', $scripturl, '?action=profile;area=deleteaccount;save" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
2498
			<div class="cat_bar">
2499
				<h3 class="catbg profile_hd">
2500
					', $txt['deleteAccount'], '
2501
				</h3>
2502
			</div>';
2503
2504
	// If deleting another account give them a lovely info box.
2505
	if (!$context['user']['is_owner'])
2506
		echo '
2507
			<p class="information">', $txt['deleteAccount_desc'], '</p>';
2508
	echo '
2509
			<div class="windowbg2">';
2510
2511
	// If they are deleting their account AND the admin needs to approve it - give them another piece of info ;)
2512
	if ($context['needs_approval'])
2513
		echo '
2514
				<div class="errorbox">', $txt['deleteAccount_approval'], '</div>';
2515
2516
	// If the user is deleting their own account warn them first - and require a password!
2517
	if ($context['user']['is_owner'])
2518
	{
2519
		echo '
2520
				<div class="alert">', $txt['own_profile_confirm'], '</div>
2521
				<div>
2522
					<strong', (isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : ''), '>', $txt['current_password'], ': </strong>
2523
					<input type="password" name="oldpasswrd" size="20" class="input_password">&nbsp;&nbsp;&nbsp;&nbsp;
2524
					<input type="submit" value="', $txt['yes'], '" class="button_submit">';
2525
2526 View Code Duplication
		if (!empty($context['token_check']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2527
			echo '
2528
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2529
2530
		echo '
2531
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2532
					<input type="hidden" name="u" value="', $context['id_member'], '">
2533
					<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
2534
				</div>';
2535
	}
2536
	// Otherwise an admin doesn't need to enter a password - but they still get a warning - plus the option to delete lovely posts!
2537
	else
2538
	{
2539
		echo '
2540
				<div class="alert">', $txt['deleteAccount_warning'], '</div>';
2541
2542
		// Only actually give these options if they are kind of important.
2543
		if ($context['can_delete_posts'])
2544
		{
2545
			echo '
2546
				<div>
2547
					<label for="deleteVotes"><input type="checkbox" name="deleteVotes" id="deleteVotes" value="1" class="input_check"> ', $txt['deleteAccount_votes'], ':</label><br>
2548
					<label for="deletePosts"><input type="checkbox" name="deletePosts" id="deletePosts" value="1" class="input_check"> ', $txt['deleteAccount_posts'], ':</label>
2549
					<select name="remove_type">
2550
						<option value="posts">', $txt['deleteAccount_all_posts'], '</option>
2551
						<option value="topics">', $txt['deleteAccount_topics'], '</option>
2552
					</select>';
2553
2554
			if ($context['show_perma_delete'])
2555
				echo '
2556
					<br><label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1" class="input_check">', $txt['deleteAccount_permanent'], ':</label>';
2557
2558
			echo '
2559
				</div>';
2560
		}
2561
2562
		echo '
2563
				<div>
2564
					<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>
2565
				</div>
2566
				<div>
2567
					<input type="submit" value="', $txt['delete'], '" class="button_submit">';
2568
2569 View Code Duplication
		if (!empty($context['token_check']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2570
			echo '
2571
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2572
2573
		echo '
2574
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
2575
					<input type="hidden" name="u" value="', $context['id_member'], '">
2576
					<input type="hidden" name="sa" value="', $context['menu_item_selected'], '">
2577
				</div>';
2578
	}
2579
	echo '
2580
			</div>
2581
			<br>
2582
		</form>';
2583
}
2584
2585
/**
2586
 * Template for the password box/save button stuck at the bottom of every profile page.
2587
 */
2588
function template_profile_save()
2589
{
2590
	global $context, $txt;
2591
2592
	echo '
2593
2594
					<hr>';
2595
2596
	// Only show the password box if it's actually needed.
2597 View Code Duplication
	if ($context['require_password'])
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2598
		echo '
2599
					<dl>
2600
						<dt>
2601
							<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br>
2602
							<span class="smalltext">', $txt['required_security_reasons'], '</span>
2603
						</dt>
2604
						<dd>
2605
							<input type="password" name="oldpasswrd" size="20" style="margin-right: 4ex;" class="input_password">
2606
						</dd>
2607
					</dl>';
2608
2609
	echo '
2610
					<div class="righttext">';
2611
2612 View Code Duplication
		if (!empty($context['token_check']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

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