Portions created by the Initial Developer are Copyright (C) 2008-2014 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ include "root.php"; require_once "resources/require.php"; //check permissions require_once "resources/check_auth.php"; if (permission_exists('group_edit')) { //access allowed } else { echo "access denied"; return; } //add multi-lingual support $language = new text; $text = $language->get(); //process update if (count($_POST) > 0) { //set the variables $group_uuid = check_str($_POST['group_uuid']); $group_name = check_str($_POST['group_name']); $domain_uuid = check_str($_POST["domain_uuid"]); $group_description = check_str($_POST["group_description"]); //check for global/domain duplicates $sql = "select count(*) as num_rows from v_groups where "; $sql .= "group_name = '".$group_name."' "; $sql .= "and group_uuid <> '".$group_uuid."' "; $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 = "update v_groups "; $sql .= "set "; $sql .= "group_name = '".$group_name."', "; $sql .= "domain_uuid = ".(($domain_uuid != '') ? "'".$domain_uuid."'" : "null").", "; $sql .= "group_description = '".$group_description."' "; $sql .= "where group_uuid = '".$group_uuid."' "; if (!$db->exec(check_sql($sql))) { //echo $db->errorCode() . "
"; $info = $db->errorInfo(); echo "
".print_r($info, true)."
"; 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-update']; header("Location: groups.php"); } else { $_SESSION['message_mood'] = 'negative'; $_SESSION["message"] = $text['message-group_exists']; header("Location: groupedit.php?id=".$group_uuid); } //redirect the user return; } //pre-populate the form $group_uuid = check_str($_REQUEST['id']); if ($group_uuid != '') { $sql = "select * from v_groups where "; $sql .= "group_uuid = '".$group_uuid."' "; $prep_statement = $db->prepare($sql); if ($prep_statement) { $prep_statement->execute(); $row = $prep_statement->fetch(PDO::FETCH_ASSOC); $group_name = $row['group_name']; $domain_uuid = $row['domain_uuid']; $group_description = $row['group_description']; } } //include the header include "resources/header.php"; $document['title'] = $text['title-group_edit']; //show the content echo "
\n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['header-group_edit']."\n"; echo "

\n"; echo " ".$text['description-group_edit']."\n"; echo "
\n"; echo " "; echo " \n"; echo "
\n"; echo "
"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if (permission_exists('group_domain')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } else { echo ""; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo $text['label-group_name']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo " ".$text['label-domain']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-domain_name']."\n"; echo "
\n"; echo $text['label-group_description']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo "
"; echo " \n"; echo "
\n"; echo "

"; echo "
"; //include the footer include "resources/footer.php"; ?>