Call Flows allow feature code and alternate destination to be optional. If feature code is empty and pin number is provided then require the pin number.

This commit is contained in:
FusionPBX
2023-10-19 19:35:36 -06:00
committed by GitHub
parent fb834ccf8a
commit 100ccc0db2
3 changed files with 172 additions and 142 deletions
+1 -1
View File
@@ -50,7 +50,7 @@
$apps[$x]['destinations'][$y]['label'] = "call_flows";
$apps[$x]['destinations'][$y]['name'] = "call_flows";
$apps[$x]['destinations'][$y]['sql'] = "select call_flow_name as name, call_flow_uuid, call_flow_uuid as uuid, call_flow_extension as extension, call_flow_feature_code as destination, call_flow_context as context from v_call_flows ";
$apps[$x]['destinations'][$y]['where'] = "where domain_uuid = '\${domain_uuid}' and call_flow_enabled = 'true' ";
$apps[$x]['destinations'][$y]['where'] = "where domain_uuid = '\${domain_uuid}' and call_flow_feature_code is not null and call_flow_enabled = 'true' ";
$apps[$x]['destinations'][$y]['order_by'] = "natural_sort(call_flow_feature_code) asc";
$apps[$x]['destinations'][$y]['field']['uuid'] = "uuid";
$apps[$x]['destinations'][$y]['field']['name'] = "name";
+7 -6
View File
@@ -121,7 +121,7 @@
//if (empty($dialplan_uuid)) { $msg .= $text['message-required']." ".$text['label-dialplan_uuid']."<br>\n"; }
//if (empty($call_flow_name)) { $msg .= $text['message-required']." ".$text['label-call_flow_name']."<br>\n"; }
if (empty($call_flow_extension)) { $msg .= $text['message-required']." ".$text['label-call_flow_extension']."<br>\n"; }
if (empty($call_flow_feature_code)) { $msg .= $text['message-required']." ".$text['label-call_flow_feature_code']."<br>\n"; }
//if (empty($call_flow_feature_code)) { $msg .= $text['message-required']." ".$text['label-call_flow_feature_code']."<br>\n"; }
//if (empty($call_flow_context)) { $msg .= $text['message-required']." ".$text['label-call_flow_context']."<br>\n"; }
//if (empty($call_flow_status)) { $msg .= $text['message-required']." ".$text['label-call_flow_status']."<br>\n"; }
//if (empty($call_flow_pin_number)) { $msg .= $text['message-required']." ".$text['label-call_flow_pin_number']."<br>\n"; }
@@ -181,6 +181,7 @@
//build the xml dialplan
$dialplan_xml = "<extension name=\"".xml::sanitize($call_flow_name)."\" continue=\"\" uuid=\"".xml::sanitize($dialplan_uuid)."\">\n";
if (!empty($call_flow_feature_code)) {
$dialplan_xml .= " <condition field=\"destination_number\" expression=\"^".xml::sanitize($destination_feature)."$\" break=\"on-true\">\n";
$dialplan_xml .= " <action application=\"answer\" data=\"\"/>\n";
$dialplan_xml .= " <action application=\"sleep\" data=\"200\"/>\n";
@@ -188,6 +189,7 @@
$dialplan_xml .= " <action application=\"set\" data=\"call_flow_uuid=".xml::sanitize($call_flow_uuid)."\"/>\n";
$dialplan_xml .= " <action application=\"lua\" data=\"call_flow.lua\"/>\n";
$dialplan_xml .= " </condition>\n";
}
$dialplan_xml .= " <condition field=\"destination_number\" expression=\"^".xml::sanitize($destination_extension)."$\">\n";
$dialplan_xml .= " <action application=\"set\" data=\"call_flow_uuid=".xml::sanitize($call_flow_uuid)."\"/>\n";
$dialplan_xml .= " <action application=\"lua\" data=\"call_flow.lua\"/>\n";
@@ -254,6 +256,7 @@
$p->delete("dialplan_edit", "temp");
// Update subscribed endpoints
if (!empty($call_flow_feature_code)) {
$fp = event_socket_create();
if ($fp) {
//send the event
@@ -271,11 +274,9 @@
} else {
$event .= "answer-state: terminated\n";
}
event_socket_request($fp, $event);
//echo $event."<br />";
fclose($fp);
}
}
//debug info
@@ -558,7 +559,7 @@
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-call_flow_feature_code']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
@@ -695,7 +696,7 @@
*/
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-call_flow_alternate_destination']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
+37 -8
View File
@@ -83,29 +83,58 @@
end
if call_flow_status == "true" then
app = row.call_flow_app;
data = row.call_flow_data
data = row.call_flow_data;
else
app = row.call_flow_alternate_app;
data = row.call_flow_alternate_data
data = row.call_flow_alternate_data;
end
end);
--if feature code toggle the status or send to the destination
if (feature_code == "true") then
--if the pin number is provided then require it
--check to see if the pin number should be required
pin_required = false;
if (feature_code == "true" and #pin_number > 0) then
pin_required = true;
end
if (#call_flow_feature_code == 0 and #pin_number > 0) then
pin_required = true;
end
--define the check pin number function
function validate_pin_number(pin_number)
if (session:ready()) then
if #pin_number > 0 then
if (#pin_number > 0) then
max_tries = 3;
local min_digits = #pin_number;
local max_digits = #pin_number+1;
session:answer();
local digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:voicemail_enter_pass:#", "", "\\d+");
if digits ~= pin_number then
if (digits == pin_number) then
return true;
else
return false;
end
end
end
end
--request the pin number
if (pin_required) then
valid = validate_pin_number(pin_number);
if (not valid) then
valid = validate_pin_number(pin_number);
end
if (not valid) then
valid = validate_pin_number(pin_number);
end
if (not valid) then
session:streamFile("phrase:voicemail_fail_auth:#");
session:hangup("NORMAL_CLEARING");
return;
end
end
end
--if feature code toggle the status or send to the destination
if (feature_code == "true") then
--feature code - toggle the status
local toggle = (call_flow_status == "true") and "false" or "true"