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

Register.template.php ➔ template_registration_form()   F

Complexity

Conditions 46
Paths 256

Size

Total Lines 273

Duplication

Lines 59
Ratio 21.61 %

Importance

Changes 0
Metric Value
cc 46
nc 256
nop 0
dl 59
loc 273
rs 2.1065
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 2018 Simple Machines and individual contributors
8
 * @license http://www.simplemachines.org/about/smf/license.php BSD
9
 *
10
 * @version 2.1 Beta 4
11
 */
12
13
/**
14
 * Before showing users a registration form, show them the registration agreement.
15
 */
16
function template_registration_agreement()
17
{
18
	global $context, $scripturl, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

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

1. Pass all data via parameters

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

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

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

    public function myFunction() {
        // Do something
    }
}
Loading history...
19
20
	echo '
21
		<form action="', $scripturl, '?action=signup" method="post" accept-charset="', $context['character_set'], '" id="registration">
22
			<div class="cat_bar">
23
				<h3 class="catbg">', $txt['registration_agreement'], '</h3>
24
			</div>
25
			<div class="roundframe">
26
				<p>', $context['agreement'], '</p>
27
			</div>
28
			<div id="confirm_buttons">';
29
30
	// Age restriction in effect?
31
	if ($context['show_coppa'])
32
		echo '
33
				<input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br>
34
				<br>
35
				<input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">';
36
	else
37
		echo '
38
				<input type="submit" name="accept_agreement" value="', $txt['policy_agree'], '" class="button">';
39
40
	echo '
41
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
42
				<input type="hidden" name="', $context['register_token_var'], '" value="', $context['register_token'], '">
43
			</div><!-- .confirm_buttons -->
44
			<input type="hidden" name="step" value="1">
45
		</form>';
46
47
}
48
49
/**
50
 * Before showing users a registration form, show them the registration policy.
51
 */
52
function template_registration_policy()
53
{
54
	global $context, $scripturl, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

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

1. Pass all data via parameters

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

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

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

    public function myFunction() {
        // Do something
    }
}
Loading history...
55
56
	echo '
57
		<form action="', $scripturl, '?action=signup" method="post" accept-charset="', $context['character_set'], '" id="registration">
58
			<div class="cat_bar">
59
				<h3 class="catbg">', $txt['registration_policy'], '</h3>
60
			</div>
61
			<div class="roundframe">
62
				<p>', $context['policy'], '</p>
63
			</div>
64
			<div id="confirm_buttons">';
65
66
67
	echo '
68
				<input type="submit" name="accept_policy" value="', $txt['policy_agree'], '" class="button">';
69
70
	echo '
71
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
72
				<input type="hidden" name="', $context['register_token_var'], '" value="', $context['register_token'], '">
73
			</div><!-- .confirm_buttons -->
74
			<input type="hidden" name="step" value="2">
75
		</form>';
76
77
}
78
79
/**
80
 * Before registering - get their information.
81
 */
82
function template_registration_form()
83
{
84
	global $context, $scripturl, $txt, $modSettings;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

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

1. Pass all data via parameters

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

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

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

    public function myFunction() {
        // Do something
    }
}
Loading history...
85
86
	echo '
87
		<script>
88
			function verifyAgree()
