Completed
Pull Request — development (#3082)
by John
14:20
created

ManageMembergroups.template.php ➔ template_new_group()   C

Complexity

Conditions 12
Paths 24

Size

Total Lines 144
Code Lines 57

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 12
eloc 57
nc 24
nop 0
dl 0
loc 144
rs 5.034
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
 * @name      ElkArte Forum
5
 * @copyright ElkArte Forum contributors
6
 * @license   BSD http://opensource.org/licenses/BSD-3-Clause
7
 *
8
 * This file contains code covered by:
9
 * copyright:	2011 Simple Machines (http://www.simplemachines.org)
10
 * license:  	BSD, See included LICENSE.TXT for terms and conditions.
11
 *
12
 * @version 1.1
13
 *
14
 */
15
16
/**
17
 * Regular membergroups list template
18
 */
19
function template_regular_membergroups_list()
20
{
21
	template_show_list('regular_membergroups_list');
22
23
	echo '<br /><br />';
24
25
	template_show_list('post_count_membergroups_list');
26
}
27
28
/**
29
 * Template for a new group
30
 */
31
function template_new_group()
32
{
33
	global $context, $scripturl, $txt, $modSettings;
34
35
	echo '
36
	<div id="admincenter">
37
		<form id="admin_form_wrapper" name="new_group" action="', $scripturl, '?action=admin;area=membergroups;sa=add" method="post" accept-charset="UTF-8">
38
			<h2 class="category_header">', $txt['membergroups_new_group'], '</h2>
39
			<div class="content">
40
				<dl class="settings">
41
					<dt>
42
						<label for="group_name_input">', $txt['membergroups_group_name'], ':</label>
43
					</dt>
44
					<dd>
45
						<input type="text" name="group_name" id="group_name_input" size="30" class="input_text" />
46
					</dd>';
47
48
	if ($context['undefined_group'])
49
	{
50
		echo '
51
					<dt>
52
						<label for="group_type">', $txt['membergroups_edit_group_type'], ':</label>
53
					</dt>
54
					<dd>
55
						<fieldset id="group_type">
56
							<legend>', $txt['membergroups_edit_select_group_type'], '</legend>
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
			echo '
62
							<input type="radio" name="group_type" id="group_type_protected" value="1" onclick="swapPostGroup(0);" />
63
							<label for="group_type_protected">', $txt['membergroups_group_type_protected'], '</label><br />';
64
65
		echo '
66
							<input type="radio" name="group_type" id="group_type_request" value="2" onclick="swapPostGroup(0);" />
67
							<label for="group_type_request">', $txt['membergroups_group_type_request'], '</label><br />
68
69
							<input type="radio" name="group_type" id="group_type_free" value="3"  onclick="swapPostGroup(0);" />
70
							<label for="group_type_free">', $txt['membergroups_group_type_free'], '</label><br />
71
72
							<input type="radio" name="group_type" id="group_type_post" value="-1" onclick="swapPostGroup(1);" />
73
							<label for="group_type_post">', $txt['membergroups_group_type_post'], '</label><br />
74
						</fieldset>
75
					</dd>';
76
	}
77
78
	if ($context['post_group'] || $context['undefined_group'])
79
		echo '
80
					<dt id="min_posts_text">
81
						<label for="min_posts_input">', $txt['membergroups_min_posts'], ':</label>
82
					</dt>
83
					<dd>
84
						<input type="text" name="min_posts" id="min_posts_input" size="5" class="input_text" />
85
					</dd>';
86
87
	if (!$context['post_group'] || !empty($modSettings['permission_enable_postgroups']))
88
	{
89
		echo '
90
					<dt>
91
						<label for="permission_base">', $txt['membergroups_permissions'], ':</label><br />
92
						<span class="smalltext">', $txt['membergroups_can_edit_later'], '</span>
93
					</dt>
94
					<dd>
95
						<fieldset id="permission_base">
96
							<legend>', $txt['membergroups_select_permission_type'], '</legend>
97
							<input type="radio" name="perm_type" id="perm_type_inherit" value="inherit" checked="checked" />
98
							<label for="perm_type_inherit">', $txt['membergroups_new_as_inherit'], ':</label>
99
							<select name="inheritperm" id="inheritperm_select" onclick="document.getElementById(\'perm_type_inherit\').checked = true;">
100
								<option value="-1">', $txt['membergroups_guests'], '</option>
101
								<option value="0" selected="selected">', $txt['membergroups_members'], '</option>';
102
103
		foreach ($context['groups'] as $group)
104
			echo '
105
								<option value="', $group['id'], '">', $group['name'], '</option>';
106
107
		echo '
108
							</select>
109
							<br />
110
							<input type="radio" name="perm_type" id="perm_type_copy" value="copy" />
111
							<label for="perm_type_copy">', $txt['membergroups_new_as_copy'], ':</label>
112
							<select name="copyperm" id="copyperm_select" onclick="document.getElementById(\'perm_type_copy\').checked = true;">
113
								<option value="-1">', $txt['membergroups_guests'], '</option>
114
								<option value="0" selected="selected">', $txt['membergroups_members'], '</option>';
115
116
		foreach ($context['groups'] as $group)
117
			echo '
118
								<option value="', $group['id'], '">', $group['name'], '</option>';
119
120
		echo '
121
							</select>
122
							<br />
123
							<input type="radio" name="perm_type" id="perm_type_predefined" value="predefined" />
124
							<label for="perm_type_predefined">', $txt['membergroups_new_as_type'], ':</label>
125
							<select name="level" id="level_select" onclick="document.getElementById(\'perm_type_predefined\').checked = true;">
126
								<option value="restrict">', $txt['permitgroups_restrict'], '</option>
127
								<option value="standard" selected="selected">', $txt['permitgroups_standard'], '</option>
128
								<option value="moderator">', $txt['permitgroups_moderator'], '</option>
129
								<option value="maintenance">', $txt['permitgroups_maintenance'], '</option>
130
							</select>
131
						</fieldset>
132
					</dd>';
133
	}
134
135
	echo '
136
					<dt>
137
						<label>', $txt['membergroups_new_board'], ':</label>', $context['post_group'] ? '<br />
138
						<span class="smalltext" style="font-weight: normal;">' . $txt['membergroups_new_board_post_groups'] . '</span>' : '', '
139
					</dt>
140
					<dd>';
141
142
	template_add_edit_group_boards_list('new_group', false);
143
144
	echo '
145
					</dd>
146
				</dl>
147
				<div class="submitbutton">
148
					<input type="submit" value="', $txt['membergroups_add_group'], '" />
149
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
150
					<input type="hidden" name="', $context['admin-mmg_token_var'], '" value="', $context['admin-mmg_token'], '" />
151
				</div>
152
			</div>';
153
154
	if ($context['undefined_group'])
155
	{
156
		// Enable / disable the required posts box when the group type is post based
157
		echo '
158
			<script>
159
				function swapPostGroup(isChecked)
160
				{
161
					var min_posts_text = document.getElementById(\'min_posts_text\');
162
163
					document.getElementById(\'min_posts_input\').disabled = !isChecked;
164
					min_posts_text.style.color = isChecked ? "" : "#888";
165
				}
166
167
				swapPostGroup(', $context['post_group'] ? 'true' : 'false', ');
168
			</script>';
169
	}
170
171
	echo '
172
		</form>
173
	</div>';
174
}
175
176
/**
177
 * Template edit group
178
 */
179
function template_edit_group()
180
{
181
	global $context, $settings, $scripturl, $txt;
182
183
	echo '
184
	<div id="admincenter">
185
		<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" >
186
			<h2 class="category_header">', $txt['membergroups_edit_group'], ' - ', $context['group']['name'], '</h2>
187
			<div class="content">
188
				<dl class="settings">
189
					<dt>
190
						<label for="group_name_input">', $txt['membergroups_edit_name'], ':</label>
191
					</dt>
192
					<dd>
193
						<input type="text" name="group_name" id="group_name_input" value="', $context['group']['editable_name'], '" size="30" class="input_text" />
194
					</dd>';
195
196
	if ($context['group']['id'] != 3 && $context['group']['id'] != 4)
197
		echo '
198
					<dt id="group_desc_text">
199
						<label for="group_desc_input">', $txt['membergroups_edit_desc'], ':</label>
200
					</dt>
201
					<dd>
202
						<textarea name="group_desc" id="group_desc_input" rows="4" cols="40">', $context['group']['description'], '</textarea>
203
					</dd>';
204
205
	// Group type...
206
	if ($context['group']['allow_post_group'])
207
	{
208
		echo '
209
					<dt>
210
						<label for="group_type">', $txt['membergroups_edit_group_type'], ':</label>
211
					</dt>
212
					<dd>
213
						<fieldset id="group_type">
214
							<legend>', $txt['membergroups_edit_select_group_type'], '</legend>
215
							<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);" />
216
							<label for="group_type_private">', $txt['membergroups_group_type_private'], '</label><br />';
217
218
		if ($context['group']['allow_protected'])
219
			echo '
220
							<input type="radio" name="group_type" id="group_type_protected" value="1" ', $context['group']['type'] == 1 ? 'checked="checked"' : '', ' onclick="swapPostGroup(0);" />
221
							<label for="group_type_protected">', $txt['membergroups_group_type_protected'], '</label><br />';
222
223
224
		echo '
225
							<input type="radio" name="group_type" id="group_type_request" value="2" ', $context['group']['type'] == 2 ? 'checked="checked"' : '', ' onclick="swapPostGroup(0);" />
226
							<label for="group_type_request">', $txt['membergroups_group_type_request'], '</label><br />
227
							<input type="radio" name="group_type" id="group_type_free" value="3" ', $context['group']['type'] == 3 ? 'checked="checked"' : '', ' onclick="swapPostGroup(0);" />
228
							<label for="group_type_free">', $txt['membergroups_group_type_free'], '</label><br />
229
							<input type="radio" name="group_type" id="group_type_post" value="-1" ', $context['group']['is_post_group'] ? 'checked="checked"' : '', ' onclick="swapPostGroup(1);" />
230
							<label for="group_type_post">', $txt['membergroups_group_type_post'], '</label><br />
231
						</fieldset>
232
					</dd>';
233
	}
234
235
	if ($context['group']['id'] != 3 && $context['group']['id'] != 4)
236
		echo '
237
					<dt id="group_moderators_text">
238
						<label for="group_moderators">', $txt['moderators'], ':</label>
239
					</dt>
240
					<dd>
241
						<input type="text" name="group_moderators" id="group_moderators" value="', $context['group']['moderator_list'], '" size="30" class="input_text" />
242
						<div id="moderator_container"></div>
243
					</dd>
244
					<dt id="group_hidden_text">
245
						<label for="group_hidden_input">', $txt['membergroups_edit_hidden'], ':</label>
246
					</dt>
247
					<dd>
248
						<select name="group_hidden" id="group_hidden_input" onchange="if (this.value == 2 &amp;&amp; !confirm(\'', $txt['membergroups_edit_hidden_warning'], '\')) this.value = 0;">
249
							<option value="0" ', $context['group']['hidden'] ? '' : 'selected="selected"', '>', $txt['membergroups_edit_hidden_no'], '</option>
250
							<option value="1" ', $context['group']['hidden'] == 1 ? 'selected="selected"' : '', '>', $txt['membergroups_edit_hidden_boardindex'], '</option>
251
							<option value="2" ', $context['group']['hidden'] == 2 ? 'selected="selected"' : '', '>', $txt['membergroups_edit_hidden_all'], '</option>
252
						</select>
253
					</dd>';
254
255
	// Can they inherit permissions?
256
	if ($context['group']['id'] > 1 && $context['group']['id'] != 3)
257
	{
258
		echo '
259
					<dt id="group_inherit_text">
260
						<label for="group_inherit_input">', $txt['membergroups_edit_inherit_permissions'], '</label>:<br />
261
						<span class="smalltext">', $txt['membergroups_edit_inherit_permissions_desc'], '</span>
262
					</dt>
263
					<dd>
264
						<select name="group_inherit" id="group_inherit_input">
265
							<option value="-2">', $txt['membergroups_edit_inherit_permissions_no'], '</option>
266
							<option value="-1" ', $context['group']['inherited_from'] == -1 ? 'selected="selected"' : '', '>', $txt['membergroups_edit_inherit_permissions_from'], ': ', $txt['membergroups_guests'], '</option>
267
							<option value="0" ', $context['group']['inherited_from'] == 0 ? 'selected="selected"' : '', '>', $txt['membergroups_edit_inherit_permissions_from'], ': ', $txt['membergroups_members'], '</option>';
268
269
		// For all the inheritable groups show an option.
270
		foreach ($context['inheritable_groups'] as $id => $group)
271
			echo '
272
							<option value="', $id, '" ', $context['group']['inherited_from'] == $id ? 'selected="selected"' : '', '>', $txt['membergroups_edit_inherit_permissions_from'], ': ', $group, '</option>';
273
274
		echo '
275
						</select>
276
						<input type="hidden" name="old_inherit" value="', $context['group']['inherited_from'], '" />
277
					</dd>';
278
	}
279
280
	if ($context['group']['allow_post_group'])
281
		echo '
282
					<dt id="min_posts_text">
283
						<label for="min_posts_input">', $txt['membergroups_min_posts'], ':</label>
284
					</dt>
285
					<dd>
286
						<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" />
287
					</dd>';
288
289
	// Hide the online color for our local moderators group.
290
	if ($context['group']['id'] != 3)
291
		echo '
292
					<dt>
293
						<label for="online_color_input">', $txt['membergroups_online_color'], ':</label>
294
					</dt>
295
					<dd>
296
						<input type="text" name="online_color" id="online_color_input" value="', $context['group']['color'], '" size="20" class="input_text" />
297
					</dd>';
298
	echo '
299
					<dt>
300
						<label for="icon_count_input">', $txt['membergroups_icon_count'], ':</label>
301
					</dt>
302
					<dd>
303
						<input type="number" min="0" max="10" step="1" name="icon_count" id="icon_count_input" value="', $context['group']['icon_count'], '" size="4" 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" />
304
					</dd>
305
					<dt>
306
						<label for="icon_image_input">', $txt['membergroups_icon_image'], ':</label>
307
						<br />
308
						<span class="smalltext">', $txt['membergroups_icon_image_note'], '</span>
309
					</dt>
310
					<dd>
311
						<span class="floatleft">
312
							', $txt['membergroups_images_url'], '
313
							<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" />
314
						</span>
315
						<span id="messageicon_0" class="groupicon">
316
							<img id="msg_icon_0" src="', $settings['images_url'], '/group_icons/', $context['group']['icon_image'] == '' ? 'blank.png' : $context['group']['icon_image'], '" alt="*" />
317
						</span>
318
					</dd>
319
					<dt>
320
						<label for="max_messages_input">', $txt['membergroups_max_messages'], ':</label><br />
321
						<span class="smalltext">', $txt['membergroups_max_messages_note'], '</span>
322
					</dt>
323
					<dd>
324
						<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" />
325
					</dd>';
326
327
	if (!empty($context['categories']))
328
	{
329
		echo '
330
					<dt>
331
						<label>', $txt['membergroups_new_board'], ':</label>', $context['group']['is_post_group'] ? '<br />
332
						<span class="smalltext">' . $txt['membergroups_new_board_post_groups'] . '</span>' : '', '
333
					</dt>
334
					<dd>';
335
336
		template_add_edit_group_boards_list('groupForm', true);
337
338
		echo '
339
					</dd>';
340
	}
341
342
	echo '
343
				</dl>
344
				<div class="submitbutton">
345
					<input type="submit" name="save" value="', $txt['membergroups_edit_save'], '" />', $context['group']['allow_delete'] ? '
346
					<input type="submit" name="delete" value="' . $txt['membergroups_delete'] . '" onclick="return confirm(\'' . $txt['membergroups_confirm_delete'] . '\');" />' : '', '
347
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
348
					<input type="hidden" name="', $context['admin-mmg_token_var'], '" value="', $context['admin-mmg_token'], '" />
349
				</div>
350
			</div>
351
		</form>
352
	</div>';
353
354
	theme()->addInlineJavascript('
355
		aIconLists[aIconLists.length] = new IconList({
356
			sBackReference: "aIconLists[" + aIconLists.length + "]",
357
			sIconIdPrefix: "msg_icon_",
358
			bShowModify: false,
359
			sAction: "groupicons",
360
			sLabelIconList: ' . JavaScriptEscape($txt['membergroups_icons']) . ',
361
			sLabelIconBox: "icon_image_input",
362
			sBoxBackground: "transparent",
363
			sBoxBackgroundHover: "#fff",
364
			iBoxBorderWidthHover: 1,
365
			sBoxBorderColorHover: "#adadad",
366
			sContainerBackground: "#fff",
367
			sContainerBorder: "1px solid #adadad",
368
			sItemBorder: "1px solid #fff",
369
			sItemBorderHover: "1px dotted gray",
370
			sItemBackground: "transparent",
371
			sItemBackgroundHover: "#e0e0f0"
372
		});', true);
373
374
	if ($context['group']['id'] != 3 && $context['group']['id'] != 4)
375
	{
376
		$js = '
377
		new smc_AutoSuggest({
378
			sSessionId: elk_session_id,
379
			sSessionVar: elk_session_var,
380
			sSuggestId: \'group_moderators\',
381
			sControlId: \'group_moderators\',
382
			sSearchType: \'member\',
383
			bItemList: true,
384
			sPostName: \'moderator_list\',
385
			sURLMask: \'action=profile;u=%item_id%\',
386
			sTextDeleteItem: ' . ', JavaScriptEscape($txt['autosuggest_delete_item']), ' . ',
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING
Loading history...
387
			sItemListContainerId: \'moderator_container\',
388
			aListItems: [';
389
390
		foreach ($context['group']['moderators'] as $id_member => $member_name)
391
			$js .= '
392
						{
393
							sItemId: ' . JavaScriptEscape($id_member) . ',
394
							sItemName: ' . JavaScriptEscape($member_name) . '
395
						}' . $id_member == $context['group']['last_moderator_id'] ? '' : ',';
396
397
		$js .= '
398
			]
399
		});';
400
401
		theme()->addInlineJavascript($js, true);
402
	}
403
404
	// If post based is selected, disable moderation selection, visability, group description and enable post count,
405
	if ($context['group']['allow_post_group'])
406
		theme()->addInlineJavascript('swapPostGroup(' . ($context['group']['is_post_group'] ? 'true' : 'false') . ');', true);
407
}
408
409
/**
410
 * Template to edit the boards and groups access to them
411
 *
412
 * Accessed with ?action=admin;area=membergroups;sa=add
413
 *
414
 * @param int $form_id
415
 * @param bool $collapse
416
 */
417
function template_add_edit_group_boards_list($form_id, $collapse = true)
418
{
419
	global $context, $txt, $modSettings;
420
421
	$deny = !empty($modSettings['deny_boards_access']);
422
423
	echo '
424
							<fieldset class="visible_boards">
425
								<legend', $collapse ? ' data-collapsed="true"' : '', '>', $txt['membergroups_new_board_desc'], '</legend>
426
								<ul>';
427
428
	foreach ($context['categories'] as $category)
429
	{
430
		if (empty($deny))
431
			echo '
432
									<li class="category">
433
										<a href="javascript:void(0);" onclick="selectBoards([', implode(', ', $category['child_ids']), '], \'', $form_id, '\', \'boardaccess\'); return false;"><strong>', $category['name'], '</strong></a>
434
									<ul>';
435
		else
436
			echo '
437
									<li class="category">
438
										<strong>', $category['name'], '</strong>
439
										<ul id="boards_list_', $category['id'], '">';
440
441
		if (!empty($deny))
442
			echo '
443
										<li class="board select_category">
444
											', $txt['all_boards_in_cat'], ':
445
											<span class="floatright">
446
												<label for="all_sel_', $category['id'], '">
447
													<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'], '
448
												</label>
449
												<label for="all_ign_', $category['id'], '">
450
													<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'], '
451
												</label>
452
												<label for="all_den_', $category['id'], '">
453
													<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'], '
454
												</label>
455
											</span>
456
										</li>';
457
458
		foreach ($category['boards'] as $board)
459
		{
460
			if (empty($deny))
461
				echo '
462
										<li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">
463
											<input id="brd', $board['id'], '"  name="boardaccess[', $board['id'], ']" type="checkbox" value="allow" ', $board['allow'] ? ' checked="checked"' : '', ' />
464
											<label for="brd', $board['id'], '">', $board['name'], '</label>
465
										</li>';
466
			else
467
				echo '
468
										<li class="board">
469
											<span style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">', $board['name'], ': </span>
470
											<span class="floatright">
471
												<label for="allow_brd', $board['id'], '">
472
													<input type="radio" name="boardaccess[', $board['id'], ']" id="allow_brd', $board['id'], '" value="allow" ', $board['allow'] ? ' checked="checked"' : '', ' /> ', $txt['permissions_option_on'], '
473
												</label>
474
												<label for="ignore_brd', $board['id'], '">
475
													<input type="radio" name="boardaccess[', $board['id'], ']" id="ignore_brd', $board['id'], '" value="ignore" ', !$board['allow'] && !$board['deny'] ? ' checked="checked"' : '', ' /> ', $txt['permissions_option_off'], '
476
												</label>
477
												<label for="deny_brd', $board['id'], '">
478
													<input type="radio" name="boardaccess[', $board['id'], ']" id="deny_brd', $board['id'], '" value="deny" ', $board['deny'] ? ' checked="checked"' : '', ' /> ', $txt['permissions_option_deny'], '
479
												</label>
480
											</span>
481
										</li>';
482
		}
483
484
		echo '
485
									</ul>
486
								</li>';
487
	}
488
489
	echo '
490
							</ul>';
491
492
	if (empty($deny))
493
		echo '
494
								<br />
495
								<div class="select_all_box">
496
									<input id="checkall_check" type="checkbox" onclick="invertAll(this, this.form, \'boardaccess\');" />
497
									<label for="checkall_check"><em>', $txt['check_all'], '</em></label>
498
								</div>';
499
	else
500
		echo '
501
								<div class="select_all_box">
502
									', $txt['all'], ':
503
									<span class="floatright">
504
										<label for="all_', $category['id'], '">
505
											<input type="radio" name="select_all" id="allow_all" onclick="selectAllRadio(this, this.form, \'boardaccess\', \'allow\');" /> ', $txt['board_perms_allow'], '
506
										</label>
507
										<label for="all_', $category['id'], '">
508
											<input type="radio" name="select_all" id="ignore_all" onclick="selectAllRadio(this, this.form, \'boardaccess\', \'ignore\');" /> ', $txt['board_perms_ignore'], '
509
										</label>
510
										<label for="all_', $category['id'], '">
511
											<input type="radio" name="select_all" id="deny_all" onclick="selectAllRadio(this, this.form, \'boardaccess\', \'deny\');" /> ', $txt['board_perms_deny'], '
512
										</label>
513
									</span>
514
								</div>';
515
516
	// select_all_box is hidden and it's made available only if js is enabled
517
	echo '
518
							</fieldset>
519
							<script>
520
								$(function() {
521
									$(".select_all_box").each(function () {
522
										$(this).show();
523
									});
524
								});
525
							</script>';
526
}
527
528
/**
529
 * Template for viewing the members of a group.
530
 */
531
function template_group_members()
532
{
533
	global $context, $scripturl, $txt;
534
535
	echo '
536
	<div id="admincenter">
537
		<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">
538
			<h2 class="category_header">', $context['page_title'], '</h2>
539
				<div class="content">
540
				<dl class="settings">
541
					<dt>
542
						<label>', $txt['name'], ':</label>
543
					</dt>
544
					<dd>
545
						<span ', $context['group']['online_color'] ? 'style="color: ' . $context['group']['online_color'] . ';"' : '', '>', $context['group']['name'], '</span> ', $context['group']['icons'], '
546
					</dd>';
547
548
	// Any description to show?
549
	if (!empty($context['group']['description']))
550
		echo '
551
					<dt>
552
						<label>' . $txt['membergroups_members_description'] . ':</label>
553
					</dt>
554
					<dd>
555
						', $context['group']['description'], '
556
					</dd>';
557
558
	echo '
559
					<dt>
560
						<label>', $txt['membergroups_members_top'], ':</label>
561
					</dt>
562
					<dd>
563
						', $context['total_members'], '
564
					</dd>';
565
566
	// Any group moderators to show?
567
	if (!empty($context['group']['moderators']))
568
	{
569
		$moderators = array();
570
		foreach ($context['group']['moderators'] as $moderator)
571
			$moderators[] = '<a href="' . $scripturl . '?action=profile;u=' . $moderator['id'] . '">' . $moderator['name'] . '</a>';
572
573
		echo '
574
					<dt>
575
						<label>', $txt['membergroups_members_group_moderators'], ':</<label>
576
					</dt>
577
					<dd>
578
						', implode(', ', $moderators), '
579
					</dd>';
580
	}
581
582
	echo '
583
				</dl>
584
			</div>
585
			<h2 class="category_header">', $txt['membergroups_members_group_members'], '</h2>
586
			', template_pagesection(), '
587
			<table class="table_grid">
588
				<thead>
589
					<tr class="table_head">
590
						<th><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></th>';
591
592
	if ($context['can_send_email'])
593
		echo '
594
						<th><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></th>';
595
596
	echo '
597
						<th><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></th>
598
						<th><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></th>
599
						<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>';
600
601
	if (!empty($context['group']['assignable']))
602
		echo '
603
						<th style="width: 4%;"><input type="checkbox" onclick="invertAll(this, this.form);" /></th>';
604
605
	echo '
606
					</tr>
607
				</thead>
608
				<tbody>';
609
610
	if (empty($context['members']))
611
		echo '
612
					<tr>
613
						<td colspan="6" class="centertext">', $txt['membergroups_members_no_members'], '</td>
614
					</tr>';
615
616
	foreach ($context['members'] as $member)
617
	{
618
		echo '
619
					<tr>
620
						<td>', $member['name'], '</td>';
621
622
		if ($context['can_send_email'])
623
		{
624
			echo '
625
						<td class="centertext"><em>' . template_member_email($member, true) . '</em></td>';
626
		}
627
628
		echo '
629
						<td>', $member['last_online'], '</td>
630
						<td>', $member['registered'], '</td>
631
						<td', empty($context['group']['assignable']) ? ' colspan="2"' : '', '>', $member['posts'], '</td>';
632
633
		if (!empty($context['group']['assignable']))
634
			echo '
635
						<td class="centertext" style="width: 4%;">
636
							<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'] . '\')" ' : ''), '/>
637
						</td>';
638
639
		echo '
640
					</tr>';
641
	}
642
643
	echo '
644
				</tbody>
645
			</table>';
646
647
			template_pagesection(false, '', array('extra' => '<div class="floatright"><input type="submit" name="remove" value="' . $txt['membergroups_members_remove'] . '" /></div>'));
648
649
	if (!empty($context['group']['assignable']))
650
	{
651
		echo '
652
			<div class="separator">
653
				<h2 class="category_header">', $txt['membergroups_members_add_title'], '</h2>
654
				<div class="content">
655
					<dl class="settings">
656
						<dt>
657
							<label for="toAdd">', $txt['membergroups_members_add_desc'], ':</label>
658
						</dt>
659
						<dd>
660
							<input type="text" name="toAdd" id="toAdd" value="" class="input_text" />
661
							<div id="toAddItemContainer"></div>
662
						</dd>
663
					</dl>
664
					<div class="submitbutton">
665
						<input type="submit" name="add" value="', $txt['membergroups_members_add'], '" />
666
					</div>
667
				</div>
668
			</div>';
669
	}
670
671
	echo '
672
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
673
			<input type="hidden" name="', $context['mod-mgm_token_var'], '" value="', $context['mod-mgm_token'], '" />
674
		</form>
675
	</div>';
676
677
	if (!empty($context['group']['assignable']))
678
		theme()->addInlineJavascript('
679
		new smc_AutoSuggest({
680
			sSessionId: elk_session_id,
681
			sSessionVar: elk_session_var,
682
			sSuggestId: \'to_suggest\',
683
			sControlId: \'toAdd\',
684
			sSearchType: \'member\',
685
			sPostName: \'member_add\',
686
			sURLMask: \'action=profile;u=%item_id%\',
687
			sTextDeleteItem: ' . JavaScriptEscape($txt['autosuggest_delete_item']) . ',
688
			bItemList: true,
689
			sItemListContainerId: \'toAddItemContainer\'
690
		});', true);
691
}
692
693
/**
694
 * Allow the moderator to enter a reason to each user being rejected.
695
 */
696
function template_group_request_reason()
697
{
698
	global $context, $txt, $scripturl;
699
700
	// Show a welcome message to the user.
701
	echo '
702
	<div id="moderationcenter">
703
		<form action="', $scripturl, '?action=groups;sa=requests" method="post" accept-charset="UTF-8">
704
			<h2 class="category_header">', $txt['mc_groups_reason_title'], '</h2>
705
			<div class="content">
706
				<dl class="settings">';
707
708
	// Loop through and print out a reason box for each...
709
	foreach ($context['group_requests'] as $request)
710
		echo '
711
					<dt>
712
						<label for="groupreason">', sprintf($txt['mc_groupr_reason_desc'], $request['member_link'], $request['group_link']), ':</label>
713
					</dt>
714
					<dd>
715
						<input type="hidden" name="groupr[]" value="', $request['id'], '" />
716
						<textarea id="groupreason" name="groupreason[', $request['id'], ']" rows="3" cols="40" style="min-width: 80%; max-width: 99%;"></textarea>
717
					</dd>';
718
719
	echo '
720
				</dl>
721
				<div class="submitbutton">
722
					<input type="submit" name="go" value="', $txt['mc_groupr_submit'], '" />
723
					<input type="hidden" name="req_action" value="got_reason" />
724
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
725
					<input type="hidden" name="', $context['mod-gr_token_var'], '" value="', $context['mod-gr_token'], '" />
726
				</div>
727
			</div>
728
		</form>
729
	</div>';
730
}
731