Project

General

Profile

Download (14.3 KB) Statistics
| Branch: | Tag: | Revision:
1 4c291f4c Renato Botelho
<?php
2 fab7ff44 Bill Marquette
/*
3 919d91f9 Phil Davis
	system_groupmanager.php
4 fab7ff44 Bill Marquette
*/
5 f74457df Stephen Beaver
/* ====================================================================
6
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
7 cb41dd63 Renato Botelho
 *	Copyright (c)  2005 Paul Taylor <paultaylor@winn-dixie.com>
8
 *	Copyright (c)  2008 Shrew Soft Inc
9 191cb31d Stephen Beaver
 *
10 cb41dd63 Renato Botelho
 *	Some or all of this file is based on the m0n0wall project which is
11
 *	Copyright (c)  2004 Manuel Kasper (BSD 2 clause)
12 f74457df Stephen Beaver
 *
13
 *	Redistribution and use in source and binary forms, with or without modification,
14
 *	are permitted provided that the following conditions are met:
15
 *
16
 *	1. Redistributions of source code must retain the above copyright notice,
17
 *		this list of conditions and the following disclaimer.
18
 *
19
 *	2. Redistributions in binary form must reproduce the above copyright
20
 *		notice, this list of conditions and the following disclaimer in
21
 *		the documentation and/or other materials provided with the
22
 *		distribution.
23
 *
24
 *	3. All advertising materials mentioning features or use of this software
25
 *		must display the following acknowledgment:
26
 *		"This product includes software developed by the pfSense Project
27
 *		 for use in the pfSense software distribution. (http://www.pfsense.org/).
28
 *
29
 *	4. The names "pfSense" and "pfSense Project" must not be used to
30
 *		 endorse or promote products derived from this software without
31
 *		 prior written permission. For written permission, please contact
32
 *		 coreteam@pfsense.org.
33
 *
34
 *	5. Products derived from this software may not be called "pfSense"
35
 *		nor may "pfSense" appear in their names without prior written
36
 *		permission of the Electric Sheep Fencing, LLC.
37
 *
38
 *	6. Redistributions of any form whatsoever must retain the following
39
 *		acknowledgment:
40
 *
41
 *	"This product includes software developed by the pfSense Project
42
 *	for use in the pfSense software distribution (http://www.pfsense.org/).
43
 *
44
 *	THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
45
 *	EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46
 *	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
47
 *	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
48
 *	ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
49
 *	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
50
 *	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
51
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52
 *	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
53
 *	STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
54
 *	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
55
 *	OF THE POSSIBILITY OF SUCH DAMAGE.
56
 *
57
 *	====================================================================
58
 *
59
 */
