diff --git a/app/call_flows/call_flow_edit.php b/app/call_flows/call_flow_edit.php
index 9e2ed167f7..8b9ca4f2d1 100644
--- a/app/call_flows/call_flow_edit.php
+++ b/app/call_flows/call_flow_edit.php
@@ -28,9 +28,9 @@
//includes
require_once "root.php";
require_once "resources/require.php";
- require_once "resources/check_auth.php";
//check permissions
+ require_once "resources/check_auth.php";
if (permission_exists('call_flow_add') || permission_exists('call_flow_edit')) {
//access granted
}
@@ -53,8 +53,10 @@
}
//get http post variables and set them to php variables
- if (count($_POST) > 0) {
+ if (is_array($_POST)) {
//set the variables from the http values
+ $call_flow_uuid = check_str($_POST["call_flow_uuid"]);
+ $dialplan_uuid = check_str($_POST["dialplan_uuid"]);
$call_flow_name = check_str($_POST["call_flow_name"]);
$call_flow_extension = check_str($_POST["call_flow_extension"]);
$call_flow_feature_code = check_str($_POST["call_flow_feature_code"]);
@@ -64,11 +66,18 @@
$call_flow_label = check_str($_POST["call_flow_label"]);
$call_flow_sound = check_str($_POST["call_flow_sound"]);
$call_flow_destination = check_str($_POST["call_flow_destination"]);
+ //$call_flow_app = check_str($_POST["call_flow_app"]);
+ //$call_flow_data = check_str($_POST["call_flow_data"]);
$call_flow_alternate_label = check_str($_POST["call_flow_alternate_label"]);
$call_flow_alternate_sound = check_str($_POST["call_flow_alternate_sound"]);
$call_flow_alternate_destination = check_str($_POST["call_flow_alternate_destination"]);
+ //$call_flow_alternate_app = check_str($_POST["call_flow_alternate_app"]);
+ //$call_flow_alternate_data = check_str($_POST["call_flow_alternate_data"]);
$call_flow_description = check_str($_POST["call_flow_description"]);
- $dialplan_uuid = check_str($_POST["dialplan_uuid"]);
+
+ //unset the values
+ unset($_POST["call_flow_destination"]);
+ unset($_POST["call_flow_alternate_destination"]);
//seperate the action and the param
$destination_array = explode(":", $call_flow_destination);
@@ -80,323 +89,176 @@
$call_flow_alternate_app = array_shift($alternate_destination_array);
$call_flow_alternate_data = join(':', $alternate_destination_array);
+
//set the context for users that are not in the superadmin group
if (!if_group("superadmin")) {
$call_flow_context = $_SESSION['domain_name'];
}
-
}
-if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
+//process the user data and save it to the database
+ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
- $msg = '';
- if ($action == "update") {
- $call_flow_uuid = check_str($_POST["call_flow_uuid"]);
- }
-
- //check for all required data
- if (strlen($call_flow_name) == 0) { $msg .= $text['message-required'].$text['label-name']."
\n"; }
- if (strlen($call_flow_extension) == 0) { $msg .= $text['message-required'].$text['label-extension']."
\n"; }
- //if (strlen($call_flow_feature_code) == 0) { $msg .= $text['message-required'].$text['label-feature_code']."
\n"; }
- if (strlen($call_flow_context) == 0) { $msg .= $text['message-required'].$text['label-context']."
\n"; }
- //if (strlen($call_flow_status) == 0) { $msg .= $text['message-required'].$text['label-status']."
\n"; }
- //if (strlen($call_flow_pin_number) == 0) { $msg .= $text['message-required'].$text['label-pin_number']."
\n"; }
- //if (strlen($call_flow_status) == 0) { $msg .= $text['message-required'].$text['label-status']."
\n"; }
- //if (strlen($call_flow_label) == 0) { $msg .= $text['message-required'].$text['label-destination_label']."
\n"; }
- //if (strlen($call_flow_app) == 0) { $msg .= $text['message-required'].$text['label-destination']."
\n"; }
- //if (strlen($call_flow_data) == 0) { $msg .= $text['message-required'].$text['label-destination']."
\n"; }
- //if (strlen($call_flow_alternate_label) == 0) { $msg .= $text['message-required'].$text['label-alternate_label']."
\n"; }
- //if (strlen($call_flow_alternate_app) == 0) { $msg .= $text['message-required'].$text['label-alternate_destination']."
\n"; }
- //if (strlen($call_flow_alternate_data) == 0) { $msg .= $text['message-required'].$text['label-alternate_destination']."
\n"; }
- //if (strlen($call_flow_description) == 0) { $msg .= $text['message-required'].$text['label-description']."
\n"; }
- if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
- require_once "resources/header.php";
- require_once "resources/persist_form_var.php";
- echo "
| \n";
- echo $msg." "; - echo " |
| \n";
+ echo $msg." "; + echo " |
"; + //print_r($message); + //echo ""; + //exit; + + //save the xml + save_dialplan_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + + //clear the cache + $cache = new cache; + $cache->delete("dialplan:".$call_flow_context); + + //redirect the user + if (isset($action)) { + if ($action == "add") { + $_SESSION["message"] = $text['message-add']; + } + if ($action == "update") { + $_SESSION["message"] = $text['message-update']; + } + header("Location: call_flows.php"); + return; + } + } //(is_array($_POST) && strlen($_POST["persistformvar"]) == 0) //initialize the destinations object $destination = new destinations; //pre-populate the form - if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { + if (is_array($_GET) && $_POST["persistformvar"] != "true") { $call_flow_uuid = check_str($_GET["id"]); $sql = "select * from v_call_flows "; - $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "where domain_uuid = '".$_SESSION["domain_uuid"]."' "; $sql .= "and call_flow_uuid = '$call_flow_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); - $result = $prep_statement->fetchAll(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { //set the php variables + $call_flow_uuid = $row["call_flow_uuid"]; + $dialplan_uuid = $row["dialplan_uuid"]; $call_flow_name = $row["call_flow_name"]; $call_flow_extension = $row["call_flow_extension"]; $call_flow_feature_code = $row["call_flow_feature_code"]; $call_flow_context = $row["call_flow_context"]; $call_flow_status = $row["call_flow_status"]; + $call_flow_pin_number = $row["call_flow_pin_number"]; $call_flow_label = $row["call_flow_label"]; $call_flow_sound = $row["call_flow_sound"]; $call_flow_app = $row["call_flow_app"]; - $call_flow_pin_number = $row["call_flow_pin_number"]; $call_flow_data = $row["call_flow_data"]; $call_flow_alternate_label = $row["call_flow_alternate_label"]; $call_flow_alternate_sound = $row["call_flow_alternate_sound"]; $call_flow_alternate_app = $row["call_flow_alternate_app"]; $call_flow_alternate_data = $row["call_flow_alternate_data"]; $call_flow_description = $row["call_flow_description"]; - $dialplan_uuid = $row["dialplan_uuid"]; //if superadmin show both the app and data if (if_group("superadmin")) { @@ -417,18 +279,9 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { unset ($prep_statement); } - //set the context for users that are not in the superadmin group - if (strlen($call_flow_context) == 0) { - $call_flow_context = $_SESSION['domain_name']; - } - -//show the header - require_once "resources/header.php"; - if ($action == "update") { - $document['title'] = $text['title-call_flow-edit']; - } - if ($action == "add") { - $document['title'] = $text['title-call_flow-add']; +//set the context for users that are not in the superadmin group + if (strlen($call_flow_context) == 0) { + $call_flow_context = $_SESSION['domain_name']; } //get the recordings @@ -576,71 +429,67 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; } +//show the header + require_once "resources/header.php"; + //show the content - echo "