mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Add ring group call screening
This commit is contained in:
@@ -142,6 +142,10 @@
|
||||
$apps[$x]['permissions'][$y]['name'] = "ring_group_destinations";
|
||||
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
|
||||
$apps[$x]['permissions'][$y]['groups'][] = "admin";
|
||||
$y++;
|
||||
$apps[$x]['permissions'][$y]['name'] = "ring_group_call_screen_enabled";
|
||||
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
|
||||
$apps[$x]['permissions'][$y]['groups'][] = "admin";
|
||||
|
||||
//default settings
|
||||
$y=0;
|
||||
@@ -313,6 +317,10 @@
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Select the ringback.";
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = "ring_group_call_screen_enabled";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = "ring_group_call_forward_enabled";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Choose to follow a ring group destination's call forward.";
|
||||
|
||||
@@ -186,6 +186,7 @@
|
||||
$ring_group_cid_number_prefix = $_POST["ring_group_cid_number_prefix"] ?? null;
|
||||
$ring_group_distinctive_ring = $_POST["ring_group_distinctive_ring"];
|
||||
$ring_group_ringback = $_POST["ring_group_ringback"];
|
||||
$ring_group_call_screen_enabled = $_POST["ring_group_call_screen_enabled"];
|
||||
$ring_group_call_forward_enabled = $_POST["ring_group_call_forward_enabled"];
|
||||
$ring_group_follow_me_enabled = $_POST["ring_group_follow_me_enabled"];
|
||||
$ring_group_missed_call_app = $_POST["ring_group_missed_call_app"];
|
||||
@@ -375,6 +376,7 @@
|
||||
}
|
||||
$array["ring_groups"][0]["ring_group_distinctive_ring"] = $ring_group_distinctive_ring;
|
||||
$array["ring_groups"][0]["ring_group_ringback"] = $ring_group_ringback;
|
||||
$array["ring_groups"][0]["ring_group_call_screen_enabled"] = $ring_group_call_screen_enabled;
|
||||
$array["ring_groups"][0]["ring_group_call_forward_enabled"] = $ring_group_call_forward_enabled;
|
||||
$array["ring_groups"][0]["ring_group_follow_me_enabled"] = $ring_group_follow_me_enabled;
|
||||
if (permission_exists('ring_group_missed_call')) {
|
||||
@@ -559,6 +561,7 @@
|
||||
$ring_group_cid_number_prefix = $row["ring_group_cid_number_prefix"];
|
||||
$ring_group_distinctive_ring = $row["ring_group_distinctive_ring"];
|
||||
$ring_group_ringback = $row["ring_group_ringback"];
|
||||
$ring_group_call_screen_enabled = $row["ring_group_call_screen_enabled"];
|
||||
$ring_group_call_forward_enabled = $row["ring_group_call_forward_enabled"];
|
||||
$ring_group_follow_me_enabled = $row["ring_group_follow_me_enabled"];
|
||||
$ring_group_missed_call_app = $row["ring_group_missed_call_app"];
|
||||
@@ -1139,6 +1142,33 @@
|
||||
echo " </td>";
|
||||
echo " </tr>";
|
||||
|
||||
if (permission_exists('ring_group_call_screen_enabled')) {
|
||||
echo "<tr>\n";
|
||||
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
||||
echo " ".$text['label-ring_group_call_screen_enabled']."\n";
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
echo " <select class='formfld' name='ring_group_call_screen_enabled'>\n";
|
||||
echo " <option value=''></option>\n";
|
||||
if ($ring_group_call_screen_enabled == "true") {
|
||||
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
|
||||
}
|
||||
else {
|
||||
echo " <option value='true'>".$text['label-true']."</option>\n";
|
||||
}
|
||||
if ($ring_group_call_screen_enabled == "false") {
|
||||
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
|
||||
}
|
||||
else {
|
||||
echo " <option value='false'>".$text['label-false']."</option>\n";
|
||||
}
|
||||
echo " </select>\n";
|
||||
echo "<br />\n";
|
||||
echo $text['description-ring_group_call_screen_enabled']."\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
||||
echo " ".$text['label-ring_group_call_forward_enabled']."\n";
|
||||
|
||||
@@ -48,6 +48,7 @@ log = require "resources.functions.log".ring_group
|
||||
require "resources.functions.channel_utils"
|
||||
require "resources.functions.format_ringback"
|
||||
require "resources.functions.send_presence";
|
||||
require "resources.functions.mkdir";
|
||||
|
||||
--- include libs
|
||||
local route_to_bridge = require "resources.functions.route_to_bridge"
|
||||
@@ -239,6 +240,7 @@ log = require "resources.functions.log".ring_group
|
||||
ring_group_caller_id_number = row["ring_group_caller_id_number"];
|
||||
ring_group_cid_name_prefix = row["ring_group_cid_name_prefix"];
|
||||
ring_group_cid_number_prefix = row["ring_group_cid_number_prefix"];
|
||||
ring_group_call_screen_enabled = row["ring_group_call_screen_enabled"];
|
||||
ring_group_call_forward_enabled = row["ring_group_call_forward_enabled"];
|
||||
ring_group_follow_me_enabled = row["ring_group_follow_me_enabled"];
|
||||
missed_call_app = row["ring_group_missed_call_app"];
|
||||
@@ -249,6 +251,14 @@ log = require "resources.functions.log".ring_group
|
||||
local Settings = require "resources.functions.lazy_settings";
|
||||
local settings = Settings.new(dbh, domain_name, domain_uuid);
|
||||
|
||||
--get the recordings dir
|
||||
--recordings_dir = settings:get('switch', 'recordings', 'dir');
|
||||
|
||||
--set the default record extension
|
||||
if (record_ext == nil) then
|
||||
record_ext = 'wav';
|
||||
end
|
||||
|
||||
--prepare the recording path
|
||||
record_path = recordings_dir .. "/" .. domain_name .. "/archive/" .. os.date("%Y/%b/%d");
|
||||
record_path = record_path:gsub("\\", "/");
|
||||
@@ -284,9 +294,55 @@ log = require "resources.functions.log".ring_group
|
||||
if (session:ready()) then
|
||||
if (ring_group_greeting and #ring_group_greeting > 0) then
|
||||
session:answer();
|
||||
session_answer = true
|
||||
session:sleep(1000);
|
||||
play_file(dbh, domain_name, domain_uuid, ring_group_greeting)
|
||||
session:sleep(1000);
|
||||
else
|
||||
session_answer = false
|
||||
end
|
||||
end
|
||||
|
||||
--call screen enabled
|
||||
if (ring_group_call_screen_enabled == 'true') then
|
||||
|
||||
--answer the call if not answered
|
||||
if (not session_answer) then
|
||||
session:answer();
|
||||
end
|
||||
|
||||
--flush dtmf digits from the input buffer
|
||||
session:flushDigits();
|
||||
|
||||
--set the variables
|
||||
min_digits = 1;
|
||||
max_digits = 1;
|
||||
max_attempts = 1;
|
||||
timeout = 3000
|
||||
|
||||
--play the name record
|
||||
dtmf_digits = '';
|
||||
session:execute("playback", "phrase:voicemail_record_name");
|
||||
--session:execute("sleep", "1000");
|
||||
session:streamFile("tone_stream://L=1;%(1000, 0, 640)");
|
||||
|
||||
--recording settings
|
||||
max_length_seconds = 30;
|
||||
silence_threshold = 30;
|
||||
silence_seconds = 3;
|
||||
|
||||
--create the call scree file name
|
||||
call_sreen_name = 'call_screen.'..uuid..'.'..record_ext;
|
||||
|
||||
--make sure the recording directory exists
|
||||
if (not file_exists(record_path)) then
|
||||
mkdir(record_path);
|
||||
end
|
||||
|
||||
--record the name and reason for calling
|
||||
if (session:ready()) then
|
||||
result = session:recordFile(record_path..'/'..call_sreen_name, max_length_seconds, silence_threshold, silence_seconds);
|
||||
--session:execute("record", record_path..'/'..call_sreen_name.." 180 200");
|
||||
end
|
||||
end
|
||||
|
||||
@@ -853,7 +909,7 @@ log = require "resources.functions.log".ring_group
|
||||
user_hold_music = trim(api:executeString(cmd));
|
||||
if (user_hold_music ~= nil) and (string.len(user_hold_music) > 0) then
|
||||
hold_music = user_hold_music;
|
||||
else
|
||||
else
|
||||
hold_music = default_hold_music
|
||||
end
|
||||
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
--
|
||||
-- The Initial Developer of the Original Code is
|
||||
-- Mark J Crane <markjcrane@fusionpbx.com>
|
||||
-- Copyright (C) 2010-2015
|
||||
-- Copyright (C) 2010-2024
|
||||
-- the Initial Developer. All Rights Reserved.
|
||||
--
|
||||
-- Contributor(s):
|
||||
-- Mark J Crane <markjcrane@fusionpbx.com>
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
require "resources.functions.config";
|
||||
|
||||
--set variables
|
||||
digit_timeout = "5000";
|
||||
@@ -40,7 +40,7 @@
|
||||
--session:sleep(1000);
|
||||
|
||||
--get the variables
|
||||
uuid = session:getVariable("uuid");
|
||||
call_uuid = session:getVariable("call_uuid");
|
||||
domain_name = session:getVariable("domain_name");
|
||||
context = session:getVariable("context");
|
||||
sounds_dir = session:getVariable("sounds_dir");
|
||||
@@ -64,12 +64,32 @@
|
||||
if (not default_dialect) then default_dialect = 'us'; end
|
||||
if (not default_voice) then default_voice = 'callie'; end
|
||||
|
||||
--create the settings object
|
||||
--local Settings = require "resources.functions.lazy_settings";
|
||||
--local settings = Settings.new(dbh, domain_name, domain_uuid);
|
||||
|
||||
--get the recordings dir
|
||||
--recordings_dir = settings:get('switch', 'recordings', 'dir');
|
||||
|
||||
--set the default record extension
|
||||
if (record_ext == nil) then
|
||||
record_ext = 'wav';
|
||||
end
|
||||
|
||||
--prepare the recording path
|
||||
record_path = recordings_dir .. "/" .. domain_name .. "/archive/" .. os.date("%Y/%b/%d");
|
||||
record_path = record_path:gsub("\\", "/");
|
||||
|
||||
--if the screen file is found then set confirm to true
|
||||
if (domain_name ~= nil) then
|
||||
if (file_exists(temp_dir .. "/" .. domain_name .. "-" .. caller_id_number .. "." .. record_ext)) then
|
||||
call_screen_file = temp_dir .. "/" .. domain_name .. "-" .. caller_id_number .. "." .. record_ext;
|
||||
confirm = "true";
|
||||
end
|
||||
if (file_exists(record_path.."/call_screen."..call_uuid .."."..record_ext)) then
|
||||
call_screen_file = record_path.."/call_screen."..call_uuid .."."..record_ext;
|
||||
confirm = "true";
|
||||
end
|
||||
end
|
||||
|
||||
--confirm the calls
|
||||
|
||||
Reference in New Issue
Block a user