60 fab7ff44 Bill Marquette
61 6b07c15a Matthew Grooms
##|+PRIV
62
##|*IDENT=page-system-groupmanager
63 5230f468 jim-p
##|*NAME=System: Group manager
64 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'System: Group manager' page.
65
##|*MATCH=system_groupmanager.php*
66
##|-PRIV
67 fab7ff44 Bill Marquette
68 c81ef6e2 Phil Davis
require_once("guiconfig.inc");
69 d88c6a9f Scott Ullrich
70 e0c7b2fe Phil Davis
if (!is_array($config['system']['group'])) {
71 6b07c15a Matthew Grooms
	$config['system']['group'] = array();
72 e0c7b2fe Phil Davis
}
73 d81c2ad1 Scott Ullrich
74 6b07c15a Matthew Grooms
$a_group = &$config['system']['group'];
75 d81c2ad1 Scott Ullrich
76 7ea27b0d Renato Botelho
unset($id);
77 06683083 Stephen Beaver
78 e0c7b2fe Phil Davis
if (isset($_POST['groupid']) && is_numericint($_POST['groupid'])) {
79 7ea27b0d Renato Botelho
	$id = $_POST['groupid'];
80 e0c7b2fe Phil Davis
}
81 d81c2ad1 Scott Ullrich
82 2f1e91e4 Stephen Beaver
if (isset($_GET['groupid']) && is_numericint($_GET['groupid'])) {
83
	$id = $_GET['groupid'];
84
}
85
86
$act = (isset($_GET['act']) ? $_GET['act'] : '');
87 31b53653 Scott Ullrich
88 06683083 Stephen Beaver
function cpusercmp($a, $b) {
89
	return strcasecmp($a['name'], $b['name']);
90
}
91 23d09a2e Stephen Beaver
92 06683083 Stephen Beaver
function admin_groups_sort() {
93
	global $a_group;
94
95
	if (!is_array($a_group)) {
96
		return;
97
	}
98
99
	usort($a_group, "cpusercmp");
100
}
101
102 7ea27b0d Renato Botelho
if ($act == "delgroup") {
103
104 2f1e91e4 Stephen Beaver
	if (!isset($id) || !isset($_GET['groupname']) || !isset($a_group[$id]) || ($_GET['groupname'] != $a_group[$id]['name'])) {
105 6b07c15a Matthew Grooms
		pfSenseHeader("system_groupmanager.php");
106
		exit;
107
	}
108 31b53653 Scott Ullrich
109 920dbb26 Renato Botelho
	conf_mount_rw();
110 7ea27b0d Renato Botelho
	local_group_del($a_group[$id]);
111 920dbb26 Renato Botelho
	conf_mount_ro();
112 7ea27b0d Renato Botelho
	$groupdeleted = $a_group[$id]['name'];
113
	unset($a_group[$id]);
114 6b07c15a Matthew Grooms
	write_config();
115 8545adde k-paulius
	$savemsg = sprintf(gettext("Group %s successfully deleted."), $groupdeleted);
116 fab7ff44 Bill Marquette
}
117 d88c6a9f Scott Ullrich
118 7ea27b0d Renato Botelho
if ($act == "delpriv") {
119 6b07c15a Matthew Grooms
120 7ea27b0d Renato Botelho
	if (!isset($id) || !isset($a_group[$id])) {
121 6b07c15a Matthew Grooms
		pfSenseHeader("system_groupmanager.php");
122
		exit;
123
	}
124 fab7ff44 Bill Marquette
125 7ea27b0d Renato Botelho
	$privdeleted = $priv_list[$a_group[$id]['priv'][$_POST['privid']]]['name'];
126 2f1e91e4 Stephen Beaver
	unset($a_group[$id]['priv'][$_GET['privid']]);
127 6b07c15a Matthew Grooms
128 2ee08031 Erik Fonnesbeck
	if (is_array($a_group[$id]['member'])) {
129
		foreach ($a_group[$id]['member'] as $uid) {
130
			$user = getUserEntryByUID($uid);
131 e0c7b2fe Phil Davis
			if ($user) {
132 2ee08031 Erik Fonnesbeck
				local_user_set($user);
133 64600f94 Sjon Hortensius
			}
134 2ee08031 Erik Fonnesbeck
		}
135 64600f94 Sjon Hortensius
	}
136 45ee90ed Matthew Grooms
137 6b07c15a Matthew Grooms
	write_config();
138 7ea27b0d Renato Botelho
	$act = "edit";
139 8545adde k-paulius
	$savemsg = sprintf(gettext("Privilege %s successfully deleted."), $privdeleted);
140 6b07c15a Matthew Grooms
}
141 45ee90ed Matthew Grooms
142 7ea27b0d Renato Botelho
if ($act == "edit") {
143
	if (isset($id) && isset($a_group[$id])) {
144 45ee90ed Matthew Grooms
		$pconfig['name'] = $a_group[$id]['name'];
145 6b07c15a Matthew Grooms
		$pconfig['gid'] = $a_group[$id]['gid'];
146 79ed8ce0 Stephen Beaver
		$pconfig['gtype'] = empty($a_group[$id]['scope']) ? "local" : $a_group[$id]['scope'];
147 45ee90ed Matthew Grooms
		$pconfig['description'] = $a_group[$id]['description'];
148 6b07c15a Matthew Grooms
		$pconfig['members'] = $a_group[$id]['member'];
149
		$pconfig['priv'] = $a_group[$id]['priv'];
150 45ee90ed Matthew Grooms
	}
151
}
152 6b07c15a Matthew Grooms
153 2f1e91e4 Stephen Beaver
if (isset($_GET['dellall_x'])) {
154 c0c5b8cc bruno
155 2f1e91e4 Stephen Beaver
	$del_groups = $_GET['delete_check'];
156 c0c5b8cc bruno
157 e0c7b2fe Phil Davis
	if (!empty($del_groups)) {
158
		foreach ($del_groups as $groupid) {
159
			if (isset($a_group[$groupid]) && $a_group[$groupid]['scope'] != "system") {
160 c0c5b8cc bruno
				conf_mount_rw();
161
				local_group_del($a_group[$groupid]);
162
				conf_mount_ro();
163
				unset($a_group[$groupid]);
164
			}
165
		}
166 8545adde k-paulius
		$savemsg = gettext("Selected groups removed successfully.");
167 c0c5b8cc bruno
		write_config($savemsg);
168
	}
169
}
170
171 7ea27b0d Renato Botelho
if (isset($_POST['save'])) {
172 d88c6a9f Scott Ullrich
	unset($input_errors);
173
	$pconfig = $_POST;
174
175
	/* input validation */
176
	$reqdfields = explode(" ", "groupname");
177 b4fd804b Carlos Eduardo Ramos
	$reqdfieldsn = array(gettext("Group Name"));
178 4c291f4c Renato Botelho
179 1e9b4611 Renato Botelho
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
180 4c291f4c Renato Botelho
181 d7689b2c Stephen Beaver
	if ($_POST['gtype'] != "remote") {
182 79ed8ce0 Stephen Beaver
		if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['groupname'])) {
183 d7689b2c Stephen Beaver
			$input_errors[] = sprintf(gettext("The (%s) group name contains invalid characters."), $_POST['gtype']);
184 79ed8ce0 Stephen Beaver
		}
