From 1c5e9196d62ce7e5d4d2f7fd465b639544737c5b Mon Sep 17 00:00:00 2001 From: Nate Jones Date: Wed, 18 Mar 2015 22:21:40 +0000 Subject: [PATCH] Destinations: Fixed a logic issue causing actions to be discarded. Also, retain the existing dialplan Name and Description through an update of a Destination. --- app/destinations/destination_edit.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/destinations/destination_edit.php b/app/destinations/destination_edit.php index a777fbf96e..d92d7daf3a 100644 --- a/app/destinations/destination_edit.php +++ b/app/destinations/destination_edit.php @@ -152,19 +152,16 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { unset($_POST["dialplan_details"]); //array cleanup - $x = 0; - foreach ($dialplan_details as $row) { + foreach ($dialplan_details as $index => $row) { //unset the empty row if (strlen($row["dialplan_detail_data"]) == 0) { - unset($dialplan_details[$x]); + unset($dialplan_details[$index]); } - //increment the row - $x++; } //check to see if the dialplan exists if (strlen($dialplan_uuid) > 0) { - $sql = "select dialplan_uuid from v_dialplans "; + $sql = "select dialplan_uuid, dialplan_name, dialplan_description from v_dialplans "; $sql .= "where domain_uuid = '".$domain_uuid."' "; $sql .= "and dialplan_uuid = '".$dialplan_uuid."' "; $prep_statement = $db->prepare($sql); @@ -173,6 +170,8 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $row = $prep_statement->fetch(PDO::FETCH_ASSOC); if (strlen($row['dialplan_uuid']) > 0) { $dialplan_uuid = $row['dialplan_uuid']; + $dialplan_name = $row['dialplan_name']; + $dialplan_description = $row['dialplan_description']; } else { $dialplan_uuid = ""; @@ -190,13 +189,13 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $dialplan["dialplan_uuid"] = $dialplan_uuid; } $dialplan["domain_uuid"] = $domain_uuid; - $dialplan["dialplan_name"] = format_phone($destination_number); + $dialplan["dialplan_name"] = ($dialplan_name != '') ? $dialplan_name : format_phone($destination_number); $dialplan["dialplan_number"] = $destination_number; $dialplan["dialplan_context"] = $destination_context; $dialplan["dialplan_continue"] = "false"; $dialplan["dialplan_order"] = "100"; $dialplan["dialplan_enabled"] = $destination_enabled; - $dialplan["dialplan_description"] = $destination_description; + $dialplan["dialplan_description"] = ($dialplan_description != '') ? $dialplan_description : $destination_description; $dialplan_detail_order = 10; //add the public condition