1 |
6b07c15a
|
Matthew Grooms
|
<?php
|
2 |
|
|
/* $Id$ */
|
3 |
|
|
/*
|
4 |
|
|
system_groupmanager_addprivs.php
|
5 |
|
|
|
6 |
|
|
Copyright (C) 2006 Daniel S. Haischt.
|
7 |
|
|
All rights reserved.
|
8 |
|
|
|
9 |
|
|
Redistribution and use in source and binary forms, with or without
|
10 |
|
|
modification, are permitted provided that the following conditions are met:
|
11 |
|
|
|
12 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
13 |
|
|
this list of conditions and the following disclaimer.
|
14 |
|
|
|
15 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
16 |
|
|
notice, this list of conditions and the following disclaimer in the
|
17 |
|
|
documentation and/or other materials provided with the distribution.
|
18 |
|
|
|
19 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
20 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
21 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
22 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
23 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
24 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
25 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
26 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
29 |
|
|
*/
|
30 |
1d333258
|
Scott Ullrich
|
/*
|
31 |
|
|
pfSense_MODULE: auth
|
32 |
|
|
*/
|
33 |
6b07c15a
|
Matthew Grooms
|
|
34 |
|
|
##|+PRIV
|
35 |
|
|
##|*IDENT=page-system-groupmanager-addprivs
|
36 |
|
|
##|*NAME=System: Group Manager: Add Privileges page
|
37 |
|
|
##|*DESCR=Allow access to the 'System: Group Manager: Add Privileges' page.
|
38 |
|
|
##|*MATCH=system_groupmanager_addprivs.php*
|
39 |
|
|
##|-PRIV
|
40 |
|
|
|
41 |
4504a769
|
Ermal Lu?i
|
function cpusercmp($a, $b) {
|
42 |
|
|
return strcasecmp($a['name'], $b['name']);
|
43 |
|
|
}
|
44 |
|
|
|
45 |
0d64af59
|
Ermal Lu?i
|
function admin_groups_sort() {
|
46 |
4504a769
|
Ermal Lu?i
|
global $config;
|
47 |
0d64af59
|
Ermal Lu?i
|
|
48 |
|
|
if (!is_array($config['system']['group']))
|
49 |
|
|
return;
|
50 |
|
|
|
51 |
|
|
usort($config['system']['group'], "cpusercmp");
|
52 |
|
|
}
|
53 |
6b07c15a
|
Matthew Grooms
|
|
54 |
|
|
require("guiconfig.inc");
|
55 |
|
|
|
56 |
c3c68a70
|
Vinicius Coque
|
$pgtitle = array(gettext("System"),gettext("Group manager"),gettext("Add privileges"));
|
57 |
6b07c15a
|
Matthew Grooms
|
|
58 |
|
|
$groupid = $_GET['groupid'];
|
59 |
|
|
if (isset($_POST['groupid']))
|
60 |
|
|
$groupid = $_POST['groupid'];
|
61 |
|
|
|
62 |
|
|
$a_group = & $config['system']['group'][$groupid];
|
63 |
|
|
|
64 |
|
|
if (!is_array($a_group)) {
|
65 |
|
|
pfSenseHeader("system_groupmanager.php?id={$groupid}");
|
66 |
|
|
exit;
|
67 |
|
|
}
|
68 |
|
|
|
69 |
|
|
if (!is_array($a_group['priv']))
|
70 |
|
|
$a_group['priv'] = array();
|
71 |
|
|
|
72 |
|
|
if ($_POST) {
|
73 |
|
|
|
74 |
|
|
unset($input_errors);
|
75 |
|
|
$pconfig = $_POST;
|
76 |
|
|
|
77 |
|
|
/* input validation */
|
78 |
|
|
$reqdfields = explode(" ", "sysprivs");
|
79 |
76d49f20
|
Renato Botelho
|
$reqdfieldsn = array(gettext("Selected priveleges"));
|
80 |
6b07c15a
|
Matthew Grooms
|
|
81 |
|
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
82 |
|
|
|
83 |
|
|
/* if this is an AJAX caller then handle via JSON */
|
84 |
|
|
if(isAjax() && is_array($input_errors)) {
|
85 |
|
|
input_errors2Ajax($input_errors);
|
86 |
|
|
exit;
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
if (!$input_errors) {
|
90 |
|
|
|
91 |
|
|
if (!is_array($pconfig['sysprivs']))
|
92 |
|
|
$pconfig['sysprivs'] = array();
|
93 |
|
|
|
94 |
|
|
if (!count($a_group['priv']))
|
95 |
|
|
$a_group['priv'] = $pconfig['sysprivs'];
|
96 |
|
|
else
|
97 |
|
|
$a_group['priv'] = array_merge($a_group['priv'], $pconfig['sysprivs']);
|
98 |
|
|
|
99 |
2ee08031
|
Erik Fonnesbeck
|
if (is_array($a_group['member'])) {
|
100 |
|
|
foreach ($a_group['member'] as $uid) {
|
101 |
|
|
$user = getUserEntryByUID($uid);
|
102 |
|
|
if ($user)
|
103 |
|
|
local_user_set($user);
|
104 |
|
|
}
|
105 |
6b07c15a
|
Matthew Grooms
|
}
|
106 |
|
|
|
107 |
0d64af59
|
Ermal Lu?i
|
admin_groups_sort();
|
108 |
|
|
|
109 |
6b07c15a
|
Matthew Grooms
|
$retval = write_config();
|
110 |
|
|
$savemsg = get_std_save_message($retval);
|
111 |
|
|
|
112 |
|
|
pfSenseHeader("system_groupmanager.php?act=edit&id={$groupid}");
|
113 |
|
|
exit;
|
114 |
|
|
}
|
115 |
|
|
}
|
116 |
|
|
|
117 |
|
|
/* if ajax is calling, give them an update message */
|
118 |
|
|
if(isAjax())
|
119 |
|
|
print_info_box_np($savemsg);
|
120 |
|
|
|
121 |
|
|
include("head.inc");
|
122 |
|
|
?>
|
123 |
|
|
|
124 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
|
125 |
|
|
<?php include("fbegin.inc"); ?>
|
126 |
f1a73dbf
|
sullrich
|
<script src="/javascript/scriptaculous/prototype.js" type="text/javascript">
|
127 |
|
|
</script>
|
128 |
6b07c15a
|
Matthew Grooms
|
<script type="text/javascript">
|
129 |
|
|
<!--
|
130 |
|
|
|
131 |
|
|
<?php
|
132 |
|
|
|
133 |
|
|
if (is_array($priv_list)) {
|
134 |
|
|
$id = 0;
|
135 |
|
|
|
136 |
|
|
$jdescs = "var descs = new Array();\n";
|
137 |
|
|
foreach($priv_list as $pname => $pdata) {
|
138 |
|
|
if (in_array($pname, $a_group['priv']))
|
139 |
|
|
continue;
|
140 |
|
|
$desc = addslashes($pdata['descr']);
|
141 |
|
|
$jdescs .= "descs[{$id}] = '{$desc}';\n";
|
142 |
|
|
$id++;
|
143 |
|
|
}
|
144 |
|
|
|
145 |
|
|
echo $jdescs;
|
146 |
|
|
}
|
147 |
|
|
|
148 |
|
|
?>
|
149 |
|
|
|
150 |
|
|
function update_description() {
|
151 |
|
|
var index = document.iform.sysprivs.selectedIndex;
|
152 |
|
|
document.getElementById("pdesc").innerHTML = descs[index];
|
153 |
|
|
}
|
154 |
|
|
|
155 |
|
|
//-->
|
156 |
|
|
</script>
|
157 |
|
|
<?php
|
158 |
|
|
if ($input_errors)
|
159 |
|
|
print_input_errors($input_errors);
|
160 |
|
|
if ($savemsg)
|
161 |
|
|
print_info_box($savemsg);
|
162 |
|
|
?>
|
163 |
e30001cf
|
Matthew Grooms
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
164 |
|
|
<tr>
|
165 |
|
|
<td>
|
166 |
|
|
<?php
|
167 |
|
|
$tab_array = array();
|
168 |
|
|
$tab_array[] = array(gettext("Users"), false, "system_usermanager.php");
|
169 |
|
|
$tab_array[] = array(gettext("Groups"), true, "system_groupmanager.php");
|
170 |
|
|
$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
|
171 |
|
|
$tab_array[] = array(gettext("Servers"), false, "system_authservers.php");
|
172 |
|
|
display_top_tabs($tab_array);
|
173 |
|
|
?>
|
174 |
|
|
</td>
|
175 |
|
|
</tr>
|
176 |
|
|
<tr>
|
177 |
|
|
<td id="mainarea">
|
178 |
|
|
<div class="tabcont">
|
179 |
|
|
<form action="system_groupmanager_addprivs.php" method="post" name="iform" id="iform">
|
180 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
181 |
|
|
<tr>
|
182 |
|
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("System Privileges");?></td>
|
183 |
|
|
<td width="78%" class="vtable">
|
184 |
f1a73dbf
|
sullrich
|
<table>
|
185 |
|
|
<tr><td>
|
186 |
e30001cf
|
Matthew Grooms
|
<select name="sysprivs[]" id="sysprivs" class="formselect" onchange="update_description();" multiple>
|
187 |
|
|
<?php
|
188 |
|
|
foreach($priv_list as $pname => $pdata):
|
189 |
|
|
if (in_array($pname, $a_group['priv']))
|
190 |
|
|
continue;
|
191 |
|
|
?>
|
192 |
|
|
<option value="<?=$pname;?>"><?=$pdata['name'];?></option>
|
193 |
|
|
<?php endforeach; ?>
|
194 |
|
|
</select>
|
195 |
|
|
<br/>
|
196 |
|
|
<?=gettext("Hold down CTRL (pc)/COMMAND (mac) key to select multiple items");?>
|
197 |
f1a73dbf
|
sullrich
|
</td><td>
|
198 |
|
|
<a href='#'onClick="selectAll();">Select all</a>
|
199 |
|
|
<script type="text/javascript">
|
200 |
|
|
function selectAll() {
|
201 |
|
|
var options = $$('select#sysprivs option');
|
202 |
|
|
var len = options.length;
|
203 |
|
|
for (var i = 0; i < len; i++) {
|
204 |
|
|
options[i].selected = true;
|
205 |
|
|
}
|
206 |
|
|
}
|
207 |
|
|
selectAll();
|
208 |
|
|
</script>
|
209 |
|
|
<br/>
|
210 |
|
|
</td>
|
211 |
|
|
</tr>
|
212 |
|
|
</table>
|
213 |
e30001cf
|
Matthew Grooms
|
</td>
|
214 |
|
|
</tr>
|
215 |
|
|
<tr height="60">
|
216 |
|
|
<td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
|
217 |
|
|
<td width="78%" valign="top" class="vtable" id="pdesc">
|
218 |
c3c68a70
|
Vinicius Coque
|
<em><?=gettext("Select a privilege from the list above for a description");?></em>
|
219 |
e30001cf
|
Matthew Grooms
|
</td>
|
220 |
|
|
</tr>
|
221 |
|
|
<tr>
|
222 |
|
|
<td width="22%" valign="top"> </td>
|
223 |
|
|
<td width="78%">
|
224 |
|
|
<input id="submitt" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
|
225 |
|
|
<input id="cancelbutton" class="formbtn" type="button" value="<?=gettext("Cancel");?>" onclick="history.back()" />
|
226 |
|
|
<?php if (isset($groupid)): ?>
|
227 |
|
|
<input name="groupid" type="hidden" value="<?=$groupid;?>" />
|
228 |
|
|
<?php endif; ?>
|
229 |
|
|
</td>
|
230 |
|
|
</tr>
|
231 |
|
|
</table>
|
232 |
|
|
</form>
|
233 |
|
|
</div>
|
234 |
|
|
</td>
|
235 |
|
|
</tr>
|
236 |
|
|
</table>
|
237 |
6b07c15a
|
Matthew Grooms
|
<?php include("fend.inc"); ?>
|
238 |
|
|
</body>
|
239 |
|
|
</html>
|