89
			{
90
				if (currentAuthMethod == \'passwd\' && document.forms.registration.smf_autov_pwmain.value != document.forms.registration.smf_autov_pwverify.value)
91
				{
92
					alert("', $txt['register_passwords_differ_js'], '");
93
					return false;
94
				}
95
96
				return true;
97
			}
98
99
			var currentAuthMethod = \'passwd\';
100
		</script>';
101
102
	// Any errors?
103
	if (!empty($context['registration_errors']))
104
	{
105
		echo '
106
		<div class="errorbox">
107
			<span>', $txt['registration_errors_occurred'], '</span>
108
			<ul>';
109
110
		// Cycle through each error and display an error message.
111
		foreach ($context['registration_errors'] as $error)
112
			echo '
113
				<li>', $error, '</li>';
114
115
		echo '
116
			</ul>
117
		</div>';
118
	}
119
120
	echo '
121
		<form action="', !empty($modSettings['force_ssl']) ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=signup2" method="post" accept-charset="', $context['character_set'], '" name="registration" id="registration" onsubmit="return verifyAgree();">
122
			<div class="cat_bar">
123
				<h3 class="catbg">', $txt['registration_form'], '</h3>
124
			</div>
125
			<div class="title_bar">
126
				<h3 class="titlebg">', $txt['required_info'], '</h3>
127
			</div>
128
			<div class="roundframe noup">
129
				<fieldset>
130
					<dl class="register_form">
131
						<dt>
132
							<strong><label for="smf_autov_username">', $txt['username'], ':</label></strong>
133
						</dt>
134
						<dd>
135
							<input type="text" name="user" id="smf_autov_username" size="50" tabindex="', $context['tabindex']++, '" maxlength="25" value="', isset($context['username']) ? $context['username'] : '', '">
136
							<span id="smf_autov_username_div" style="display: none;">
137
								<a id="smf_autov_username_link" href="#">
138
									<span id="smf_autov_username_img" class="generic_icons check"></span>
139
								</a>
140
							</span>
141
						</dd>
142
						<dt><strong><label for="smf_autov_reserve1">', $txt['user_email_address'], ':</label></strong></dt>
143
						<dd>
144
							<input type="text" name="email" id="smf_autov_reserve1" size="50" tabindex="', $context['tabindex']++, '" value="', isset($context['email']) ? $context['email'] : '', '">
145
						</dd>
146
					</dl>
147
					<dl class="register_form" id="password1_group">
148
						<dt><strong><label for="smf_autov_pwmain">', ucwords($txt['choose_pass']), ':</label></strong></dt>
149
						<dd>
150
							<input type="password" name="passwrd1" id="smf_autov_pwmain" size="50" tabindex="', $context['tabindex']++, '">
151
							<span id="smf_autov_pwmain_div" style="display: none;">
152
								<span id="smf_autov_pwmain_img" class="generic_icons invalid"></span>
153
							</span>
154
						</dd>
155
					</dl>
156
					<dl class="register_form" id="password2_group">
157
						<dt>
158
							<strong><label for="smf_autov_pwverify">', ucwords($txt['verify_pass']), ':</label></strong>
159
						</dt>
160
						<dd>
161
							<input type="password" name="passwrd2" id="smf_autov_pwverify" size="50" tabindex="', $context['tabindex']++, '">
162
							<span id="smf_autov_pwverify_div" style="display: none;">
163
								<span id="smf_autov_pwverify_img" class="generic_icons valid"></span>
164
							</span>
165
						</dd>
166
					</dl>
167
					<dl class="register_form" id="notify_announcements">
168
						<dt>
169
							<strong><label for="notify_announcements">', $txt['notify_announcements'], ':</label></strong>
170
						</dt>
171
						<dd>
172
							<input type="checkbox" name="notify_announcements" id="notify_announcements" tabindex="', $context['tabindex']++, '"', $context['notify_announcements'] ? ' checked="checked"' : '', '>
173
						</dd>
174
					</dl>';
175
176
	// If there is any field marked as required, show it here!
177 View Code Duplication
	if (!empty($context['custom_fields_required']) && !empty($context['custom_fields']))
178
	{
179
		echo '
180
					<dl class="register_form">';
181
182
		foreach ($context['custom_fields'] as $field)
183
			if ($field['show_reg'] > 1)
184
				echo '
185
						<dt>
186
							<strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong>
187
							<span class="smalltext">', $field['desc'], '</span>
188
						</dt>
189
						<dd>', str_replace('name="', 'tabindex="' . $context['tabindex']++ . '" name="', $field['input_html']), '</dd>';
0 ignored issues
show
Coding Style introduced by
Increment and decrement operators must be bracketed when used in string concatenation
Loading history...
190
191
		echo '
192
					</dl>';
193
	}
194
195
	echo '
196
				</fieldset>
197
			</div><!-- .roundframe -->';
198
199
	// If we have either of these, show the extra group.
200
	if (!empty($context['profile_fields']) || !empty($context['custom_fields']))
201
		echo '
202
			<div class="title_bar">
203
				<h3 class="titlebg">', $txt['additional_information'], '</h3>
204
			</div>
205
			<div class="roundframe noup">
206
				<fieldset>
207
					<dl class="register_form" id="custom_group">';
208
209
	if (!empty($context['profile_fields']))
210
	{
211
		// Any fields we particularly want?
212
		foreach ($context['profile_fields'] as $key => $field)
213
		{
214
			if ($field['type'] == 'callback')
215
			{
216 View Code Duplication
				if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func']))
217
				{
218
					$callback_func = 'template_profile_' . $field['callback_func'];
219
					$callback_func();
220
				}
221
			}
222
			else
223
			{
224
				echo '
225
						<dt>
226
							<strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['label'], ':</strong>';
227
228
				// Does it have any subtext to show?
229
				if (!empty($field['subtext']))
230
					echo '
231
							<span class="smalltext">', $field['subtext'], '</span>';
232
233
				echo '
234
						</dt>
235
						<dd>';
236
237
				// Want to put something infront of the box?
238
				if (!empty($field['preinput']))
239
					echo '
240
							', $field['preinput'];
241
242
				// What type of data are we showing?
243
				if ($field['type'] == 'label')
244
					echo '
245
							', $field['value'];
246
247
				// Maybe it's a text box - very likely!
248
				elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'url')))
249
					echo '
250
							<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'], '>';
251
252
				// You "checking" me out? ;)
253 View Code Duplication
				elseif ($field['type'] == 'check')
254
					echo '
255
							<input type="hidden" name="', $key, '" value="0"><input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], '>';
