Portions created by the Initial Developer are Copyright (C) 2008-2012 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"; require_once "resources/paging.php"; if (permission_exists('fifo_add') || permission_exists('fifo_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']]; } //set the action to an add or an update if (isset($_REQUEST["id"])) { $action = "update"; $dialplan_uuid = check_str($_REQUEST["id"]); } else { $action = "add"; } //get http values and set them as variables if (count($_POST)>0) { //$domain_uuid = check_str($_POST["domain_uuid"]); $dialplan_name = check_str($_POST["dialplan_name"]); $dialplan_order = check_str($_POST["dialplan_order"]); $dialplan_continue = check_str($_POST["dialplan_continue"]); $dialplan_context = check_str($_POST["dialplan_context"]); $dialplan_enabled = check_str($_POST["dialplan_enabled"]); $dialplan_description = check_str($_POST["dialplan_description"]); } if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $msg = ''; if ($action == "update") { $dialplan_uuid = check_str($_POST["dialplan_uuid"]); } //check for all required data if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']."domain_uuid
\n"; } if (strlen($dialplan_name) == 0) { $msg .= $text['message-required'].$text['label-name']."
\n"; } if (strlen($dialplan_order) == 0) { $msg .= $text['message-required'].$text['label-order']."
\n"; } if (strlen($dialplan_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."
\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; } //set the default dialplan_continue to false if (strlen($dialplan_continue) == 0) { $dialplan_continue = 'false'; } //add or update the database if ($_POST["persistformvar"] != "true") { if ($action == "add" && permission_exists('fifo_add')) { $dialplan_context = $_SESSION['context']; $dialplan_uuid = uuid(); $sql = "insert into v_dialplans "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "dialplan_uuid, "; $sql .= "app_uuid, "; $sql .= "dialplan_name, "; $sql .= "dialplan_order, "; $sql .= "dialplan_continue, "; $sql .= "dialplan_context, "; $sql .= "dialplan_enabled, "; $sql .= "dialplan_description "; $sql .= ")"; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'$dialplan_uuid', "; $sql .= "'16589224-c876-aeb3-f59f-523a1c0801f7', "; $sql .= "'$dialplan_name', "; $sql .= "'$dialplan_order', "; $sql .= "'$dialplan_continue', "; $sql .= "'$dialplan_context', "; $sql .= "'$dialplan_enabled', "; $sql .= "'$dialplan_description' "; $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"]."@".$_SESSION['domain_name']; $switch_result = event_socket_request($fp, 'api '.$switch_cmd); } require_once "resources/header.php"; echo "\n"; echo "
\n"; echo $text['message-add']."\n"; echo "
\n"; require_once "resources/footer.php"; return; } //if ($action == "add") if ($action == "update" && permission_exists('fifo_edit')) { $sql = "update v_dialplans set "; $sql .= "domain_uuid = '$domain_uuid', "; $sql .= "dialplan_name = '$dialplan_name', "; $sql .= "dialplan_order = '$dialplan_order', "; $sql .= "dialplan_continue = '$dialplan_continue', "; $sql .= "dialplan_context = '$dialplan_context', "; $sql .= "dialplan_enabled = '$dialplan_enabled', "; $sql .= "dialplan_description = '$dialplan_description' "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and dialplan_uuid = '$dialplan_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); } require_once "resources/header.php"; echo "\n"; echo "
\n"; echo $text['message-update']."\n"; echo "
\n"; require_once "resources/footer.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") { $dialplan_uuid = $_GET["id"]; $sql = ""; $sql .= "select * from v_dialplans "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and dialplan_uuid = '$dialplan_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { $dialplan_name = $row["dialplan_name"]; $dialplan_order = $row["dialplan_order"]; $dialplan_continue = $row["dialplan_continue"]; $dialplan_context = $row["dialplan_context"]; $dialplan_enabled = $row["dialplan_enabled"]; $dialplan_description = $row["dialplan_description"]; break; //limit to 1 row } unset ($prep_statement); } //show the header require_once "resources/header.php"; $page["title"] = $text['title-queue_edit']; //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 "

".$text['header-queue_edit']."

