1 |
4c291f4c
|
Renato Botelho
|
<?php
|
2 |
fab7ff44
|
Bill Marquette
|
/*
|
3 |
c5d81585
|
Renato Botelho
|
* system_groupmanager.php
|
4 |
191cb31d
|
Stephen Beaver
|
*
|
5 |
c5d81585
|
Renato Botelho
|
* part of pfSense (https://www.pfsense.org)
|
6 |
81299b5c
|
Renato Botelho
|
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
|
7 |
c5d81585
|
Renato Botelho
|
* 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 |
c5d81585
|
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 |
b12ea3fb
|
Renato Botelho
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
16 |
|
|
* you may not use this file except in compliance with the License.
|
17 |
|
|
* You may obtain a copy of the License at
|
18 |
f74457df
|
Stephen Beaver
|
*
|
19 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
20 |
f74457df
|
Stephen Beaver
|
*
|
21 |
b12ea3fb
|
Renato Botelho
|
* Unless required by applicable law or agreed to in writing, software
|
22 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
23 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
24 |
|
|
* See the License for the specific language governing permissions and
|
25 |
|
|
* limitations under the License.
|
26 |
f74457df
|
Stephen Beaver
|
*/
|
27 |
fab7ff44
|
Bill Marquette
|
|
28 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
29 |
|
|
##|*IDENT=page-system-groupmanager
|
30 |
48157a04
|
Phil Davis
|
##|*NAME=System: Group Manager
|
31 |
|
|
##|*DESCR=Allow access to the 'System: Group Manager' page.
|
32 |
57188e47
|
Phil Davis
|
##|*WARN=standard-warning-root
|
33 |
6b07c15a
|
Matthew Grooms
|
##|*MATCH=system_groupmanager.php*
|
34 |
|
|
##|-PRIV
|
35 |
fab7ff44
|
Bill Marquette
|
|
36 |
c81ef6e2
|
Phil Davis
|
require_once("guiconfig.inc");
|
37 |
15c74b5b
|
doktornotor
|
require_once("pfsense-utils.inc");
|
38 |
d88c6a9f
|
Scott Ullrich
|
|
39 |
e0c7b2fe
|
Phil Davis
|
if (!is_array($config['system']['group'])) {
|
40 |
6b07c15a
|
Matthew Grooms
|
$config['system']['group'] = array();
|
41 |
e0c7b2fe
|
Phil Davis
|
}
|
42 |
d81c2ad1
|
Scott Ullrich
|
|
43 |
6b07c15a
|
Matthew Grooms
|
$a_group = &$config['system']['group'];
|
44 |
d81c2ad1
|
Scott Ullrich
|
|
45 |
7ea27b0d
|
Renato Botelho
|
unset($id);
|
46 |
4611e283
|
Steve Beaver
|
$id = $_REQUEST['groupid'];
|
47 |
|
|
$act = (isset($_REQUEST['act']) ? $_REQUEST['act'] : '');
|
48 |
31b53653
|
Scott Ullrich
|
|
49 |
06683083
|
Stephen Beaver
|
function cpusercmp($a, $b) {
|
50 |
|
|
return strcasecmp($a['name'], $b['name']);
|
51 |
|
|
}
|
52 |
23d09a2e
|
Stephen Beaver
|
|
53 |
06683083
|
Stephen Beaver
|
function admin_groups_sort() {
|
54 |
|
|
global $a_group;
|
55 |
|
|
|
56 |
|
|
if (!is_array($a_group)) {
|
57 |
|
|
return;
|
58 |
|
|
}
|
59 |
|
|
|
60 |
|
|
usort($a_group, "cpusercmp");
|
61 |
|
|
}
|
62 |
|
|
|
63 |
4611e283
|
Steve Beaver
|
if ($_POST['act'] == "delgroup") {
|
64 |
7ea27b0d
|
Renato Botelho
|
|
65 |
4611e283
|
Steve Beaver
|
if (!isset($id) || !isset($_REQUEST['groupname']) || !isset($a_group[$id]) || ($_REQUEST['groupname'] != $a_group[$id]['name'])) {
|
66 |
6b07c15a
|
Matthew Grooms
|
pfSenseHeader("system_groupmanager.php");
|
67 |
|
|
exit;
|
68 |
|
|
}
|
69 |
31b53653
|
Scott Ullrich
|
|
70 |
7ea27b0d
|
Renato Botelho
|
local_group_del($a_group[$id]);
|
71 |
|
|
$groupdeleted = $a_group[$id]['name'];
|
72 |
|
|
unset($a_group[$id]);
|
73 |
6b07c15a
|
Matthew Grooms
|
write_config();
|
74 |
8545adde
|
k-paulius
|
$savemsg = sprintf(gettext("Group %s successfully deleted."), $groupdeleted);
|
75 |
fab7ff44
|
Bill Marquette
|
}
|
76 |
d88c6a9f
|
Scott Ullrich
|
|
77 |
4611e283
|
Steve Beaver
|
if ($_POST['act'] == "delpriv") {
|
78 |
6b07c15a
|
Matthew Grooms
|
|
79 |
7ea27b0d
|
Renato Botelho
|
if (!isset($id) || !isset($a_group[$id])) {
|
80 |
6b07c15a
|
Matthew Grooms
|
pfSenseHeader("system_groupmanager.php");
|
81 |
|
|
exit;
|
82 |
|
|
}
|
83 |
fab7ff44
|
Bill Marquette
|
|
84 |
4611e283
|
Steve Beaver
|
$privdeleted = $priv_list[$a_group[$id]['priv'][$_REQUEST['privid']]]['name'];
|
85 |
|
|
unset($a_group[$id]['priv'][$_REQUEST['privid']]);
|
86 |
6b07c15a
|
Matthew Grooms
|
|
87 |
2ee08031
|
Erik Fonnesbeck
|
if (is_array($a_group[$id]['member'])) {
|
88 |
|
|
foreach ($a_group[$id]['member'] as $uid) {
|
89 |
|
|
$user = getUserEntryByUID($uid);
|
90 |
e0c7b2fe
|
Phil Davis
|
if ($user) {
|
91 |
2ee08031
|
Erik Fonnesbeck
|
local_user_set($user);
|
92 |
64600f94
|
Sjon Hortensius
|
}
|
93 |
2ee08031
|
Erik Fonnesbeck
|
}
|
94 |
64600f94
|
Sjon Hortensius
|
}
|
95 |
45ee90ed
|
Matthew Grooms
|
|
96 |
6b07c15a
|
Matthew Grooms
|
write_config();
|
97 |
7ea27b0d
|
Renato Botelho
|
$act = "edit";
|
98 |
8545adde
|
k-paulius
|
$savemsg = sprintf(gettext("Privilege %s successfully deleted."), $privdeleted);
|
99 |
6b07c15a
|
Matthew Grooms
|
}
|
100 |
45ee90ed
|
Matthew Grooms
|
|
101 |
7ea27b0d
|
Renato Botelho
|
if ($act == "edit") {
|
102 |
|
|
if (isset($id) && isset($a_group[$id])) {
|
103 |
45ee90ed
|
Matthew Grooms
|
$pconfig['name'] = $a_group[$id]['name'];
|
104 |
6b07c15a
|
Matthew Grooms
|
$pconfig['gid'] = $a_group[$id]['gid'];
|
105 |
79ed8ce0
|
Stephen Beaver
|
$pconfig['gtype'] = empty($a_group[$id]['scope']) ? "local" : $a_group[$id]['scope'];
|
106 |
45ee90ed
|
Matthew Grooms
|
$pconfig['description'] = $a_group[$id]['description'];
|
107 |
6b07c15a
|
Matthew Grooms
|
$pconfig['members'] = $a_group[$id]['member'];
|
108 |
|
|
$pconfig['priv'] = $a_group[$id]['priv'];
|
109 |
45ee90ed
|
Matthew Grooms
|
}
|
110 |
|
|
}
|
111 |
6b07c15a
|
Matthew Grooms
|
|
112 |
20231404
|
Steve Beaver
|
if (isset($_POST['dellall_x'])) {
|
113 |
c0c5b8cc
|
bruno
|
|
114 |
20231404
|
Steve Beaver
|
$del_groups = $_POST['delete_check'];
|
115 |
c0c5b8cc
|
bruno
|
|
116 |
e0c7b2fe
|
Phil Davis
|
if (!empty($del_groups)) {
|
117 |
|
|
foreach ($del_groups as $groupid) {
|
118 |
|
|
if (isset($a_group[$groupid]) && $a_group[$groupid]['scope'] != "system") {
|
119 |
c0c5b8cc
|
bruno
|
local_group_del($a_group[$groupid]);
|
120 |
|
|
unset($a_group[$groupid]);
|
121 |
|
|
}
|
122 |
|
|
}
|
123 |
8545adde
|
k-paulius
|
$savemsg = gettext("Selected groups removed successfully.");
|
124 |
c0c5b8cc
|
bruno
|
write_config($savemsg);
|
125 |
|
|
}
|
126 |
|
|
}
|
127 |
|
|
|
128 |
7ea27b0d
|
Renato Botelho
|
if (isset($_POST['save'])) {
|
129 |
d88c6a9f
|
Scott Ullrich
|
unset($input_errors);
|
130 |
|
|
$pconfig = $_POST;
|
131 |
|
|
|
132 |
|
|
/* input validation */
|
133 |
|
|
$reqdfields = explode(" ", "groupname");
|
134 |
b4fd804b
|
Carlos Eduardo Ramos
|
$reqdfieldsn = array(gettext("Group Name"));
|
135 |
4c291f4c
|
Renato Botelho
|
|
136 |
1e9b4611
|
Renato Botelho
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
|
137 |
4c291f4c
|
Renato Botelho
|
|
138 |
d7689b2c
|
Stephen Beaver
|
if ($_POST['gtype'] != "remote") {
|
139 |
79ed8ce0
|
Stephen Beaver
|
if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['groupname'])) {
|
140 |
d7689b2c
|
Stephen Beaver
|
$input_errors[] = sprintf(gettext("The (%s) group name contains invalid characters."), $_POST['gtype']);
|
141 |
79ed8ce0
|
Stephen Beaver
|
}
|
142 |
|
|
} else {
|
143 |
|
|
if (preg_match("/[^a-zA-Z0-9\.\- _]/", $_POST['groupname'])) {
|
144 |
d7689b2c
|
Stephen Beaver
|
$input_errors[] = sprintf(gettext("The (%s) group name contains invalid characters."), $_POST['gtype']);
|
145 |
79ed8ce0
|
Stephen Beaver
|
}
|
146 |
e0c7b2fe
|
Phil Davis
|
}
|
147 |
4c291f4c
|
Renato Botelho
|
|
148 |
e0c7b2fe
|
Phil Davis
|
if (strlen($_POST['groupname']) > 16) {
|
149 |
3db408b3
|
PiBa-NL
|
$input_errors[] = gettext("The group name is longer than 16 characters.");
|
150 |
e0c7b2fe
|
Phil Davis
|
}
|
151 |
4c291f4c
|
Renato Botelho
|
|
152 |
5bef2407
|
jim-p
|
/* Check the POSTed members to ensure they are valid and exist */
|
153 |
9d3e8723
|
Phil Davis
|
if (is_array($_POST['members'])) {
|
154 |
9f472202
|
NewEraCracker
|
foreach ($_POST['members'] as $newmember) {
|
155 |
|
|
if (!is_numeric($newmember) || empty(getUserEntryByUID($newmember))) {
|
156 |
|
|
$input_errors[] = gettext("One or more invalid group members was submitted.");
|
157 |
|
|
}
|
158 |
5bef2407
|
jim-p
|
}
|
159 |
|
|
}
|
160 |
|
|
|
161 |
d88c6a9f
|
Scott Ullrich
|
if (!$input_errors && !(isset($id) && $a_group[$id])) {
|
162 |
|
|
/* make sure there are no dupes */
|
163 |
|
|
foreach ($a_group as $group) {
|
164 |
|
|
if ($group['name'] == $_POST['groupname']) {
|
165 |
bbf825ab
|
Vinicius Coque
|
$input_errors[] = gettext("Another entry with the same group name already exists.");
|
166 |
d88c6a9f
|
Scott Ullrich
|
break;
|
167 |
|
|
}
|
168 |
|
|
}
|
169 |
|
|
}
|
170 |
4c291f4c
|
Renato Botelho
|
|
171 |
d88c6a9f
|
Scott Ullrich
|
if (!$input_errors) {
|
172 |
45ee90ed
|
Matthew Grooms
|
$group = array();
|
173 |
e0c7b2fe
|
Phil Davis
|
if (isset($id) && $a_group[$id]) {
|
174 |
d88c6a9f
|
Scott Ullrich
|
$group = $a_group[$id];
|
175 |
e0c7b2fe
|
Phil Davis
|
}
|
176 |
4c291f4c
|
Renato Botelho
|
|
177 |
d88c6a9f
|
Scott Ullrich
|
$group['name'] = $_POST['groupname'];
|
178 |
|
|
$group['description'] = $_POST['description'];
|
179 |
79ed8ce0
|
Stephen Beaver
|
$group['scope'] = $_POST['gtype'];
|
180 |
45ee90ed
|
Matthew Grooms
|
|
181 |
e0c7b2fe
|
Phil Davis
|
if (empty($_POST['members'])) {
|
182 |
70d6b5c4
|
Ermal
|
unset($group['member']);
|
183 |
e0c7b2fe
|
Phil Davis
|
} else if ($group['gid'] != 1998) { // all group
|
184 |
6b07c15a
|
Matthew Grooms
|
$group['member'] = $_POST['members'];
|
185 |
e0c7b2fe
|
Phil Davis
|
}
|
186 |
45ee90ed
|
Matthew Grooms
|
|
187 |
e0c7b2fe
|
Phil Davis
|
if (isset($id) && $a_group[$id]) {
|
188 |
d88c6a9f
|
Scott Ullrich
|
$a_group[$id] = $group;
|
189 |
e0c7b2fe
|
Phil Davis
|
} else {
|
190 |
45ee90ed
|
Matthew Grooms
|
$group['gid'] = $config['system']['nextgid']++;
|
191 |
d88c6a9f
|
Scott Ullrich
|
$a_group[] = $group;
|
192 |
45ee90ed
|
Matthew Grooms
|
}
|
193 |
|
|
|
194 |
06683083
|
Stephen Beaver
|
admin_groups_sort();
|
195 |
|
|
|
196 |
659fa7f2
|
Matthew Grooms
|
local_group_set($group);
|
197 |
2a0e8512
|
jim-p
|
|
198 |
|
|
/* Refresh users in this group since their privileges may have changed. */
|
199 |
5709072a
|
jim-p
|
if (is_array($group['member'])) {
|
200 |
|
|
$a_user = &$config['system']['user'];
|
201 |
|
|
foreach ($a_user as & $user) {
|
202 |
e0c7b2fe
|
Phil Davis
|
if (in_array($user['uid'], $group['member'])) {
|
203 |
5709072a
|
jim-p
|
local_user_set($user);
|
204 |
e0c7b2fe
|
Phil Davis
|
}
|
205 |
5709072a
|
jim-p
|
}
|
206 |
2a0e8512
|
jim-p
|
}
|
207 |
|
|
|
208 |
d88c6a9f
|
Scott Ullrich
|
write_config();
|
209 |
4c291f4c
|
Renato Botelho
|
|
210 |
d88c6a9f
|
Scott Ullrich
|
header("Location: system_groupmanager.php");
|
211 |
|
|
exit;
|
212 |
|
|
}
|
213 |
23d09a2e
|
Stephen Beaver
|
|
214 |
|
|
$pconfig['name'] = $_POST['groupname'];
|
215 |
fab7ff44
|
Bill Marquette
|
}
|
216 |
|
|
|
217 |
2f1e91e4
|
Stephen Beaver
|
function build_priv_table() {
|
218 |
|
|
global $a_group, $id;
|
219 |
|
|
|
220 |
|
|
$privhtml = '<div class="table-responsive">';
|
221 |
|
|
$privhtml .= '<table class="table table-striped table-hover table-condensed">';
|
222 |
|
|
$privhtml .= '<thead>';
|
223 |
70da45c9
|
NOYB
|
$privhtml .= '<tr>';
|
224 |
|
|
$privhtml .= '<th>' . gettext('Name') . '</th>';
|
225 |
|
|
$privhtml .= '<th>' . gettext('Description') . '</th>';
|
226 |
|
|
$privhtml .= '<th>' . gettext('Action') . '</th>';
|
227 |
|
|
$privhtml .= '</tr>';
|
228 |
2f1e91e4
|
Stephen Beaver
|
$privhtml .= '</thead>';
|
229 |
|
|
$privhtml .= '<tbody>';
|
230 |
|
|
|
231 |
57188e47
|
Phil Davis
|
$user_has_root_priv = false;
|
232 |
|
|
|
233 |
2f1e91e4
|
Stephen Beaver
|
foreach (get_user_privdesc($a_group[$id]) as $i => $priv) {
|
234 |
|
|
$privhtml .= '<tr>';
|
235 |
|
|
$privhtml .= '<td>' . htmlspecialchars($priv['name']) . '</td>';
|
236 |
57188e47
|
Phil Davis
|
$privhtml .= '<td>' . htmlspecialchars($priv['descr']);
|
237 |
|
|
if (isset($priv['warn']) && ($priv['warn'] == 'standard-warning-root')) {
|
238 |
21312954
|
Phil Davis
|
$privhtml .= ' ' . gettext('(admin privilege)');
|
239 |
57188e47
|
Phil Davis
|
$user_has_root_priv = true;
|
240 |
|
|
}
|
241 |
|
|
$privhtml .= '</td>';
|
242 |
20231404
|
Steve Beaver
|
$privhtml .= '<td><a class="fa fa-trash" title="' . gettext('Delete Privilege') . '" href="system_groupmanager.php?act=delpriv&groupid=' . $id . '&privid=' . $i . '" usepost></a></td>';
|
243 |
2f1e91e4
|
Stephen Beaver
|
$privhtml .= '</tr>';
|
244 |
d61309a0
|
Phil Davis
|
|
245 |
2f1e91e4
|
Stephen Beaver
|
}
|
246 |
|
|
|
247 |
57188e47
|
Phil Davis
|
if ($user_has_root_priv) {
|
248 |
|
|
$privhtml .= '<tr>';
|
249 |
|
|
$privhtml .= '<td colspan="2">';
|
250 |
9187d6f7
|
Phil Davis
|
$privhtml .= '<b>' . gettext('Security notice: Users in this group effectively have administrator-level access') . '</b>';
|
251 |
57188e47
|
Phil Davis
|
$privhtml .= '</td>';
|
252 |
|
|
$privhtml .= '<td>';
|
253 |
|
|
$privhtml .= '</td>';
|
254 |
|
|
$privhtml .= '</tr>';
|
255 |
20231404
|
Steve Beaver
|
|
256 |
57188e47
|
Phil Davis
|
}
|
257 |
|
|
|
258 |
2f1e91e4
|
Stephen Beaver
|
$privhtml .= '</tbody>';
|
259 |
|
|
$privhtml .= '</table>';
|
260 |
|
|
$privhtml .= '</div>';
|
261 |
|
|
|
262 |
|
|
$privhtml .= '<nav class="action-buttons">';
|
263 |
4611e283
|
Steve Beaver
|
$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>';
|
264 |
2f1e91e4
|
Stephen Beaver
|
$privhtml .= '</nav>';
|
265 |
|
|
|
266 |
|
|
return($privhtml);
|
267 |
|
|
}
|
268 |
|
|
|
269 |
8f1ab2a4
|
k-paulius
|
$pgtitle = array(gettext("System"), gettext("User Manager"), gettext("Groups"));
|
270 |
edcd7535
|
Phil Davis
|
$pglinks = array("", "system_usermanager.php", "system_groupmanager.php");
|
271 |
8f1ab2a4
|
k-paulius
|
|
272 |
|
|
if ($act == "new" || $act == "edit") {
|
273 |
|
|
$pgtitle[] = gettext('Edit');
|
274 |
edcd7535
|
Phil Davis
|
$pglinks[] = "@self";
|
275 |
8f1ab2a4
|
k-paulius
|
}
|
276 |
23d09a2e
|
Stephen Beaver
|
|
277 |
fab7ff44
|
Bill Marquette
|
include("head.inc");
|
278 |
|
|
|
279 |
d61309a0
|
Phil Davis
|
if ($input_errors) {
|
280 |
64600f94
|
Sjon Hortensius
|
print_input_errors($input_errors);
|
281 |
d61309a0
|
Phil Davis
|
}
|
282 |
23d09a2e
|
Stephen Beaver
|
|
283 |
d61309a0
|
Phil Davis
|
if ($savemsg) {
|
284 |
f78bbe16
|
Phil Davis
|
print_info_box($savemsg, 'success');
|
285 |
d61309a0
|
Phil Davis
|
}
|
286 |
64600f94
|
Sjon Hortensius
|
|
287 |
|
|
$tab_array = array();
|
288 |
|
|
$tab_array[] = array(gettext("Users"), false, "system_usermanager.php");
|
289 |
|
|
$tab_array[] = array(gettext("Groups"), true, "system_groupmanager.php");
|
290 |
|
|
$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
|
291 |
2d1f33d9
|
k-paulius
|
$tab_array[] = array(gettext("Authentication Servers"), false, "system_authservers.php");
|
292 |
64600f94
|
Sjon Hortensius
|
display_top_tabs($tab_array);
|
293 |
|
|
|
294 |
4611e283
|
Steve Beaver
|
if (!($act == "new" || $act == "edit")) {
|
295 |
64600f94
|
Sjon Hortensius
|
?>
|
296 |
060ed238
|
Stephen Beaver
|
<div class="panel panel-default">
|
297 |
|
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('Groups')?></h2></div>
|
298 |
|
|
<div class="panel-body">
|
299 |
|
|
<div class="table-responsive">
|
300 |
1c10ce97
|
PiBa-NL
|
<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap table-rowdblclickedit" data-sortable>
|
301 |
060ed238
|
Stephen Beaver
|
<thead>
|
302 |
|
|
<tr>
|
303 |
|
|
<th><?=gettext("Group name")?></th>
|
304 |
|
|
<th><?=gettext("Description")?></th>
|
305 |
|
|
<th><?=gettext("Member Count")?></th>
|
306 |
|
|
<th><?=gettext("Actions")?></th>
|
307 |
|
|
</tr>
|
308 |
|
|
</thead>
|
309 |
|
|
<tbody>
|
310 |
64600f94
|
Sjon Hortensius
|
<?php
|
311 |
d61309a0
|
Phil Davis
|
foreach ($a_group as $i => $group):
|
312 |
|
|
if ($group["name"] == "all") {
|
313 |
64600f94
|
Sjon Hortensius
|
$groupcount = count($config['system']['user']);
|
314 |
d61309a0
|
Phil Davis
|
} else {
|
315 |
64600f94
|
Sjon Hortensius
|
$groupcount = count($group['member']);
|
316 |
d61309a0
|
Phil Davis
|
}
|
317 |
64600f94
|
Sjon Hortensius
|
?>
|
318 |
060ed238
|
Stephen Beaver
|
<tr>
|
319 |
|
|
<td>
|
320 |
|
|
<?=htmlspecialchars($group['name'])?>
|
321 |
|
|
</td>
|
322 |
|
|
<td>
|
323 |
|
|
<?=htmlspecialchars($group['description'])?>
|
324 |
|
|
</td>
|
325 |
|
|
<td>
|
326 |
|
|
<?=$groupcount?>
|
327 |
|
|
</td>
|
328 |
|
|
<td>
|
329 |
4611e283
|
Steve Beaver
|
<a class="fa fa-pencil" title="<?=gettext("Edit group"); ?>" href="?act=edit&groupid=<?=$i?>"></a>
|
330 |
060ed238
|
Stephen Beaver
|
<?php if ($group['scope'] != "system"): ?>
|
331 |
20231404
|
Steve Beaver
|
<a class="fa fa-trash" title="<?=gettext("Delete group")?>" href="?act=delgroup&groupid=<?=$i?>&groupname=<?=$group['name']?>" usepost></a>
|
332 |
060ed238
|
Stephen Beaver
|
<?php endif;?>
|
333 |
|
|
</td>
|
334 |
|
|
</tr>
|
335 |
64600f94
|
Sjon Hortensius
|
<?php
|
336 |
|
|
endforeach;
|
337 |
fab7ff44
|
Bill Marquette
|
?>
|
338 |
060ed238
|
Stephen Beaver
|
</tbody>
|
339 |
|
|
</table>
|
340 |
|
|
</div>
|
341 |
94404d94
|
Sander van Leeuwen
|
</div>
|
342 |
060ed238
|
Stephen Beaver
|
</div>
|
343 |
|
|
|
344 |
|
|
<nav class="action-buttons">
|
345 |
4611e283
|
Steve Beaver
|
<a href="?act=new" class="btn btn-success btn-sm">
|
346 |
060ed238
|
Stephen Beaver
|
<i class="fa fa-plus icon-embed-btn"></i>
|
347 |
|
|
<?=gettext("Add")?>
|
348 |
|
|
</a>
|
349 |
|
|
</nav>
|
350 |
64600f94
|
Sjon Hortensius
|
<?php
|
351 |
|
|
include('foot.inc');
|
352 |
|
|
exit;
|
353 |
6b07c15a
|
Matthew Grooms
|
}
|
354 |
|
|
|
355 |
64600f94
|
Sjon Hortensius
|
$form = new Form;
|
356 |
|
|
$form->setAction('system_groupmanager.php?act=edit');
|
357 |
|
|
$form->addGlobal(new Form_Input(
|
358 |
|
|
'groupid',
|
359 |
|
|
null,
|
360 |
|
|
'hidden',
|
361 |
|
|
$id
|
362 |
|
|
));
|
363 |
|
|
|
364 |
9d3e8723
|
Phil Davis
|
if (isset($id) && $a_group[$id]) {
|
365 |
64600f94
|
Sjon Hortensius
|
$form->addGlobal(new Form_Input(
|
366 |
|
|
'id',
|
367 |
|
|
null,
|
368 |
|
|
'hidden',
|
369 |
|
|
$id
|
370 |
|
|
));
|
371 |
|
|
|
372 |
|
|
$form->addGlobal(new Form_Input(
|
373 |
|
|
'gid',
|
374 |
|
|
null,
|
375 |
|
|
'hidden',
|
376 |
|
|
$pconfig['gid']
|
377 |
|
|
));
|
378 |
61dec0b0
|
Renato Botelho
|
}
|
379 |
|
|
|
380 |
5f88f964
|
k-paulius
|
$section = new Form_Section('Group Properties');
|
381 |
82833610
|
Stephen Beaver
|
|
382 |
e6acc2ee
|
Sjon Hortensius
|
$section->addInput($input = new Form_Input(
|
383 |
64600f94
|
Sjon Hortensius
|
'groupname',
|
384 |
153c3aa6
|
Phil Davis
|
'*Group name',
|
385 |
64600f94
|
Sjon Hortensius
|
'text',
|
386 |
|
|
$pconfig['name']
|
387 |
|
|
));
|
388 |
|
|
|
389 |
d61309a0
|
Phil Davis
|
if ($pconfig['gtype'] == "system") {
|
390 |
1192840b
|
Sjon Hortensius
|
$input->setReadonly();
|
391 |
79ed8ce0
|
Stephen Beaver
|
|
392 |
|
|
$section->addInput(new Form_Input(
|
393 |
|
|
'gtype',
|
394 |
153c3aa6
|
Phil Davis
|
'*Scope',
|
395 |
79ed8ce0
|
Stephen Beaver
|
'text',
|
396 |
|
|
$pconfig['gtype']
|
397 |
|
|
))->setReadonly();
|
398 |
|
|
} else {
|
399 |
|
|
$section->addInput(new Form_Select(
|
400 |
|
|
'gtype',
|
401 |
153c3aa6
|
Phil Davis
|
'*Scope',
|
402 |
79ed8ce0
|
Stephen Beaver
|
$pconfig['gtype'],
|
403 |
82833610
|
Stephen Beaver
|
["local" => gettext("Local"), "remote" => gettext("Remote")]
|
404 |
79ed8ce0
|
Stephen Beaver
|
));
|
405 |
d61309a0
|
Phil Davis
|
}
|
406 |
e6acc2ee
|
Sjon Hortensius
|
|
407 |
64600f94
|
Sjon Hortensius
|
$section->addInput(new Form_Input(
|
408 |
|
|
'description',
|
409 |
|
|
'Description',
|
410 |
|
|
'text',
|
411 |
|
|
$pconfig['description']
|
412 |
89140b63
|
NOYB
|
))->setHelp('Group description, for administrative information only');
|
413 |
64600f94
|
Sjon Hortensius
|
|
414 |
79ed8ce0
|
Stephen Beaver
|
|
415 |
64600f94
|
Sjon Hortensius
|
$form->add($section);
|
416 |
d61309a0
|
Phil Davis
|
if ($pconfig['gid'] != 1998) { // all users group
|
417 |
|
|
|
418 |
2f1e91e4
|
Stephen Beaver
|
// ==== Group membership ==================================================
|
419 |
|
|
$group = new Form_Group('Group membership');
|
420 |
|
|
|
421 |
|
|
// Make a list of all the groups configured on the system, and a list of
|
422 |
|
|
// those which this user is a member of
|
423 |
|
|
$systemGroups = array();
|
424 |
|
|
$usersGroups = array();
|
425 |
|
|
|
426 |
|
|
foreach ($config['system']['user'] as $user) {
|
427 |
d61309a0
|
Phil Davis
|
if (is_array($pconfig['members']) && in_array($user['uid'], $pconfig['members'])) {
|
428 |
2f1e91e4
|
Stephen Beaver
|
$usersGroups[ $user['uid'] ] = $user['name']; // Add it to the user's list
|
429 |
d61309a0
|
Phil Davis
|
} else {
|
430 |
2f1e91e4
|
Stephen Beaver
|
$systemGroups[ $user['uid'] ] = $user['name']; // Add it to the 'not a member of' list
|
431 |
d61309a0
|
Phil Davis
|
}
|
432 |
2f1e91e4
|
Stephen Beaver
|
}
|
433 |
|
|
|
434 |
|
|
$group->add(new Form_Select(
|
435 |
|
|
'notmembers',
|
436 |
|
|
null,
|
437 |
|
|
array_combine((array)$pconfig['groups'], (array)$pconfig['groups']),
|
438 |
|
|
$systemGroups,
|
439 |
|
|
true
|
440 |
6ef8f2e9
|
heper
|
))->setHelp('Not members');
|
441 |
64600f94
|
Sjon Hortensius
|
|
442 |
2f1e91e4
|
Stephen Beaver
|
$group->add(new Form_Select(
|
443 |
64600f94
|
Sjon Hortensius
|
'members',
|
444 |
2f1e91e4
|
Stephen Beaver
|
null,
|
445 |
|
|
array_combine((array)$pconfig['groups'], (array)$pconfig['groups']),
|
446 |
|
|
$usersGroups,
|
447 |
64600f94
|
Sjon Hortensius
|
true
|
448 |
6ef8f2e9
|
heper
|
))->setHelp('Members');
|
449 |
2f1e91e4
|
Stephen Beaver
|
|
450 |
|
|
$section->add($group);
|
451 |
|
|
|
452 |
|
|
$group = new Form_Group('');
|
453 |
|
|
|
454 |
|
|
$group->add(new Form_Button(
|
455 |
|
|
'movetoenabled',
|
456 |
faab522f
|
Renato Botelho
|
'Move to "Members"',
|
457 |
37676f4e
|
jim-p
|
null,
|
458 |
|
|
'fa-angle-double-right'
|
459 |
347c0214
|
Phil Davis
|
))->setAttribute('type','button')->removeClass('btn-primary')->addClass('btn-info btn-sm');
|
460 |
2f1e91e4
|
Stephen Beaver
|
|
461 |
|
|
$group->add(new Form_Button(
|
462 |
|
|
'movetodisabled',
|
463 |
faab522f
|
Renato Botelho
|
'Move to "Not members',
|
464 |
37676f4e
|
jim-p
|
null,
|
465 |
|
|
'fa-angle-double-left'
|
466 |
347c0214
|
Phil Davis
|
))->setAttribute('type','button')->removeClass('btn-primary')->addClass('btn-info btn-sm');
|
467 |
2f1e91e4
|
Stephen Beaver
|
|
468 |
e4c7d45f
|
NewEraCracker
|
$group->setHelp('Hold down CTRL (PC)/COMMAND (Mac) key to select multiple items.');
|
469 |
2f1e91e4
|
Stephen Beaver
|
$section->add($group);
|
470 |
64600f94
|
Sjon Hortensius
|
|
471 |
6b07c15a
|
Matthew Grooms
|
}
|
472 |
|
|
|
473 |
20231404
|
Steve Beaver
|
if ($_POST['act'] != "new") {
|
474 |
64600f94
|
Sjon Hortensius
|
$section = new Form_Section('Assigned Privileges');
|
475 |
|
|
|
476 |
|
|
$section->addInput(new Form_StaticText(
|
477 |
|
|
null,
|
478 |
2f1e91e4
|
Stephen Beaver
|
build_priv_table()
|
479 |
64600f94
|
Sjon Hortensius
|
));
|
480 |
6b07c15a
|
Matthew Grooms
|
|
481 |
2f1e91e4
|
Stephen Beaver
|
|
482 |
64600f94
|
Sjon Hortensius
|
$form->add($section);
|
483 |
6b07c15a
|
Matthew Grooms
|
}
|
484 |
|
|
|
485 |
64600f94
|
Sjon Hortensius
|
print $form;
|
486 |
2f1e91e4
|
Stephen Beaver
|
?>
|
487 |
8fd9052f
|
Colin Fleming
|
<script type="text/javascript">
|
488 |
2f1e91e4
|
Stephen Beaver
|
//<![CDATA[
|
489 |
d61309a0
|
Phil Davis
|
events.push(function() {
|
490 |
2f1e91e4
|
Stephen Beaver
|
|
491 |
|
|
// On click . .
|
492 |
|
|
$("#movetodisabled").click(function() {
|
493 |
|
|
moveOptions($('[name="members[]"] option'), $('[name="notmembers[]"]'));
|
494 |
|
|
});
|
495 |
|
|
|
496 |
|
|
$("#movetoenabled").click(function() {
|
497 |
|
|
moveOptions($('[name="notmembers[]"] option'), $('[name="members[]"]'));
|
498 |
|
|
});
|
499 |
|
|
|
500 |
|
|
// On submit mark all the user's groups as "selected"
|
501 |
d61309a0
|
Phil Davis
|
$('form').submit(function() {
|
502 |
2f1e91e4
|
Stephen Beaver
|
AllServers($('[name="members[]"] option'), true);
|
503 |
|
|
});
|
504 |
|
|
});
|
505 |
|
|
//]]>
|
506 |
|
|
</script>
|
507 |
|
|
<?php
|
508 |
854fa106
|
heper
|
include('foot.inc');
|