185
	} else {
186
		if (preg_match("/[^a-zA-Z0-9\.\- _]/", $_POST['groupname'])) {
187 d7689b2c Stephen Beaver
			$input_errors[] = sprintf(gettext("The (%s) group name contains invalid characters."), $_POST['gtype']);
188 79ed8ce0 Stephen Beaver
		}
189 e0c7b2fe Phil Davis
	}
190 4c291f4c Renato Botelho
191 e0c7b2fe Phil Davis
	if (strlen($_POST['groupname']) > 16) {
192 3db408b3 PiBa-NL
		$input_errors[] = gettext("The group name is longer than 16 characters.");
193 e0c7b2fe Phil Davis
	}
194 4c291f4c Renato Botelho
195 5bef2407 jim-p
	/* Check the POSTed members to ensure they are valid and exist */
196 9f472202 NewEraCracker
	if(is_array($_POST['members'])) {
197
		foreach ($_POST['members'] as $newmember) {
198
			if (!is_numeric($newmember) || empty(getUserEntryByUID($newmember))) {
199
				$input_errors[] = gettext("One or more invalid group members was submitted.");
200
			}
201 5bef2407 jim-p
		}
202
	}
203
204 d88c6a9f Scott Ullrich
	if (!$input_errors && !(isset($id) && $a_group[$id])) {
205
		/* make sure there are no dupes */
206
		foreach ($a_group as $group) {
207
			if ($group['name'] == $_POST['groupname']) {
208 bbf825ab Vinicius Coque
				$input_errors[] = gettext("Another entry with the same group name already exists.");
209 d88c6a9f Scott Ullrich
				break;
210
			}
211
		}
212
	}