256
257
				// Always fun - select boxes!
258 View Code Duplication
				elseif ($field['type'] == 'select')
259
				{
260
					echo '
261
							<select name="', $key, '" id="', $key, '" tabindex="', $context['tabindex']++, '">';
262
263
					if (isset($field['options']))
264
					{
265
						// Is this some code to generate the options?
266
						if (!is_array($field['options']))
267
							$field['options'] = eval($field['options']);
0 ignored issues
show
Coding Style introduced by
The function template_registration_form() contains an eval expression.

On one hand, eval might be exploited by malicious users if they somehow manage to inject dynamic content. On the other hand, with the emergence of faster PHP runtimes like the HHVM, eval prevents some optimization that they perform.

Loading history...
268
269
						// Assuming we now have some!
270
						if (is_array($field['options']))
271
							foreach ($field['options'] as $value => $name)
272
								echo '
273
								<option', is_numeric($value) ? ' value="" disabled' : ' value="' . $value . '"', $value === $field['value'] ? ' selected' : '', '>', $name, '</option>';
274
					}
275
276
					echo '
277
							</select>';
278
				}
279
280
				// Something to end with?
281
				if (!empty($field['postinput']))
282
					echo '
283
							', $field['postinput'];
284
285
				echo '
286
						</dd>';
287
			}
288
		}
289
	}
290
291
	// Are there any custom fields?
292
	if (!empty($context['custom_fields']))
293
	{
294
		foreach ($context['custom_fields'] as $field)
295
			if ($field['show_reg'] < 2)
296
				echo '
297
						<dt>
298
							<strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong>
299
							<span class="smalltext">', $field['desc'], '</span>
300
						</dt>
301
						<dd>', $field['input_html'], '</dd>';
302
	}
303
304
	// If we have either of these, close the list like a proper gent.
305
	if (!empty($context['profile_fields']) || !empty($context['custom_fields']))
306
		echo '
307
					</dl>
308
				</fieldset>
309
			</div><!-- .roundframe -->';
310
311 View Code Duplication
	if ($context['visual_verification'])
312
		echo '
313
			<div class="title_bar">
314
				<h3 class="titlebg">', $txt['verification'], '</h3>
315
			</div>
316
			<div class="roundframe noup">
317
				<fieldset class="centertext">
318
					', template_control_verification($context['visual_verification_id'], 'all'), '
319
				</fieldset>
320
			</div>';
321
322
	echo '
323
			<div id="confirm_buttons" class="flow_auto">';
324
325
	// Age restriction in effect?
326
	if (!$context['require_agreement'] && $context['show_coppa'])
327
		echo '
328
				<input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br>
329
				<br>
330
				<input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">';
331
	else
332
		echo '
333
				<input type="submit" name="regSubmit" value="', $txt['register'], '" tabindex="', $context['tabindex']++, '" class="button">';
334
335
	echo '
336
			</div>
337
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
338
			<input type="hidden" name="', $context['register_token_var'], '" value="', $context['register_token'], '">
339
			<input type="hidden" name="step" value="3">
340
		</form>
341
		<script>
