Issues (1686)

themes/default/ProfileOptions.template.php (1 issue)

Severity
1
<?php
2
3
/**
4
 * @package   ElkArte Forum
5
 * @copyright ElkArte Forum contributors
6
 * @license   BSD http://opensource.org/licenses/BSD-3-Clause (see accompanying LICENSE.txt file)
7
 *
8
 * This file contains code covered by:
9
 * copyright: 2011 Simple Machines (http://www.simplemachines.org)
10
 *
11
 * @version 2.0 dev
12
 *
13
 */
14
15
/**
16
 * We need this template in order to look at ignored boards
17
 */
18
function template_ProfileOptions_init()
19
{
20
	global $context, $txt;
21
22
	theme()->getTemplates()->load('GenericBoards');
23
24
	if (!empty($context['menu_item_selected']) && $context['menu_item_selected'] === 'notification')
25
	{
26
		loadJavascriptFile('ext/jquery.multiselect.min.js');
27
		theme()->addInlineJavascript('
28
			$(\'.select_multiple\').multiselect({\'language_strings\': {\'Select all\': ' . JavascriptEscape($txt['notify_select_all']) . '}});'
29
			, true);
30
31
		loadCSSFile('multiselect.css');
32
	}
33
}
34
35
/**
36
 * Template for showing all the buddies of the current user.
37
 */
38
function template_editBuddies()
39
{
40
	global $context, $txt;
41
42
	echo '
43
	<div id="edit_buddies">
44
		<h2 class="category_header hdicon i-users">
45
			', $txt['editBuddies'], '
46
		</h2>
47
		<table class="table_grid">
48
			<tr class="table_head">
49
				<th scope="col" class="grid20">', $txt['name'], '</th>
50
				<th scope="col">', $txt['status'], '</th>';
51
52
	if ($context['can_send_email'])
53
	{
54
		echo '
55
				<th scope="col">', $txt['email'], '</th>';
56
	}
57
58
	echo '
59
				<th scope="col">', $txt['profile_contact'], '</th>
60
				<th scope="col"></th>
61
			</tr>';
62
63
	// If they don't have any buddies don't list them!
64
	if (empty($context['buddies']))
65
	{
66
		echo '
67
			<tr>
68
				<td colspan="5" class="centertext">
69
					<strong>', $txt['no_buddies'], '</strong>
70
				</td>
71
			</tr>';
72
	}
73
74
	// Now loop through each buddy showing info on each.
75
	foreach ($context['buddies'] as $buddy)
76
	{
77
		echo '
78
			<tr>
79
				<td>', $buddy['link'], '</td>
80
				<td>
81
					', template_member_online($buddy), '
82
				</td>';
83
84
		if ($context['can_send_email'])
85
		{
86
			echo '
87
				<td>', template_member_email($buddy), '</td>';
88
		}
89
90
		//  Any custom profile (with icon) fields to show
91
		$im = array();
92
		if (!empty($buddy['custom_fields']))
93
		{
94
95
			foreach ($buddy['custom_fields'] as $cpf)
96
			{
97
				if ((int) $cpf['placement'] === 1)
98
				{
99
					$im[] = $cpf['value'];
100
				}
101
			}
102
		}
103
104
		echo '
105
				<td>' . implode(' | ', $im) . '</td>';
106
107
		echo '
108
				<td class="righttext">
109
					<a href="', getUrl('action', ['action' => 'profile', 'area' => 'lists', 'sa' => 'buddies', 'u' => $context['id_member'], 'remove' => $buddy['id'], '{session_data}']), '" class="icon i-remove" title="', $txt['buddy_remove'], '"></a>
110
				</td>
111
			</tr>';
112
	}
113
114
	echo '
115
		</table>
116
	</div>';
117
118
	// Add a new buddy?
119
	echo '
120
	<form action="', getUrl('action', ['action' => 'profile', 'u' => $context['id_member'], 'area' => 'lists', 'sa' => 'buddies']), '" method="post" accept-charset="UTF-8">
121
		<div class="add_buddy">
122
			<h2 class="category_header">', $txt['buddy_add'], '</h2>
123
			<div class="well">
124
				<dl class="settings">
125
					<dt>
126
						<label for="new_buddy">', $txt['who_member'], '</label>
127
					</dt>
128
					<dd>
129
						<input type="text" name="new_buddy" id="new_buddy" size="30" class="input_text" />
130
						<input type="submit" value="', $txt['buddy_add_button'], '" />
131
					</dd>
132
				</dl>';
133
134
	if (!empty($context['token_check']))
135
	{
136
		echo '
137
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '" />';
138
	}
139
140
	echo '
141
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
142
			</div>
143
		</div>
144
	</form>';
145
146
	// Initialize the member suggest object
147
	theme()->addInlineJavascript('
148
		isFunctionLoaded("elk_AutoSuggest").then((available) => { 
149
			if (available) {
150
				new elk_AutoSuggest({
151
					sSessionId: elk_session_id,
152
					sSessionVar: elk_session_var,
153
					sSuggestId: "new_buddy",
154
					sControlId: "new_buddy",
155
					sSearchType: "member",
156
				});
157
			}
158
		});', true);
159
}
160
161
/**
162
 * Template for showing the ignore list of the current user.
163
 */
164
function template_editIgnoreList()
165
{
166
	global $context, $txt;
167
168
	echo '
169
	<div id="edit_buddies">
170
		<h2 class="category_header hdicon i-user">
171
			', $txt['editIgnoreList'], '
172
		</h2>
173
		<table class="table_grid">
174
			<tr class="table_head">
175
				<th scope="col" style="width: 20%;">', $txt['name'], '</th>
176
				<th scope="col">', $txt['status'], '</th>';
177
178
	if ($context['can_send_email'])
179
	{
180
		echo '
181
				<th scope="col">', $txt['email'], '</th>';
182
	}
183
184
	echo '
185
				<th scope="col"></th>
186
			</tr>';
187
188
	// If they don't have anyone on their ignore list, don't list it!
189
	if (empty($context['ignore_list']))
190
	{
191
		echo '
192
			<tr>
193
				<td colspan="4" class="centertext">
194
					<strong>', $txt['no_ignore'], '</strong>
195
				</td>
196
			</tr>';
197
	}
198
199
	// Now loop through each buddy showing info on each.
200
	foreach ($context['ignore_list'] as $member)
201
	{
202
		echo '
203
			<tr>
204
				<td>', $member['link'], '</td>
205
				<td>
206
					', template_member_online($member), '
207
				</td>';
208
209
		if ($context['can_send_email'])
210
		{
211
			echo '
212
				<td>', template_member_email($member), '</td>';
213
		}
214
215
		echo '
216
				<td class="righttext">
217
					<a href="', getUrl('profile', ['action' => 'profile', 'u' => $context['id_member'], 'name' => $context['member']['name'], 'area' => 'lists', 'sa' => 'ignore', 'remove' => $member['id'], '{session_data}']), '" class="icon i-remove" title="', $txt['ignore_remove'], '">
218
					</a>
219
				</td>
220
			</tr>';
221
	}
222
223
	echo '
224
		</table>
225
	</div>';
226
227
	// Add to the ignore list?
228
	echo '
229
	<form action="', getUrl('action', ['action' => 'profile', 'u' => $context['id_member'], 'area' => 'lists', 'sa' => 'ignore']) . '" method="post" accept-charset="UTF-8">
230
		<div class="add_buddy">
231
			<h2 class="category_header">', $txt['ignore_add'], '</h2>
232
			<div class="well">
233
				<dl class="settings">
234
					<dt>
235
						<label for="new_ignore">', $txt['who_member'], '</label>
236
					</dt>
237
					<dd>
238
						<input type="text" name="new_ignore" id="new_ignore" size="25" class="input_text" />
239
						<input type="submit" value="', $txt['ignore_add_button'], '" />
240
					</dd>
241
				</dl>';
242
243
	if (!empty($context['token_check']))
244
	{
245
		echo '
246
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '" />';
247
	}
248
249
	echo '
250
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
251
			</div>
252
		</div>
253
	</form>';
254
255
	theme()->addInlineJavascript('
256
		isFunctionLoaded("elk_AutoSuggest").then((available) => { 
257
			if (available) {
258
				new elk_AutoSuggest({
259
					sSessionId: elk_session_id,
260
					sSessionVar: elk_session_var,
261
					sSuggestId: "new_ignore",
262
					sControlId: "new_ignore",
263
					sSearchType: "member",
264
					sTextDeleteItem: ' . JavaScriptEscape($txt['autosuggest_delete_item']) . ',
265
					bItemList: false
266
				});
267
			}
268
		});', true);
269
}
270
271
/**
272
 * Template for editing profile options.
273
 *
274
 * @uses ParseError
275
 */
276
function template_edit_options()
277
{
278
	global $context, $txt;
279
280
	// The main header!
281
	echo '
282
		<form action="', (empty($context['profile_custom_submit_url']) ? getUrl('action', ['action' => 'profile', 'area' => $context['menu_item_selected'], 'u' => $context['id_member']]) : $context['profile_custom_submit_url']), '" method="post" accept-charset="UTF-8" name="creator" id="creator" enctype="multipart/form-data" onsubmit="return checkProfileSubmit();">
283
			<h2 class="category_header hdicon i-user">';
284
285
	// Don't say "Profile" if this isn't the profile...
286
	if (!empty($context['profile_header_text']))
287
	{
288
		echo '
289
				', $context['profile_header_text'];
290
	}
291
	else
292
	{
293
		echo '
294
				', $txt['profile'];
295
	}
296
297
	echo '
298
			</h2>';
299
300
	// Have we some description?
301
	if ($context['page_desc'])
302
	{
303
		echo '
304
			<p class="description">', $context['page_desc'], '</p>';
305
	}
306
307
	echo '
308
			<div class="content">';
309
310
	// Any bits at the start?
311
	if (!empty($context['profile_prehtml']))
312
	{
313
		echo '
314
				<div>', $context['profile_prehtml'], '</div>';
315
	}
316
317
	// Profile fields, standard and custom
318
	$lastItem = template_profile_options();
319
	template_custom_profile_options($lastItem);
320
321
	// Any closing HTML?
322
	if (!empty($context['profile_posthtml']))
323
	{
324
		echo '
325
				<div>', $context['profile_posthtml'], '</div>';
326
	}
327
328
	// Only show the password box if it's actually needed.
329
	template_profile_save();
330
331
	echo '
332
			</div>
333
		</form>';
334
335
	// Some javascript!
336
	echo '
337
		<script>
338
			function checkProfileSubmit()
339
			{';
340
341
	// If this part requires a password, make sure to give a warning.
342
	if ($context['require_password'])
343
	{
344
		echo '
345
				// Did you forget to type your password?
346
				if (document.forms.creator.oldpasswrd.value === "")
347
				{
348
					alert("', $txt['required_security_reasons'], '");
349
					return false;
350
				}';
351
	}
352
353
	// Any onsubmit javascript?
354
	if (!empty($context['profile_onsubmit_javascript']))
355
	{
356
		echo '
357
				', $context['profile_onsubmit_javascript'];
358
	}
359
360
	echo '
361
			}';
362
363
	if (!empty($context['load_google_authenticator']))
364
	{
365
		echo '
366
			var secret = document.getElementById("otp_secret").value;
367
368
			if (secret)
369
			{
370
				var qrcode = new QRCode("qrcode", {
371
					text: "otpauth://totp/' . $context['forum_name'] . '?secret=" + secret,
372
					width: 100,
373
					height: 100,
374
					colorDark : "#000000",
375
					colorLight : "#ffffff",
376
				});
377
			}
378
379
			/**
380
			* Generate a secret key for Google Authenticator
381
			*/
382
			function generateSecret() {
383
				var text = "",
384
					possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
385
					qr = document.getElementById("qrcode");
386
387
				for (var i = 0; i < 16; i++)
388
					text += possible.charAt(Math.floor(Math.random() * possible.length));
389
390
				document.getElementById("otp_secret").value = text;
391
392
				while (qr.firstChild) {
393
					qr.removeChild(qr.firstChild);
394
				}
395
396
				var qrcode = new QRCode("qrcode", {
397
					text: "otpauth://totp/' . $context['forum_name'] . '?secret=" + text,
398
					width: 100,
399
					height: 100,
400
					colorDark: "#000000",
401
					colorLight: "#ffffff",
402
				});
403
			}';
404
	}
405
406
	echo '
407
		</script>';
408
}
409
410
/**
411
 * All the profile options as defined in profile.subs or via an addon
412
 */
413
function template_profile_options()
414
{
415
	global $context;
416
417
	if (empty($context['profile_fields']))
418
	{
419
		return '';
420
	}
421
422
	// Start the big old loop 'of love.
423
	echo '
424
				<dl>';
425
426
	$lastItem = 'hr';
427
	foreach ($context['profile_fields'] as $key => $field)
428
	{
429
		// We add a little hack to be sure we never get more than one hr in a row!
430
		if ($lastItem === 'hr' && $field['type'] === 'hr')
431
		{
432
			continue;
433
		}
434
435
		$lastItem = $field['type'];
436
		if ($field['type'] === 'hr')
437
		{
438
			echo '
439
				</dl>
440
				<hr class="clear" />
441
				<dl>';
442
		}
443
		elseif ($field['type'] === 'callback')
444
		{
445
			if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func']))
446
			{
447
				$callback_func = 'template_profile_' . $field['callback_func'];
448
				$callback_func();
449
			}
450
		}
451
		else
452
		{
453
			echo '
454
					<dt>
455
						<label', empty($field['is_error']) ? '' : ' class="error"', ' for="' . $key . '">', $field['label'], '</label>';
456
457
			// Does it have any subtext to show?
458
			if (!empty($field['subtext']))
459
			{
460
				echo '
461
						<p class="smalltext">', $field['subtext'], '</p>';
462
			}
463
464
			echo '
465
					</dt>
466
					<dd>';
467
468
			// Want to put something in front of the box?
469
			if (!empty($field['preinput']))
470
			{
471
				echo '
472
						', $field['preinput'];
473
			}
474
475
			// What type of data are we showing?
476
			if ($field['type'] === 'label')
477
			{
478
				echo '
479
						', $field['value'];
480
			}
481
			// Maybe it's a text box - very likely!
482
			elseif (in_array($field['type'], array('int', 'float', 'text', 'password')))
483
			{
484
				echo '
485
				
486
						<input type="', $field['type'] === 'password' ? 'password' : 'text', '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], ' class="input_', $field['type'] === 'password' ? 'password' : 'text', '" />';
487
			}
488
			// Maybe it's an html5 input
489
			elseif (in_array($field['type'], array('url', 'search', 'date', 'email', 'color')))
490
			{
491
				echo '
492
						<input type="', $field['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', '" />';
493
			}
494
			// You "checking" me out? ;)
495
			elseif ($field['type'] === 'check')
496
			{
497
				echo '
498
				<input type="hidden" name="', $key, '" value="0" /><input type="checkbox" name="', $key, '" id="', $key, '" ', empty($field['value']) ? '' : ' checked="checked"', ' value="1" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], ' />';
499
			}
500
			// Always fun - select boxes!
501
			elseif ($field['type'] === 'select')
502
			{
503
				echo '
504
						<select name="', $key, '" id="', $key, '">';
505
506
				if (isset($field['options']))
507
				{
508
					// Is this some code to generate the options?
509
					if (!is_array($field['options']))
510
					{
511
						try
512
						{
513
							$field['options'] = eval($field['options']);
0 ignored issues
show
The use of eval() is discouraged.
Loading history...
514
						}
515
						catch (ParseError)
516
						{
517
							$field['options'] = '';
518
						}
519
					}
520
521
					// Assuming we now have some!
522
					if (is_array($field['options']))
523
					{
524
						foreach ($field['options'] as $value => $name)
525
						{
526
							echo '
527
							<option value="', $value, '" ', $value == $field['value'] ? 'selected="selected"' : '', '>', $name, '</option>';
528
						}
529
					}
530
				}
531
532
				echo '
533
						</select>';
534
			}
535
536
			// Something to end with?
537
			if (!empty($field['postinput']))
538
			{
539
				echo '
540
						', $field['postinput'];
541
			}
542
543
			echo '
544
					</dd>';
545
		}
546
	}
547
548
	echo '
549
				</dl>';
550
551
	return $lastItem;
552
}
553
554
/**
555
 * Output any custom profile fields
556
 *
557
 * @param string $lastItem
558
 */
559
function template_custom_profile_options($lastItem = '')
560
{
561
	global $context;
562
563
	if (empty($context['custom_fields']))
564
	{
565
		return;
566
	}
567
568
	// Are there any custom profile fields - if so print them!
569
	if ($lastItem !== 'hr')
570
	{
571
		echo '
572
				<hr class="clear" />';
573
	}
574
575
	echo '
576
				<dl>';
577
578
	foreach ($context['custom_fields'] as $field)
579
	{
580
		echo '
581
					<dt>
582
						<strong>', $field['name'], '</strong><br />
583
						<span class="smalltext">', $field['desc'], '</span>
584
					</dt>
585
					<dd>
586
						', $field['input_html'], '
587
					</dd>';
588
	}
589
590
	echo '
591
			</dl>';
592
}
593
594
/**
595
 * Personal Message settings.
596
 */
597
function template_profile_pm_settings()
598
{
599
	global $context, $modSettings, $txt;
600
601
	echo '
602
							<dt>
603
								<label for="pm_settings">', $txt['pm_display_mode'], '</label>
604
							</dt>
605
							<dd>
606
								<select name="pm_settings" id="pm_settings">
607
									<option value="0"', $context['display_mode'] == 0 ? ' selected="selected"' : '', '>', $txt['pm_display_mode_all'], '</option>
608
									<option value="1"', $context['display_mode'] == 1 ? ' selected="selected"' : '', '>', $txt['pm_display_mode_one'], '</option>
609
									<option value="2"', $context['display_mode'] == 2 ? ' selected="selected"' : '', '>', $txt['pm_display_mode_linked'], '</option>
610
								</select>
611
							</dd>
612
							<dt>
613
								<label for="view_newest_pm_first">', $txt['recent_pms_at_top'], '</label>
614
							</dt>
615
							<dd>
616
								<input type="hidden" name="default_options[view_newest_pm_first]" value="0" />
617
								<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="checked"', ' />
618
							</dd>
619
						</dl>
620
						<dl>
621
							<dt>
622
								<label for="pm_email_notify">', $txt['email_notify'], '</label>
623
							</dt>
624
							<dd>
625
								<select name="pm_email_notify" id="pm_email_notify">
626
									<option value="0"', empty($context['send_email']) ? ' selected="selected"' : '', '>', $txt['email_notify_never'], '</option>
627
									<option value="1"', !empty($context['send_email']) && ($context['send_email'] == 1 || (empty($modSettings['enable_buddylist']) && $context['send_email'] > 1)) ? ' selected="selected"' : '', '>', $txt['email_notify_always'], '</option>';
628
629
	if (!empty($modSettings['enable_buddylist']))
630
	{
631
		echo '
632
										<option value="2"', !empty($context['send_email']) && $context['send_email'] > 1 ? ' selected="selected"' : '', '>', $txt['email_notify_buddies'], '</option>';
633
	}
634
635
	echo '
636
								</select>
637
							</dd>
638
							<dt>
639
									<label for="popup_messages">', $txt['popup_messages'], '</label>
640
							</dt>
641
							<dd>
642
									<input type="hidden" name="default_options[popup_messages]" value="0" />
643
									<input type="checkbox" name="default_options[popup_messages]" id="popup_messages" value="1"', empty($context['member']['options']['popup_messages']) ? '' : ' checked="checked"', ' />
644
							</dd>
645
						</dl>
646
						<dl>
647
							<dt>
648
									<label for="pm_remove_inbox_label">', $txt['pm_remove_inbox_label'], '</label>
649
							</dt>
650
							<dd>
651
									<input type="hidden" name="default_options[pm_remove_inbox_label]" value="0" />
652
									<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="checked"', ' />
653
							</dd>';
654
}
655
656
/**
657
 * Template for showing theme settings. Note: template_options() actually adds the theme specific options.
658
 */
659
function template_profile_theme_settings()
660
{
661
	global $context, $modSettings, $txt;
662
663
	echo '
664
							<dt>
665
								<label for="use_sidebar_menu">', $txt['use_sidebar_menu'], '</label>
666
							</dt>
667
							<dd>
668
								<input type="hidden" name="default_options[use_sidebar_menu]" value="0" />
669
								<input type="checkbox" name="default_options[use_sidebar_menu]" id="use_sidebar_menu" value="1"', empty($context['member']['options']['use_sidebar_menu']) ? '' : ' checked="checked"', ' />
670
							</dd>
671
							<dt>
672
								<label for="use_click_menu">', $txt['use_click_menu'], '</label>
673
							</dt>
674
							<dd>
675
								<input type="hidden" name="default_options[use_click_menu]" value="0" />
676
								<input type="checkbox" name="default_options[use_click_menu]" id="use_click_menu" value="1"', empty($context['member']['options']['use_click_menu']) ? '' : ' checked="checked"', ' />
677
							</dd>
678
							<dt>
679
								<label for="show_no_avatars">', $txt['show_no_avatars'], '</label>
680
							</dt>
681
							<dd>
682
								<input type="hidden" name="default_options[show_no_avatars]" value="0" />
683
								<input type="checkbox" name="default_options[show_no_avatars]" id="show_no_avatars" value="1"', empty($context['member']['options']['show_no_avatars']) ? '' : ' checked="checked"', ' />
684
							</dd>
685
							<dt>
686
								<label for="show_no_smileys">', $txt['show_no_smileys'], '</label>
687
							</dt>
688
							<dd>
689
								<input type="hidden" name="default_options[show_no_smileys]" value="0" />
690
								<input type="checkbox" name="default_options[show_no_smileys]" id="show_no_smileys" value="1"', empty($context['member']['options']['show_no_smileys']) ? '' : ' checked="checked"', ' />
691
							</dd>
692
							<dt>
693
								<label for="hide_poster_area">', $txt['hide_poster_area'], '</label>
694
							</dt>
695
							<dd>
696
								<input type="hidden" name="default_options[hide_poster_area]" value="0" />
697
								<input type="checkbox" name="default_options[hide_poster_area]" id="hide_poster_area" value="1"', empty($context['member']['options']['hide_poster_area']) ? '' : ' checked="checked"', ' />
698
							</dd>
699
							<dt>
700
								<label for="show_no_signatures">', $txt['show_no_signatures'], '</label>
701
							</dt>
702
							<dd>
703
								<input type="hidden" name="default_options[show_no_signatures]" value="0" />
704
								<input type="checkbox" name="default_options[show_no_signatures]" id="show_no_signatures" value="1"', empty($context['member']['options']['show_no_signatures']) ? '' : ' checked="checked"', ' />
705
							</dd>';
706
707
	if ($context['allow_no_censored'])
708
	{
709
		echo '
710
							<dt>
711
								<label for="show_no_censored">', $txt['show_no_censored'], '</label>
712
							</dt>
713
							<dd>
714
								<input type="hidden" name="default_options[show_no_censored]" value="0" />
715
								<input type="checkbox" name="default_options[show_no_censored]" id="show_no_censored" value="1"' . (empty($context['member']['options']['show_no_censored']) ? '' : ' checked="checked"') . ' />
716
							</dd>';
717
	}
718
719
	echo '
720
							<dt>
721
								<label for="return_to_post">', $txt['return_to_post'], '</label>
722
							</dt>
723
							<dd>
724
								<input type="hidden" name="default_options[return_to_post]" value="0" />
725
								<input type="checkbox" name="default_options[return_to_post]" id="return_to_post" value="1"', empty($context['member']['options']['return_to_post']) ? '' : ' checked="checked"', ' />
726
							</dd>
727
							<dt>
728
								<label for="no_new_reply_warning">', $txt['no_new_reply_warning'], '</label>
729
							</dt>
730
							<dd>
731
								<input type="hidden" name="default_options[no_new_reply_warning]" value="0" />
732
								<input type="checkbox" name="default_options[no_new_reply_warning]" id="no_new_reply_warning" value="1"', empty($context['member']['options']['no_new_reply_warning']) ? '' : ' checked="checked"', ' />
733
							</dd>
734
							<dt>
735
								<label for="wysiwyg_default">', $txt['wysiwyg_default'], '</label>
736
							</dt>
737
							<dd>
738
								<input type="hidden" name="default_options[wysiwyg_default]" value="0" />
739
								<input type="checkbox" name="default_options[wysiwyg_default]" id="wysiwyg_default" value="1"', empty($context['member']['options']['wysiwyg_default']) ? '' : ' checked="checked"', ' />
740
							</dd>';
741
742
	if (empty($modSettings['disableCustomPerPage']))
743
	{
744
		echo '
745
							<dt>
746
								<label for="topics_per_page">', $txt['topics_per_page'], '</label>
747
							</dt>
748
							<dd>
749
								<select name="default_options[topics_per_page]" id="topics_per_page">
750
									<option value="0"', empty($context['member']['options']['topics_per_page']) ? ' selected="selected"' : '', '>', $txt['per_page_default'], ' (', $modSettings['defaultMaxTopics'], ')</option>
751
									<option value="5"', !empty($context['member']['options']['topics_per_page']) && $context['member']['options']['topics_per_page'] == 5 ? ' selected="selected"' : '', '>5</option>
752
									<option value="10"', !empty($context['member']['options']['topics_per_page']) && $context['member']['options']['topics_per_page'] == 10 ? ' selected="selected"' : '', '>10</option>
753
									<option value="25"', !empty($context['member']['options']['topics_per_page']) && $context['member']['options']['topics_per_page'] == 25 ? ' selected="selected"' : '', '>25</option>
754
									<option value="50"', !empty($context['member']['options']['topics_per_page']) && $context['member']['options']['topics_per_page'] == 50 ? ' selected="selected"' : '', '>50</option>
755
								</select>
756
							</dd>
757
							<dt>
758
								<label for="messages_per_page">', $txt['messages_per_page'], '</label>
759
							</dt>
760
							<dd>
761
								<select name="default_options[messages_per_page]" id="messages_per_page">
762
									<option value="0"', empty($context['member']['options']['messages_per_page']) ? ' selected="selected"' : '', '>', $txt['per_page_default'], ' (', $modSettings['defaultMaxMessages'], ')</option>
763
									<option value="5"', !empty($context['member']['options']['messages_per_page']) && $context['member']['options']['messages_per_page'] == 5 ? ' selected="selected"' : '', '>5</option>
764
									<option value="10"', !empty($context['member']['options']['messages_per_page']) && $context['member']['options']['messages_per_page'] == 10 ? ' selected="selected"' : '', '>10</option>
765
									<option value="25"', !empty($context['member']['options']['messages_per_page']) && $context['member']['options']['messages_per_page'] == 25 ? ' selected="selected"' : '', '>25</option>
766
									<option value="50"', !empty($context['member']['options']['messages_per_page']) && $context['member']['options']['messages_per_page'] == 50 ? ' selected="selected"' : '', '>50</option>
767
								</select>
768
							</dd>';
769
	}
770
771
	if (!empty($modSettings['cal_enabled']))
772
	{
773
		echo '
774
							<dt>
775
								<label for="calendar_start_day">', $txt['calendar_start_day'], '</label>
776
							</dt>
777
							<dd>
778
								<select name="default_options[calendar_start_day]" id="calendar_start_day">
779
									<option value="0"', empty($context['member']['options']['calendar_start_day']) ? ' selected="selected"' : '', '>', $txt['days'][0], '</option>
780
									<option value="1"', !empty($context['member']['options']['calendar_start_day']) && $context['member']['options']['calendar_start_day'] == 1 ? ' selected="selected"' : '', '>', $txt['days'][1], '</option>
781
									<option value="6"', !empty($context['member']['options']['calendar_start_day']) && $context['member']['options']['calendar_start_day'] == 6 ? ' selected="selected"' : '', '>', $txt['days'][6], '</option>
782
								</select>
783
								</dd>';
784
	}
785
786
	if (!empty($modSettings['drafts_enabled']) && !empty($modSettings['drafts_autosave_enabled']))
787
	{
788
		echo '
789
							<dt>
790
								<label for="drafts_autosave_enabled">', $txt['drafts_autosave_enabled'], '</label>
791
							</dt>
792
							<dd>
793
								<input type="hidden" name="default_options[drafts_autosave_enabled]" value="0" />
794
								<label for="drafts_autosave_enabled"><input type="checkbox" name="default_options[drafts_autosave_enabled]" id="drafts_autosave_enabled" value="1"', empty($context['member']['options']['drafts_autosave_enabled']) ? '' : ' checked="checked"', ' /></label>
795
							</dd>';
796
	}
797
798
	echo '
799
							<dt>
800
								<label for="display_quick_reply">', $txt['display_quick_reply'], '</label>
801
							</dt>
802
							<dd>
803
								<input type="hidden" name="default_options[display_quick_reply]" value="0" />
804
								<input type="checkbox" name="default_options[display_quick_reply]" id="display_quick_reply" value="1"', empty($context['member']['options']['display_quick_reply']) ? '' : ' checked="checked"', ' />
805
							</dd>
806
							<dt>
807
								<label for="display_quick_mod">', $txt['display_quick_mod'], '</label>
808
							</dt>
809
							<dd>
810
								<input type="hidden" name="default_options[display_quick_mod]" value="0" />
811
								<input type="checkbox" name="default_options[display_quick_mod]" id="display_quick_mod" value="1"', empty($context['member']['options']['display_quick_mod']) ? '' : ' checked="checked"', ' />
812
							</dd>';
813
}
814
815
/**
816
 * Template for setting up how and what you want to be notified about
817
 */
818
function template_action_notification()
819
{
820
	global $context, $txt, $modSettings;
821
822
	// The main containing header.
823
	echo '
824
		<form id="creator" class="flow_hidden" action="', getUrl('action', ['action' => 'profile', 'area' => 'notification']), '" method="post" accept-charset="UTF-8">
825
			<h2 class="category_header hdicon i-comment">
826
				', $txt['notifications'], '
827
			</h2>
828
			<p class="description">', $txt['notification_settings_info'], '</p>
829
			<div class="content">
830
				<dl>
831
					<dt>
832
						<label for="notify_from">', $txt['notify_from'], '</label>
833
						<p class="smalltext">', $txt['notify_from_description'], '</p>
834
					</dt>
835
					<dd>
836
						<select name="notify_from" id="notify_from">
837
							<option value="0"', $context['member']['notify_from'] == 0 ? ' selected="selected"' : '', '>', $txt['receive_from_everyone'], '</option>
838
							<option value="1"', $context['member']['notify_from'] == 1 ? ' selected="selected"' : '', '>', $txt['receive_from_ignore'], '</option>
839
							<option value="2"', $context['member']['notify_from'] == 2 ? ' selected="selected"' : '', '>', $txt['receive_from_buddies'], '</option>
840
						</select>
841
					</dd>
842
				</dl>
843
				
844
				<dl>';
845
846
	foreach ($context['mention_types'] as $type => $mention_methods)
847
	{
848
		if ($type === 'watchedtopic' || $type === 'watchedboard')
849
		{
850
			continue;
851
		}
852
853
		echo '
854
					<dt>
855
						<label for="notify_', $type, '">', $txt['notify_type_' . $type], '</label>
856
					</dt>
857
					<dd>	
858
						<label for="notify_', $type, '_default">', $txt['notify_method_use_default'], '</label>
859
						<input id="notify_', $type, '_default" name="', $mention_methods['default_input_name'], '" class="toggle_notify" type="checkbox" value="', $mention_methods['value'], '" ', $mention_methods['value'] ? '' : 'checked="checked"', '/>
860
						<select class="select_multiple" multiple="multiple" id="notify_', $type, '" name="', $mention_methods['default_input_name'], '[]">';
861
862
		foreach ($mention_methods['data'] as $key => $method)
863
		{
864
			echo '
865
							<option value="', $key, '"', $method['enabled'] ? ' selected="selected"' : '', '>', $method['text'], '</option>';
866
		}
867
868
		echo '
869
						</select>
870
					</dd>';
871
	}
872
873
	echo '
874
				</dl>
875
			</div>
876
			<h2 class="category_header hdicon i-envelope">
877
				', $txt['notify_topic_board'], '
878
			</h2>
879
			<p class="description">', $txt['notification_info'], '</p>
880
			<div class="content">
881
				<dl>';
882
883
	// Allow notification on announcements to be disabled?
884
	if (!empty($modSettings['allow_disableAnnounce']))
885
	{
886
		echo '
887
					<dt>
888
						<label for="notify_announcements">', $txt['notify_important_email'], '</label>
889
					</dt>
890
					<dd>
891
						<input type="hidden" name="notify_announcements" value="0" />
892
						<input type="checkbox" id="notify_announcements" name="notify_announcements"', empty($context['member']['notify_announcements']) ? '' : ' checked="checked"', ' />
893
					</dd>';
894
	}
895
896
	// Auto notification when you reply / start a topic?
897
	echo '
898
					<dt>
899
						<label for="auto_notify">', $txt['auto_notify'], '</label>
900
					</dt>
901
					<dd>
902
						<input type="hidden" name="default_options[auto_notify]" value="0" />
903
						<input type="checkbox" id="auto_notify" name="default_options[auto_notify]" value="1"', empty($context['member']['options']['auto_notify']) ? '' : ' checked="checked"', ' />
904
						', (empty($modSettings['maillist_enabled']) ? '' : $txt['auto_notify_pbe_post']), '
905
					</dd>';
906
907
	// Can the body of the post be sent, PBE will ensure it can
908
	if (empty($modSettings['disallow_sendBody']))
909
	{
910
		echo '
911
					<dt>
912
						<label for="notify_send_body">', $txt['notify_send_body'], '</label>
913
					</dt>
914
					<dd>
915
						<input type="hidden" name="notify_send_body" value="0" />
916
						<input type="checkbox" id="notify_send_body" name="notify_send_body"', empty($context['member']['notify_send_body']) ? '' : ' checked="checked"', ' />
917
						', $txt['notify_send_body_pbe_post'], '
918
					</dd>';
919
	}
920
921
	// How often do you want to hear from us, instant, daily, weekly?
922
	echo '
923
					<dt>
924
						<label for="notify_regularity">', $txt['notify_regularity'], '</label>
925
					</dt>
926
					<dd>
927
						<select name="notify_regularity" id="notify_regularity">
928
							<option value="99"', $context['member']['notify_regularity'] == 99 ? ' selected="selected"' : '', '>', $txt['notify_regularity_none'], '</option>
929
							<option value="4"', $context['member']['notify_regularity'] == 4 ? ' selected="selected"' : '', '>', $txt['notify_regularity_onsite'], '</option>
930
							<option value="0"', $context['member']['notify_regularity'] == 0 ? ' selected="selected"' : '', '>', $txt['notify_regularity_instant'], '</option>
931
							<option value="1"', $context['member']['notify_regularity'] == 1 ? ' selected="selected"' : '', '>', $txt['notify_regularity_first_only'], '</option>
932
							<option value="2"', $context['member']['notify_regularity'] == 2 ? ' selected="selected"' : '', '>', $txt['notify_regularity_daily'], '</option>
933
							<option value="3"', $context['member']['notify_regularity'] == 3 ? ' selected="selected"' : '', '>', $txt['notify_regularity_weekly'], '</option>
934
						</select>
935
					</dd>
936
					<dt>
937
						<label for="notify_types">', $txt['notify_send_types'], '</label>
938
					</dt>
939
					<dd>
940
						<select name="notify_types" id="notify_types">';
941
942
	// Using the maillist functions, then limit the options, so they make sense
943
	if (empty($modSettings['maillist_enabled']) || (empty($modSettings['pbe_no_mod_notices'])))
944
	{
945
		echo '
946
							<option value="1"', $context['member']['notify_types'] == 1 ? ' selected="selected"' : '', '>', $txt['notify_send_type_everything'], '</option>
947
							<option value="2"', $context['member']['notify_types'] == 2 ? ' selected="selected"' : '', '>', $txt['notify_send_type_everything_own'], '</option>';
948
	}
949
950
	echo '
951
							<option value="3"', $context['member']['notify_types'] == 3 ? ' selected="selected"' : '', '>', $txt['notify_send_type_only_replies' . (empty($modSettings['maillist_enabled']) ? '' : '_pbe')], '</option>
952
							<option value="4"', $context['member']['notify_types'] == 4 ? ' selected="selected"' : '', '>', $txt['notify_send_type_nothing'], '</option>
953
						</select>
954
					</dd>
955
				</dl>
956
				
957
				<div class="submitbutton">
958
					<input id="notify_submit" name="notify_submit" type="submit" value="', $txt['notify_save'], '" />
959
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />', empty($context['token_check']) ? '' : '
960
					<input type="hidden" name="' . $context[$context['token_check'] . '_token_var'] . '" value="' . $context[$context['token_check'] . '_token'] . '" />', '
961
					<input type="hidden" name="u" value="', $context['id_member'], '" />
962
					<input type="hidden" name="sa" value="', $context['menu_item_selected'], '" />
963
					<input type="hidden" name="save" value="save" />
964
				</div>
965
			</div>
966
		</form>';
967
}
968
969
/**
970
 * Template for showing which boards you have subscribed to
971
 * and allowing for modification.
972
 */
973
function template_board_notification_list()
974
{
975
	template_show_list('board_notification_list');
976
}
977
978
/**
979
 * Template for showing which topics you have subscribed to
980
 * and allowing for modification.
981
 */
982
function template_topic_notification_list()
983
{
984
	template_show_list('topic_notification_list');
985
}
986
987
/**
988
 * Template for choosing group membership.
989
 */
990
function template_groupMembership()
991
{
992
	global $context, $txt;
993
994
	// The main containing header.
995
	echo '
996
		<form action="', getUrl('action', ['action' => 'profile', 'area' => 'groupmembership']), '" method="post" accept-charset="UTF-8" name="creator" id="creator">
997
			<h2 class="category_header hdicon i-user">
998
				', $txt['profile'], '
999
			</h2>
1000
			<p class="description">', $txt['groupMembership_info'], '</p>';
1001
1002
	// Do we have an update message?
1003
	if (!empty($context['update_message']))
1004
	{
1005
		echo '
1006
			<div class="successbox">
1007
				', $context['update_message'], '
1008
			</div>';
1009
	}
1010
1011
	// Requesting membership to a group?
1012
	if (!empty($context['group_request']))
1013
	{
1014
		echo '
1015
			<div class="groupmembership">
1016
				<h2 class="category_header">', $txt['request_group_membership'], '</h2>
1017
				<div class="well">
1018
					', $txt['request_group_membership_desc'], ':
1019
					<textarea name="reason" rows="4" style="width: 99%;"></textarea>
1020
					<div class="submitbutton">
1021
						<input type="hidden" name="gid" value="', $context['group_request']['id'], '" />
1022
						<input type="submit" name="req" value="', $txt['submit_request'], '" />
1023
					</div>
1024
				</div>
1025
			</div>';
1026
	}
1027
	else
1028
	{
1029
		echo '
1030
			<table class="table_grid">
1031
				<thead>
1032
					<tr class="table_head">
1033
						<th scope="col" ', $context['can_edit_primary'] ? ' colspan="2"' : '', '>', $txt['current_membergroups'], '</th>
1034
						<th scope="col"></th>
1035
					</tr>
1036
				</thead>
1037
				<tbody>';
1038
1039
		foreach ($context['groups']['member'] as $group)
1040
		{
1041
			echo '
1042
					<tr  id="primdiv_', $group['id'], '">';
1043
1044
			if ($context['can_edit_primary'])
1045
			{
1046
				echo '
1047
						<td>
1048
							<input type="radio" name="primary" id="primary_', $group['id'], '" value="', $group['id'], '" ', $group['is_primary'] ? 'checked="checked" ' : '', $group['can_be_primary'] ? '' : 'disabled="disabled" ', ' />
1049
						</td>';
1050
			}
1051
1052
			echo '
1053
						<td>
1054
							<label for="primary_', $group['id'], '">
1055
								<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>'), '
1056
							</label>
1057
						</td>
1058
						<td class="grid17 righttext">';
1059
1060
			// Can they leave their group?
1061
			if ($group['can_leave'])
1062
			{
1063
				echo '
1064
							<a class="linkbutton" href="' . getUrl('action', ['action' => 'profile', 'save', 'u' => $context['id_member'], 'area' => 'groupmembership', '{session_data}', 'gid' => $group['id'], $context[$context['token_check'] . '_token_var'] => $context[$context['token_check'] . '_token']]), '">' . $txt['leave_group'] . '</a>';
1065
			}
1066
1067
			echo '
1068
						</td>
1069
					</tr>';
1070
		}
1071
1072
		echo '
1073
				</tbody>
1074
			</table>';
1075
1076
		if ($context['can_edit_primary'])
1077
		{
1078
			echo '
1079
			<div class="submitbutton">
1080
				<input type="submit" value="', $txt['make_primary'], '" />
1081
			</div>';
1082
		}
1083
1084
		// Any groups they can join?
1085
		if (!empty($context['groups']['available']))
1086
		{
1087
			echo '
1088
			<br />
1089
			<table class="table_grid">
1090
				<thead>
1091
					<tr class="table_head">
1092
						<th scope="col">
1093
							', $txt['available_groups'], '
1094
						</th>
1095
						<th scope="col"></th>
1096
					</tr>
1097
				</thead>
1098
				<tbody>';
1099
1100
			foreach ($context['groups']['available'] as $group)
1101
			{
1102
				echo '
1103
					<tr>
1104
						<td>
1105
							<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>'), '
1106
						</td>
1107
						<td class="lefttext">';
1108
1109
				if ($group['type'] == 3)
1110
				{
1111
					echo '
1112
							<a class="linkbutton floatright" href="', getUrl('action', ['action' => 'profile', 'save', 'u' => $context['id_member'], 'area' => 'groupmembership', '{session_data}', 'gid' => $group['id'], $context[$context['token_check'] . '_token_var'] => $context[$context['token_check'] . '_token']]), '">', $txt['join_group'], '</a>';
1113
				}
1114
				elseif ($group['type'] == 2 && $group['pending'])
1115
				{
1116
					echo '
1117
							', $txt['approval_pending'];
1118
				}
1119
				elseif ($group['type'] == 2)
1120
				{
1121
					echo '
1122
							<a class="linkbutton floatright" href="', getUrl('action', ['action' => 'profile', 'u' => $context['id_member'], 'area' => 'groupmembership', 'request' => $group['id'], '{session_data}']), '">', $txt['request_group'], '</a>';
1123
				}
1124
1125
// @todo
1126
//				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '" />';
1127
1128
				echo '
1129
						</td>
1130
					</tr>';
1131
			}
1132
1133
			echo '
1134
				</tbody>
1135
			</table>';
1136
		}
1137
1138
		// Javascript for the selector stuff.
1139
		echo '
1140
		<script>
1141
		console.log("bas");
1142
			var prevClass = "",
1143
				prevDiv = "";';
1144
1145
		echo '
1146
		</script>';
1147
	}
1148
1149
	if (!empty($context['token_check']))
1150
	{
1151
		echo '
1152
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '" />';
1153
	}
1154
1155
	echo '
1156
				<input type="hidden" name="save" value="save" />
1157
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
1158
				<input type="hidden" name="u" value="', $context['id_member'], '" />
1159
			</form>';
1160
}
1161
1162
/**
1163
 * Display a list of boards so a user can choose to ignore some
1164
 */
1165
function template_ignoreboards()
1166
{
1167
	global $txt;
1168
1169
	// The main containing header.
1170
	echo '
1171
	<form id="creator" action="', getUrl('action', ['action' => 'profile', 'area' => 'ignoreboards']), '" method="post" accept-charset="UTF-8" name="creator">
1172
		<h2 class="category_header hdicon i-user">
1173
			', $txt['profile'], '
1174
		</h2>
1175
		<p class="description">', $txt['ignoreboards_info'], '</p>
1176
		<div class="content flow_hidden">';
1177
1178
	template_pick_boards('creator', 'ignore_brd', false);
1179
1180
	// Show the standard "Save Settings" profile button.
1181
	template_profile_save();
1182
1183
	echo '
1184
			<input type="hidden" name="save" value="save" />
1185
		</div>
1186
	</form>
1187
	<br />';
1188
}
1189
1190
/**
1191
 * Display a load of drop down selectors for allowing the user to change group.
1192
 */
1193
function template_profile_group_manage()
1194
{
1195
	global $context, $txt;
1196
1197
	echo '
1198
							<dt>
1199
								<label>', $txt['primary_membergroup'], '</label>
1200
								<p class="smalltext">[<a href="', getUrl('action', ['action' => 'quickhelp', 'help' => 'moderator_why_missing']), '" onclick="return reqOverlayDiv(this.href);">', $txt['moderator_why_missing'], '</a>]</p>
1201
							</dt>
1202
							<dd>
1203
								<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;"' : ''), '>';
1204
1205
	// Fill the select box with all primary membergroups that can be assigned to a member.
1206
	foreach ($context['member_groups'] as $member_group)
1207
	{
1208
		if (!empty($member_group['can_be_primary']))
1209
		{
1210
			echo '
1211
									<option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected="selected"' : '', '>
1212
										', $member_group['name'], '
1213
									</option>';
1214
		}
1215
	}
1216
1217
	echo '
1218
								</select>
1219
							</dd>
1220
							<dt>
1221
								<label>', $txt['additional_membergroups'], '</label>
1222
							</dt>
1223
							<dd>
1224
								<input type="hidden" name="additional_groups[]" value="0" />
1225
								<fieldset id="additional_groupsList">
1226
									<legend data-collapsed="', count($context['member_groups']) === 0 ? 'true' : 'false', '">', $txt['additional_membergroups_show'], '</legend>
1227
									<ul>';
1228
1229
	// For each membergroup show a checkbox so members can be assigned to more than one group.
1230
	foreach ($context['member_groups'] as $member_group)
1231
	{
1232
		if ($member_group['can_be_additional'])
1233
		{
1234
			echo '
1235
										<li>
1236
											<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="checked"' : '', ' /> ', $member_group['name'], '</label>
1237
										</li>';
1238
		}
1239
	}
1240
1241
	echo '
1242
									</ul>
1243
								</fieldset>
1244
							</dd>';
1245
}
1246
1247
/**
1248
 * Callback function for entering a birth date!
1249
 */
1250
function template_profile_birthdate()
1251
{
1252
	global $txt, $context;
1253
1254
	// Just show the pretty box!
1255
	echo '
1256
							<dt>
1257
								<label>', $txt['dob'], '</label>
1258
								<p class="smalltext">', $txt['dob_month'], ' - ', $txt['dob_day'], ' - ', $txt['dob_year'], '</p>
1259
							</dt>
1260
							<dd>
1261
								<input type="date" name="bday1" value="', sprintf('%04d-%02d-%02d', $context['member']['birth_date']['year'], $context['member']['birth_date']['month'], $context['member']['birth_date']['day']), '" />
1262
							</dd>';
1263
}
1264
1265
/**
1266
 * Show the signature editing box.
1267
 */
1268
function template_profile_signature_modify()
1269
{
1270
	global $txt, $context;
1271
1272
	echo '
1273
							<dt id="current_signature"', isset($context['member']['current_signature']) ? '' : ' class="hide"', '>
1274
								<label>', $txt['current_signature'], ':</label>
1275
							</dt>
1276
							<dd id="current_signature_display"', isset($context['member']['current_signature']) ? '' : ' class="hide"', '>
1277
								', $context['member']['current_signature'] ?? '', '<hr />
1278
							</dd>
1279
1280
							<dt id="preview_signature"', isset($context['member']['signature_preview']) ? '' : ' class="hide"', '>
1281
								<label>', $txt['signature_preview'], ':</label>
1282
							</dt>
1283
							<dd id="preview_signature_display"', isset($context['member']['signature_preview']) ? '' : ' class="hide"', '>
1284
								', $context['member']['signature_preview'] ?? '', '<hr />
1285
							</dd>
1286
							<dt>
1287
								<label>', $txt['signature'], '</label>
1288
								<p class="smalltext">', $txt['sig_info'], '</p>
1289
							</dt>
1290
							<dd>
1291
								<textarea class="editor" id="signature" name="signature" rows="5" cols="50" style="min-width: 50%; width: 99%;">', $context['member']['signature'], '</textarea>';
1292
1293
	// If there is a limit at all!
1294
	if (!empty($context['signature_limits']['max_length']))
1295
	{
1296
		echo '
1297
								<p class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></p>';
1298
	}
1299
1300
	if (!empty($context['show_preview_button']))
1301
	{
1302
		echo '
1303
								<input type="submit" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '"  tabindex="', $context['tabindex']++, '" class="right_submit" />';
1304
	}
1305
1306
	if ($context['signature_warning'])
1307
	{
1308
		echo '
1309
								<span class="smalltext">', $context['signature_warning'], '</span>';
1310
	}
1311
1312
	// Some javascript used to count how many characters have been used so far in the signature.
1313
	echo '
1314
								<script>
1315
									var maxLength = ', $context['signature_limits']['max_length'], ';
1316
1317
									document.getElementById("signature").addEventListener("keyup", function(event) {
1318
									    calcCharLeft(false, event);
1319
									});
1320
1321
									$(function() {
1322
										calcCharLeft(true);
1323
										$("#preview_button").click(function() {
1324
											return ajax_getSignaturePreview(true);
1325
										});
1326
									});
1327
								</script>
1328
							</dd>';
1329
}
1330
1331
/**
1332
 * Interface to select an avatar in profile.
1333
 */
1334
function template_profile_avatar_select()
1335
{
1336
	global $context, $txt, $modSettings;
1337
1338
	// Start with left side menu
1339
	echo '
1340
							<dt>
1341
								<label id="personal_picture">', $txt['personal_picture'], '</label>
1342
								<ul id="avatar_choices">
1343
									<li>
1344
										<input type="radio" onclick="swap_avatar();" name="avatar_choice" id="avatar_choice_none" value="none"' . ($context['member']['avatar']['choice'] == 'none' ? ' checked="checked"' : '') . ' />
1345
										<label for="avatar_choice_none"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>
1346
											' . $txt['no_avatar'] . '
1347
										</label>
1348
									</li>', empty($context['member']['avatar']['allow_server_stored']) ? '' : '
1349
									<li>
1350
										<input type="radio" onclick="swap_avatar();" name="avatar_choice" id="avatar_choice_server_stored" value="server_stored"' . ($context['member']['avatar']['choice'] === 'server_stored' ? ' checked="checked"' : '') . ' />
1351
										<label for="avatar_choice_server_stored"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>
1352
											' . $txt['choose_avatar_gallery'] . '
1353
										</label>
1354
									</li>', empty($context['member']['avatar']['allow_external']) ? '' : '
1355
									<li>
1356
										<input type="radio" onclick="swap_avatar();" name="avatar_choice" id="avatar_choice_external" value="external"' . ($context['member']['avatar']['choice'] === 'external' ? ' checked="checked"' : '') . ' />
1357
										<label for="avatar_choice_external"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>
1358
											' . $txt['my_own_pic'] . '
1359
										</label>
1360
									</li>', empty($context['member']['avatar']['allow_gravatar']) ? '' : '
1361
									<li>
1362
										<input type="radio" onclick="swap_avatar();" name="avatar_choice" id="avatar_choice_gravatar" value="gravatar"' . ($context['member']['avatar']['choice'] === 'gravatar' ? ' checked="checked"' : '') . ' />
1363
										<label for="avatar_choice_gravatar"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>
1364
											' . $txt['gravatar'] . '
1365
										</label>
1366
									</li>', empty($context['member']['avatar']['allow_upload']) ? '' : '
1367
									<li>
1368
										<input type="radio" onclick="swap_avatar();" name="avatar_choice" id="avatar_choice_upload" value="upload"' . ($context['member']['avatar']['choice'] === 'upload' ? ' checked="checked"' : '') . ' />
1369
										<label for="avatar_choice_upload"' . (isset($context['modify_error']['bad_avatar']) ? ' class="error"' : '') . '>
1370
											' . $txt['avatar_will_upload'] . '
1371
										</label>
1372
									</li>', '
1373
								</ul>
1374
							</dt>
1375
							<dd>';
1376
1377
	// If users are allowed to choose avatars stored on the server show the selection boxes to choose them.
1378
	if (!empty($context['member']['avatar']['allow_server_stored']))
1379
	{
1380
		echo '
1381
								<div id="avatar_server_stored">
1382
									<div>
1383
										<select name="cat" id="cat" size="10" onchange="changeSel(\'\');">';
1384
1385
		// This lists all the file categories.
1386
		foreach ($context['avatars'] as $avatar)
1387
		{
1388
			echo '
1389
											<option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected="selected"' : ''), '>', $avatar['name'], '</option>';
1390
		}
1391
1392
		echo '
1393
										</select>
1394
									</div>
1395
									<div>
1396
										<select id="file" name="file" size="10" class="hide" onchange="showAvatar()" disabled="disabled">
1397
											<option> </option>
1398
										</select>
1399
									</div>
1400
									<div>
1401
										<img id="avatar" class="avatar avatarresize" src="', $modSettings['avatar_url'] . '/blank.png', '" alt="" />
1402
									</div>
1403
								</div>';
1404
	}
1405
1406
	// If the user can link to an off server avatar, show them a box to input the address.
1407
	if (!empty($context['member']['avatar']['allow_external']))
1408
	{
1409
		echo '
1410
								<div id="avatar_external">
1411
									<div class="smalltext">
1412
										<label for="userpicpersonal">', $txt['avatar_by_url'], '</label>
1413
									</div>
1414
									<input type="url" id="userpicpersonal" name="userpicpersonal" value="', $context['member']['avatar']['external'], '" onchange="previewExternalAvatar(this.value);" class="input_text" placeholder="', $context['member']['avatar']['placeholder'] ?? '', '"/>
1415
									<br /><br />
1416
									<img id="external" src="', $context['member']['avatar']['choice'] === 'external' ? $context['member']['avatar']['external'] : $modSettings['avatar_url'] . '/blank.png', '" alt="" class="avatar avatarresize" />
1417
								</div>';
1418
	}
1419
1420
	// If the user is allowed to use a Gravatar.
1421
	if (!empty($context['member']['avatar']['allow_gravatar']))
1422
	{
1423
		echo '
1424
								<div id="avatar_gravatar">
1425
									<img src="' . $context['member']['avatar']['gravatar_preview'] . '" alt="" />
1426
								</div>';
1427
	}
1428
1429
	// If the user is able to upload avatars to the server show them an upload box.
1430
	if (!empty($context['member']['avatar']['allow_upload']))
1431
	{
1432
		echo '
1433
								<div id="avatar_upload">
1434
									<input type="file" name="attachment" id="avatar_upload_box" class="input_file" accept="image/*" onchange="previewUploadedAvatar(this)"/>
1435
									', ($context['member']['avatar']['id_attach'] > 0 ? '
1436
									<br /><br />
1437
									<img id="current_avatar" class="avatar avatarresize" src="' . $context['member']['avatar']['href'] . (strpos($context['member']['avatar']['href'], '?') === false ? '?' : '&') . 'time=' . time() . '" alt="" />
1438
									<div id="current_avatar_new" class="hide">
1439
										<img id="current_avatar_new_preview" class="avatar avatarresize border_error" style="vertical-align: middle" alt="" src="" />
1440
										<span>' . $txt['preview'] . '</span>
1441
									</div>
1442
									<input type="hidden" name="id_attach" value="' . $context['member']['avatar']['id_attach'] . '" />' : ''), '
1443
								</div>';
1444
	}
1445
1446
	echo '
1447
								<script>
1448
									var files = ["' . implode('", "', $context['avatar_list']) . '"],
1449
										cat = document.getElementById("cat"),
1450
										file = document.getElementById("file"),
1451
										selavatar = "' . $context['avatar_selected'] . '",
1452
										avatardir = "' . $modSettings['avatar_url'] . '/",
1453
										refuse_too_large = ', !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_refuse' ? 'true' : 'false', ',
1454
										maxHeight = ', empty($modSettings['avatar_max_height']) ? 0 : $modSettings['avatar_max_height'], ',
1455
										maxWidth = ', empty($modSettings['avatar_max_width']) ? 0 : $modSettings['avatar_max_width'], ';
1456
1457
									// Display the right avatar box based on what they are using
1458
									init_avatars();
1459
								</script>
1460
							</dd>';
1461
}
1462
1463
/**
1464
 * Callback for modifying karma.
1465
 */
1466
function template_profile_karma_modify()
1467
{
1468
	global $context, $modSettings, $txt;
1469
1470
	echo '
1471
							<dt>
1472
								<label>', $modSettings['karmaLabel'], '</label>
1473
							</dt>
1474
							<dd>
1475
								<label for="karma_good">', $modSettings['karmaApplaudLabel'], '</label> <input type="text" id="karma_good" name="karma_good" size="4" value="', $context['member']['karma']['good'], '" style="margin-right: 2ex;" class="input_text" />
1476
								<label for="karma_bad">', $modSettings['karmaSmiteLabel'], '</label> <input type="text" id="karma_bad" name="karma_bad" size="4" value="', $context['member']['karma']['bad'], '" class="input_text" /><br />
1477
								(', $txt['total'], ': <span id="karmaTotal">', ($context['member']['karma']['good'] - $context['member']['karma']['bad']), '</span>)
1478
							</dd>';
1479
1480
	echo "
1481
							<script>
1482
							document.addEventListener('DOMContentLoaded', function () {
1483
								let karma_good = document.querySelector('#karma_good'),
1484
									karma_bad = document.querySelector('#karma_bad'),
1485
									karmaTotal = document.querySelector('#karmaTotal');
1486
						
1487
								// Profile options changing karma
1488
								[karma_good, karma_bad].forEach(function (input) {
1489
									input.addEventListener('keyup', function () {
1490
										let good = parseInt(karma_good.value, 10),
1491
											bad = parseInt(karma_bad.value, 10);
1492
										karmaTotal.innerText = (isNaN(good) ? 0 : good) - (isNaN(bad) ? 0 : bad);
1493
									});
1494
								});
1495
							});
1496
							</script>";
1497
}
1498
1499
/**
1500
 * Select the time format!.
1501
 */
1502
function template_profile_timeformat_modify()
1503
{
1504
	global $context, $txt;
1505
1506
	echo '
1507
							<dt>
1508
								<label for="easyformat">', $txt['time_format'], '</label>
1509
								<p>
1510
									<a href="', getUrl('action', ['action' => 'quickhelp', 'help' => 'time_format']), '" onclick="return reqOverlayDiv(this.href);" class="helpicon i-help"><s>', $txt['help'], '</s></a>
1511
									&nbsp;', $txt['date_format'], '
1512
								</p>
1513
							</dt>
1514
							<dd>
1515
								<select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;" style="margin-bottom: 4px;">';
1516
1517
	// Help the user by showing a list of common time formats.
1518
	foreach ($context['easy_timeformats'] as $time_format)
1519
	{
1520
		echo '
1521
									<option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected="selected"' : '', '>', $time_format['title'], '</option>';
1522
	}
1523
1524
	echo '
1525
								</select>
1526
								<br />
1527
								<input type="text" name="time_format" id="time_format" value="', $context['member']['time_format'], '" size="30" class="input_text" />
1528
							</dd>';
1529
}
1530
1531
/**
1532
 * Time offset.
1533
 */
1534
function template_profile_timeoffset_modify()
1535
{
1536
	global $txt, $context;
1537
1538
	echo '
1539
							<dt>
1540
								<label', (isset($context['modify_error']['bad_offset']) ? ' class="error"' : ''), ' for="time_offset">', $txt['time_offset'], '</label>
1541
								<p>', $txt['personal_time_offset'], '</p>
1542
							</dt>
1543
							<dd>
1544
								<input type="text" name="time_offset" id="time_offset" size="5" maxlength="5" value="', $context['member']['time_offset'], '" class="input_text" /> ', $txt['hours'], ' <a class="linkbutton" href="javascript:void(0);" onclick="currentDate = new Date(', $context['current_forum_time_js'], '); document.getElementById(\'time_offset\').value = autoDetectTimeOffset(currentDate); return false;">', $txt['timeoffset_autodetect'], '</a><br />', $txt['current_time'], ': <em>', $context['current_forum_time'], '</em>
1545
							</dd>';
1546
}
1547
1548
/**
1549
 * Button to allow the member to pick a theme.
1550
 */
1551
function template_profile_theme_pick()
1552
{
1553
	global $txt, $context;
1554
1555
	echo '
1556
							<dt>
1557
								<label>', $txt['current_theme'], '</label>
1558
							</dt>
1559
							<dd>
1560
								', $context['member']['theme']['name'], ' <a class="linkbutton" href="', getUrl('action', ['action' => 'profile', 'area' => 'pick', 'u' => $context['id_member'], '{session_data}']), '">', $txt['change'], '</a>
1561
							</dd>';
1562
}
1563
1564
/**
1565
 * Interface to allow the member to change the way they login to the forum.
1566
 */
1567
function template_authentication_method()
1568
{
1569
	global $context, $modSettings, $txt;
1570
1571
	// The main header!
1572
	echo '
1573
		<form action="', getUrl('action', ['action' => 'profile', 'area' => 'authentication']), '" method="post" accept-charset="UTF-8" name="creator" id="creator" enctype="multipart/form-data">
1574
			<h2 class="category_header hdicon i-user">
1575
				', $txt['authentication'], '
1576
			</h2>
1577
			<p class="description">', $txt['change_authentication'], '</p>
1578
			<div class="content">
1579
				<dl>
1580
					<dt>
1581
						<input type="radio" name="authenticate" value="passwd" id="auth_pass"', $context['auth_method'] == 'password' ? ' checked="checked"' : '', ' />
1582
						<label for="auth_pass">', $txt['authenticate_password'], '</label>
1583
					</dt>
1584
					<dd>
1585
						<dl id="password1_group">
1586
							<dt>
1587
								<em>', $txt['choose_pass'], ':</em>
1588
							</dt>
1589
							<dd>
1590
								<input type="password" name="passwrd1" id="elk_autov_pwmain" size="30" autocomplete="new-password" tabindex="', $context['tabindex']++, '" class="input_password" placeholder="', $txt['choose_pass'], '" />
1591
								<span id="elk_autov_pwmain_div" class="hide">
1592
									<i id="elk_autov_pwmain_img" class="icon i-warn" alt="*"></i>
1593
								</span>
1594
							</dd>
1595
						</dl>
1596
						<dl id="password2_group">
1597
							<dt>
1598
								<em for="elk_autov_pwverify">', $txt['verify_pass'], ':</em>
1599
							</dt>
1600
							<dd>
1601
								<input type="password" name="passwrd2" id="elk_autov_pwverify" size="30" autocomplete="new-password" tabindex="', $context['tabindex']++, '" class="input_password" placeholder="', $txt['verify_pass'], '" />
1602
								<span id="elk_autov_pwverify_div" class="hide">
1603
									<i id="elk_autov_pwverify_img" class="icon i-warn" alt="*"></i>
1604
								</span>
1605
							</dd>
1606
						</dl>
1607
					</dd>
1608
				</dl>';
1609
1610
	template_profile_save();
1611
1612
	echo '
1613
				<input type="hidden" name="save" value="save" />
1614
			</div>
1615
		</form>';
1616
1617
	// The password stuff.
1618
	echo '
1619
	<script>
1620
		var regTextStrings = {
1621
			"password_short": "', $txt['registration_password_short'], '",
1622
			"password_reserved": "', $txt['registration_password_reserved'], '",
1623
			"password_numbercase": "', $txt['registration_password_numbercase'], '",
1624
			"password_no_match": "', $txt['registration_password_no_match'], '",
1625
			"password_valid": "', $txt['registration_password_valid'], '"
1626
		};
1627
		var verificationHandle = new elkRegister("creator", ', empty($modSettings['password_strength']) ? 0 : $modSettings['password_strength'], ', regTextStrings);
1628
1629
	</script>';
1630
}
1631
1632
/**
1633
 * This template allows for the selection of different themes.
1634
 */
1635
function template_pick()
1636
{
1637
	global $context, $scripturl, $txt;
1638
1639
	echo '
1640
	<div id="pick_theme">
1641
		<form action="', $scripturl, '?action=profile;area=pick;u=', $context['current_member'], ';', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="UTF-8">';
1642
1643
	// Just go through each theme and show its information - thumbnail, etc.
1644
	foreach ($context['available_themes'] as $theme)
1645
	{
1646
		echo '
1647
			<h2 class="category_header">
1648
				', $theme['name'], '
1649
			</h2>
1650
			<div class="flow_hidden content">
1651
				<div class="floatright">
1652
					<a href="', $scripturl, '?action=profile;area=pick;u=', $context['current_member'], ';theme=', $theme['id'], ';variant=', $theme['selected_variant'], ';', $context['session_var'], '=', $context['session_id'], '" id="theme_thumb_preview_', $theme['id'], '" title="', $txt['theme_preview'], '">
1653
						<img class="avatar" src="', $theme['thumbnail_href'], '" id="theme_thumb_', $theme['id'], '" alt="" />
1654
					</a>
1655
				</div>
1656
				<p>', $theme['description'], '</p>';
1657
1658
		if (!empty($theme['variants']))
1659
		{
1660
			echo '
1661
				<label for="variant', $theme['id'], '">
1662
					<strong>', $theme['pick_label'], '</strong>
1663
				</label>
1664
				<select id="variant', $theme['id'], '" name="vrt[', $theme['id'], ']" onchange="changeVariant', $theme['id'], '(this.value);">';
1665
1666
			foreach ($theme['variants'] as $key => $variant)
1667
			{
1668
				echo '
1669
					<option value="', $key, '" ', $theme['selected_variant'] == $key ? 'selected="selected"' : '', '>', $variant['label'], '</option>';
1670
			}
1671
1672
			echo '
1673
				</select>
1674
				<noscript>
1675
					<input type="submit" name="save[', $theme['id'], ']" value="', $txt['save'], '" />
1676
				</noscript>';
1677
		}
1678
1679
		echo '
1680
				<br />
1681
				<div class="separator"></div>
1682
				<a class="linkbutton" href="', $scripturl, '?action=profile;area=pick;u=', $context['current_member'], ';th=', $theme['id'], ';', $context['session_var'], '=', $context['session_id'], empty($theme['variants']) ? '' : ';vrt=' . $theme['selected_variant'], '" id="theme_use_', $theme['id'], '">', $txt['theme_set'], '</a>
1683
				<a class="linkbutton" href="', $scripturl, '?action=profile;area=pick;u=', $context['current_member'], ';theme=', $theme['id'], ';', $context['session_var'], '=', $context['session_id'], ';variant=', $theme['selected_variant'], '" id="theme_preview_', $theme['id'], '">', $txt['theme_preview'], '</a>
1684
			</div>';
1685
1686
		if (!empty($theme['variants']))
1687
		{
1688
			echo '
1689
			<script>
1690
				let sBaseUseUrl', $theme['id'], " = elk_prepareScriptUrl(elk_scripturl) + 'action=profile;area=pick;u=", $context['current_member'], ';th=', $theme['id'], ';', $context['session_var'], '=', $context['session_id'], '\',
1691
					sBasePreviewUrl', $theme['id'], " = elk_prepareScriptUrl(elk_scripturl) + 'action=profile;area=pick;u=", $context['current_member'], ';theme=', $theme['id'], ';', $context['session_var'], '=', $context['session_id'], '\',
1692
					oThumbnails', $theme['id'], ' = {';
1693
1694
			// All the variant thumbnails.
1695
			$count = 1;
1696
			foreach ($theme['variants'] as $key => $variant)
1697
			{
1698
				echo '
1699
					\'', $key, "': '", $variant['thumbnail'], "'", (count($theme['variants']) === $count ? '' : ',');
1700
1701
				$count++;
1702
			}
1703
1704
			echo '
1705
				};
1706
1707
				function changeVariant', $theme['id'], '(sVariant)
1708
				{
1709
					document.getElementById(\'theme_thumb_', $theme['id'], "').src = oThumbnails", $theme['id'], '[sVariant];
1710
					document.getElementById(\'theme_use_', $theme['id'], "').href = sBaseUseUrl", $theme['id'] == 0 ? $context['default_theme_id'] : $theme['id'], ' + \';vrt=\' + sVariant;
1711
					document.getElementById(\'theme_thumb_preview_', $theme['id'], "').href = sBasePreviewUrl", $theme['id'], ' + \';variant=\' + sVariant;
1712
					document.getElementById(\'theme_preview_', $theme['id'], "').href = sBasePreviewUrl", $theme['id'], ' + \';variant=\' + sVariant;
1713
				}
1714
			</script>';
1715
		}
1716
	}
1717
1718
	echo '
1719
		</form>
1720
	</div>';
1721
}
1722