From 35ff0c00ab60b47fc69942b4e4953ad62f399602 Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Sat, 28 Sep 2013 19:40:34 +0000 Subject: [PATCH] Add dialplan context to the dialplan, improve some of the formatting add page and fix memcache flush. --- app/dialplan/dialplan_add.php | 97 +++++++++++++----------- app/dialplan/dialplan_copy.php | 2 +- app/dialplan/dialplan_delete.php | 2 +- app/dialplan/dialplan_details_delete.php | 2 +- app/dialplan/dialplan_details_edit.php | 2 +- app/dialplan/dialplan_edit.php | 2 +- app/dialplan/dialplans.php | 13 ++-- 7 files changed, 65 insertions(+), 55 deletions(-) diff --git a/app/dialplan/dialplan_add.php b/app/dialplan/dialplan_add.php index bc581fc528..99c1e09067 100644 --- a/app/dialplan/dialplan_add.php +++ b/app/dialplan/dialplan_add.php @@ -40,18 +40,15 @@ else { $text[$key] = $value[$_SESSION['domain']['language']['code']]; } -require_once "resources/header.php"; -$page["title"] = $text['title-dialplan_add']; -require_once "resources/paging.php"; +//additional includes + require_once "resources/header.php"; + $page["title"] = $text['title-dialplan_add']; + require_once "resources/paging.php"; -$order_by = $_GET["order_by"]; -$order = $_GET["order"]; - - -//POST to PHP variables - if (count($_POST)>0) { +//set the variables + if (count($_POST) > 0) { $dialplan_name = check_str($_POST["dialplan_name"]); - $dialplan_order = check_str($_POST["dialplan_order"]); + $condition_field_1 = check_str($_POST["condition_field_1"]); $condition_expression_1 = check_str($_POST["condition_expression_1"]); $condition_field_2 = check_str($_POST["condition_field_2"]); @@ -74,11 +71,16 @@ $order = $_GET["order"]; //$action_application_2 = check_str($_POST["action_application_2"]); //$action_data_2 = check_str($_POST["action_data_2"]); + $dialplan_context = check_str($_POST["dialplan_context"]); + $dialplan_order = check_str($_POST["dialplan_order"]); $dialplan_enabled = check_str($_POST["dialplan_enabled"]); $dialplan_description = check_str($_POST["dialplan_description"]); if (strlen($dialplan_enabled) == 0) { $dialplan_enabled = "true"; } //set default to enabled } +//set the default + if (strlen($dialplan_context) == 0) { $dialplan_context = $_SESSION['context']; } + if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { //check for all required data if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']."domain_uuid
\n"; } @@ -109,7 +111,6 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $db->exec("BEGIN;"); //returns affected rows //add the main dialplan include entry - $dialplan_context = $_SESSION['context']; $dialplan_uuid = uuid(); $sql = "insert into v_dialplans "; $sql .= "("; @@ -131,7 +132,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $sql .= "'$dialplan_name', "; $sql .= "'$dialplan_order', "; $sql .= "'false', "; - $sql .= "'".$_SESSION['context']."', "; + $sql .= "'$dialplan_context', "; $sql .= "'$dialplan_enabled', "; $sql .= "'$dialplan_description' "; $sql .= ")"; @@ -251,7 +252,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { //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_cmd = "memcache delete dialplan:".$dialplan_context; $switch_result = event_socket_request($fp, 'api '.$switch_cmd); } @@ -314,6 +315,7 @@ echo " \n"; echo " \n"; echo " \n"; echo " \n"; + echo " \n"; echo " \n"; echo "
".$text['description-dialplan_manager-superadmin']."\n"; @@ -566,62 +568,69 @@ switch_select_destination("dialplan", "", "action_2", $action_2, "width: 60%;", echo "\n"; echo "\n"; +echo "\n"; +echo " \n"; +echo " ".$text['label-context'].":\n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "
\n"; +echo " \n"; +echo "\n"; + echo "\n"; echo "\n"; -echo " ".$text['label-order'].":\n"; +echo " ".$text['label-order'].":\n"; echo "\n"; echo "\n"; -echo " \n"; +//echo " \n"; if (strlen(htmlspecialchars($dialplan_order))> 0) { - echo " \n"; + echo " \n"; } $i=0; while($i<=999) { - if (strlen($i) == 1) { echo " \n"; } - if (strlen($i) == 2) { echo " \n"; } - if (strlen($i) == 3) { echo " \n"; } + if (strlen($i) == 1) { echo " \n"; } + if (strlen($i) == 2) { echo " \n"; } + if (strlen($i) == 3) { echo " \n"; } $i++; } -echo " \n"; -echo "
\n"; -echo "\n"; +echo " \n"; +echo "
\n"; echo "\n"; echo "\n"; echo "\n"; -echo "\n"; -echo " ".$text['label-enabled'].":\n"; -echo "\n"; -echo "\n"; -echo " \n"; if ($dialplan_enabled == "true") { - echo " \n"; + echo " \n"; } else { - echo " \n"; + echo " \n"; } if ($dialplan_enabled == "false") { - echo " \n"; + echo " \n"; } else { - 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 " ".$text['label-description'].":\n"; -echo "\n"; -echo "\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"; echo "\n"; echo "\n"; diff --git a/app/dialplan/dialplan_copy.php b/app/dialplan/dialplan_copy.php index 4e71ea35ee..91be445587 100644 --- a/app/dialplan/dialplan_copy.php +++ b/app/dialplan/dialplan_copy.php @@ -146,7 +146,7 @@ else { //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_cmd = "memcache delete dialplan:".$dialplan_context; $switch_result = event_socket_request($fp, 'api '.$switch_cmd); } diff --git a/app/dialplan/dialplan_delete.php b/app/dialplan/dialplan_delete.php index 48f4dc9f96..667051ecb3 100644 --- a/app/dialplan/dialplan_delete.php +++ b/app/dialplan/dialplan_delete.php @@ -89,7 +89,7 @@ if (strlen($dialplan_uuid)>0) { //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_cmd = "memcache delete dialplan:".$dialplan_context; $switch_result = event_socket_request($fp, 'api '.$switch_cmd); } } diff --git a/app/dialplan/dialplan_details_delete.php b/app/dialplan/dialplan_details_delete.php index 2de3b918e0..330737dd54 100644 --- a/app/dialplan/dialplan_details_delete.php +++ b/app/dialplan/dialplan_details_delete.php @@ -66,7 +66,7 @@ if (strlen($id)>0) { //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_cmd = "memcache delete dialplan:".$_SESSION["context"]; $switch_result = event_socket_request($fp, 'api '.$switch_cmd); } } diff --git a/app/dialplan/dialplan_details_edit.php b/app/dialplan/dialplan_details_edit.php index 1e2cf23afa..17e9b9d861 100644 --- a/app/dialplan/dialplan_details_edit.php +++ b/app/dialplan/dialplan_details_edit.php @@ -146,7 +146,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { //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_cmd = "memcache delete dialplan:".$_SESSION["context"]; $switch_result = event_socket_request($fp, 'api '.$switch_cmd); } diff --git a/app/dialplan/dialplan_edit.php b/app/dialplan/dialplan_edit.php index 3849cbc7d4..be4279509d 100644 --- a/app/dialplan/dialplan_edit.php +++ b/app/dialplan/dialplan_edit.php @@ -187,7 +187,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { //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:".$dialplan_context."@".$_SESSION['domain_name']; + $switch_cmd = "memcache delete dialplan:".$dialplan_context; $switch_result = event_socket_request($fp, 'api '.$switch_cmd); } diff --git a/app/dialplan/dialplans.php b/app/dialplan/dialplans.php index 4a92d2f4f2..3bd7ef928b 100644 --- a/app/dialplan/dialplans.php +++ b/app/dialplan/dialplans.php @@ -347,14 +347,15 @@ else { echo "\n"; echo "\n"; - echo "\n"; - echo "\n"; - echo "
\n"; if ($v_path_show) { - echo $_SESSION['switch']['dialplan']['dir']; + echo "\n"; + echo " \n"; + echo "
\n"; + echo " ".$_SESSION['switch']['dialplan']['dir']; + echo " \n"; + echo "\n"; } - echo "\n"; - echo "\n"; + echo ""; echo ""; echo "

";