Project

General

Profile

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