Portions created by the Initial Developer are Copyright (C) 2008-2013 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; if (permission_exists('dialplan_add') || permission_exists('dialplan_edit') || permission_exists('inbound_route_add') || permission_exists('inbound_route_edit') || permission_exists('outbound_route_add') || permission_exists('outbound_route_edit') || permission_exists('fifo_edit') || permission_exists('fifo_add') || permission_exists('time_condition_add') || permission_exists('time_condition_edit')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //set the action as an add or update if (isset($_REQUEST["id"])) { $action = "update"; $dialplan_detail_uuid = check_str($_REQUEST["id"]); } else { $action = "add"; } $dialplan_uuid = check_str($_REQUEST["dialplan_uuid"]); //get the http values and set them as php variables $app_uuid = check_str($_REQUEST["app_uuid"]); if (count($_POST)>0) { $dialplan_uuid = check_str($_POST["dialplan_uuid"]); $dialplan_detail_tag = check_str($_POST["dialplan_detail_tag"]); $dialplan_detail_order = check_str($_POST["dialplan_detail_order"]); $dialplan_detail_type = check_str($_POST["dialplan_detail_type"]); $dialplan_detail_data = check_str($_POST["dialplan_detail_data"]); $dialplan_detail_break = check_str($_POST["dialplan_detail_break"]); $dialplan_detail_inline = check_str($_POST["dialplan_detail_inline"]); $dialplan_detail_group = check_str($_POST["dialplan_detail_group"]); } if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $msg = ''; if ($action == "update") { $dialplan_detail_uuid = check_str($_POST["dialplan_detail_uuid"]); } //check for all required data if (strlen($dialplan_detail_tag) == 0) { $msg .= $text['message-required'].$text['label-tag']."
\n"; } if (strlen($dialplan_detail_order) == 0) { $msg .= $text['message-required'].$text['label-order']."
\n"; } //if (strlen($dialplan_detail_type) == 0) { $msg .= $text['message-required'].$text['label-type']."
\n"; } //if (strlen($dialplan_detail_data) == 0) { $msg .= $text['message-required'].$text['label-data']."
\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('dialplan_add')) { $dialplan_detail_uuid = uuid(); $sql = "insert into v_dialplan_details "; $sql .= "("; $sql .= "dialplan_uuid, "; $sql .= "dialplan_detail_uuid, "; $sql .= "dialplan_detail_tag, "; $sql .= "dialplan_detail_order, "; $sql .= "dialplan_detail_type, "; $sql .= "dialplan_detail_data, "; $sql .= "dialplan_detail_break, "; $sql .= "dialplan_detail_inline, "; $sql .= "dialplan_detail_group, "; $sql .= "domain_uuid "; $sql .= ")"; $sql .= "values "; $sql .= "("; $sql .= "'$dialplan_uuid', "; $sql .= "'$dialplan_detail_uuid', "; $sql .= "'$dialplan_detail_tag', "; $sql .= "'$dialplan_detail_order', "; $sql .= "'$dialplan_detail_type', "; $sql .= "'$dialplan_detail_data', "; $sql .= "'$dialplan_detail_break', "; $sql .= "'$dialplan_detail_inline', "; if (strlen($dialplan_detail_group) == 0) { $sql .= "null, "; } else { $sql .= "'$dialplan_detail_group', "; } $sql .= "'".$_SESSION['domain_uuid']."' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); //synchronize the xml config save_dialplan_xml(); //delete the dialplan context from memcache $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); if ($fp) { $switch_cmd = "memcache delete dialplan:".$_SESSION["context"]; $switch_result = event_socket_request($fp, 'api '.$switch_cmd); } $_SESSION["message"] = $text['message-add']; header("Location: dialplan_edit.php?id=".$dialplan_uuid."&app_uuid=".$app_uuid); return; } //if ($action == "add") if ($action == "update" && permission_exists('dialplan_edit')) { $sql = "update v_dialplan_details set "; $sql .= "dialplan_uuid = '$dialplan_uuid', "; $sql .= "dialplan_detail_tag = '$dialplan_detail_tag', "; $sql .= "dialplan_detail_order = '$dialplan_detail_order', "; $sql .= "dialplan_detail_type = '$dialplan_detail_type', "; $sql .= "dialplan_detail_data = '$dialplan_detail_data', "; $sql .= "dialplan_detail_break = '$dialplan_detail_break', "; $sql .= "dialplan_detail_inline = '$dialplan_detail_inline', "; if (strlen($dialplan_detail_group) == 0) { $sql .= "dialplan_detail_group = null "; } else { $sql .= "dialplan_detail_group = '$dialplan_detail_group' "; } $sql .= "where (domain_uuid = '".$_SESSION['domain_uuid']."' or domain_uuid is null) "; $sql .= "and dialplan_detail_uuid = '$dialplan_detail_uuid'"; $db->exec(check_sql($sql)); unset($sql); //synchronize the xml config save_dialplan_xml(); //delete the dialplan context from memcache $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); if ($fp) { $switch_cmd = "memcache delete dialplan:".$_SESSION["context"]."@".$_SESSION['domain_name']; $switch_result = event_socket_request($fp, 'api '.$switch_cmd); } $_SESSION["message"] = $text['message-update']; header("Location: dialplan_edit.php?id=".$dialplan_uuid."&app_uuid=".$app_uuid); 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") { $dialplan_detail_uuid = $_GET["id"]; $sql = "select * from v_dialplan_details "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and dialplan_detail_uuid = '$dialplan_detail_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { $dialplan_uuid = $row["dialplan_uuid"]; $dialplan_detail_tag = $row["dialplan_detail_tag"]; $dialplan_detail_order = $row["dialplan_detail_order"]; $dialplan_detail_type = $row["dialplan_detail_type"]; $dialplan_detail_data = $row["dialplan_detail_data"]; $dialplan_detail_break = $row["dialplan_detail_break"]; $dialplan_detail_inline = $row["dialplan_detail_inline"]; $dialplan_detail_group = $row["dialplan_detail_group"]; } unset ($prep_statement); } //show the header require_once "resources/header.php"; $document['title'] = $text['title-dialplan_detail']; //show the content 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"; ?> \n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if ($action == "update") { if ($dialplan_detail_tag == "condition") { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if ($dialplan_detail_tag == "action") { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } } echo " \n"; echo " \n"; echo " "; echo "
".$text['header-dialplan_detail']."
\n"; echo "  \n"; echo "
\n"; echo " ".$text['label-tag']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
\n"; echo " ".$text['label-order']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
\n"; echo " ".$text['label-type']."\n"; echo "\n"; echo "\n"; echo "
\n"; echo " ".$text['label-data']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
\n"; echo " ".$text['label-group']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
\n"; echo " ".$text['label-break']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
\n"; echo " ".$text['label-inline']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
\n"; echo " \n"; echo " \n"; if ($action == "update") { echo " \n"; } echo "
"; echo " \n"; echo "
"; echo "

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