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_add')) { //access allowed } else { echo "access denied"; return; } //add multi-lingual support $language = new text; $text = $language->get(); //get the http values and set them as variables 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"]); //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() . "
"; $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-add']; header("Location: groups.php"); } else { $_SESSION['message_mood'] = 'negative'; $_SESSION["message"] = $text['message-group_exists']; header("Location: groupadd.php"); } //redirect the user return; } //include the header include "resources/header.php"; $document['title'] = $text['title-group_add']; //show the content echo "
\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['header-group_add']."\n"; echo "

\n"; echo " ".$text['description-group_add']."\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"; } 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"; ?>