Project

General

Profile

« Previous | Next » 

Revision 64600f94

Added by Sjon Hortensius about 10 years ago

Some bugfixes, converted addPrivs

refs #18

View differences:

usr/local/www/system_groupmanager_addprivs.php
44 44
}
45 45

  
46 46
function admin_groups_sort() {
47
        global $config;
47
	global $config;
48 48

  
49
        if (!is_array($config['system']['group']))
50
                return;
49
	if (!is_array($config['system']['group']))
50
			return;
51 51

  
52
        usort($config['system']['group'], "cpusercmp");
52
	usort($config['system']['group'], "cpusercmp");
53 53
}
54 54

  
55 55
require("guiconfig.inc");
......
58 58

  
59 59
if (is_numericint($_GET['groupid']))
60 60
	$groupid = $_GET['groupid'];
61
if (isset($_POST['groupid']) && is_numericint($_POST['groupid']))
61
elseif (isset($_POST['groupid']) && is_numericint($_POST['groupid']))
62 62
	$groupid = $_POST['groupid'];
63 63

  
64 64
$a_group = & $config['system']['group'][$groupid];
......
111 111
		$retval = write_config();
112 112
		$savemsg = get_std_save_message($retval);
113 113

  
114
		pfSenseHeader("system_groupmanager.php?act=edit&id={$groupid}");
114
		pfSenseHeader("system_groupmanager.php?act=edit&groupid={$groupid}");
115 115
		exit;
116 116
	}
117 117
}
......
121 121
	print_info_box_np($savemsg);
122 122

  
123 123
include("head.inc");
124
?>
125 124

  
126
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
127
<?php include("fbegin.inc"); ?>
128
<script type="text/javascript">
129
//<![CDATA[
125
if ($input_errors)
126
	print_input_errors($input_errors);
127
if ($savemsg)
128
	print_info_box($savemsg);
129

  
130
$tab_array = array();
131
$tab_array[] = array(gettext("Users"), false, "system_usermanager.php");
132
$tab_array[] = array(gettext("Groups"), true, "system_groupmanager.php");
133
$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
134
$tab_array[] = array(gettext("Servers"), false, "system_authservers.php");
135
display_top_tabs($tab_array);
136

  
137
require('classes/Form.class.php');
138
$form = new Form;
139
if (isset($groupid))
140
{
141
	$form->addGlobal(new Form_Input(
142
		'groupid',
143
		null,
144
		'hidden',
145
		$groupid
146
	));
147
}
130 148

  
131
<?php
149
$section = new Form_Section('Add privileges for '. $a_group['name']);
132 150

  
133
if (is_array($priv_list)) {
134
	$id = 0;
151
$priv_list = array_map(function($p){ return $p['name']; }, $priv_list);
152
asort($priv_list);
135 153

  
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
	}
154
$section->addInput(new Form_Select(
155
	'sysprivs',
156
	'Assigned privileges',
157
	$a_group['priv'],
158
	$priv_list,
159
	true
160
))->setHelp('Hold down CTRL (pc)/COMMAND (mac) key to select')->setAttribute('size', 30);
144 161

  
145
	echo $jdescs;
146
}
162
$form->add($section);
147 163

  
148
?>
164
print $form;
149 165

  
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
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="group manager add privileges">
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" summary="main area">
181
						<tr>
182
							<td width="22%" valign="top" class="vncellreq"><?=gettext("System Privileges");?></td>
183
							<td width="78%" class="vtable">
184
								<table>
185
									<tr><td>
186
								<select name="sysprivs[]" id="sysprivs" class="formselect" onchange="update_description();" multiple="multiple" size="35">
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
								</td><td>
198
								<a href='#'onClick="selectAll();">Select all</a>
199
								<script type="text/javascript">
200
								//<![CDATA[
201
									function selectAll() {
202
										var options = jQuery('select#sysprivs option');
203
										var len = options.length;
204
										for (var i = 0; i < len; i++) {
205
										    options[i].selected = true;
206
										}
207
									}
208
									selectAll();
209
								//]]>									
210
								</script>
211
								<br />
212
								</td>
213
								</tr>
214
								</table>
215
							</td>
216
						</tr>
217
						<tr height="60">
218
							<td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
219
							<td width="78%" valign="top" class="vtable" id="pdesc">
220
								<em><?=gettext("Select a privilege from the list above for a description");?></em>
221
							</td>
222
						</tr>
223
						<tr>
224
							<td width="22%" valign="top">&nbsp;</td>
225
							<td width="78%">
226
								<input id="submitt"  name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
227
								<input id="cancelbutton" class="formbtn" type="button" value="<?=gettext("Cancel");?>" onclick="history.back()" />
228
								<?php if (isset($groupid)): ?>
229
								<input name="groupid" type="hidden" value="<?=htmlspecialchars($groupid);?>" />
230
								<?php endif; ?>
231
							</td>
232
						</tr>
233
					</table>
234
				</form>
235
			</div>
236
		</td>
237
	</tr>
238
</table>
239
<?php include("fend.inc"); ?>
240
</body>
241
</html>
166
include('foot.inc');

Also available in: Unified diff