213 4c291f4c Renato Botelho
214 d88c6a9f Scott Ullrich
	if (!$input_errors) {
215 45ee90ed Matthew Grooms
		$group = array();
216 e0c7b2fe Phil Davis
		if (isset($id) && $a_group[$id]) {
217 d88c6a9f Scott Ullrich
			$group = $a_group[$id];
218 e0c7b2fe Phil Davis
		}
219 4c291f4c Renato Botelho
220 d88c6a9f Scott Ullrich
		$group['name'] = $_POST['groupname'];
221
		$group['description'] = $_POST['description'];
222 79ed8ce0 Stephen Beaver
		$group['scope'] = $_POST['gtype'];
223 45ee90ed Matthew Grooms
224 e0c7b2fe Phil Davis
		if (empty($_POST['members'])) {
225 70d6b5c4 Ermal
			unset($group['member']);
226 e0c7b2fe Phil Davis
		} else if ($group['gid'] != 1998) { // all group
227 6b07c15a Matthew Grooms
			$group['member'] = $_POST['members'];
228 e0c7b2fe Phil Davis
		}
229 45ee90ed Matthew Grooms
230 e0c7b2fe Phil Davis
		if (isset($id) && $a_group[$id]) {
231 d88c6a9f Scott Ullrich
			$a_group[$id] = $group;
232 e0c7b2fe Phil Davis
		} else {
233 45ee90ed Matthew Grooms
			$group['gid'] = $config['system']['nextgid']++;
234 d88c6a9f Scott Ullrich
			$a_group[] = $group;
235 45ee90ed Matthew Grooms
		}
236
237 06683083 Stephen Beaver
		admin_groups_sort();
238
239 920dbb26 Renato Botelho
		conf_mount_rw();
240 659fa7f2 Matthew Grooms
		local_group_set($group);
241 920dbb26 Renato Botelho
		conf_mount_ro();
242 2a0e8512 jim-p
243
		/* Refresh users in this group since their privileges may have changed. */
244 5709072a jim-p
		if (is_array($group['member'])) {
245
			$a_user = &$config['system']['user'];
246
			foreach ($a_user as & $user) {
247 e0c7b2fe Phil Davis
				if (in_array($user['uid'], $group['member'])) {
248 5709072a jim-p
					local_user_set($user);
249 e0c7b2fe Phil Davis
				}
250 5709072a jim-p
			}
251 2a0e8512 jim-p
		}
252
253 d88c6a9f Scott Ullrich
		write_config();
254 4c291f4c Renato Botelho
255 d88c6a9f Scott Ullrich
		header("Location: system_groupmanager.php");
256
		exit;
257
	}
258 23d09a2e Stephen Beaver
259
	$pconfig['name'] = $_POST['groupname'];
