Update destination_edit.php

This commit is contained in:
FusionPBX
2020-02-07 20:04:15 -07:00
committed by GitHub
parent 2244501da3
commit da3c290973

View File

@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2019
Portions created by the Initial Developer are Copyright (C) 2008-2020
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -42,6 +42,9 @@
$language = new text;
$text = $language->get();
//initialize the destinations object
$destination = new destinations;
//action add or update
if (is_uuid($_REQUEST["id"])) {
$action = "update";
@@ -184,10 +187,12 @@
$dialplan_details = $_POST["dialplan_details"];
//array cleanup
foreach ($dialplan_details as $index => $row) {
//unset the empty row
if (strlen($row["dialplan_detail_data"]) == 0) {
unset($dialplan_details[$index]);
if (is_array($dialplan_details)) {
foreach ($dialplan_details as $index => $row) {
//unset the empty row
if (strlen($row["dialplan_detail_data"]) == 0) {
unset($dialplan_details[$index]);
}
}
}
@@ -245,7 +250,7 @@
}
//set the dialplan_uuid
$destination["dialplan_uuid"] = $dialplan_uuid;
$array['destinations'][0]["dialplan_uuid"] = $dialplan_uuid;
//build the dialplan array
if ($destination_type == "inbound") {
@@ -306,8 +311,10 @@
$dialplan["dialplan_xml"] .= " <action application=\"answer\" data=\"\"/>\n";
$dialplan["dialplan_xml"] .= " <action application=\"sleep\" data=\"3000\"/>\n";
}
$dialplan["dialplan_xml"] .= " <action application=\"".$destination_app."\" data=\"".$destination_data."\"/>\n";
if (strlen($destination_alternate_app) > 0) {
if ($destination->valid($destination_app.':'.$destination_data)) {
$dialplan["dialplan_xml"] .= " <action application=\"".$destination_app."\" data=\"".$destination_data."\"/>\n";
}
if (strlen($destination_alternate_app) > 0 && $destination->valid($destination_alternate_app.':'.$destination_alternate_data)) {
$dialplan["dialplan_xml"] .= " <action application=\"".$destination_alternate_app."\" data=\"".$destination_alternate_data."\"/>\n";
}
$dialplan["dialplan_xml"] .= " </condition>\n";
@@ -427,7 +434,7 @@
//increment the dialplan detail order
$dialplan_detail_order = $dialplan_detail_order + 10;
// execute on tone detect
//execute on tone detect
$dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
@@ -449,7 +456,7 @@
//increment the dialplan detail order
$dialplan_detail_order = $dialplan_detail_order + 10;
// answer
//answer
$dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "answer";
@@ -460,7 +467,7 @@
//increment the dialplan detail order
$dialplan_detail_order = $dialplan_detail_order + 10;
// execute on tone detect
//execute on tone detect
$dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "sleep";
@@ -555,26 +562,30 @@
}
//add the actions
foreach ($dialplan_details as $row) {
if (strlen($row["dialplan_detail_data"]) > 1) {
$actions = explode(":", $row["dialplan_detail_data"]);
$dialplan_detail_type = array_shift($actions);
$dialplan_detail_data = join(':', $actions);
if (is_array($dialplan_details)) {
foreach ($dialplan_details as $row) {
if (strlen($row["dialplan_detail_data"]) > 1) {
$actions = explode(":", $row["dialplan_detail_data"]);
$dialplan_detail_type = array_shift($actions);
$dialplan_detail_data = join(':', $actions);
//add to the dialplan_details array
$dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $dialplan_detail_type;
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = $dialplan_detail_data;
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
$dialplan_detail_order = $dialplan_detail_order + 10;
//add to the dialplan_details array
$dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $dialplan_detail_type;
if ($destination->valid($dialplan_detail_type.':'.$dialplan_detail_data)) {
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = $dialplan_detail_data;
}
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order;
$dialplan_detail_order = $dialplan_detail_order + 10;
//set the destination app and data
$destination_app = $dialplan_detail_type;
$destination_data = $dialplan_detail_data;
//set the destination app and data
$destination_app = $dialplan_detail_type;
$destination_data = $dialplan_detail_data;
//increment the array id
$y++;
//increment the array id
$y++;
}
}
}
@@ -594,34 +605,37 @@
}
//build the destination array
$destination["domain_uuid"] = $domain_uuid;
$destination["destination_uuid"] = $destination_uuid;
$destination["dialplan_uuid"] = $dialplan_uuid;
$destination["fax_uuid"] = $fax_uuid;
$destination["destination_type"] = $destination_type;
$array['destinations'][0]["domain_uuid"] = $domain_uuid;
$array['destinations'][0]["destination_uuid"] = $destination_uuid;
$array['destinations'][0]["dialplan_uuid"] = $dialplan_uuid;
$array['destinations'][0]["fax_uuid"] = $fax_uuid;
$array['destinations'][0]["destination_type"] = $destination_type;
if (permission_exists('destination_number')) {
$destination["destination_number"] = $destination_number;
$destination["destination_number_regex"] = $destination_number_regex;
$destination["destination_prefix"] = $destination_prefix;
$array['destinations'][0]["destination_number"] = $destination_number;
$array['destinations'][0]["destination_number_regex"] = $destination_number_regex;
$array['destinations'][0]["destination_prefix"] = $destination_prefix;
}
$destination["destination_caller_id_name"] = $destination_caller_id_name;
$destination["destination_caller_id_number"] = $destination_caller_id_number;
$destination["destination_cid_name_prefix"] = $destination_cid_name_prefix;
$destination["destination_context"] = $destination_context;
$destination["destination_record"] = $destination_record;
$destination["destination_accountcode"] = $destination_accountcode;
$destination["destination_type_voice"] = $destination_type_voice ? 1 : null;
$destination["destination_type_fax"] = $destination_type_fax ? 1 : null;
$destination["destination_type_text"] = $destination_type_text ? 1 : null;
$destination["destination_app"] = $destination_app;
$destination["destination_data"] = $destination_data;
$destination["destination_alternate_app"] = $destination_alternate_app;
$destination["destination_alternate_data"] = $destination_alternate_data;
$destination["destination_enabled"] = $destination_enabled;
$destination["destination_description"] = $destination_description;
$array['destinations'][0]["destination_caller_id_name"] = $destination_caller_id_name;
$array['destinations'][0]["destination_caller_id_number"] = $destination_caller_id_number;
$array['destinations'][0]["destination_cid_name_prefix"] = $destination_cid_name_prefix;
$array['destinations'][0]["destination_context"] = $destination_context;
$array['destinations'][0]["destination_record"] = $destination_record;
$array['destinations'][0]["destination_accountcode"] = $destination_accountcode;
$array['destinations'][0]["destination_type_voice"] = $destination_type_voice ? 1 : null;
$array['destinations'][0]["destination_type_fax"] = $destination_type_fax ? 1 : null;
$array['destinations'][0]["destination_type_text"] = $destination_type_text ? 1 : null;
if ($destination->valid($destination_app.':'.$destination_data)) {
$array['destinations'][0]["destination_app"] = $destination_app;
$array['destinations'][0]["destination_data"] = $destination_data;
}
if ($destination->valid($destination_alternate_app.':'.$destination_alternate_data)) {
$array['destinations'][0]["destination_alternate_app"] = $destination_alternate_app;
$array['destinations'][0]["destination_alternate_data"] = $destination_alternate_data;
}
$array['destinations'][0]["destination_enabled"] = $destination_enabled;
$array['destinations'][0]["destination_description"] = $destination_description;
//prepare the array
$array['destinations'][] = $destination;
$array['dialplans'][] = $dialplan;
unset($dialplan);
@@ -702,9 +716,6 @@
}
//initialize the destinations object
$destination = new destinations;
//pre-populate the form
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
if (is_uuid($_GET["id"])) {
@@ -1214,4 +1225,4 @@
//include the footer
require_once "resources/footer.php";
?>
?>