\n"; echo " ".$text['description-queue_edit']."\n"; 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 "\n"; echo " \n"; echo " \n"; echo " "; echo "
\n"; echo " ".$text['label-name'].":\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 "
\n"; echo " ".$text['label-continue'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-continue']."\n"; echo "
\n"; echo " ".$text['label-enabled'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
\n"; echo " ".$text['label-description'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
\n"; if ($action == "update") { echo " \n"; } echo " \n"; echo "
"; echo ""; echo "
"; echo "
"; //v_dialplan_details if ($action == "update" && permission_exists('fifo_edit')) { echo "
"; echo "\n"; echo "\n"; echo " "; echo ""; echo "
\n"; echo "
"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo "

".$text['header-conditions_and_actions']."
\n"; echo " ".$text['description-conditions_and_actions']."\n"; echo "

"; echo "
\n"; $sql = ""; $sql .= " select * from v_dialplan_details "; $sql .= " where domain_uuid = '$domain_uuid' "; $sql .= " and dialplan_uuid = '$dialplan_uuid' "; $sql .= " and dialplan_detail_tag = 'condition' "; $sql .= " order by dialplan_detail_order asc"; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result_count = count($result); unset ($prep_statement, $sql); $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if ($result_count > 0) { foreach($result as $row) { echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; if ($c==0) { $c=1; } else { $c=0; } } //end foreach unset($sql, $result, $row_count); } //end if results //v_dialplan_details dialplan_detail_tag: action $sql = ""; $sql .= " select * from v_dialplan_details "; $sql .= " where domain_uuid = '$domain_uuid' "; $sql .= " and dialplan_uuid = '$dialplan_uuid' "; $sql .= " and dialplan_detail_tag = 'action' "; $sql .= " order by dialplan_detail_order asc"; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result_count = count($result); unset ($prep_statement, $sql); if ($result_count > 0) { foreach($result as $row) { echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; if ($c==0) { $c=1; } else { $c=0; } } //end foreach unset($sql, $result, $row_count); } //end if results //v_dialplan_details dialplan_detail_tag: anti-action $sql = ""; $sql .= " select * from v_dialplan_details "; $sql .= " where domain_uuid = '$domain_uuid' "; $sql .= " and dialplan_uuid = '$dialplan_uuid' "; $sql .= " and dialplan_detail_tag = 'anti-action' "; $sql .= " order by dialplan_detail_order asc"; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result_count = count($result); unset ($prep_statement, $sql); if ($result_count == 0) { //no results } else { //received results foreach($result as $row) { echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; if ($c==0) { $c=1; } else { $c=0; } } //end foreach unset($sql, $result, $row_count); } //end if results echo "\n"; echo "\n"; echo "\n"; echo "
".$text['label-tag']."".$text['label-type']."".$text['label-data']."".$text['label-order']."\n"; if (permission_exists('fifo_add')) { echo " $v_link_label_add\n"; } echo "
  ".$row[dialplan_detail_tag]."  ".$row[dialplan_detail_type]."  ".$row[dialplan_detail_data]."  ".$row[dialplan_detail_order]."\n"; if (permission_exists('fifo_edit')) { echo " $v_link_label_edit\n"; } if (permission_exists('fifo_delete')) { echo " $v_link_label_delete\n"; } echo "
  ".$row[dialplan_detail_tag]."  ".$row[dialplan_detail_type]."  ".$row[dialplan_detail_data]."  ".$row[dialplan_detail_order]."\n"; if (permission_exists('fifo_edit')) { echo " $v_link_label_edit\n"; } if (permission_exists('fifo_delete')) { echo " $v_link_label_delete\n"; } echo "
  ".$row[dialplan_detail_tag]."  ".$row[dialplan_detail_type]."  ".$row[dialplan_detail_data]."  ".$row[dialplan_detail_order]."\n"; if (permission_exists('fifo_edit')) { echo " $v_link_label_edit\n"; } if (permission_exists('fifo_delete')) { echo " $v_link_label_delete\n"; } echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
 $paging_controls\n"; if (permission_exists('fifo_add')) { echo " $v_link_label_add\n"; } echo "
\n"; echo "
"; echo "
"; echo "

"; echo "

"; echo "
"; echo "
"; echo "

"; } //end if update //show the footer require_once "resources/footer.php"; ?>