Portions created by the Initial Developer are Copyright (C) 2008-2012 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane James Rose */ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; if (permission_exists('acl_add') || permission_exists('acl_edit')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support require_once "app_languages.php"; foreach($text as $key => $value) { $text[$key] = $value[$_SESSION['domain']['language']['code']]; } //action add or update if (isset($_REQUEST["id"])) { $action = "update"; $acl_uuid = check_str($_REQUEST["id"]); } else { $action = "add"; } //get http post variables and set them to php variables if (count($_POST) > 0) { $acl_name = check_str($_POST["acl_name"]); $acl_type = check_str($_POST["acl_type"]); $acl_description = check_str($_POST["acl_description"]); } if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { if ($action == "update") { $acl_uuid = check_str($_POST["acl_uuid"]); } //check for all required data $msg = ''; if (strlen($acl_name) == 0) { $msg .= $text['message-required']." ".$text['label-acl_name']."
\n"; } if (strlen($acl_type) == 0) { $msg .= $text['message-required']." ".$text['label-acl_type']."
\n"; } if (strlen($acl_description) == 0) { $msg .= $text['message-required']." ".$text['label-acl_description']."
\n"; } if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; echo "
\n"; echo $msg."
"; echo "
\n"; persistformvar($_POST); echo "
\n"; require_once "resources/footer.php"; return; } //add or update the database if ($_POST["persistformvar"] != "true") { if ($action == "add" && permission_exists('acl_add')) { $sql = "insert into v_acl "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "acl_uuid, "; $sql .= "acl_name, "; $sql .= "acl_type, "; $sql .= "acl_description "; $sql .= ")"; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'".uuid()."', "; $sql .= "'$acl_name', "; $sql .= "'$acl_type', "; $sql .= "'$acl_description' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); $_SESSION['message'] = $text['message-add']; header('Location: acls.php'); return; } //if ($action == "add") if ($action == "update" && permission_exists('acl_edit')) { $sql = "update v_acl set "; $sql .= "acl_name = '$acl_name', "; $sql .= "acl_type = '$acl_type', "; $sql .= "acl_description = '$acl_description' "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and acl_uuid = '$acl_uuid'"; $db->exec(check_sql($sql)); unset($sql); $_SESSION['message'] = $text['message-update']; header('Location: acls.php'); return; } //if ($action == "update") } //if ($_POST["persistformvar"] != "true") } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) //pre-populate the form if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { $acl_uuid = check_str($_GET["id"]); $sql = "select * from v_acl "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and acl_uuid = '$acl_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { $acl_name = $row["acl_name"]; $acl_type = $row["acl_type"]; $acl_description = $row["acl_description"]; break; //limit to 1 row } unset ($prep_statement); } //show the header require_once "resources/header.php"; //show the content echo "
"; echo "\n"; echo "\n"; echo " "; echo " "; echo "
\n"; echo "
"; 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 "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " "; echo "
".$text['title-acl']."\n"; echo " "; echo " "; echo "
\n"; echo " ".$text['label-acl_name']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-acl_name']."\n"; echo "
\n"; echo " ".$text['label-acl_type']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-acl_type']."\n"; echo "
\n"; echo " ".$text['label-acl_description']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-acl_description']."\n"; echo "
\n"; if ($action == "update") { echo " \n"; } echo " \n"; echo "
"; echo ""; echo "
"; echo "
"; //include the footer require_once "resources/footer.php"; ?>