Groups: Integrate Show All and ability to edit assigned Domain. Create, edit, delete non-default groups.

Users: Adjust so assigned Domain doesn't get overwritten if user_all permission exists, but user_domain doesn't.
Destinations: Adjust so assigned Domain doesn't get overwritten if destination_all permission exists, but destination_domain doesn't.
This commit is contained in:
Nate Jones
2015-03-31 21:47:31 +00:00
parent 30bb3e211d
commit 88295a53d7
12 changed files with 548 additions and 233 deletions

View File

@@ -41,37 +41,68 @@ require_once "resources/require.php";
$text = $language->get();
//get the http values and set them as variables
$path = check_str($_GET["path"]);
$msg = check_str($_GET["msg"]);
$group_name = check_str($_POST["group_name"]);
$group_description = check_str($_POST["group_description"]);
if (count($_POST) > 0) {
//set the variables
$group_name = check_str($_POST["group_name"]);
if (permission_exists('group_domain')) {
$domain_uuid = check_str($_POST["domain_uuid"]);
}
else {
$domain_uuid = $_SESSION['domain_uuid'];
}
$group_description = check_str($_POST["group_description"]);
//insert into groups
if (strlen($group_name) > 0) {
$sql_insert = "insert into v_groups ";
$sql_insert .= "(";
$sql_insert .= "group_uuid, ";
$sql_insert .= "group_name, ";
$sql_insert .= "group_description ";
$sql_insert .= ")";
$sql_insert .= "values ";
$sql_insert .= "(";
$sql_insert .= "'".uuid()."', ";
$sql_insert .= "'$group_name', ";
$sql_insert .= "'$group_description' ";
$sql_insert .= ")";
if (!$db->exec($sql_insert)) {
//echo $db->errorCode() . "<br>";
$info = $db->errorInfo();
print_r($info);
// $info[0] == $db->errorCode() unified error code
// $info[1] is the driver specific error code
// $info[2] is the driver specific error string
}
//check for global/domain duplicates
$sql = "select count(*) as num_rows from v_groups where ";
$sql .= "group_name = '".$group_name."' ";
$sql .= "and domain_uuid ".(($domain_uuid != '') ? " = '".$domain_uuid."' " : " is null ");
$prep_statement = $db->prepare($sql);
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
$group_exists = ($row['num_rows'] > 0) ? true : false;
}
else {
$group_exists = false;
}
unset($sql, $prep_statement, $row);
//insert group
if (!$group_exists) {
$sql = "insert into v_groups ";
$sql .= "(";
$sql .= "group_uuid, ";
$sql .= "domain_uuid, ";
$sql .= "group_name, ";
$sql .= "group_description ";
$sql .= ")";
$sql .= "values ";
$sql .= "(";
$sql .= "'".uuid()."', ";
$sql .= (($domain_uuid != '') ? "'".$domain_uuid."'" : "null").", ";
$sql .= "'".$group_name."', ";
$sql .= "'".$group_description."' ";
$sql .= ")";
if (!$db->exec($sql)) {
//echo $db->errorCode() . "<br>";
$info = $db->errorInfo();
echo "<pre>".print_r($info, true)."</pre>";
exit;
// $info[0] == $db->errorCode() unified error code
// $info[1] is the driver specific error code
// $info[2] is the driver specific error string
}
$_SESSION["message"] = $text['message-add'];
header("Location: groups.php");
}
else {
$_SESSION['message_mood'] = 'negative';
$_SESSION["message"] = $text['message-group_exists'];
header("Location: groupadd.php");
}
//redirect the user
$_SESSION["message"] = $text['message-add'];
header("Location: groups.php");
return;
}
@@ -80,48 +111,64 @@ require_once "resources/require.php";
$document['title'] = $text['title-group_add'];
//show the content
echo "<form name='login' method='post' action=''>\n";
echo "<table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td align='left'>\n";
echo " <td align='left' valign='top'>\n";
echo " <b>".$text['header-group_add']."</b>\n";
echo " <br><br>\n";
echo " ".$text['description-group_add']."\n";
echo " </td>\n";
echo " <td align='right'>\n";
echo " <td align='right' valign='top'>\n";
echo " <input type='button' class='btn' name='' alt='back' onclick=\"window.location='groups.php'\" value='".$text['button-back']."'> ";
echo " <input type=\"submit\" class='btn' value=\"".$text['button-save']."\">\n";
echo " <input type='submit' class='btn' value=\"".$text['button-save']."\">\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<br>";
echo "<form name='login' METHOD=\"POST\" action=\"groupadd.php\">\n";
echo "<table width='100%' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncellreq'>\n";
echo $text['label-group_name']."\n";
echo "</td>\n";
echo "<td width='70%' align='left' class='vtable'>\n";
echo " <input type=\"text\" class='formfld' name=\"group_name\">\n";
echo " <input type='text' class='formfld' name='group_name'>\n";
echo "</td>\n";
echo "</tr>\n";
if (permission_exists('group_domain')) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-domain']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='domain_uuid'>\n";
echo " <option value='' ".((strlen($domain_uuid) == 0) ? "selected='selected'" : null).">".$text['option-global']."</option>\n";
foreach ($_SESSION['domains'] as $row) {
echo " <option value='".$row['domain_uuid']."' ".(($row['domain_uuid'] == $domain_uuid) ? "selected='selected'" : null).">".$row['domain_name']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-domain_name']."\n";
echo "</td>\n";
echo "</tr>\n";
}
echo "<tr>\n";
echo "<td class='vncellreq'>\n";
echo "<td class='vncell'>\n";
echo $text['label-group_description']."\n";
echo "</td>\n";
echo "<td align='left' class='vtable'>\n";
echo "<textarea name='group_description' class='formfld'></textarea>\n";
echo "<textarea name='group_description' class='formfld' style='width: 250px; height: 50px;'></textarea>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>\n";
echo "</td>\n";
echo "<td align=\"right\">\n";
echo " <input type=\"hidden\" name=\"path\" value=\"$path\">\n";
echo " <br><br>";
echo " <input type=\"submit\" class='btn' value=\"".$text['button-save']."\">\n";
echo "<td colspan='2' align='right'>\n";
echo " <br />";
echo " <input type='submit' class='btn' value=\"".$text['button-save']."\">\n";
echo "</td>\n";
echo "</tr>\n";