template_new_group()   C
last analyzed

Complexity

Conditions 12
Paths 24

Size

Total Lines 150
Code Lines 56

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 12
eloc 56
nc 24
nop 0
dl 0
loc 150
rs 6.5333
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
/**
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
 * Regular membergroups list template
17
 */
18
function template_regular_membergroups_list()
19
{
20
	template_show_list('regular_membergroups_list');
21
22
	echo '<br /><br />';
23
24
	template_show_list('post_count_membergroups_list');
25
}
26
27
/**
28
 * Template for a new group
29
 */
30
function template_new_group()
31
{
32
	global $context, $scripturl, $txt, $modSettings;
33
34
	echo '
35
	<div id="admincenter">
36
		<form id="admin_form_wrapper" name="new_group" action="', $scripturl, '?action=admin;area=membergroups;sa=add" method="post" accept-charset="UTF-8">
37
			<h2 class="category_header">', $txt['membergroups_new_group'], '</h2>
38
			<div class="content">
39
				<dl class="settings">
40
					<dt>
41
						<label for="group_name_input">', $txt['membergroups_group_name'], ':</label>
42
					</dt>
43
					<dd>
44
						<input type="text" name="group_name" id="group_name_input" size="30" class="input_text" />
45
					</dd>';
46
47
	if ($context['undefined_group'])
48
	{
49
		echo '
50
					<dt>
51
						<label for="group_type">', $txt['membergroups_edit_group_type'], ':</label>
52
					</dt>
53
					<dd>
54
						<fieldset id="group_type">
55
							<legend>', $txt['membergroups_edit_select_group_type'], '</legend>
56
							<br />
57
							<input type="radio" name="group_type" id="group_type_private" value="0" checked="checked" onclick="swapPostGroup(0);" />
58
							<label for="group_type_private">', $txt['membergroups_group_type_private'], '</label><br />';
59
60
		if ($context['allow_protected'])
61
		{
62
			echo '
63
							<input type="radio" name="group_type" id="group_type_protected" value="1" onclick="swapPostGroup(0);" />
64
							<label for="group_type_protected">', $txt['membergroups_group_type_protected'], '</label><br />';
65
		}
66
67
		echo '
68
							<input type="radio" name="group_type" id="group_type_request" value="2" onclick="swapPostGroup(0);" />
69
							<label for="group_type_request">', $txt['membergroups_group_type_request'], '</label><br />
70
71
							<input type="radio" name="group_type" id="group_type_free" value="3"  onclick="swapPostGroup(0);" />
72
							<label for="group_type_free">', $txt['membergroups_group_type_free'], '</label><br />
73
74
							<input type="radio" name="group_type" id="group_type_post" value="-1" onclick="swapPostGroup(1);" />
75
							<label for="group_type_post">', $txt['membergroups_group_type_post'], '</label><br />
76
						</fieldset>
77
					</dd>';
78
	}
79
80
	if ($context['post_group'] || $context['undefined_group'])
81
	{
82
		echo '
83
					<dt id="min_posts_text">
84
						<label for="min_posts_input">', $txt['membergroups_min_posts'], ':</label>
85
					</dt>
86
					<dd>
87
						<input type="text" name="min_posts" id="min_posts_input" size="5" class="input_text" />
88
					</dd>';
89
	}
90
91
	if (!$context['post_group'] || !empty($modSettings['permission_enable_postgroups']))
92
	{
93
		echo '
94
					<dt>
95
						<label for="permission_base">', $txt['membergroups_permissions'], ':</label><br />
96
						<span class="smalltext">', $txt['membergroups_can_edit_later'], '</span>
97
					</dt>
98
					<dd>
99
						<fieldset id="permission_base">
100
							<legend>', $txt['membergroups_select_permission_type'], '</legend>
101
							<input type="radio" name="perm_type" id="perm_type_inherit" value="inherit" checked="checked" />
102
							<label for="perm_type_inherit">', $txt['membergroups_new_as_inherit'], ':</label>
103
							<select name="inheritperm" id="inheritperm_select" onclick="document.getElementById(\'perm_type_inherit\').checked = true;">
104
								<option value="-1">', $txt['membergroups_guests'], '</option>
105
								<option value="0" selected="selected">', $txt['membergroups_members'], '</option>';
106
107
		foreach ($context['groups'] as $group)
108
		{
109
			echo '
110
								<option value="', $group['id'], '">', $group['name'], '</option>';
111
		}
112
113
		echo '
114
							</select>
115
							<br />
116
							<input type="radio" name="perm_type" id="perm_type_copy" value="copy" />
117
							<label for="perm_type_copy">', $txt['membergroups_new_as_copy'], ':</label>
118
							<select name="copyperm" id="copyperm_select" onclick="document.getElementById(\'perm_type_copy\').checked = true;">
119
								<option value="-1">', $txt['membergroups_guests'], '</option>
120
								<option value="0" selected="selected">', $txt['membergroups_members'], '</option>';
121
122
		foreach ($context['groups'] as $group)
123
		{
124
			echo '
125
								<option value="', $group['id'], '">', $group['name'], '</option>';
126
		}
127
128
		echo '
129
							</select>
130
							<br />
131
							<input type="radio" name="perm_type" id="perm_type_predefined" value="predefined" />
132
							<label for="perm_type_predefined">', $txt['membergroups_new_as_type'], ':</label>
133
							<select name="level" id="level_select" onclick="document.getElementById(\'perm_type_predefined\').checked = true;">
134
								<option value="restrict">', $txt['permitgroups_restrict'], '</option>
135
								<option value="standard" selected="selected">', $txt['permitgroups_standard'], '</option>
136
								<option value="moderator">', $txt['permitgroups_moderator'], '</option>
137
								<option value="maintenance">', $txt['permitgroups_maintenance'], '</option>
138
							</select>
139
						</fieldset>
140
					</dd>';
141
	}
142
143
	echo '
144
					<dt>
145
						<label>', $txt['membergroups_new_board'], ':</label>', $context['post_group'] ? '<br />
146
						<span class="smalltext" style="font-weight: normal;">' . $txt['membergroups_new_board_post_groups'] . '</span>' : '', '
147
					</dt>
148
					<dd>';
149
150
	template_add_edit_group_boards_list('new_group', false);
0 ignored issues
show
Bug introduced by
'new_group' of type string is incompatible with the type integer expected by parameter $form_id of template_add_edit_group_boards_list(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

150
	template_add_edit_group_boards_list(/** @scrutinizer ignore-type */ 'new_group', false);
Loading history...
151
152
	echo '
153
					</dd>
154
				</dl>
155
				<div class="submitbutton">
156
					<input type="submit" value="', $txt['membergroups_add_group'], '" />
157
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
158
					<input type="hidden" name="', $context['admin-mmg_token_var'], '" value="', $context['admin-mmg_token'], '" />
159
				</div>
160
			</div>';
161
162
	if ($context['undefined_group'])
163
	{
164
		// Enable / disable the required posts box when the group type is post based
165
		echo '
166
			<script>
167
				function swapPostGroup(isChecked)
168
				{
169
					var min_posts_text = document.getElementById(\'min_posts_text\');
170
171
					document.getElementById(\'min_posts_input\').disabled = !isChecked;
172
					min_posts_text.style.color = isChecked ? "" : "#888";
173
				}
174
175
				swapPostGroup(', $context['post_group'] ? 'true' : 'false', ');
176
			</script>';
177
	}
178
179
	echo '
180
		</form>
181
	</div>';
182
}
183
184
/**
185
 * Template edit group
186
 */
187
function template_edit_group()
188
{
189
	global $context, $settings, $scripturl, $txt;
190
191
	echo '
192
	<div id="admincenter">
193
		<form id="admin_form_wrapper" name="groupForm" action="', $scripturl, '?action=admin;area=membergroups;sa=edit;group=', $context['group']['id'], '" method="post" accept-charset="UTF-8" >
194
			<h2 class="category_header">', $txt['membergroups_edit_group'], ' - ', $context['group']['name'], '</h2>
195
			<div class="content">
196
				<dl class="settings">
197
					<dt>
198
						<label for="group_name_input">', $txt['membergroups_edit_name'], ':</label>
199
					</dt>
200
					<dd>
201
						<input type="text" name="group_name" id="group_name_input" value="', $context['group']['editable_name'], '" size="30" class="input_text" />
202
					</dd>';
203
204
	if ($context['group']['id'] != 3 && $context['group']['id'] != 4)
205
	{
206
		echo '
207
					<dt id="group_desc_text">
208
						<label for="group_desc_input">', $txt['membergroups_edit_desc'], ':</label>
209
					</dt>
210
					<dd>
211
						<textarea name="group_desc" id="group_desc_input" rows="4" cols="40">', $context['group']['description'], '</textarea>
212
					</dd>';
213
	}
214
215
	// Group type...
216
	if ($context['group']['allow_post_group'])
217
	{
218
		echo '
219
					<dt>
220
						<label for="group_type">', $txt['membergroups_edit_group_type'], ':</label>
221
					</dt>
222
					<dd>
223
						<fieldset id="group_type">
224
							<legend>', $txt['membergroups_edit_select_group_type'], '</legend>
225
							<br />
226
							<input type="radio" name="group_type" id="group_type_private" value="0" ', !$context['group']['is_post_group'] && $context['group']['type'] == 0 ? 'checked="checked"' : '', ' onclick="swapPostGroup(0);" />
227
							<label for="group_type_private">', $txt['membergroups_group_type_private'], '</label><br />';
228
229
		if ($context['group']['allow_protected'])
230
		{
231
			echo '
232
							<input type="radio" name="group_type" id="group_type_protected" value="1" ', $context['group']['type'] == 1 ? 'checked="checked"' : '', ' onclick="swapPostGroup(0);" />
233
							<label for="group_type_protected">', $txt['membergroups_group_type_protected'], '</label><br />';
234
		}
235
236
237
		echo '
238
							<input type="radio" name="group_type" id="group_type_request" value="2" ', $context['group']['type'] == 2 ? 'checked="checked"' : '', ' onclick="swapPostGroup(0);" />
239
							<label for="group_type_request">', $txt['membergroups_group_type_request'], '</label><br />
240
							<input type="radio" name="group_type" id="group_type_free" value="3" ', $context['group']['type'] == 3 ? 'checked="checked"' : '', ' onclick="swapPostGroup(0);" />
241
							<label for="group_type_free">', $txt['membergroups_group_type_free'], '</label><br />
242
							<input type="radio" name="group_type" id="group_type_post" value="-1" ', $context['group']['is_post_group'] ? 'checked="checked"' : '', ' onclick="swapPostGroup(1);" />
243
							<label for="group_type_post">', $txt['membergroups_group_type_post'], '</label><br />
244
						</fieldset>
245
					</dd>';
246
	}
247
248
	if ($context['group']['id'] != 3 && $context['group']['id'] != 4)
249
	{
250
		echo '
251
					<dt id="group_moderators_text">
252
						<label for="group_moderators">', $txt['moderators'], ':</label>
253
					</dt>
254
					<dd>
255
						<input type="text" name="group_moderators" id="group_moderators" value="', $context['group']['moderator_list'], '" size="30" class="input_text" />
256
						<div id="moderator_container"></div>
257
					</dd>
258
					<dt id="group_hidden_text">
259
						<label for="group_hidden_input">', $txt['membergroups_edit_hidden'], ':</label>
260
					</dt>
261
					<dd>
262
						<select name="group_hidden" id="group_hidden_input" onchange="if (this.value == 2 &amp;&amp; !confirm(\'', $txt['membergroups_edit_hidden_warning'], '\')) this.value = 0;">
263
							<option value="0" ', $context['group']['hidden'] ? '' : 'selected="selected"', '>', $txt['membergroups_edit_hidden_no'], '</option>
264
							<option value="1" ', $context['group']['hidden'] == 1 ? 'selected="selected"' : '', '>', $txt['membergroups_edit_hidden_boardindex'], '</option>
265
							<option value="2" ', $context['group']['hidden'] == 2 ? 'selected="selected"' : '', '>', $txt['membergroups_edit_hidden_all'], '</option>
266
						</select>
267
					</dd>';
268
	}
269
270
	// Can they inherit permissions?
271
	if ($context['group']['id'] > 1 && $context['group']['id'] != 3)
272
	{
273
		echo '
274
					<dt id="group_inherit_text">
275
						<label for="group_inherit_input">', $txt['membergroups_edit_inherit_permissions'], '</label>:<br />
276
						<span class="smalltext">', $txt['membergroups_edit_inherit_permissions_desc'], '</span>
277
					</dt>
278
					<dd>
279
						<select name="group_inherit" id="group_inherit_input">
280
							<option value="-2">', $txt['membergroups_edit_inherit_permissions_no'], '</option>
281
							<option value="-1" ', $context['group']['inherited_from'] == -1 ? 'selected="selected"' : '', '>', $txt['membergroups_edit_inherit_permissions_from'], ': ', $txt['membergroups_guests'], '</option>
282
							<option value="0" ', $context['group']['inherited_from'] == 0 ? 'selected="selected"' : '', '>', $txt['membergroups_edit_inherit_permissions_from'], ': ', $txt['membergroups_members'], '</option>';
283
284
		// For all the inheritable groups show an option.
285
		foreach ($context['inheritable_groups'] as $id => $group)
286
		{
287
			echo '
288
							<option value="', $id, '" ', $context['group']['inherited_from'] == $id ? 'selected="selected"' : '', '>', $txt['membergroups_edit_inherit_permissions_from'], ': ', $group, '</option>';
289
		}
290
291
		echo '
292
						</select>
293
						<input type="hidden" name="old_inherit" value="', $context['group']['inherited_from'], '" />
294
					</dd>';
295
	}
296
297
	if ($context['group']['allow_post_group'])
298
	{
299
		echo '
300
					<dt id="min_posts_text">
301
						<label for="min_posts_input">', $txt['membergroups_min_posts'], ':</label>
302
					</dt>
303
					<dd>
304
						<input type="text" name="min_posts" id="min_posts_input"', $context['group']['is_post_group'] ? ' value="' . $context['group']['min_posts'] . '"' : '', ' size="6" class="input_text" />
305
					</dd>';
306
	}
307
308
	// Hide the online color for our local moderators group.
309
	if ($context['group']['id'] != 3)
310
	{
311
		echo '
312
					<dt>
313
						<label for="online_color_input">', $txt['membergroups_online_color'], ':</label>
314
					</dt>
315
					<dd>
316
						<input type="text" name="online_color" id="online_color_input" value="', $context['group']['color'], '" size="20" class="input_text" />
317
					</dd>';
318
	}
319
320
	echo '
321
					<dt>
322
						<label for="icon_count_input">', $txt['membergroups_icon_count'], ':</label>
323
					</dt>
324
					<dd>
325
						<input type="number" min="0" max="10" step="1" name="icon_count" id="icon_count_input" value="', $context['group']['icon_count'], '" onkeyup="if (parseInt(this.value, 10) > 10) this.value = 10;" onchange="this.value = Math.floor(this.value);this.form.icon_image.onchange();" class="input_text" />
326
					</dd>
327
					<dt>
328
						<label for="icon_image_input">', $txt['membergroups_icon_image'], ':</label>
329
						<br />
330
						<span class="smalltext">', $txt['membergroups_icon_image_note'], '</span>
331
					</dt>
332
					<dd>
333
						<span class="floatleft">
334
							', $txt['membergroups_images_url'], '
335
							<input type="text" name="icon_image" id="icon_image_input" value="', $context['group']['icon_image'], '" onchange="if (this.value &amp;&amp; this.form.icon_count.value == 0) this.form.icon_count.value = 1;else if (!this.value) this.form.icon_count.value = 0; document.getElementById(\'msg_icon_0\').src = elk_images_url + \'/group_icons/\' + (this.value &amp;&amp; this.form.icon_count.value > 0 ? this.value : \'blank.png\')" size="20" class="input_text" />
336
						</span>
337
						<span id="messageicon_0" class="groupicon">
338
							<img id="msg_icon_0" src="', $settings['images_url'], '/group_icons/', $context['group']['icon_image'] == '' ? 'blank.png' : $context['group']['icon_image'], '" alt="*" />
339
						</span>
340
					</dd>
341
					<dt>
342
						<label for="max_messages_input">', $txt['membergroups_max_messages'], ':</label><br />
343
						<span class="smalltext">', $txt['membergroups_max_messages_note'], '</span>
344
					</dt>
345
					<dd>
346
						<input type="text" name="max_messages" id="max_messages_input" value="', $context['group']['id'] == 1 ? 0 : $context['group']['max_messages'], '" size="6"', $context['group']['id'] == 1 ? ' disabled="disabled"' : '', ' class="input_text" />
347
					</dd>';
348
349
	if (!empty($context['categories']))
350
	{
351
		echo '
352
					<dt>
353
						<label>', $txt['membergroups_new_board'], ':</label>', $context['group']['is_post_group'] ? '<br />
354
						<span class="smalltext">' . $txt['membergroups_new_board_post_groups'] . '</span>' : '', '
355
					</dt>
356
					<dd>';
357
358
		template_add_edit_group_boards_list('groupForm', true);
0 ignored issues
show
Bug introduced by
'groupForm' of type string is incompatible with the type integer expected by parameter $form_id of template_add_edit_group_boards_list(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

358
		template_add_edit_group_boards_list(/** @scrutinizer ignore-type */ 'groupForm', true);
Loading history...
359
360
		echo '
361
					</dd>';
362
	}
363
364
	echo '
365
				</dl>
366
				<div class="submitbutton">
367
					<input type="submit" id="save" name="save" value="', $txt['membergroups_edit_save'], '" />', $context['group']['allow_delete'] ? '
368
					<input type="submit" id="delete" name="delete" value="' . $txt['membergroups_delete'] . '" onclick="return confirm(\'' . $txt['membergroups_confirm_delete'] . '\');" />' : '', '
369
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
370
					<input type="hidden" name="', $context['admin-mmg_token_var'], '" value="', $context['admin-mmg_token'], '" />
371
				</div>
372
			</div>
373
		</form>
374
	</div>';
375
376
	theme()->addInlineJavascript('
377
		aIconLists[aIconLists.length] = new IconList({
378
			sBackReference: "aIconLists[" + aIconLists.length + "]",
379
			sIconIdPrefix: "msg_icon_",
380
			bShowModify: false,
381
			sAction: "groupicons",
382
			sLabelIconList: ' . JavaScriptEscape($txt['membergroups_icons']) . ',
383
			sLabelIconBox: "icon_image_input",
384
			sBoxBackground: "transparent",
385
			sBoxBackgroundHover: "#fff",
386
			iBoxBorderWidthHover: 1,
387
			sBoxBorderColorHover: "#adadad",
388
			sContainerBackground: "#fff",
389
			sContainerBorder: "1px solid #adadad",
390
			sItemBorder: "1px solid #fff",
391
			sItemBorderHover: "1px dotted gray",
392
			sItemBackground: "transparent",
393
			sItemBackgroundHover: "#e0e0f0"
394
		});', true);
395
396
	if ($context['group']['id'] != 3 && $context['group']['id'] != 4)
397
	{
398
		$js = '
399
		isFunctionLoaded("elk_AutoSuggest").then((available) => { 
400
			if (available) {
401
				new elk_AutoSuggest({
402
					sSessionId: elk_session_id,
403
					sSessionVar: elk_session_var,
404
					sSuggestId: \'group_moderators\',
405
					sControlId: \'group_moderators\',
406
					sSearchType: \'member\',
407
					bItemList: true,
408
					sPostName: \'moderator_list\',
409
					sURLMask: \'action=profile;u=%item_id%\',
410
					sTextDeleteItem: ' . JavaScriptEscape($txt['autosuggest_delete_item']) . ',
411
					sItemListContainerId: \'moderator_container\',
412
					aListItems: [';
413
414
		foreach ($context['group']['moderators'] as $id_member => $member_name)
415
		{
416
			$js .= '
417
						{
418
							sItemId: ' . JavaScriptEscape($id_member) . ',
419
							sItemName: ' . JavaScriptEscape($member_name) . '
420
						}' . $id_member == $context['group']['last_moderator_id'] ? '' : ',';
421
		}
422
423
		$js .= '
424
			]
425
				});
426
			}
427
		});';
428
429
		theme()->addInlineJavascript($js, true);
430
	}
431
432
	// If post based is selected, disable moderation selection, visability, group description and enable post count,
433
	if ($context['group']['allow_post_group'])
434
	{
435
		theme()->addInlineJavascript('swapPostGroup(' . ($context['group']['is_post_group'] ? 'true' : 'false') . ');', true);
436
	}
437
}
438
439
/**
440
 * Template to edit the boards and groups access to them
441
 *
442
 * Accessed with ?action=admin;area=membergroups;sa=add
443
 *
444
 * @param int $form_id
445
 * @param bool $collapse
446
 */
447
function template_add_edit_group_boards_list($form_id, $collapse = true)
448
{
449
	global $context, $txt, $modSettings;
450
451
	$deny = !empty($modSettings['deny_boards_access']);
452
453
	echo '
454
							<fieldset class="visible_boards">
455
								<legend', $collapse ? ' data-collapsed="true"' : '', '>', $txt['membergroups_new_board_desc'], '</legend>
456
								<ul>';
457
458
	foreach ($context['categories'] as $category)
459
	{
460
		if (empty($deny))
461
		{
462
			echo '
463
									<li class="category">
464
										<a href="javascript:void(0);" onclick="selectBoards([', implode(', ', $category['child_ids']), "], '", $form_id, '\', \'boardaccess\'); return false;"><strong>', $category['name'], '</strong></a>
465
									<ul>';
466
		}
467
		else
468
		{
469
			echo '
470
									<li class="category">
471
										<strong>', $category['name'], '</strong>
472
										<ul id="boards_list_', $category['id'], '">';
473
		}
474
475
		if (!empty($deny))
476
		{
477
			echo '
478
										<li class="board select_category">
479
											', $txt['all_boards_in_cat'], ':
480
											<span class="floatright">
481
												<label for="all_sel_', $category['id'], '">
482
													<input type="radio" onchange="select_in_category(\'allow\', [', implode(',', array_keys($category['boards'])), ']);" id="all_sel_', $category['id'], '" name="all_', $category['id'], '" /> ', $txt['board_perms_allow'], '
483
												</label>
484
												<label for="all_ign_', $category['id'], '">
485
													<input type="radio" onchange="select_in_category(\'ignore\', [', implode(',', array_keys($category['boards'])), ']);" id="all_ign_', $category['id'], '" name="all_', $category['id'], '" /> ', $txt['board_perms_ignore'], '
486
												</label>
487
												<label for="all_den_', $category['id'], '">
488
													<input type="radio" onchange="select_in_category(\'deny\', [', implode(',', array_keys($category['boards'])), ']);" id="all_den_', $category['id'], '" name="all_', $category['id'], '" /> ', $txt['board_perms_deny'], '
489
												</label>
490
											</span>
491
										</li>';
492
		}
493
494
		foreach ($category['boards'] as $board)
495
		{
496
			if (empty($deny))
497
			{
498
				echo '
499
										<li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">
500
											<input id="brd', $board['id'], '"  name="boardaccess[', $board['id'], ']" type="checkbox" value="allow" ', $board['allow'] ? ' checked="checked"' : '', ' />
501
											<label for="brd', $board['id'], '">', $board['name'], '</label>
502
										</li>';
503
			}
504
			else
505
			{
506
				echo '
507
										<li class="board">
508
											<span style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">', $board['name'], ': </span>
509
											<span class="floatright">
510
												<label for="allow_brd', $board['id'], '">
511
													<input type="radio" name="boardaccess[', $board['id'], ']" id="allow_brd', $board['id'], '" value="allow" ', $board['allow'] ? ' checked="checked"' : '', ' /> ', $txt['permissions_option_on'], '
512
												</label>
513
												<label for="ignore_brd', $board['id'], '">
514
													<input type="radio" name="boardaccess[', $board['id'], ']" id="ignore_brd', $board['id'], '" value="ignore" ', !$board['allow'] && !$board['deny'] ? ' checked="checked"' : '', ' /> ', $txt['permissions_option_off'], '
515
												</label>
516
												<label for="deny_brd', $board['id'], '">
517
													<input type="radio" name="boardaccess[', $board['id'], ']" id="deny_brd', $board['id'], '" value="deny" ', $board['deny'] ? ' checked="checked"' : '', ' /> ', $txt['permissions_option_deny'], '
518
												</label>
519
											</span>
520
										</li>';
521
			}
522
		}
523
524
		echo '
525
									</ul>
526
								</li>';
527
	}
528
529
	echo '
530
							</ul>';
531
532
	if (empty($deny))
533
	{
534
		echo '
535
								<br />
536
								<div class="select_all_box">
537
									<input id="checkall_check" type="checkbox" onclick="invertAll(this, this.form, \'boardaccess\');" />
538
									<label for="checkall_check"><em>', $txt['check_all'], '</em></label>
539
								</div>';
540
	}
541
	else
542
	{
543
		echo '
544
								<div class="select_all_box">
545
									', $txt['all'], ':
546
									<span class="floatright">
547
										<label for="all_', $category['id'], '">
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $category seems to be defined by a foreach iteration on line 458. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
548
											<input type="radio" name="select_all" id="allow_all" onclick="selectAllRadio(this, this.form, \'boardaccess\', \'allow\');" /> ', $txt['board_perms_allow'], '
549
										</label>
550
										<label for="all_', $category['id'], '">
551
											<input type="radio" name="select_all" id="ignore_all" onclick="selectAllRadio(this, this.form, \'boardaccess\', \'ignore\');" /> ', $txt['board_perms_ignore'], '
552
										</label>
553
										<label for="all_', $category['id'], '">
554
											<input type="radio" name="select_all" id="deny_all" onclick="selectAllRadio(this, this.form, \'boardaccess\', \'deny\');" /> ', $txt['board_perms_deny'], '
555
										</label>
556
									</span>
557
								</div>';
558
	}
559
560
	// select_all_box is hidden and it's made available only if js is enabled
561
	echo '
562
							</fieldset>
563
							<script>
564
								$(function() {
565
									$(".select_all_box").each(function () {
566
										$(this).show();
567
									});
568
								});
569
							</script>';
570
}
571
572
/**
573
 * Template for viewing the members of a group.
574
 */
575
function template_group_members()
576
{
577
	global $context, $scripturl, $txt;
578
579
	echo '
580
	<div id="admincenter">
581
		<form action="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;group=', $context['group']['id'], '" method="post" accept-charset="UTF-8" id="view_group">
582
			<h2 class="category_header">', $context['page_title'], '</h2>
583
				<div class="content">
584
				<dl class="settings">
585
					<dt>
586
						<label>', $txt['name'], ':</label>
587
					</dt>
588
					<dd>
589
						<span ', $context['group']['online_color'] ? 'style="color: ' . $context['group']['online_color'] . ';"' : '', '>', $context['group']['name'], '</span> ', $context['group']['icons'], '
590
					</dd>';
591
592
	// Any description to show?
593
	if (!empty($context['group']['description']))
594
	{
595
		echo '
596
					<dt>
597
						<label>' . $txt['membergroups_members_description'] . ':</label>
598
					</dt>
599
					<dd>
600
						', $context['group']['description'], '
601
					</dd>';
602
	}
603
604
	echo '
605
					<dt>
606
						<label>', $txt['membergroups_members_top'], ':</label>
607
					</dt>
608
					<dd>
609
						', $context['total_members'], '
610
					</dd>';
611
612
	// Any group moderators to show?
613
	if (!empty($context['group']['moderators']))
614
	{
615
		$moderators = array();
616
		foreach ($context['group']['moderators'] as $moderator)
617
		{
618
			$moderators[] = '<a href="' . $scripturl . '?action=profile;u=' . $moderator['id'] . '">' . $moderator['name'] . '</a>';
619
		}
620
621
		echo '
622
					<dt>
623
						<label>', $txt['membergroups_members_group_moderators'], ':</<label>
624
					</dt>
625
					<dd>
626
						', implode(', ', $moderators), '
627
					</dd>';
628
	}
629
630
	echo '
631
				</dl>
632
			</div>
633
			<h2 class="category_header">', $txt['membergroups_members_group_members'], '</h2>
634
			', template_pagesection(), '
635
			<table class="table_grid">
636
				<thead>
637
					<tr class="table_head">
638
						<th>
639
							<a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=name', $context['sort_by'] == 'name' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['name'], $context['sort_by'] == 'name' ? ' <i class="icon icon-small i-sort-alpha-' . $context['sort_direction'] . '"></i>' : '', '</a>
640
						</th>';
641
642
	if ($context['can_send_email'])
643
	{
644
		echo '
645
						<th>
646
							<a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=email', $context['sort_by'] == 'email' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['email'], $context['sort_by'] == 'email' ? ' <i class="icon icon-small i-sort-alpha-' . $context['sort_direction'] . '"></i>' : '', '</a>
647
						</th>';
648
	}
649
650
	echo '
651
						<th>
652
							<a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=active', $context['sort_by'] == 'active' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['membergroups_members_last_active'], $context['sort_by'] == 'active' ? '<i class="icon icon-small i-sort-numeric-' . $context['sort_direction'] . '"></i>' : '', '</a>
653
						</th>
654
						<th>
655
							<a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=registered', $context['sort_by'] == 'registered' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['date_registered'], $context['sort_by'] == 'registered' ? '<i class="icon icon-small i-sort-numeric-' . $context['sort_direction'] . '"></i>' : '', '</a>
656
						</th>
657
						<th ', empty($context['group']['assignable']) ? ' colspan="2"' : '', '><a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=posts', $context['sort_by'] == 'posts' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['posts'], $context['sort_by'] == 'posts' ? ' <i class="icon icon-small i-sort-numeric-' . $context['sort_direction'] . '"></i>' : '', '</a></th>';
658
659
	if (!empty($context['group']['assignable']))
660
	{
661
		echo '
662
						<th style="width: 4%;" class="centertext">
663
							<input type="checkbox" onclick="invertAll(this, this.form);" />
664
						</th>';
665
	}
666
667
	echo '
668
					</tr>
669
				</thead>
670
				<tbody>';
671
672
	if (empty($context['members']))
673
	{
674
		echo '
675
					<tr>
676
						<td colspan="6" class="centertext">', $txt['membergroups_members_no_members'], '</td>
677
					</tr>';
678
	}
679
680
	foreach ($context['members'] as $member)
681
	{
682
		echo '
683
					<tr>
684
						<td>', $member['name'], '</td>';
685
686
		if ($context['can_send_email'])
687
		{
688
			echo '
689
						<td><em>' . template_member_email($member, true) . '</em></td>';
690
		}
691
692
		echo '
693
						<td>', $member['last_online'], '</td>
694
						<td>', $member['registered'], '</td>
695
						<td', empty($context['group']['assignable']) ? ' colspan="2"' : '', '>', $member['posts'], '</td>';
696
697
		if (!empty($context['group']['assignable']))
698
		{
699
			echo '
700
						<td class="centertext" style="width: 4%;">
701
							<input type="checkbox" name="rem[]" value="', $member['id'], '" ', ($context['user']['id'] == $member['id'] && $context['group']['id'] == 1 ? 'onclick="if (this.checked) return confirm(\'' . $txt['membergroups_members_deadmin_confirm'] . '\')" ' : ''), '/>
702
						</td>';
703
		}
704
705
		echo '
706
					</tr>';
707
	}
708
709
	echo '
710
				</tbody>
711
			</table>';
712
713
			template_pagesection(false, '', array('extra' => '<div class="flow_flex_right"><input type="submit" name="remove" value="' . $txt['membergroups_members_remove'] . '" /></div>'));
714
715
	if (!empty($context['group']['assignable']))
716
	{
717
		echo '
718
			<div class="separator">
719
				<h2 class="category_header">', $txt['membergroups_members_add_title'], '</h2>
720
				<div class="content">
721
					<dl class="settings">
722
						<dt>
723
							<label for="toAdd">', $txt['membergroups_members_add_desc'], ':</label>
724
						</dt>
725
						<dd>
726
							<input type="text" name="toAdd" id="toAdd" value="" class="input_text" />
727
							<div id="toAddItemContainer"></div>
728
						</dd>
729
					</dl>
730
					<div class="submitbutton">
731
						<input type="submit" name="add" value="', $txt['membergroups_members_add'], '" />
732
					</div>
733
				</div>
734
			</div>';
735
	}
736
737
	echo '
738
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
739
			<input type="hidden" name="', $context['mod-mgm_token_var'], '" value="', $context['mod-mgm_token'], '" />
740
		</form>
741
	</div>';
742
743
	if (!empty($context['group']['assignable']))
744
	{
745
		theme()->addInlineJavascript('
746
		isFunctionLoaded("elk_AutoSuggest").then((available) => { 
747
			if (available) {
748
				new elk_AutoSuggest({
749
					sSessionId: elk_session_id,
750
					sSessionVar: elk_session_var,
751
					sSuggestId: \'to_suggest\',
752
					sControlId: \'toAdd\',
753
					sSearchType: \'member\',
754
					sPostName: \'member_add\',
755
					sURLMask: \'action=profile;u=%item_id%\',
756
					sTextDeleteItem: ' . JavaScriptEscape($txt['autosuggest_delete_item']) . ',
757
					bItemList: true,
758
					sItemListContainerId: \'toAddItemContainer\'
759
				});
760
			}
761
		});', true);
762
	}
763
}
764
765
/**
766
 * Allow the moderator to enter a reason to each user being rejected.
767
 */
768
function template_group_request_reason()
769
{
770
	global $context, $txt, $scripturl;
771
772
	// Show a welcome message to the user.
773
	echo '
774
	<div id="moderationcenter">
775
		<form action="', $scripturl, '?action=groups;sa=requests" method="post" accept-charset="UTF-8">
776
			<h2 class="category_header">', $txt['mc_groups_reason_title'], '</h2>
777
			<div class="content">
778
				<dl class="settings">';
779
780
	// Loop through and print out a reason box for each...
781
	foreach ($context['group_requests'] as $request)
782
	{
783
		echo '
784
					<dt>
785
						<label for="groupreason">', sprintf($txt['mc_groupr_reason_desc'], $request['member_link'], $request['group_link']), ':</label>
786
					</dt>
787
					<dd>
788
						<input type="hidden" name="groupr[]" value="', $request['id'], '" />
789
						<textarea id="groupreason" name="groupreason[', $request['id'], ']" rows="3" cols="40" style="min-width: 80%; max-width: 99%;"></textarea>
790
					</dd>';
791
	}
792
793
	echo '
794
				</dl>
795
				<div class="submitbutton">
796
					<input type="submit" name="go" value="', $txt['mc_groupr_submit'], '" />
797
					<input type="hidden" name="req_action" value="got_reason" />
798
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
799
					<input type="hidden" name="', $context['mod-gr_token_var'], '" value="', $context['mod-gr_token'], '" />
800
				</div>
801
			</div>
802
		</form>
803
	</div>';
804
}
805