342
			var regTextStrings = {
343
				"username_valid": "', $txt['registration_username_available'], '",
344
				"username_invalid": "', $txt['registration_username_unavailable'], '",
345
				"username_check": "', $txt['registration_username_check'], '",
346
				"password_short": "', $txt['registration_password_short'], '",
347
				"password_reserved": "', $txt['registration_password_reserved'], '",
348
				"password_numbercase": "', $txt['registration_password_numbercase'], '",
349
				"password_no_match": "', $txt['registration_password_no_match'], '",
350
				"password_valid": "', $txt['registration_password_valid'], '"
351
			};
352
			var verificationHandle = new smfRegister("registration", ', empty($modSettings['password_strength']) ? 0 : $modSettings['password_strength'], ', regTextStrings);
353
		</script>';
354
}
355
356
/**
357
 * After registration... all done ;).
358
 */
359
function template_after()
360
{
361
	global $context;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

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

1. Pass all data via parameters

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

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

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

    public function myFunction() {
        // Do something
    }
}
Loading history...
362
363
	// Not much to see here, just a quick... "you're now registered!" or what have you.
364
	echo '
365
		<div id="registration_success">
366
			<div class="cat_bar">
367
				<h3 class="catbg">', $context['title'], '</h3>
368
			</div>
369
			<div class="windowbg">
370
				<p>', $context['description'], '</p>
371
			</div>
372
		</div>';
373
}
374
375
/**
376
 * Template for giving instructions about COPPA activation.
377
 */
378
function template_coppa()
379
{
380
	global $context, $txt, $scripturl;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

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

1. Pass all data via parameters

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

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

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

    public function myFunction() {
        // Do something
    }
}
Loading history...
381
382
	// Formulate a nice complicated message!
383
	echo '
384
			<div class="title_bar">
385
				<h3 class="titlebg">', $context['page_title'], '</h3>
386
			</div>
387
			<div id="coppa" class="roundframe noup">
388
				<p>', $context['coppa']['body'], '</p>
389
				<p>
390
					<span><a href="', $scripturl, '?action=coppa;form;member=', $context['coppa']['id'], '" target="_blank" rel="noopener">', $txt['coppa_form_link_popup'], '</a> | <a href="', $scripturl, '?action=coppa;form;dl;member=', $context['coppa']['id'], '">', $txt['coppa_form_link_download'], '</a></span>
391
				</p>
392
				<p>', $context['coppa']['many_options'] ? $txt['coppa_send_to_two_options'] : $txt['coppa_send_to_one_option'], '</p>';
393
394
	// Can they send by post?
395
	if (!empty($context['coppa']['post']))
396
		echo '
397
				<h4>1) ', $txt['coppa_send_by_post'], '</h4>
398
				<div class="coppa_contact">
399
					', $context['coppa']['post'], '
400
				</div>';
401
402
	// Can they send by fax??
403
	if (!empty($context['coppa']['fax']))
404
		echo '
405
				<h4>', !empty($context['coppa']['post']) ? '2' : '1', ') ', $txt['coppa_send_by_fax'], '</h4>
406
				<div class="coppa_contact">
407
					', $context['coppa']['fax'], '
408
				</div>';
409
410
	// Offer an alternative Phone Number?
411
	if ($context['coppa']['phone'])
412
		echo '
413
				<p>', $context['coppa']['phone'], '</p>';
414
415
	echo '
416
			</div><!-- #coppa -->';
417
}
418
419
/**
420
 * An easily printable form for giving permission to access the forum for a minor.
421
 */
422
function template_coppa_form()
423
{
424
	global $context, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

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

1. Pass all data via parameters

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

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

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

    public function myFunction() {
        // Do something
    }
}
Loading history...
425
426
	// Show the form (As best we can)
427
	echo '
428
		<table style="width: 100%; padding: 3px; border: 0" class="tborder">
429
			<tr>
430
				<td>', $context['forum_contacts'], '</td>
431
			</tr>
432
			<tr>
433
				<td class="righttext">
434
					<em>', $txt['coppa_form_address'], '</em>: ', $context['ul'], '<br>
435
					', $context['ul'], '<br>
436
					', $context['ul'], '<br>
437
					', $context['ul'], '
438
				</td>
439
			</tr>
440
			<tr>
441
				<td class="righttext">
442
					<em>', $txt['coppa_form_date'], '</em>: ', $context['ul'], '
443
					<br><br>
444
				</td>
445
			</tr>
446
			<tr>
447
				<td>
448
					', $context['coppa_body'], '
449
				</td>
450
			</tr>
451
		</table>
452
		<br>';
453
}
454
455
/**
456
 * Show a window containing the spoken verification code.
457
 */
