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 (is_uuid($_REQUEST["id"])) { $action = "update"; $dialplan_detail_uuid = $_REQUEST["id"]; } else { $action = "add"; } $dialplan_uuid = $_REQUEST["dialplan_uuid"]; //get the http values and set them as php variables $app_uuid = $_REQUEST["app_uuid"]; if (count($_POST)>0) { $dialplan_uuid = $_POST["dialplan_uuid"]; $dialplan_detail_tag = $_POST["dialplan_detail_tag"]; $dialplan_detail_order = $_POST["dialplan_detail_order"]; $dialplan_detail_type = $_POST["dialplan_detail_type"]; $dialplan_detail_data = $_POST["dialplan_detail_data"]; $dialplan_detail_break = $_POST["dialplan_detail_break"]; $dialplan_detail_inline = $_POST["dialplan_detail_inline"]; $dialplan_detail_group = $_POST["dialplan_detail_group"]; } if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $msg = ''; if ($action == "update") { $dialplan_detail_uuid = $_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(); $array['dialplan_details'][0]['dialplan_uuid'] = $dialplan_uuid; $array['dialplan_details'][0]['dialplan_detail_uuid'] = $dialplan_detail_uuid; $array['dialplan_details'][0]['dialplan_detail_tag'] = $dialplan_detail_tag; $array['dialplan_details'][0]['dialplan_detail_order'] = $dialplan_detail_order; $array['dialplan_details'][0]['dialplan_detail_type'] = $dialplan_detail_type; $array['dialplan_details'][0]['dialplan_detail_data'] = $dialplan_detail_data; $array['dialplan_details'][0]['dialplan_detail_break'] = $dialplan_detail_break; $array['dialplan_details'][0]['dialplan_detail_inline'] = $dialplan_detail_inline; $array['dialplan_details'][0]['dialplan_detail_group'] = $dialplan_detail_group != '' ? $dialplan_detail_group : null; $array['dialplan_details'][0]['domain_uuid'] = $_SESSION['domain_uuid']; $p = new permissions; $p->add('dialplan_detail_add', 'temp'); $database = new database; $database->app_name = 'dialplans'; $database->app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db'; $database->save($array); unset($array); $p->delete('dialplan_detail_add', 'temp'); //synchronize the xml config save_dialplan_xml(); //clear the cache $cache = new cache; $cache->delete("dialplan:".$_SESSION["context"]); //set the message and redirect the user message::add($text['message-add']); header("Location: dialplan_edit.php?id=".$dialplan_uuid."&app_uuid=".$app_uuid); return; } 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, "; $sql .= "dialplan_detail_group = :dialplan_detail_group "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and dialplan_detail_uuid = :dialplan_detail_uuid "; $parameters['dialplan_uuid'] = $dialplan_uuid; $parameters['dialplan_detail_tag'] = $dialplan_detail_tag; $parameters['dialplan_detail_order'] = $dialplan_detail_order; $parameters['dialplan_detail_type'] = $dialplan_detail_type; $parameters['dialplan_detail_data'] = $dialplan_detail_data; $parameters['dialplan_detail_break'] = $dialplan_detail_break; $parameters['dialplan_detail_inline'] = $dialplan_detail_inline; $parameters['dialplan_detail_group'] = $dialplan_detail_group != '' ? $dialplan_detail_group : null; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['dialplan_detail_uuid'] = $dialplan_detail_uuid; $database = new database; $database->execute($sql, $parameters); unset($sql, $parameters); //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); } message::add($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 "; $parameters['domain_uuid'] = $domain_uuid; $parameters['dialplan_detail_uuid'] = $dialplan_detail_uuid; $database = new database; $row = $database->select($sql, $parameters, 'row'); if (is_array($row) && @sizeof($row) != 0) { $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($sql, $parameters, $row); } //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"; ?>