Portions created by the Initial Developer are Copyright (C) 2008-2018 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane Luis Daniel Lucio Quiroz Igor Olhovskiy Call ACL is written on Call Block base by Gerrit Visser */ //includes require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; //check permissions if (permission_exists('call_acl_edit') || permission_exists('call_acl_add')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //action add or update if (isset($_REQUEST["id"])) { $action = "update"; $call_acl_uuid = check_str($_REQUEST["id"]); } else { $action = "add"; } //get http post variables and set them to php variables if (count($_POST) > 0) { $call_acl_order = check_str($_POST["call_acl_order"]); $call_acl_name = check_str($_POST["call_acl_name"]); $call_acl_source = check_str($_POST["call_acl_source"]); $call_acl_destination = check_str($_POST["call_acl_destination"]); $call_acl_action = check_str($_POST["call_acl_action"]); $call_acl_enabled = check_str($_POST["call_acl_enabled"]); } //handle the http post if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $msg = ''; //check for all required data if (strlen($call_acl_name) == 0) { $msg .= $text['label-call_acl_name']."
\n"; } if (strlen($call_acl_source) == 0) { $msg .= $text['label-call_acl_source']."
\n"; } if (strlen($call_acl_destination) == 0) { $msg .= $text['label-call_acl_destination']."
\n"; } if (strlen($call_acl_order) == 0) { $msg .= $text['label-call_acl_order']."
\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") > 0) { if ($action == "add") { $call_acl_uuid = uuid(); $sql = "INSERT INTO v_call_acl"; $sql .= " ("; $sql .= "domain_uuid, "; $sql .= "call_acl_uuid, "; $sql .= "call_acl_order, "; $sql .= "call_acl_name, "; $sql .= "call_acl_source, "; $sql .= "call_acl_destination, "; $sql .= "call_acl_action, "; $sql .= "call_acl_enabled "; $sql .= ") "; $sql .= "VALUES "; $sql .= "("; $sql .= "'".$_SESSION['domain_uuid']."', "; $sql .= "'$call_acl_uuid', "; $sql .= "'$call_acl_order', "; $sql .= "'$call_acl_name', "; $sql .= "'$call_acl_source', "; $sql .= "'$call_acl_destination', "; $sql .= "'$call_acl_action', "; $sql .= "'$call_acl_enabled'"; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); messages::add($text['label-add-complete']); header("Location: call_acl.php"); return; } //if ($action == "add") if ($action == "update") { $sql = "UPDATE v_call_acl SET "; $sql .= "call_acl_order = '$call_acl_order', "; $sql .= "call_acl_name = '$call_acl_name', "; $sql .= "call_acl_source = '$call_acl_source', "; $sql .= "call_acl_destination = '$call_acl_destination', "; $sql .= "call_acl_action = '$call_acl_action', "; $sql .= "call_acl_enabled = '$call_acl_enabled' "; $sql .= "WHERE domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "AND call_acl_uuid = '$call_acl_uuid'"; $db->exec(check_sql($sql)); unset($sql); messages::add($text['label-update-complete']); header("Location: call_acl.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") { $call_acl_uuid = $_GET["id"]; $sql = "SELECT * FROM v_call_acl "; $sql .= "WHERE domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "AND call_acl_uuid = '$call_acl_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(); foreach ($result as &$row) { $call_acl_order = $row["call_acl_order"]; $call_acl_name = $row["call_acl_name"]; $call_acl_source = $row["call_acl_source"]; $call_acl_destination = $row["call_acl_destination"]; $call_acl_action = $row["call_acl_action"]; $call_acl_enabled = $row["call_acl_enabled"]; break; //limit to 1 row ? Should be only 1 result at all } unset ($prep_statement, $sql); } // Get maximum order number $call_acl_order_max = isset($_SESSION['call_acl']['max_order']['numeric']) ? (int)$_SESSION['call_acl']['max_order']['numeric'] : 20; if (!$call_acl_order_max) { $call_acl_order_max = 20; } //show the header require_once "resources/header.php"; //show the content echo "
\n"; echo "\n"; echo "\n"; if ($action == "add") { echo "\n"; } if ($action == "update") { echo "\n"; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; // Show order TODO echo "\n"; echo "\n"; echo "\n"; echo "\n"; // Show name echo "\n"; echo "\n"; echo "\n"; echo "\n"; // Show source echo "\n"; echo "\n"; echo "\n"; echo "\n"; // Show destination echo "\n"; echo "\n"; echo "\n"; echo "\n"; // Show action echo "\n"; echo "\n"; echo "\n"; echo "\n"; // Show enabled echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " "; echo "
".$text['label-edit-add']."".$text['label-edit-edit'].""; echo " "; echo " \n"; echo "
\n"; if ($action == "add") { echo $text['label-add-note']."

\n"; } if ($action == "update") { echo $text['label-edit-note']."

\n"; } echo "
\n"; echo " ".$text['label-call_acl_order']."\n"; echo "\n"; echo "\n"; echo "
\n"; echo $text['description-call_acl_order']."\n"; echo "
\n"; echo "
\n"; echo " ".$text['label-call_acl_name']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-call_acl_name']."\n"; echo "
\n"; echo " ".$text['label-call_acl_source']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-call_acl_source']."\n"; echo "
\n"; echo " ".$text['label-call_acl_destination']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-call_acl_destination']."\n"; echo "
\n"; echo " ".$text['label-call_acl_action']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-call_acl_action']."\n"; echo "\n"; echo "
\n"; echo " ".$text['label-call_acl_enabled']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-call_acl_enabled']."\n"; echo "\n"; echo "
\n"; if ($action == "update") { echo " \n"; } echo "
"; echo " \n"; echo "
"; echo "

"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo "
"; echo $text['description-call_acl_templates']; echo "
"; //include the footer require_once "resources/footer.php"; ?>