diff --git a/app/dialplan/dialplan_delete.php b/app/dialplan/dialplan_delete.php
index 36734e0434..93c26b2bd4 100644
--- a/app/dialplan/dialplan_delete.php
+++ b/app/dialplan/dialplan_delete.php
@@ -45,41 +45,51 @@ else {
}
//set the dialplan uuid
- if (count($_GET) > 0) {
- $dialplan_uuid = check_str($_GET["id"]);
- }
+ $dialplan_uuids = $_REQUEST["id"];
+ $app_uuid = check_str($_REQUEST['app_uuid']);
-if (strlen($dialplan_uuid) > 0) {
- //get the dialplan data
- $sql = "select * from v_dialplans ";
- //$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
- $sql .= "where 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) {
- $database_dialplan_uuid = $row["dialplan_uuid"];
- $dialplan_context = $row["dialplan_context"];
- $app_uuid = $row["app_uuid"];
- }
- unset ($prep_statement);
+if (sizeof($dialplan_uuids) > 0) {
+
+ //get dialplan contexts
+ foreach ($dialplan_uuids as $dialplan_uuid) {
+
+ //check each
+ $dialplan_uuid = check_str($dialplan_uuid);
+
+ //get the dialplan data
+ $sql = "select * from v_dialplans ";
+ $sql .= "where 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) {
+ $database_dialplan_uuid = $row["dialplan_uuid"];
+ $dialplan_contexts[] = $row["dialplan_context"];
+ }
+ unset($prep_statement);
+ }
//start the atomic transaction
$db->beginTransaction();
- //delete child data
- $sql = "delete from v_dialplan_details ";
- //$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
- $sql .= "where dialplan_uuid = '$dialplan_uuid'; ";
- $db->query($sql);
- unset($sql);
+ //delete dialplan and details
+ $dialplans_deleted = 0;
+ foreach ($dialplan_uuids as $dialplan_uuid) {
- //delete parent data
- $sql = "delete from v_dialplans ";
- //$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
- $sql .= "where dialplan_uuid = '$dialplan_uuid'; ";
- $db->query($sql);
- unset($sql);
+ //delete child data
+ $sql = "delete from v_dialplan_details ";
+ $sql .= "where dialplan_uuid = '".$dialplan_uuid."'; ";
+ $db->query($sql);
+ unset($sql);
+
+ //delete parent data
+ $sql = "delete from v_dialplans ";
+ $sql .= "where dialplan_uuid = '".$dialplan_uuid."'; ";
+ $db->query($sql);
+ unset($sql);
+
+ $dialplans_deleted++;
+ }
//commit the atomic transaction
$db->commit();
@@ -87,26 +97,22 @@ if (strlen($dialplan_uuid) > 0) {
//synchronize the xml config
save_dialplan_xml();
- //delete the dialplan context from memcache
+ //strip duplicate contexts
+ $dialplan_contexts = array_unique($dialplan_contexts, SORT_STRING);
+
+ //delete the dialplan contexts from memcache
+ if (sizeof($dialplan_contexts) > 0) {
$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;
- $switch_result = event_socket_request($fp, 'api '.$switch_cmd);
+ foreach($dialplan_contexts as $dialplan_context) {
+ $switch_cmd = "memcache delete dialplan:".$dialplan_context;
+ $switch_result = event_socket_request($fp, 'api '.$switch_cmd);
+ }
}
+ }
}
-$_SESSION["message"] = $text['message-delete'];
-switch ($app_uuid) {
- case "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4": //inbound routes
- case "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3": //outbound routes
- case "4b821450-926b-175a-af93-a03c441818b1": //time conditions
- $redirect_url = PROJECT_PATH."/app/dialplan/dialplans.php?app_uuid=".$app_uuid;
- break;
- default:
- $redirect_url = PROJECT_PATH."/app/dialplan/dialplans.php";
-}
-header("Location: ".$redirect_url);
-return;
-
+$_SESSION["message"] = $text['message-delete'].(($dialplans_deleted > 1) ? ": ".$dialplans_deleted : null);
+header("Location: ".PROJECT_PATH."/app/dialplan/dialplans.php".(($app_uuid != '') ? "?app_uuid=".$app_uuid : null));
?>
\ No newline at end of file
diff --git a/app/dialplan/dialplan_detail_delete.php b/app/dialplan/dialplan_detail_delete.php
index 24dbc22841..83472fef85 100644
--- a/app/dialplan/dialplan_detail_delete.php
+++ b/app/dialplan/dialplan_detail_delete.php
@@ -47,8 +47,8 @@ else {
//set the variables
if (count($_GET) > 0) {
$dialplan_detail_uuid = check_str($_GET["id"]);
- $app_uuid = check_str($_REQUEST["app_uuid"]);
$dialplan_uuid = check_str($_REQUEST["dialplan_uuid"]);
+ $app_uuid = check_str($_REQUEST["app_uuid"]);
}
//delete the dialplan detail
@@ -75,7 +75,7 @@ else {
$_SESSION['message'] = $text['message-delete'];
//redirect the browser
- header("Location: dialplan_edit.php?id=".$dialplan_uuid."&app_uuid=".$app_uuid);
+ header("Location: dialplan_edit.php?id=".$dialplan_uuid.(($app_uuid != '') ? "&app_uuid=".$app_uuid : null));
exit;
?>
\ No newline at end of file
diff --git a/app/dialplan/dialplan_edit.php b/app/dialplan/dialplan_edit.php
index 26e584a525..06e7c58485 100644
--- a/app/dialplan/dialplan_edit.php
+++ b/app/dialplan/dialplan_edit.php
@@ -175,7 +175,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
else if ($action == "update") {
$_SESSION['message'] = $text['message-update'];
}
- header("Location: ?id=".$dialplan_uuid."&app_uuid=".$app_uuid);
+ header("Location: ?id=".$dialplan_uuid.(($app_uuid != '') ? "&app_uuid=".$app_uuid : null));
exit;
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
@@ -190,7 +190,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
//$message = $orm->message;
foreach ($result as &$row) {
$domain_uuid = $row["domain_uuid"];
- $app_uuid = $row["app_uuid"];
+ //$app_uuid = $row["app_uuid"];
$dialplan_name = $row["dialplan_name"];
$dialplan_number = $row["dialplan_number"];
$dialplan_order = $row["dialplan_order"];
@@ -325,6 +325,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
echo "
";
echo "