458
function template_verification_sound()
459
{
460
	global $context, $settings, $txt, $modSettings;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

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

1. Pass all data via parameters

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

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

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

    public function myFunction() {
        // Do something
    }
}
Loading history...
461
462
	echo '<!DOCTYPE html>
463
<html', $context['right_to_left'] ? ' dir="rtl"' : '', '>
464
	<head>
465
		<meta charset="', $context['character_set'], '">
466
		<title>', $txt['visual_verification_sound'], '</title>
467
		<meta name="robots" content="noindex">
468
		<link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'], '">
469
		<style>';
470
471
	// Just show the help text and a "close window" link.
472
	echo '
473
		</style>
474
	</head>
475
	<body style="margin: 1ex;">
476
		<div class="windowbg description" style="text-align: center;">';
477
478
	if (isBrowser('is_ie') || isBrowser('is_ie11'))
479
		echo '
480
			<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" type="audio/x-wav">
481
				<param name="AutoStart" value="1">
482
				<param name="FileName" value="', $context['verification_sound_href'], '">
483
			</object>';
484
	else
485
		echo '
486
			<audio src="', $context['verification_sound_href'], '" controls>
487
				<object type="audio/x-wav" data="', $context['verification_sound_href'], '">
488
					<a href="', $context['verification_sound_href'], '" rel="nofollow">', $context['verification_sound_href'], '</a>
489
				</object>
490
			</audio>';
491
492
	echo '
493
			<br>
494
			<a href="', $context['verification_sound_href'], ';sound" rel="nofollow">', $txt['visual_verification_sound_again'], '</a><br>
495
			<a href="', $context['verification_sound_href'], '" rel="nofollow">', $txt['visual_verification_sound_direct'], '</a><br><br>
496
			<a href="javascript:self.close();">', $txt['visual_verification_sound_close'], '</a><br>
497
		</div><!-- .description -->
498
	</body>
499
</html>';
500
}
501
502
/**
503
 * The template for the form allowing an admin to register a user from the admin center.
504
 */
505
function template_admin_register()
506
{
507
	global $context, $scripturl, $txt, $modSettings;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

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

1. Pass all data via parameters

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

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

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

    public function myFunction() {
        // Do something
    }
}
Loading history...
508
509
	echo '
510
	<div id="admincenter">
511
		<div id="admin_form_wrapper">
512
			<form id="postForm" action="', $scripturl, '?action=admin;area=regcenter" method="post" accept-charset="', $context['character_set'], '" name="postForm">
513
				<div class="cat_bar">
514
					<h3 class="catbg">', $txt['admin_browse_register_new'], '</h3>
515
				</div>
516
				<div id="register_screen" class="windowbg">';
517
518
	if (!empty($context['registration_done']))
519
		echo '
520
					<div class="infobox">
521
						', $context['registration_done'], '
522
					</div>';
523
524
	echo '
525
					<dl class="register_form" id="admin_register_form">
526
						<dt>
527
							<strong><label for="user_input">', $txt['admin_register_username'], ':</label></strong>
528
							<span class="smalltext">', $txt['admin_register_username_desc'], '</span>
529
						</dt>
530
						<dd>
531
							<input type="text" name="user" id="user_input" tabindex="', $context['tabindex']++, '" size="50" maxlength="25">
532
						</dd>
533
						<dt>
534
							<strong><label for="email_input">', $txt['admin_register_email'], ':</label></strong>
535
							<span class="smalltext">', $txt['admin_register_email_desc'], '</span>
536
						</dt>
537
						<dd>
538
							<input type="text" name="email" id="email_input" tabindex="', $context['tabindex']++, '" size="50">
539
						</dd>
540
						<dt>
541
							<strong><label for="password_input">', $txt['admin_register_password'], ':</label></strong>
542
							<span class="smalltext">', $txt['admin_register_password_desc'], '</span>
543
						</dt>
544
						<dd>
545
							<input type="password" name="password" id="password_input" tabindex="', $context['tabindex']++, '" size="50" onchange="onCheckChange();">
546
						</dd>';
547
548
	if (!empty($context['member_groups']))
549
	{
550
		echo '
551
						<dt>
552
							<strong><label for="group_select">', $txt['admin_register_group'], ':</label></strong>
553
							<span class="smalltext">', $txt['admin_register_group_desc'], '</span>
554
						</dt>
555
						<dd>
556
							<select name="group" id="group_select" tabindex="', $context['tabindex']++, '">';
557
558
		foreach ($context['member_groups'] as $id => $name)
559
			echo '
560
								<option value="', $id, '">', $name, '</option>';
561
562
		echo '
563
							</select>
564
						</dd>';
565
	}
