Project

General

Profile

Download (14 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 3fa86ecd sullrich
require("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 79ed8ce0 Stephen Beaver
192 e0c7b2fe Phil Davis
	if (strlen($_POST['groupname']) > 16) {
193 3db408b3 PiBa-NL
		$input_errors[] = gettext("The group name is longer than 16 characters.");
194 e0c7b2fe Phil Davis
	}
195 4c291f4c Renato Botelho
196 d88c6a9f Scott Ullrich
	if (!$input_errors && !(isset($id) && $a_group[$id])) {
197
		/* make sure there are no dupes */
198
		foreach ($a_group as $group) {
199
			if ($group['name'] == $_POST['groupname']) {
200 bbf825ab Vinicius Coque
				$input_errors[] = gettext("Another entry with the same group name already exists.");
201 d88c6a9f Scott Ullrich
				break;
202
			}
203
		}
204
	}
205 4c291f4c Renato Botelho
206 d88c6a9f Scott Ullrich
	if (!$input_errors) {
207 45ee90ed Matthew Grooms
		$group = array();
208 e0c7b2fe Phil Davis
		if (isset($id) && $a_group[$id]) {
209 d88c6a9f Scott Ullrich
			$group = $a_group[$id];
210 e0c7b2fe Phil Davis
		}
211 4c291f4c Renato Botelho
212 d88c6a9f Scott Ullrich
		$group['name'] = $_POST['groupname'];
213
		$group['description'] = $_POST['description'];
214 79ed8ce0 Stephen Beaver
		$group['scope'] = $_POST['gtype'];
215 45ee90ed Matthew Grooms
216 e0c7b2fe Phil Davis
		if (empty($_POST['members'])) {
217 70d6b5c4 Ermal
			unset($group['member']);
218 e0c7b2fe Phil Davis
		} else if ($group['gid'] != 1998) { // all group
219 6b07c15a Matthew Grooms
			$group['member'] = $_POST['members'];
220 e0c7b2fe Phil Davis
		}
221 45ee90ed Matthew Grooms
222 e0c7b2fe Phil Davis
		if (isset($id) && $a_group[$id]) {
223 d88c6a9f Scott Ullrich
			$a_group[$id] = $group;
224 e0c7b2fe Phil Davis
		} else {
225 45ee90ed Matthew Grooms
			$group['gid'] = $config['system']['nextgid']++;
226 d88c6a9f Scott Ullrich
			$a_group[] = $group;
227 45ee90ed Matthew Grooms
		}
228
229 06683083 Stephen Beaver
		admin_groups_sort();
230
231 920dbb26 Renato Botelho
		conf_mount_rw();
232 659fa7f2 Matthew Grooms
		local_group_set($group);
233 920dbb26 Renato Botelho
		conf_mount_ro();
234 2a0e8512 jim-p
235
		/* Refresh users in this group since their privileges may have changed. */
236 5709072a jim-p
		if (is_array($group['member'])) {
237
			$a_user = &$config['system']['user'];
238
			foreach ($a_user as & $user) {
239 e0c7b2fe Phil Davis
				if (in_array($user['uid'], $group['member'])) {
240 5709072a jim-p
					local_user_set($user);
241 e0c7b2fe Phil Davis
				}
242 5709072a jim-p
			}
243 2a0e8512 jim-p
		}
244
245 d88c6a9f Scott Ullrich
		write_config();
246 4c291f4c Renato Botelho
247 d88c6a9f Scott Ullrich
		header("Location: system_groupmanager.php");
248
		exit;
249
	}
250 23d09a2e Stephen Beaver
251
	$pconfig['name'] = $_POST['groupname'];
252 fab7ff44 Bill Marquette
}
253
254 2f1e91e4 Stephen Beaver
function build_priv_table() {
255
	global $a_group, $id;
256
257
	$privhtml = '<div class="table-responsive">';
258
	$privhtml .=	'<table class="table table-striped table-hover table-condensed">';
259
	$privhtml .=		'<thead>';
260 70da45c9 NOYB
	$privhtml .=			'<tr>';
261
	$privhtml .=				'<th>' . gettext('Name') . '</th>';
262
	$privhtml .=				'<th>' . gettext('Description') . '</th>';
263
	$privhtml .=				'<th>' . gettext('Action') . '</th>';
264
	$privhtml .=			'</tr>';
265 2f1e91e4 Stephen Beaver
	$privhtml .=		'</thead>';
266
	$privhtml .=		'<tbody>';
267
268
	foreach (get_user_privdesc($a_group[$id]) as $i => $priv) {
269
		$privhtml .=		'<tr>';
270
		$privhtml .=			'<td>' . htmlspecialchars($priv['name']) . '</td>';
271
		$privhtml .=			'<td>' . htmlspecialchars($priv['descr']) . '</td>';
272 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>';
273 2f1e91e4 Stephen Beaver
		$privhtml .=		'</tr>';
274 d61309a0 Phil Davis
275 2f1e91e4 Stephen Beaver
	}
276
277
	$privhtml .=		'</tbody>';
278
	$privhtml .=	'</table>';
279
	$privhtml .= '</div>';
280
281
	$privhtml .= '<nav class="action-buttons">';
282 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>';
283 2f1e91e4 Stephen Beaver
	$privhtml .= '</nav>';
284
285
	return($privhtml);
286
}
287
288 8f1ab2a4 k-paulius
$pgtitle = array(gettext("System"), gettext("User Manager"), gettext("Groups"));
289
290
if ($act == "new" || $act == "edit") {
291
	$pgtitle[] = gettext('Edit');
292
}
293 23d09a2e Stephen Beaver
294 fab7ff44 Bill Marquette
include("head.inc");
295
296 d61309a0 Phil Davis
if ($input_errors) {
297 64600f94 Sjon Hortensius
	print_input_errors($input_errors);
298 d61309a0 Phil Davis
}
299 23d09a2e Stephen Beaver
300 d61309a0 Phil Davis
if ($savemsg) {
301 f78bbe16 Phil Davis
	print_info_box($savemsg, 'success');
302 d61309a0 Phil Davis
}
303 64600f94 Sjon Hortensius
304
$tab_array = array();
305
$tab_array[] = array(gettext("Users"), false, "system_usermanager.php");
306
$tab_array[] = array(gettext("Groups"), true, "system_groupmanager.php");
307
$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
308 2d1f33d9 k-paulius
$tab_array[] = array(gettext("Authentication Servers"), false, "system_authservers.php");
309 64600f94 Sjon Hortensius
display_top_tabs($tab_array);
310
311 d61309a0 Phil Davis
if (!($_GET['act'] == "new" || $_GET['act'] == "edit")) {
312 64600f94 Sjon Hortensius
?>
313 060ed238 Stephen Beaver
<div class="panel panel-default">
314
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('Groups')?></h2></div>
315
	<div class="panel-body">
316
		<div class="table-responsive">
317
			<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
318
				<thead>
319
					<tr>
320
						<th><?=gettext("Group name")?></th>
321
						<th><?=gettext("Description")?></th>
322
						<th><?=gettext("Member Count")?></th>
323
						<th><?=gettext("Actions")?></th>
324
					</tr>
325
				</thead>
326
				<tbody>
327 64600f94 Sjon Hortensius
<?php
328 d61309a0 Phil Davis
	foreach ($a_group as $i => $group):
329
		if ($group["name"] == "all") {
330 64600f94 Sjon Hortensius
			$groupcount = count($config['system']['user']);
331 d61309a0 Phil Davis
		} else {
332 64600f94 Sjon Hortensius
			$groupcount = count($group['member']);
333 d61309a0 Phil Davis
		}
334 64600f94 Sjon Hortensius
?>
335 060ed238 Stephen Beaver
					<tr>
336
						<td>
337
							<?=htmlspecialchars($group['name'])?>
338
						</td>
339
						<td>
340
							<?=htmlspecialchars($group['description'])?>
341
						</td>
342
						<td>
343
							<?=$groupcount?>
344
						</td>
345
						<td>
346
							<a class="fa fa-pencil" title="<?=gettext("Edit group"); ?>" href="?act=edit&amp;groupid=<?=$i?>"></a>
347
							<?php if ($group['scope'] != "system"): ?>
348
								<a class="fa fa-trash"	title="<?=gettext("Delete group")?>" href="?act=delgroup&amp;groupid=<?=$i?>&amp;groupname=<?=$group['name']?>"></a>
349
							<?php endif;?>
350
						</td>
351
					</tr>
352 64600f94 Sjon Hortensius
<?php
353
	endforeach;
354 fab7ff44 Bill Marquette
?>
355 060ed238 Stephen Beaver
				</tbody>
356
			</table>
357
		</div>
358 94404d94 Sander van Leeuwen
	</div>
359 060ed238 Stephen Beaver
</div>
360
361
<nav class="action-buttons">
362
	<a href="?act=new" class="btn btn-success btn-sm">
363
		<i class="fa fa-plus icon-embed-btn"></i>
364
		<?=gettext("Add")?>
365
	</a>
366
</nav>
367 64600f94 Sjon Hortensius
<?php
368
	include('foot.inc');
369
	exit;
370 6b07c15a Matthew Grooms
}
371
372 64600f94 Sjon Hortensius
$form = new Form;
373
$form->setAction('system_groupmanager.php?act=edit');
374
$form->addGlobal(new Form_Input(
375
	'groupid',
376
	null,
377
	'hidden',
378
	$id
379
));
380
381
if (isset($id) && $a_group[$id]){
382
	$form->addGlobal(new Form_Input(
383
		'id',
384
		null,
385
		'hidden',
386
		$id
387
	));
388
389
	$form->addGlobal(new Form_Input(
390
		'gid',
391
		null,
392
		'hidden',
393
		$pconfig['gid']
394
	));
395 61dec0b0 Renato Botelho
}
396
397 5f88f964 k-paulius
$section = new Form_Section('Group Properties');
398 82833610 Stephen Beaver
399 e6acc2ee Sjon Hortensius
$section->addInput($input = new Form_Input(
400 64600f94 Sjon Hortensius
	'groupname',
401
	'Group name',
402
	'text',
403
	$pconfig['name']
404
));
405
406 d61309a0 Phil Davis
if ($pconfig['gtype'] == "system") {
407 1192840b Sjon Hortensius
	$input->setReadonly();
408 79ed8ce0 Stephen Beaver
409
	$section->addInput(new Form_Input(
410
		'gtype',
411
		'Scope',
412
		'text',
413
		$pconfig['gtype']
414
	))->setReadonly();
415
} else {
416
	$section->addInput(new Form_Select(
417
		'gtype',
418
		'Scope',
419
		$pconfig['gtype'],
420 82833610 Stephen Beaver
		["local" => gettext("Local"), "remote" => gettext("Remote")]
421 79ed8ce0 Stephen Beaver
	));
422 d61309a0 Phil Davis
}
423 e6acc2ee Sjon Hortensius
424 64600f94 Sjon Hortensius
$section->addInput(new Form_Input(
425
	'description',
426
	'Description',
427
	'text',
428
	$pconfig['description']
429 89140b63 NOYB
))->setHelp('Group description, for administrative information only');
430 64600f94 Sjon Hortensius
431 79ed8ce0 Stephen Beaver
432 64600f94 Sjon Hortensius
$form->add($section);
433 d61309a0 Phil Davis
if ($pconfig['gid'] != 1998) { // all users group
434
435 2f1e91e4 Stephen Beaver
	// ==== Group membership ==================================================
436
	$group = new Form_Group('Group membership');
437
438
	// Make a list of all the groups configured on the system, and a list of
439
	// those which this user is a member of
440
	$systemGroups = array();
441
	$usersGroups = array();
442
443
	foreach ($config['system']['user'] as $user) {
444 d61309a0 Phil Davis
		if (is_array($pconfig['members']) && in_array($user['uid'], $pconfig['members'])) {
445 2f1e91e4 Stephen Beaver
			$usersGroups[ $user['uid'] ] = $user['name'];	// Add it to the user's list
446 d61309a0 Phil Davis
		} else {
447 2f1e91e4 Stephen Beaver
			$systemGroups[ $user['uid'] ] = $user['name']; // Add it to the 'not a member of' list
448 d61309a0 Phil Davis
		}
449 2f1e91e4 Stephen Beaver
	}
450
451
	$group->add(new Form_Select(
452
		'notmembers',
453
		null,
454
		array_combine((array)$pconfig['groups'], (array)$pconfig['groups']),
455
		$systemGroups,
456
		true
457 6ef8f2e9 heper
	))->setHelp('Not members');
458 64600f94 Sjon Hortensius
459 2f1e91e4 Stephen Beaver
	$group->add(new Form_Select(
460 64600f94 Sjon Hortensius
		'members',
461 2f1e91e4 Stephen Beaver
		null,
462
		array_combine((array)$pconfig['groups'], (array)$pconfig['groups']),
463
		$usersGroups,
464 64600f94 Sjon Hortensius
		true
465 6ef8f2e9 heper
	))->setHelp('Members');
466 2f1e91e4 Stephen Beaver
467
	$section->add($group);
468
469
	$group = new Form_Group('');
470
471
	$group->add(new Form_Button(
472
		'movetoenabled',
473 faab522f Renato Botelho
		'Move to "Members"',
474 37676f4e jim-p
		null,
475
		'fa-angle-double-right'
476 347c0214 Phil Davis
	))->setAttribute('type','button')->removeClass('btn-primary')->addClass('btn-info btn-sm');
477 2f1e91e4 Stephen Beaver
478
	$group->add(new Form_Button(
479
		'movetodisabled',
480 faab522f Renato Botelho
		'Move to "Not members',
481 37676f4e jim-p
		null,
482
		'fa-angle-double-left'
483 347c0214 Phil Davis
	))->setAttribute('type','button')->removeClass('btn-primary')->addClass('btn-info btn-sm');
484 2f1e91e4 Stephen Beaver
485
	$group->setHelp('Hold down CTRL (pc)/COMMAND (mac) key to select multiple items');
486
	$section->add($group);
487 64600f94 Sjon Hortensius
488 6b07c15a Matthew Grooms
}
489
490 d61309a0 Phil Davis
if ($_GET['act'] != "new") {
491 64600f94 Sjon Hortensius
	$section = new Form_Section('Assigned Privileges');
492
493
	$section->addInput(new Form_StaticText(
494
		null,
495 2f1e91e4 Stephen Beaver
		build_priv_table()
496 64600f94 Sjon Hortensius
	));
497 6b07c15a Matthew Grooms
498 2f1e91e4 Stephen Beaver
499 64600f94 Sjon Hortensius
	$form->add($section);
500 6b07c15a Matthew Grooms
}
501
502 64600f94 Sjon Hortensius
print $form;
503 2f1e91e4 Stephen Beaver
?>
504 8fd9052f Colin Fleming
<script type="text/javascript">
505 2f1e91e4 Stephen Beaver
//<![CDATA[
506 d61309a0 Phil Davis
events.push(function() {
507 2f1e91e4 Stephen Beaver
508
	// On click . .
509
	$("#movetodisabled").click(function() {
510
		moveOptions($('[name="members[]"] option'), $('[name="notmembers[]"]'));
511
	});
512
513
	$("#movetoenabled").click(function() {
514
		moveOptions($('[name="notmembers[]"] option'), $('[name="members[]"]'));
515
	});
516
517
	// On submit mark all the user's groups as "selected"
518 d61309a0 Phil Davis
	$('form').submit(function() {
519 2f1e91e4 Stephen Beaver
		AllServers($('[name="members[]"] option'), true);
520
	});
521
});
522
//]]>
523
</script>
524
<?php
525 854fa106 heper
include('foot.inc');