Update destination_edit.php
This commit is contained in:
parent
920bddb91d
commit
20fb3ace69
|
|
@ -92,6 +92,7 @@
|
|||
$destination_caller_id_number = check_str($_POST["destination_caller_id_number"]);
|
||||
$destination_cid_name_prefix = check_str($_POST["destination_cid_name_prefix"]);
|
||||
$destination_context = check_str($_POST["destination_context"]);
|
||||
$destination_action = check_str($_POST["destination_action"]);
|
||||
$fax_uuid = check_str($_POST["fax_uuid"]);
|
||||
$destination_enabled = check_str($_POST["destination_enabled"]);
|
||||
$destination_description = check_str($_POST["destination_description"]);
|
||||
|
|
@ -104,10 +105,16 @@
|
|||
//convert the number to a regular expression
|
||||
$destination_number_regex = string_to_regex($destination_number);
|
||||
$_POST["destination_number_regex"] = $destination_number_regex;
|
||||
}
|
||||
|
||||
//get the destination app and data
|
||||
$destination_array = explode(":", $_POST["destination_action"]);
|
||||
$destination_app = $destination_array[0];
|
||||
$destination_data = $destination_array[1];
|
||||
unset($_POST["destination_action"]);
|
||||
$_POST["destination_app"] = $destination_app;
|
||||
$_POST["destination_data"] = $destination_data;
|
||||
//unset the db_destination_number
|
||||
unset($_POST["db_destination_number"]);
|
||||
}
|
||||
|
||||
//process the http post
|
||||
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
|
|
@ -182,6 +189,30 @@
|
|||
}
|
||||
}
|
||||
|
||||
//get the fax information
|
||||
if (strlen($fax_uuid) > 0) {
|
||||
$sql = "select * from v_fax ";
|
||||
$sql .= "where fax_uuid = '".$fax_uuid."' ";
|
||||
if (!permission_exists('destination_domain')) {
|
||||
$sql .= "and domain_uuid = '".$domain_uuid."' ";
|
||||
}
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$fax_extension = $row["fax_extension"];
|
||||
$fax_destination_number = $row["fax_destination_number"];
|
||||
$fax_name = $row["fax_name"];
|
||||
$fax_email = $row["fax_email"];
|
||||
$fax_pin_number = $row["fax_pin_number"];
|
||||
$fax_caller_id_name = $row["fax_caller_id_name"];
|
||||
$fax_caller_id_number = $row["fax_caller_id_number"];
|
||||
$fax_forward_number = $row["fax_forward_number"];
|
||||
$fax_description = $row["fax_description"];
|
||||
}
|
||||
unset ($prep_statement);
|
||||
}
|
||||
|
||||
//if empty then get new uuid
|
||||
if (strlen($dialplan_uuid) == 0) {
|
||||
$dialplan_uuid = uuid();
|
||||
|
|
@ -200,6 +231,44 @@
|
|||
$dialplan["dialplan_description"] = ($dialplan_description != '') ? $dialplan_description : $destination_description;
|
||||
$dialplan_detail_order = 10;
|
||||
|
||||
//set the dialplan detail type
|
||||
if (strlen($_SESSION['dialplan']['destination']['text']) > 0) {
|
||||
$dialplan_detail_type = $_SESSION['dialplan']['destination']['text'];
|
||||
}
|
||||
else {
|
||||
$dialplan_detail_type = "destination_number";
|
||||
}
|
||||
|
||||
//build the xml dialplan
|
||||
if ($_SESSION['destinations']['dialplan_details']['boolean'] == "false") {
|
||||
$dialplan["dialplan_xml"] = "<extension name=\"".$dialplan_name."\" continue=\"false\" uuid=\"".$dialplan_uuid."\">\n";
|
||||
$dialplan["dialplan_xml"] .= " <condition field=\"".$dialplan_detail_type."\" expression=\"^".$destination_number_regex."\$\">\n";
|
||||
$dialplan["dialplan_xml"] .= " <action application=\"export\" data=\"call_direction=inbound\" inline=\"true\"/>\n";
|
||||
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"domain_uuid=".$_SESSION['domain_uuid']."\" inline=\"true\"/>\n";
|
||||
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"domain_name=".$_SESSION['domain_name']."\" inline=\"true\"/>\n";
|
||||
if (strlen($destination_cid_name_prefix) > 0) {
|
||||
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"effective_caller_id_name=".$destination_cid_name_prefix."#\${caller_id_name}\" inline=\"true\"/>\n";
|
||||
}
|
||||
if (strlen($destination_accountcode) > 0) {
|
||||
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"accountcode=".$destination_accountcode."\" inline=\"true\"/>\n";
|
||||
}
|
||||
if (strlen($destination_carrier) > 0) {
|
||||
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"carrier=".$destination_carrier."\" inline=\"true\"/>\n";
|
||||
}
|
||||
if (strlen($fax_uuid) > 0) {
|
||||
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"tone_detect_hits=1\" inline=\"true\"/>\n";
|
||||
$dialplan["dialplan_xml"] .= " <action application=\"set\" data=\"execute_on_tone_detect=transfer ".$fax_extension." XML \${domain_name}\" inline=\"true\"/>\n";
|
||||
$dialplan["dialplan_xml"] .= " <action application=\"tone_detect\" data=\"fax 1100 r +5000\"/>\n";
|
||||
$dialplan["dialplan_xml"] .= " <action application=\"sleep\" data=\"3000\"/>\n";
|
||||
}
|
||||
$dialplan["dialplan_xml"] .= " <action application=\"".$destination_app."\" data=\"".$destination_data."\"/>\n";
|
||||
$dialplan["dialplan_xml"] .= " </condition>\n";
|
||||
$dialplan["dialplan_xml"] .= "</extension>\n";
|
||||
}
|
||||
|
||||
//dialplan details
|
||||
if ($_SESSION['destinations']['dialplan_details']['boolean'] == "true") {
|
||||
|
||||
//increment the dialplan detail order
|
||||
$dialplan_detail_order = $dialplan_detail_order + 10;
|
||||
|
||||
|
|
@ -260,27 +329,6 @@
|
|||
|
||||
//add fax detection
|
||||
if (strlen($fax_uuid) > 0) {
|
||||
//get the fax information
|
||||
$sql = "select * from v_fax ";
|
||||
$sql .= "where fax_uuid = '".$fax_uuid."' ";
|
||||
if (!permission_exists('destination_domain')) {
|
||||
$sql .= "and domain_uuid = '".$domain_uuid."' ";
|
||||
}
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$fax_extension = $row["fax_extension"];
|
||||
$fax_destination_number = $row["fax_destination_number"];
|
||||
$fax_name = $row["fax_name"];
|
||||
$fax_email = $row["fax_email"];
|
||||
$fax_pin_number = $row["fax_pin_number"];
|
||||
$fax_caller_id_name = $row["fax_caller_id_name"];
|
||||
$fax_caller_id_number = $row["fax_caller_id_number"];
|
||||
$fax_forward_number = $row["fax_forward_number"];
|
||||
$fax_description = $row["fax_description"];
|
||||
}
|
||||
unset ($prep_statement);
|
||||
|
||||
//delete previous fax detection settings
|
||||
$sql = "delete from v_dialplan_details ";
|
||||
|
|
@ -346,12 +394,19 @@
|
|||
$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;
|
||||
|
||||
//set the destination app and data
|
||||
$_POST["destination_app"] = $dialplan_detail_type;
|
||||
$_POST["destination_data"] = $dialplan_detail_data;
|
||||
|
||||
//increment the array id
|
||||
$y++;
|
||||
}
|
||||
}
|
||||
|
|
@ -375,6 +430,7 @@
|
|||
if(strlen($_POST["dialplan_uuid"]) == 0) {
|
||||
$_POST["dialplan_uuid"] = $dialplan_uuid;
|
||||
}
|
||||
}
|
||||
|
||||
//prepare the array
|
||||
$array['destinations'][] = $_POST;
|
||||
|
|
@ -443,10 +499,10 @@
|
|||
$sql .= "and destination_uuid = '".$destination_uuid."' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
$destinations = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
}
|
||||
if (is_array($result)) {
|
||||
foreach ($result as &$row) {
|
||||
if (is_array($destinations)) {
|
||||
foreach ($destinations as &$row) {
|
||||
$domain_uuid = $row["domain_uuid"];
|
||||
$dialplan_uuid = $row["dialplan_uuid"];
|
||||
$destination_type = $row["destination_type"];
|
||||
|
|
@ -455,6 +511,8 @@
|
|||
$destination_caller_id_number = $row["destination_caller_id_number"];
|
||||
$destination_cid_name_prefix = $row["destination_cid_name_prefix"];
|
||||
$destination_context = $row["destination_context"];
|
||||
$destination_app = $row["destination_app"];
|
||||
$destination_data = $row["destination_data"];
|
||||
$fax_uuid = $row["fax_uuid"];
|
||||
$destination_enabled = $row["destination_enabled"];
|
||||
$destination_description = $row["destination_description"];
|
||||
|
|
@ -654,12 +712,24 @@
|
|||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
if ($_SESSION['destinations']['dialplan_details']['boolean'] == "false") {
|
||||
echo "<tr id='tr_actions'>\n";
|
||||
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
||||
echo " ".$text['label-detail_action']."\n";
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
$destination_action = $destination_app.":".$destination_data;
|
||||
echo $destination->select('dialplan', 'destination_action', $destination_action);
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
|
||||
if ($_SESSION['destinations']['dialplan_details']['boolean'] == "true") {
|
||||
echo "<tr id='tr_actions'>\n";
|
||||
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
||||
echo " ".$text['label-detail_action']."\n";
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
echo " <table width='52%' border='0' cellpadding='2' cellspacing='0'>\n";
|
||||
$x = 0;
|
||||
$order = 10;
|
||||
|
|
@ -673,7 +743,6 @@
|
|||
}
|
||||
echo " <input name='dialplan_details[".$x."][dialplan_detail_type]' type='hidden' value=\"".$row['dialplan_detail_type']."\">\n";
|
||||
echo " <input name='dialplan_details[".$x."][dialplan_detail_order]' type='hidden' value=\"".$order."\">\n";
|
||||
|
||||
$data = $row['dialplan_detail_data'];
|
||||
$label = explode("XML", $data);
|
||||
$divider = ($row['dialplan_detail_type'] != '') ? ":" : null;
|
||||
|
|
@ -693,6 +762,7 @@
|
|||
echo " </table>\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
|
||||
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/fax/app_config.php")){
|
||||
$sql = "select * from v_fax ";
|
||||
|
|
|
|||
Loading…
Reference in New Issue