566
567
	// If there is any field marked as required, show it here!
568 View Code Duplication
	if (!empty($context['custom_fields_required']) && !empty($context['custom_fields']))
569
		foreach ($context['custom_fields'] as $field)
570
			if ($field['show_reg'] > 1)
571
				echo '
572
						<dt>
573
							<strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong>
574
							<span class="smalltext">', $field['desc'], '</span>
575
						</dt>
576
						<dd>
577
							', str_replace('name="', 'tabindex="' . $context['tabindex']++ . '" name="', $field['input_html']), '
0 ignored issues
show
Coding Style introduced by
Increment and decrement operators must be bracketed when used in string concatenation
Loading history...
578
						</dd>';
579
580
	echo '
581
						<dt>
582
							<strong><label for="emailPassword_check">', $txt['admin_register_email_detail'], ':</label></strong>
583
							<span class="smalltext">', $txt['admin_register_email_detail_desc'], '</span>
584
						</dt>
585
						<dd>
586
							<input type="checkbox" name="emailPassword" id="emailPassword_check" tabindex="', $context['tabindex']++, '" checked disabled>
587
						</dd>
588
						<dt>
589
							<strong><label for="emailActivate_check">', $txt['admin_register_email_activate'], ':</label></strong>
590
						</dt>
591
						<dd>
592
							<input type="checkbox" name="emailActivate" id="emailActivate_check" tabindex="', $context['tabindex']++, '"', !empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1 ? ' checked' : '', ' onclick="onCheckChange();">
593
						</dd>
594
					</dl>
595
					<div class="flow_auto">
596
						<input type="submit" name="regSubmit" value="', $txt['register'], '" tabindex="', $context['tabindex']++, '" class="button">
597
						<input type="hidden" name="sa" value="register">
598
						<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
599
						<input type="hidden" name="', $context['admin-regc_token_var'], '" value="', $context['admin-regc_token'], '">
600
					</div>
601
				</div><!-- #register_screen -->
602
			</form>
603
		</div><!-- #admin_form_wrapper -->
604
	</div><!-- #admincenter -->
605
	<br class="clear">';
606
}
607
608
/**
609
 * Form for editing the agreement shown for people registering to the forum.
610
 */
611
function template_edit_agreement()
612
{
613
	global $context, $scripturl, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

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

1. Pass all data via parameters

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

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

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

    public function myFunction() {
        // Do something
    }
}
Loading history...
614
615 View Code Duplication
	if (!empty($context['saved_successful']))
616
		echo '
617
		<div class="infobox">', $txt['settings_saved'], '</div>';
618
619
	elseif (!empty($context['could_not_save']))
620
		echo '
621
		<div class="errorbox">', $txt['admin_agreement_not_saved'], '</div>';
622
623
	// Warning for if the file isn't writable.
624
	if (!empty($context['warning']))
625
		echo '
626
		<div class="errorbox">', $context['warning'], '</div>';
627
628
	// Just a big box to edit the text file ;)
629
	echo '
630
		<div id="admin_form_wrapper">
631
			<div class="cat_bar">
632
				<h3 class="catbg">', $txt['registration_agreement'], '</h3>
633
			</div>
634
			<div class="windowbg" id="registration_agreement">';
635
636
	// Is there more than one language to choose from?
637
	if (count($context['editable_agreements']) > 1)
638
	{
639
		echo '
640
				<div class="cat_bar">
641
					<h3 class="catbg">', $txt['language_configuration'], '</h3>
642
				</div>
643
				<div class="information">
644
					<form action="', $scripturl, '?action=admin;area=regcenter" id="change_reg" method="post" accept-charset="', $context['character_set'], '" style="display: inline;">
645
						<strong>', $txt['admin_agreement_select_language'], ':</strong>
646
						<select name="agree_lang" onchange="document.getElementById(\'change_reg\').submit();" tabindex="', $context['tabindex']++, '">';
647
648
		foreach ($context['editable_agreements'] as $file => $name)
649
			echo '
650
							<option value="', $file, '"', $context['current_agreement'] == $file ? ' selected' : '', '>', $name, '</option>';
651
652
		echo '
653
						</select>
654
						<div class="righttext">
655
							<input type="hidden" name="sa" value="agreement">
656
							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
657
							<input type="hidden" name="', $context['admin-rega_token_var'], '" value="', $context['admin-rega_token'], '">
658
							<input type="submit" name="change" value="', $txt['admin_agreement_select_language_change'], '" tabindex="', $context['tabindex']++, '" class="button">
659
						</div>
660
					</form>
661
				</div><!-- .information -->';
662
	}