260 fab7ff44 Bill Marquette
}
261
262 2f1e91e4 Stephen Beaver
function build_priv_table() {
263
	global $a_group, $id;
264
265
	$privhtml = '<div class="table-responsive">';
266
	$privhtml .=	'<table class="table table-striped table-hover table-condensed">';
267
	$privhtml .=		'<thead>';
268 70da45c9 NOYB
	$privhtml .=			'<tr>';
269
	$privhtml .=				'<th>' . gettext('Name') . '</th>';
270
	$privhtml .=				'<th>' . gettext('Description') . '</th>';
271
	$privhtml .=				'<th>' . gettext('Action') . '</th>';
272
	$privhtml .=			'</tr>';
273 2f1e91e4 Stephen Beaver
	$privhtml .=		'</thead>';
274
	$privhtml .=		'<tbody>';
275
276
	foreach (get_user_privdesc($a_group[$id]) as $i => $priv) {
277
		$privhtml .=		'<tr>';
278
		$privhtml .=			'<td>' . htmlspecialchars($priv['name']) . '</td>';
279
		$privhtml .=			'<td>' . htmlspecialchars($priv['descr']) . '</td>';
280 ed10e389 Phil Davis
		$privhtml .=			'<td><a class="fa fa-trash" title="' . gettext('Delete Privilege') . '"	href="system_groupmanager.php?act=delpriv&amp;groupid=' . $id . '&amp;privid=' . $i . '"></a></td>';
281 2f1e91e4 Stephen Beaver
		$privhtml .=		'</tr>';
282 d61309a0 Phil Davis
283 2f1e91e4 Stephen Beaver
	}
284
285
	$privhtml .=		'</tbody>';
286
	$privhtml .=	'</table>';
287
	$privhtml .= '</div>';
288
289
	$privhtml .= '<nav class="action-buttons">';
290 37676f4e jim-p
	$privhtml .=	'<a href="system_groupmanager_addprivs.php?groupid=' . $id . '" class="btn btn-success"><i class="fa fa-plus icon-embed-btn"></i>' . gettext("Add") . '</a>';
291 2f1e91e4 Stephen Beaver
	$privhtml .= '</nav>';
292
293
	return($privhtml);
294
}
295
296 8f1ab2a4 k-paulius
$pgtitle = array(gettext("System"), gettext("User Manager"), gettext("Groups"));
297
298
if ($act == "new" || $act == "edit") {
299
	$pgtitle[] = gettext('Edit');
300
}
301 23d09a2e Stephen Beaver
302 fab7ff44 Bill Marquette
include("head.inc");
303
304 d61309a0 Phil Davis
if ($input_errors) {
305 64600f94 Sjon Hortensius
	print_input_errors($input_errors);
306 d61309a0 Phil Davis
}
307 23d09a2e Stephen Beaver
308 d61309a0 Phil Davis
if ($savemsg) {
309 f78bbe16 Phil Davis
	print_info_box($savemsg, 'success');
310 d61309a0 Phil Davis
}
311 64600f94 Sjon Hortensius
312
$tab_array = array();
313
$tab_array[] = array(gettext("Users"), false, "system_usermanager.php");
314
$tab_array[] = array(gettext("Groups"), true, "system_groupmanager.php");
315
$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
316 2d1f33d9 k-paulius
$tab_array[] = array(gettext("Authentication Servers"), false, "system_authservers.php");
317 64600f94 Sjon Hortensius
display_top_tabs($tab_array);
318
319 d61309a0 Phil Davis
if (!($_GET['act'] == "new" || $_GET['act'] == "edit")) {
320 64600f94 Sjon Hortensius
?>
321 060ed238 Stephen Beaver
<div class="panel panel-default">
322
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('Groups')?></h2></div>
323
	<div class="panel-body">
324
		<div class="table-responsive">
325
			<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
326
				<thead>
327
					<tr>
328
						<th><?=gettext("Group name")?></th>
329
						<th><?=gettext("Description")?></th>
330
						<th><?=gettext("Member Count")?></th>
331
						<th><?=gettext("Actions")?></th>
332
					</tr>
333
				</thead>
334
				<tbody>
335 64600f94 Sjon Hortensius
<?php
336 d61309a0 Phil Davis
	foreach ($a_group as $i => $group):
337
		if ($group["name"] == "all") {
338 64600f94 Sjon Hortensius
			$groupcount = count($config['system']['user']);
339 d61309a0 Phil Davis
		} else {
340 64600f94 Sjon Hortensius
			$groupcount = count($group['member']);
341 d61309a0 Phil Davis
		}
342 64600f94 Sjon Hortensius
?>
343 060ed238 Stephen Beaver
					<tr>
344
						<td>
345
							<?=htmlspecialchars($group['name'])?>
346
						</td>
347
						<td>
348
							<?=htmlspecialchars($group['description'])?>
349
						</td>
350
						<td>
351
							<?=$groupcount?>
352
						</td>
353
						<td>
354
							<a class="fa fa-pencil" title="<?=gettext("Edit group"); ?>" href="?act=edit&amp;groupid=<?=$i?>"></a>
355
							<?php if ($group['scope'] != "system"): ?>
356
								<a class="fa fa-trash"	title="<?=gettext("Delete group")?>" href="?act=delgroup&amp;groupid=<?=$i?>&amp;groupname=<?=$group['name']?>"></a>
357
							<?php endif;?>
358
						</td>
359
					</tr>
360 64600f94 Sjon Hortensius
<?php
361
	endforeach;
362 fab7ff44 Bill Marquette
?>
363 060ed238 Stephen Beaver
				</tbody>
364
			</table>
365
		</div>
366 94404d94 Sander van Leeuwen
	</div>
367 060ed238 Stephen Beaver
</div>
368
369
<nav class="action-buttons">
370
	<a href="?act=new" class="btn btn-success btn-sm">
371
		<i class="fa fa-plus icon-embed-btn"></i>
372
		<?=gettext("Add")?>
373
	</a>
374
</nav>
375 64600f94 Sjon Hortensius
<?php
376
	include('foot.inc');
377
	exit;
378 6b07c15a Matthew Grooms
}
379
380 64600f94 Sjon Hortensius
$form = new Form;
381
$form->setAction('system_groupmanager.php?act=edit');
382
$form->addGlobal(new Form_Input(
383
	'groupid',
384
	null,
385
	'hidden',
386
	$id
387
));
388
389
if (isset($id) && $a_group[$id]){
390
	$form->addGlobal(new Form_Input(
391
		'id',
392
		null,
393
		'hidden',
394
		$id
395
	));
396
397
	$form->addGlobal(new Form_Input(
398
		'gid',
399
		null,
400
		'hidden',
401
		$pconfig['gid']
402
	));
403 61dec0b0 Renato Botelho
}
404
405 5f88f964 k-paulius
$section = new Form_Section('Group Properties');
406 82833610 Stephen Beaver
407 e6acc2ee Sjon Hortensius
$section->addInput($input = new Form_Input(
408 64600f94 Sjon Hortensius
	'groupname',
409
	'Group name',
410
	'text',
411
	$pconfig['name']
412
));
413
414 d61309a0 Phil Davis
if ($pconfig['gtype'] == "system") {
415 1192840b Sjon Hortensius
	$input->setReadonly();
416 79ed8ce0 Stephen Beaver
417
	$section->addInput(new Form_Input(
418
		'gtype',
419
		'Scope',
420
		'text',
421
		$pconfig['gtype']
422
	))->setReadonly();
423
} else {
424
	$section->addInput(new Form_Select(
425
		'gtype',
426
		'Scope',
427
		$pconfig['gtype'],
428 82833610 Stephen Beaver
		["local" => gettext("Local"), "remote" => gettext("Remote")]
429 79ed8ce0 Stephen Beaver
	));
430 d61309a0 Phil Davis
}
431 e6acc2ee Sjon Hortensius
432 64600f94 Sjon Hortensius
$section->addInput(new Form_Input(
433
	'description',
434
	'Description',
435
	'text',
436
	$pconfig['description']
437 89140b63 NOYB
))->setHelp('Group description, for administrative information only');
438 64600f94 Sjon Hortensius
439 79ed8ce0 Stephen Beaver
440 64600f94 Sjon Hortensius
$form->add($section);
441 d61309a0 Phil Davis
if ($pconfig['gid'] != 1998) { // all users group
442
443 2f1e91e4 Stephen Beaver
	// ==== Group membership ==================================================
444
	$group = new Form_Group('Group membership');
445
446
	// Make a list of all the groups configured on the system, and a list of
447
	// those which this user is a member of
448
	$systemGroups = array();
449
	$usersGroups = array();
450
451
	foreach ($config['system']['user'] as $user) {
452 d61309a0 Phil Davis
		if (is_array($pconfig['members']) && in_array($user['uid'], $pconfig['members'])) {
453 2f1e91e4 Stephen Beaver
			$usersGroups[ $user['uid'] ] = $user['name'];	// Add it to the user's list
454 d61309a0 Phil Davis
		} else {
455 2f1e91e4 Stephen Beaver
			$systemGroups[ $user['uid'] ] = $user['name']; // Add it to the 'not a member of' list
456 d61309a0 Phil Davis
		}
457 2f1e91e4 Stephen Beaver
	}
458
459
	$group->add(new Form_Select(
460
		'notmembers',
461
		null,
462
		array_combine((array)$pconfig['groups'], (array)$pconfig['groups']),
463
		$systemGroups,
464
		true
465 6ef8f2e9 heper
	))->setHelp('Not members');
466 64600f94 Sjon Hortensius
467 2f1e91e4 Stephen Beaver
	$group->add(new Form_Select(
468 64600f94 Sjon Hortensius
		'members',
469 2f1e91e4 Stephen Beaver
		null,
470
		array_combine((array)$pconfig['groups'], (array)$pconfig['groups']),
471
		$usersGroups,
472 64600f94 Sjon Hortensius
		true
473 6ef8f2e9 heper
	))->setHelp('Members');
474 2f1e91e4 Stephen Beaver
475
	$section->add($group);
476
477
	$group = new Form_Group('');
478
479
	$group->add(new Form_Button(
480
		'movetoenabled',
481 faab522f Renato Botelho
		'Move to "Members"',
482 37676f4e jim-p
		null,
483
		'fa-angle-double-right'
484 347c0214 Phil Davis
	))->setAttribute('type','button')->removeClass('btn-primary')->addClass('btn-info btn-sm');
485 2f1e91e4 Stephen Beaver
486
	$group->add(new Form_Button(
487
		'movetodisabled',
488 faab522f Renato Botelho
		'Move to "Not members',
489 37676f4e jim-p
		null,
490
		'fa-angle-double-left'
491 347c0214 Phil Davis
	))->setAttribute('type','button')->removeClass('btn-primary')->addClass('btn-info btn-sm');
492 2f1e91e4 Stephen Beaver
493 e4c7d45f NewEraCracker
	$group->setHelp('Hold down CTRL (PC)/COMMAND (Mac) key to select multiple items.');
494 2f1e91e4 Stephen Beaver
	$section->add($group);
495 64600f94 Sjon Hortensius
496 6b07c15a Matthew Grooms
}
497
498 d61309a0 Phil Davis
if ($_GET['act'] != "new") {
499 64600f94 Sjon Hortensius
	$section = new Form_Section('Assigned Privileges');
500
501
	$section->addInput(new Form_StaticText(
502
		null,
503 2f1e91e4 Stephen Beaver
		build_priv_table()
504 64600f94 Sjon Hortensius
	));
505 6b07c15a Matthew Grooms
506 2f1e91e4 Stephen Beaver
507 64600f94 Sjon Hortensius
	$form->add($section);
508 6b07c15a Matthew Grooms
}
509
510 64600f94 Sjon Hortensius
print $form;
511 2f1e91e4 Stephen Beaver
?>
512 8fd9052f Colin Fleming
<script type="text/javascript">
513 2f1e91e4 Stephen Beaver
//<![CDATA[
514 d61309a0 Phil Davis
events.push(function() {
515 2f1e91e4 Stephen Beaver
516
	// On click . .
517
	$("#movetodisabled").click(function() {
518
		moveOptions($('[name="members[]"] option'), $('[name="notmembers[]"]'));
519
	});
520
521
	$("#movetoenabled").click(function() {
522
		moveOptions($('[name="notmembers[]"] option'), $('[name="members[]"]'));
523
	});
524
525
	// On submit mark all the user's groups as "selected"
526 d61309a0 Phil Davis
	$('form').submit(function() {
527 2f1e91e4 Stephen Beaver
		AllServers($('[name="members[]"] option'), true);
528
	});
529
});
530
//]]>
531
</script>
532
<?php
533 854fa106 heper
include('foot.inc');