*/
require "auth.inc";
require "guiconfig.inc";
if (isset($_GET['uuid'])) {
    $uuid = $_GET['uuid'];
}
if (isset($_POST['uuid'])) {
    $uuid = $_POST['uuid'];
}
$pgtitle = array(gettext("Access"), gettext("Groups"), isset($uuid) ? gettext("Edit") : gettext("Add"));
if (!isset($config['access']['group']) || !is_array($config['access']['group'])) {
    $config['access']['group'] = array();
}
array_sort_key($config['access']['group'], "name");
$a_group =& $config['access']['group'];
$a_group_system = system_get_group_list();
if (isset($uuid) && FALSE !== ($cnid = array_search_ex($uuid, $a_group, "uuid"))) {
    $pconfig['uuid'] = $a_group[$cnid]['uuid'];
    $pconfig['groupid'] = $a_group[$cnid]['id'];
    $pconfig['name'] = $a_group[$cnid]['name'];
    $pconfig['desc'] = $a_group[$cnid]['desc'];
} else {
    $pconfig['uuid'] = uuid();
    $pconfig['groupid'] = get_nextgroup_id();
    $pconfig['name'] = "";
    $pconfig['desc'] = "";
}
if ($_POST) {
    unset($input_errors);
    $pconfig = $_POST;
    if (isset($_POST['Cancel']) && $_POST['Cancel']) {
?>
					<?php 
html_titleline(gettext("Access Restrictions"));
?>
					<?php 
$a_owner = array();
foreach (system_get_user_list() as $userk => $userv) {
    $a_owner[$userk] = htmlspecialchars($userk);
}
?>
					<?php 
html_combobox("owner", gettext("Owner"), $pconfig['owner'], $a_owner, "", false);
?>
					<?php 
$a_group = array();
foreach (system_get_group_list() as $groupk => $groupv) {
    $a_group[$groupk] = htmlspecialchars($groupk);
}
?>
					<?php 
html_combobox("group", gettext("Group"), $pconfig['group'], $a_group, "", false);
?>
					<tr>
						<td width="22%" valign="top" class="vncell"><?php 
echo gettext("Mode");
?>
</td>
						<td width="78%" class="vtable">
							<table width="100%" border="0" cellpadding="0" cellspacing="0">
								<tr>
									<td width="20%" class="listhdrlr">&nbsp;</td>