663
664
665
666
	// Show the actual agreement in an oversized text box.
667
	echo '
668
				<form action="', $scripturl, '?action=admin;area=regcenter" method="post" accept-charset="', $context['character_set'], '">
669
					<textarea cols="70" rows="20" name="agreement" id="agreement">', $context['agreement'], '</textarea>
670
					<p>
671
						<label for="requireAgreement"><input type="checkbox" name="requireAgreement" id="requireAgreement"', $context['require_agreement'] ? ' checked' : '', ' tabindex="', $context['tabindex']++, '" value="1"> ', $txt['admin_agreement'], '.</label>
672
					</p>
673
					<input type="submit" value="', $txt['save'], '" tabindex="', $context['tabindex']++, '" class="button">
674
					<input type="hidden" name="agree_lang" value="', $context['current_agreement'], '">
675
					<input type="hidden" name="sa" value="agreement">
676
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
677
					<input type="hidden" name="', $context['admin-rega_token_var'], '" value="', $context['admin-rega_token'], '">
678
				</form>
679
			</div><!-- #registration_agreement -->
680
		</div><!-- #admin_form_wrapper -->';
681
}
682
683
/**
684
 * Template for editing reserved words.
685
 */
686
function template_edit_reserved_words()
687
{
688
	global $context, $scripturl, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

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

1. Pass all data via parameters

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

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

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

    public function myFunction() {
        // Do something
    }
}
Loading history...
689
690
	if (!empty($context['saved_successful']))
691
		echo '
692
	<div class="infobox">', $txt['settings_saved'], '</div>';
693
694
	echo '
695
	<form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=regcenter" method="post" accept-charset="', $context['character_set'], '">
696
		<div class="cat_bar">
697
			<h3 class="catbg">', $txt['admin_reserved_set'], '</h3>
698
		</div>
699
		<div class="windowbg">
700
			<h4>', $txt['admin_reserved_line'], '</h4>
701
			<textarea cols="30" rows="6" name="reserved" id="reserved">', implode("\n", $context['reserved_words']), '</textarea>
702
			<dl class="settings">
703
				<dt>
704
					<label for="matchword">', $txt['admin_match_whole'], '</label>
705
				</dt>
706
				<dd>
707
					<input type="checkbox" name="matchword" id="matchword" tabindex="', $context['tabindex']++, '"', $context['reserved_word_options']['match_word'] ? ' checked' : '', '>
708
				</dd>
709
				<dt>
710
					<label for="matchcase">', $txt['admin_match_case'], '</label>
711
				</dt>
712
				<dd>
713
					<input type="checkbox" name="matchcase" id="matchcase" tabindex="', $context['tabindex']++, '"', $context['reserved_word_options']['match_case'] ? ' checked' : '', '>
714
				</dd>
715
				<dt>
716
					<label for="matchuser">', $txt['admin_check_user'], '</label>
717
				</dt>
718
				<dd>
719
					<input type="checkbox" name="matchuser" id="matchuser" tabindex="', $context['tabindex']++, '"', $context['reserved_word_options']['match_user'] ? ' checked' : '', '>
720
				</dd>
721
				<dt>
722
					<label for="matchname">', $txt['admin_check_display'], '</label>
723
				</dt>
724
				<dd>
725
					<input type="checkbox" name="matchname" id="matchname" tabindex="', $context['tabindex']++, '"', $context['reserved_word_options']['match_name'] ? ' checked' : '', '>
726
				</dd>
727
			</dl>
728
			<div class="flow_auto">
729
				<input type="submit" value="', $txt['save'], '" name="save_reserved_names" tabindex="', $context['tabindex']++, '" class="button">
730
				<input type="hidden" name="sa" value="reservednames">
731
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
732
				<input type="hidden" name="', $context['admin-regr_token_var'], '" value="', $context['admin-regr_token'], '">
733
			</div>
734
		</div><!-- .windowbg -->
735
	</form>';
736
}
737
738
?>