Fix a voicemail bug
Fix the voicemail link Use only one keep local feature Deprecate the voicemail_local_after_forward
This commit is contained in:
parent
e88c43c272
commit
db5dcf4a03
|
|
@ -25,364 +25,361 @@
|
|||
-- POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
--load libraries
|
||||
local send_mail = require 'resources.functions.send_mail'
|
||||
local Database = require "resources.functions.database"
|
||||
local Settings = require "resources.functions.lazy_settings"
|
||||
local send_mail = require 'resources.functions.send_mail'
|
||||
local Database = require "resources.functions.database"
|
||||
local Settings = require "resources.functions.lazy_settings"
|
||||
|
||||
--define a function to send email
|
||||
function send_email(id, uuid)
|
||||
function send_email(id, uuid)
|
||||
--prepare the database, settings and variables
|
||||
local db = dbh or Database.new('system');
|
||||
local settings = Settings.new(db, domain_name, domain_uuid);
|
||||
local http_protocol = settings:get('domain', 'http_protocol', 'text') or "https";
|
||||
local email_queue_enabled = "true";
|
||||
|
||||
--get voicemail message details
|
||||
local sql = [[SELECT * FROM v_voicemails
|
||||
WHERE domain_uuid = :domain_uuid
|
||||
AND voicemail_id = :voicemail_id]]
|
||||
local params = {domain_uuid = domain_uuid, voicemail_id = id};
|
||||
if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||
end
|
||||
dbh:query(sql, params, function(row)
|
||||
db_voicemail_uuid = string.lower(row["voicemail_uuid"]);
|
||||
--voicemail_password = row["voicemail_password"];
|
||||
--greeting_id = row["greeting_id"];
|
||||
voicemail_mail_to = row["voicemail_mail_to"];
|
||||
voicemail_transcription_enabled = row["voicemail_transcription_enabled"];
|
||||
voicemail_file = row["voicemail_file"];
|
||||
voicemail_local_after_email = row["voicemail_local_after_email"];
|
||||
voicemail_local_after_forward = row["voicemail_local_after_forward"];
|
||||
voicemail_description = row["voicemail_description"];
|
||||
end);
|
||||
--get voicemail message details
|
||||
local sql = [[SELECT * FROM v_voicemails
|
||||
WHERE domain_uuid = :domain_uuid
|
||||
AND voicemail_id = :voicemail_id]]
|
||||
local params = {domain_uuid = domain_uuid, voicemail_id = id};
|
||||
if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||
end
|
||||
dbh:query(sql, params, function(row)
|
||||
db_voicemail_uuid = string.lower(row["voicemail_uuid"]);
|
||||
--voicemail_password = row["voicemail_password"];
|
||||
--greeting_id = row["greeting_id"];
|
||||
voicemail_mail_to = row["voicemail_mail_to"];
|
||||
voicemail_transcription_enabled = row["voicemail_transcription_enabled"];
|
||||
voicemail_file = row["voicemail_file"];
|
||||
voicemail_local_after_email = row["voicemail_local_after_email"];
|
||||
voicemail_description = row["voicemail_description"];
|
||||
end);
|
||||
|
||||
--set default values
|
||||
if (voicemail_file == nil) then
|
||||
voicemail_file = "listen";
|
||||
end
|
||||
if (voicemail_local_after_email == nil) then
|
||||
voicemail_local_after_email = "true";
|
||||
end
|
||||
if (voicemail_local_after_forward == nil) then
|
||||
voicemail_local_after_forward = "true";
|
||||
end
|
||||
--set default values
|
||||
if (voicemail_file == nil or voicemail_file == '') then
|
||||
voicemail_file = "listen";
|
||||
end
|
||||
if (voicemail_local_after_email == nil or voicemail_local_after_email == '') then
|
||||
voicemail_local_after_email = "true";
|
||||
end
|
||||
|
||||
--require the email address to send the email
|
||||
if (string.len(voicemail_mail_to) > 2) then
|
||||
--include languages file
|
||||
local Text = require "resources.functions.text"
|
||||
local text = Text.new("app.voicemail.app_languages")
|
||||
local dbh = dbh
|
||||
--require the email address to send the email
|
||||
if (string.len(voicemail_mail_to) > 2) then
|
||||
--include languages file
|
||||
local Text = require "resources.functions.text"
|
||||
local text = Text.new("app.voicemail.app_languages")
|
||||
local dbh = dbh
|
||||
|
||||
--user setting time zone, if set
|
||||
local sql = [[
|
||||
select
|
||||
us.user_setting_value as time_zone
|
||||
from
|
||||
v_user_settings as us,
|
||||
v_extension_users as eu,
|
||||
v_extensions as e,
|
||||
v_voicemails as v
|
||||
where
|
||||
v.voicemail_id = :voicemail_id and
|
||||
v.domain_uuid = :domain_uuid and
|
||||
v.voicemail_id = e.extension and
|
||||
e.domain_uuid = :domain_uuid and
|
||||
e.extension_uuid = eu.extension_uuid and
|
||||
eu.domain_uuid = :domain_uuid and
|
||||
eu.user_uuid = us.user_uuid and
|
||||
us.domain_uuid = :domain_uuid and
|
||||
us.user_setting_category = 'domain' and
|
||||
us.user_setting_subcategory = 'time_zone' and
|
||||
us.user_setting_name = 'name' and
|
||||
us.user_setting_enabled = 'true'
|
||||
order by
|
||||
eu.insert_date asc
|
||||
limit 1
|
||||
]]
|
||||
local params = {domain_uuid = domain_uuid, voicemail_id = id};
|
||||
if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||
end
|
||||
dbh:query(sql, params, function(row)
|
||||
time_zone = row["time_zone"];
|
||||
end);
|
||||
--user setting time zone, if set
|
||||
local sql = [[
|
||||
select
|
||||
us.user_setting_value as time_zone
|
||||
from
|
||||
v_user_settings as us,
|
||||
v_extension_users as eu,
|
||||
v_extensions as e,
|
||||
v_voicemails as v
|
||||
where
|
||||
v.voicemail_id = :voicemail_id and
|
||||
v.domain_uuid = :domain_uuid and
|
||||
v.voicemail_id = e.extension and
|
||||
e.domain_uuid = :domain_uuid and
|
||||
e.extension_uuid = eu.extension_uuid and
|
||||
eu.domain_uuid = :domain_uuid and
|
||||
eu.user_uuid = us.user_uuid and
|
||||
us.domain_uuid = :domain_uuid and
|
||||
us.user_setting_category = 'domain' and
|
||||
us.user_setting_subcategory = 'time_zone' and
|
||||
us.user_setting_name = 'name' and
|
||||
us.user_setting_enabled = 'true'
|
||||
order by
|
||||
eu.insert_date asc
|
||||
limit 1
|
||||
]]
|
||||
local params = {domain_uuid = domain_uuid, voicemail_id = id};
|
||||
if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||
end
|
||||
dbh:query(sql, params, function(row)
|
||||
time_zone = row["time_zone"];
|
||||
end);
|
||||
|
||||
--default/domain setting time zone
|
||||
if (time_zone == nil or time_zone == '') then
|
||||
time_zone = settings:get('domain', 'time_zone', 'name');
|
||||
end
|
||||
|
||||
--default time zone
|
||||
if (time_zone == nil or time_zone == '') then
|
||||
time_zone = 'UTC';
|
||||
end
|
||||
|
||||
--connect using other backend if needed
|
||||
if storage_type == "base64" then
|
||||
dbh = Database.new('system', 'base64/read')
|
||||
end
|
||||
|
||||
--get voicemail message details
|
||||
local sql = [[SELECT to_char(timezone(:time_zone, to_timestamp(created_epoch)), 'Day DD Mon YYYY HH:MI:SS PM') as message_date, *
|
||||
FROM v_voicemail_messages
|
||||
WHERE domain_uuid = :domain_uuid
|
||||
AND voicemail_message_uuid = :uuid]]
|
||||
local params = {domain_uuid = domain_uuid, uuid = uuid, time_zone = time_zone};
|
||||
if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||
end
|
||||
dbh:query(sql, params, function(row)
|
||||
--get the values from the database
|
||||
--uuid = row["voicemail_message_uuid"];
|
||||
created_epoch = row["created_epoch"];
|
||||
caller_id_name = row["caller_id_name"];
|
||||
caller_id_number = row["caller_id_number"];
|
||||
message_date = row["message_date"];
|
||||
message_length = row["message_length"];
|
||||
--message_status = row["message_status"];
|
||||
--message_priority = row["message_priority"];
|
||||
--get the recordings from the database
|
||||
if (storage_type == "base64") then
|
||||
--set the voicemail intro and message paths
|
||||
message_location = voicemail_dir.."/"..id.."/msg_"..uuid.."."..vm_message_ext;
|
||||
intro_location = voicemail_dir.."/"..id.."/intro_"..uuid.."."..vm_message_ext;
|
||||
|
||||
--save the recordings to the file system
|
||||
if (string.len(row["message_base64"]) > 32) then
|
||||
--save the value to a variable
|
||||
voicemail_base64 = row["message_base64"];
|
||||
|
||||
--include the file io
|
||||
local file = require "resources.functions.file"
|
||||
|
||||
--write decoded message string to file
|
||||
file.write_base64(message_location, row["message_base64"]);
|
||||
|
||||
--write decoded intro string to file, if any
|
||||
if (string.len(row["message_intro_base64"]) > 32) then
|
||||
file.write_base64(intro_location, row["message_intro_base64"]);
|
||||
end
|
||||
end
|
||||
end
|
||||
end);
|
||||
|
||||
--close temporary connection
|
||||
if storage_type == "base64" then
|
||||
dbh:release()
|
||||
end
|
||||
|
||||
--format the message length and date
|
||||
message_length_formatted = format_seconds(message_length);
|
||||
if (debug["info"]) then
|
||||
freeswitch.consoleLog("notice", "[voicemail] message date: " .. message_date .. "\n");
|
||||
freeswitch.consoleLog("notice", "[voicemail] message length: " .. message_length .. "\n");
|
||||
end
|
||||
--local message_date = os.date("%A, %d %b %Y %I:%M %p", created_epoch);
|
||||
|
||||
--connect to the database
|
||||
local dbh = Database.new('system');
|
||||
|
||||
--get the templates
|
||||
local sql = "SELECT * FROM v_email_templates ";
|
||||
sql = sql .. "WHERE (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
sql = sql .. "AND template_language = :template_language ";
|
||||
sql = sql .. "AND template_category = 'voicemail' "
|
||||
if (voicemail_transcription_enabled == 'true') then
|
||||
sql = sql .. "AND template_subcategory = 'transcription' "
|
||||
else
|
||||
sql = sql .. "AND template_subcategory = 'default' "
|
||||
end
|
||||
sql = sql .. "AND template_enabled = 'true' "
|
||||
sql = sql .. "ORDER BY domain_uuid DESC "
|
||||
local params = {domain_uuid = domain_uuid, template_language = default_language.."-"..default_dialect};
|
||||
if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||
end
|
||||
dbh:query(sql, params, function(row)
|
||||
subject = row["template_subject"];
|
||||
body = row["template_body"];
|
||||
end);
|
||||
|
||||
--get the link_address
|
||||
link_address = http_protocol.."://"..domain_name..project_path;
|
||||
|
||||
--set proper delete status
|
||||
local local_after_email = '';
|
||||
if (voicemail_local_after_email == "false" or voicemail_local_after_forward == "false") then
|
||||
local_after_email = "false";
|
||||
else
|
||||
local_after_email = "true";
|
||||
end
|
||||
|
||||
--prepare the headers
|
||||
local headers = {
|
||||
["X-FusionPBX-Domain-UUID"] = domain_uuid;
|
||||
["X-FusionPBX-Domain-Name"] = domain_name;
|
||||
["X-FusionPBX-Call-UUID"] = uuid;
|
||||
["X-FusionPBX-Email-Type"] = 'voicemail';
|
||||
["X-FusionPBX-local_after_email"] = local_after_email;
|
||||
}
|
||||
|
||||
--prepare the voicemail_name_formatted
|
||||
voicemail_name_formatted = id;
|
||||
local display_domain_name = settings:get('voicemail', 'display_domain_name', 'boolean');
|
||||
|
||||
if (display_domain_name == 'true') then
|
||||
voicemail_name_formatted = id.."@"..domain_name;
|
||||
end
|
||||
if (voicemail_description ~= nil and voicemail_description ~= "" and voicemail_description ~= id) then
|
||||
voicemail_name_formatted = voicemail_name_formatted.." ("..voicemail_description..")";
|
||||
end
|
||||
|
||||
--prepare file
|
||||
file = voicemail_dir.."/"..id.."/msg_"..uuid.."."..vm_message_ext;
|
||||
|
||||
--combine intro, if exists, with message for emailing (only)
|
||||
intro = voicemail_dir.."/"..id.."/intro_"..uuid.."."..vm_message_ext;
|
||||
combined = voicemail_dir.."/"..id.."/intro_msg_"..uuid.."."..vm_message_ext;
|
||||
if (file_exists(intro) and file_exists(file)) then
|
||||
os.execute("sox "..intro.." "..file.." "..combined);
|
||||
end
|
||||
|
||||
--prepare the subject
|
||||
if (subject ~= nil) then
|
||||
subject = subject:gsub("${caller_id_name}", caller_id_name);
|
||||
subject = subject:gsub("${caller_id_number}", caller_id_number);
|
||||
subject = subject:gsub("${message_date}", message_date);
|
||||
subject = subject:gsub("${message_duration}", message_length_formatted);
|
||||
subject = subject:gsub("${account}", voicemail_name_formatted);
|
||||
subject = subject:gsub("${voicemail_id}", id);
|
||||
subject = subject:gsub("${voicemail_description}", voicemail_description);
|
||||
subject = subject:gsub("${voicemail_name_formatted}", voicemail_name_formatted);
|
||||
subject = subject:gsub("${domain_name}", domain_name);
|
||||
subject = subject:gsub("${new_messages}", new_messages);
|
||||
subject = trim(subject);
|
||||
else
|
||||
subject = text['label-voicemail'] .. ' ' .. caller_id_name .. ' <' .. caller_id_number .. '> ' .. message_length_formatted;
|
||||
end
|
||||
subject = '=?utf-8?B?'..base64.encode(subject)..'?=';
|
||||
|
||||
--prepare the body
|
||||
if (body ~= nil) then
|
||||
body = body:gsub("${caller_id_name}", caller_id_name);
|
||||
body = body:gsub("${caller_id_number}", caller_id_number);
|
||||
body = body:gsub("${message_date}", message_date);
|
||||
if (transcription ~= nil) then
|
||||
transcription = transcription:gsub("%%", "*");
|
||||
body = body:gsub("${message_text}", transcription);
|
||||
end
|
||||
body = body:gsub("${message_duration}", message_length_formatted);
|
||||
body = body:gsub("${account}", voicemail_name_formatted);
|
||||
body = body:gsub("${voicemail_id}", id);
|
||||
body = body:gsub("${voicemail_description}", voicemail_description);
|
||||
body = body:gsub("${voicemail_name_formatted}", voicemail_name_formatted);
|
||||
body = body:gsub("${domain_name}", domain_name);
|
||||
body = body:gsub("${sip_to_user}", id);
|
||||
if (origination_callee_id_name ~= nil) then
|
||||
body = body:gsub("${origination_callee_id_name}", origination_callee_id_name);
|
||||
end
|
||||
body = body:gsub("${dialed_user}", id);
|
||||
if (voicemail_file == "attach" and file) then
|
||||
body = body:gsub("${message}", text['label-attached']);
|
||||
elseif (voicemail_file == "link") then
|
||||
body = body:gsub("${message}", "<a href='"..link_address.."/app/voicemails/voicemail_messages.php?action=download&id="..id.."&voicemail_uuid="..db_voicemail_uuid.."&uuid="..uuid.."&t=bin'>"..text['label-download'].."</a>");
|
||||
else
|
||||
body = body:gsub("${message}", "<a href='"..link_address.."/app/voicemails/voicemail_messages.php?action=autoplay&id="..db_voicemail_uuid.."&uuid="..uuid.."&vm="..id.."'>"..text['label-listen'].."</a>");
|
||||
end
|
||||
--body = body:gsub(" ", " ");
|
||||
--body = body:gsub("%s+", "");
|
||||
--body = body:gsub(" ", " ");
|
||||
body = trim(body);
|
||||
else
|
||||
body = '<html><body>';
|
||||
if (caller_id_name ~= nil and caller_id_name ~= caller_id_number) then
|
||||
body = body .. caller_id_name .. '<br>';
|
||||
end
|
||||
body = body .. caller_id_number .. '<br>';
|
||||
body = body .. message_date .. '<br>';
|
||||
if (voicemail_file == "attach" and file) then
|
||||
body = body .. '<br>' .. text['label-attached'];
|
||||
elseif (voicemail_file == "link") then
|
||||
body = body .. "<br><a href='"..link_address.."/app/voicemails/voicemail_messages.php?action=download&id="..id.."&voicemail_uuid="..db_voicemail_uuid.."&uuid="..uuid.."&t=bin'>"..text['label-download'].."</a>";
|
||||
else
|
||||
body = body .. "<br><a href='"..link_address.."/app/voicemails/voicemail_messages.php?action=autoplay&id="..db_voicemail_uuid.."&uuid="..uuid.."&vm="..id.."'>"..text['label-listen'].."</a>";
|
||||
end
|
||||
body = body .. '</body></html>';
|
||||
end
|
||||
|
||||
--get the smtp from address and name
|
||||
smtp_from = settings:get('voicemail', 'smtp_from', 'text');
|
||||
smtp_from_name = settings:get('voicemail', 'smtp_from_name', 'text');
|
||||
if (smtp_from == nil or smtp_from == '') then
|
||||
smtp_from = settings:get('email', 'smtp_from', 'text');
|
||||
end
|
||||
if (smtp_from_name == nil or smtp_from_name == '') then
|
||||
smtp_from_name = settings:get('email', 'smtp_from_name', 'text');
|
||||
end
|
||||
if (smtp_from_name and string.len(smtp_from_name) > 0 and smtp_from and string.len(smtp_from) > 2) then
|
||||
smtp_from = smtp_from_name.."<"..smtp_from..">";
|
||||
end
|
||||
|
||||
--send the email with, or without, including the intro
|
||||
if (file_exists(combined)) then
|
||||
voicemail_path = combined
|
||||
else
|
||||
voicemail_path = file
|
||||
end
|
||||
|
||||
--send the email
|
||||
send_mail(headers,
|
||||
smtp_from,
|
||||
voicemail_mail_to,
|
||||
{subject, body},
|
||||
(voicemail_file == "attach") and voicemail_path,
|
||||
voicemail_base64
|
||||
);
|
||||
|
||||
end
|
||||
|
||||
--whether to keep the voicemail message and details local after email
|
||||
if (string.len(voicemail_mail_to) > 2 and email_queue_enabled == 'false') then
|
||||
if (voicemail_local_after_email == "false" and voicemail_local_after_forward == "false") then
|
||||
--delete the voicemail message details
|
||||
local sql = [[DELETE FROM v_voicemail_messages
|
||||
WHERE domain_uuid = :domain_uuid
|
||||
AND voicemail_uuid = :voicemail_uuid
|
||||
AND voicemail_message_uuid = :uuid]]
|
||||
local params = {domain_uuid = domain_uuid,
|
||||
voicemail_uuid = db_voicemail_uuid, uuid = uuid};
|
||||
if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||
end
|
||||
dbh:query(sql, params);
|
||||
--delete voicemail recording files
|
||||
if (file_exists(file)) then
|
||||
os.remove(file);
|
||||
end
|
||||
if (file_exists(intro)) then
|
||||
os.remove(intro);
|
||||
end
|
||||
if (file_exists(combined)) then
|
||||
os.remove(combined);
|
||||
end
|
||||
--set message waiting indicator
|
||||
message_waiting(id, domain_uuid);
|
||||
--clear the variable
|
||||
db_voicemail_uuid = '';
|
||||
elseif (storage_type == "base64") then
|
||||
--delete voicemail recording files
|
||||
if (file_exists(file)) then
|
||||
os.remove(file);
|
||||
end
|
||||
if (file_exists(intro)) then
|
||||
os.remove(intro);
|
||||
end
|
||||
if (file_exists(combined)) then
|
||||
os.remove(combined);
|
||||
end
|
||||
--default/domain setting time zone
|
||||
if (time_zone == nil or time_zone == '') then
|
||||
time_zone = settings:get('domain', 'time_zone', 'name');
|
||||
end
|
||||
|
||||
--default time zone
|
||||
if (time_zone == nil or time_zone == '') then
|
||||
time_zone = 'UTC';
|
||||
end
|
||||
|
||||
--connect using other backend if needed
|
||||
if storage_type == "base64" then
|
||||
dbh = Database.new('system', 'base64/read')
|
||||
end
|
||||
|
||||
--get voicemail message details
|
||||
local sql = [[SELECT to_char(timezone(:time_zone, to_timestamp(created_epoch)), 'Day DD Mon YYYY HH:MI:SS PM') as message_date, *
|
||||
FROM v_voicemail_messages
|
||||
WHERE domain_uuid = :domain_uuid
|
||||
AND voicemail_message_uuid = :uuid]]
|
||||
local params = {domain_uuid = domain_uuid, uuid = uuid, time_zone = time_zone};
|
||||
if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||
end
|
||||
dbh:query(sql, params, function(row)
|
||||
--get the values from the database
|
||||
--uuid = row["voicemail_message_uuid"];
|
||||
created_epoch = row["created_epoch"];
|
||||
caller_id_name = row["caller_id_name"];
|
||||
caller_id_number = row["caller_id_number"];
|
||||
message_date = row["message_date"];
|
||||
message_length = row["message_length"];
|
||||
--message_status = row["message_status"];
|
||||
--message_priority = row["message_priority"];
|
||||
--get the recordings from the database
|
||||
if (storage_type == "base64") then
|
||||
--set the voicemail intro and message paths
|
||||
message_location = voicemail_dir.."/"..id.."/msg_"..uuid.."."..vm_message_ext;
|
||||
intro_location = voicemail_dir.."/"..id.."/intro_"..uuid.."."..vm_message_ext;
|
||||
|
||||
--save the recordings to the file system
|
||||
if (string.len(row["message_base64"]) > 32) then
|
||||
--save the value to a variable
|
||||
voicemail_base64 = row["message_base64"];
|
||||
|
||||
--include the file io
|
||||
local file = require "resources.functions.file"
|
||||
|
||||
--write decoded message string to file
|
||||
file.write_base64(message_location, row["message_base64"]);
|
||||
|
||||
--write decoded intro string to file, if any
|
||||
if (string.len(row["message_intro_base64"]) > 32) then
|
||||
file.write_base64(intro_location, row["message_intro_base64"]);
|
||||
end
|
||||
end
|
||||
end
|
||||
end);
|
||||
|
||||
--close temporary connection
|
||||
if storage_type == "base64" then
|
||||
dbh:release()
|
||||
end
|
||||
|
||||
--format the message length and date
|
||||
message_length_formatted = format_seconds(message_length);
|
||||
if (debug["info"]) then
|
||||
freeswitch.consoleLog("notice", "[voicemail] message date: " .. message_date .. "\n");
|
||||
freeswitch.consoleLog("notice", "[voicemail] message length: " .. message_length .. "\n");
|
||||
end
|
||||
--local message_date = os.date("%A, %d %b %Y %I:%M %p", created_epoch);
|
||||
|
||||
--connect to the database
|
||||
local dbh = Database.new('system');
|
||||
|
||||
--get the templates
|
||||
local sql = "SELECT * FROM v_email_templates ";
|
||||
sql = sql .. "WHERE (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
sql = sql .. "AND template_language = :template_language ";
|
||||
sql = sql .. "AND template_category = 'voicemail' "
|
||||
if (voicemail_transcription_enabled == 'true') then
|
||||
sql = sql .. "AND template_subcategory = 'transcription' "
|
||||
else
|
||||
sql = sql .. "AND template_subcategory = 'default' "
|
||||
end
|
||||
sql = sql .. "AND template_enabled = 'true' "
|
||||
sql = sql .. "ORDER BY domain_uuid DESC "
|
||||
local params = {domain_uuid = domain_uuid, template_language = default_language.."-"..default_dialect};
|
||||
if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||
end
|
||||
dbh:query(sql, params, function(row)
|
||||
subject = row["template_subject"];
|
||||
body = row["template_body"];
|
||||
end);
|
||||
|
||||
--get the link_address
|
||||
link_address = http_protocol.."://"..domain_name..project_path;
|
||||
|
||||
--set proper delete status
|
||||
local local_after_email = '';
|
||||
if (voicemail_local_after_email == "false") then
|
||||
local_after_email = "false";
|
||||
else
|
||||
local_after_email = "true";
|
||||
end
|
||||
|
||||
--prepare the headers
|
||||
local headers = {
|
||||
["X-FusionPBX-Domain-UUID"] = domain_uuid;
|
||||
["X-FusionPBX-Domain-Name"] = domain_name;
|
||||
["X-FusionPBX-Call-UUID"] = uuid;
|
||||
["X-FusionPBX-Email-Type"] = 'voicemail';
|
||||
["X-FusionPBX-local_after_email"] = local_after_email;
|
||||
}
|
||||
|
||||
--prepare the voicemail_name_formatted
|
||||
voicemail_name_formatted = id;
|
||||
local display_domain_name = settings:get('voicemail', 'display_domain_name', 'boolean');
|
||||
|
||||
if (display_domain_name == 'true') then
|
||||
voicemail_name_formatted = id.."@"..domain_name;
|
||||
end
|
||||
if (voicemail_description ~= nil and voicemail_description ~= "" and voicemail_description ~= id) then
|
||||
voicemail_name_formatted = voicemail_name_formatted.." ("..voicemail_description..")";
|
||||
end
|
||||
|
||||
--prepare file
|
||||
file = voicemail_dir.."/"..id.."/msg_"..uuid.."."..vm_message_ext;
|
||||
|
||||
--combine intro, if exists, with message for emailing (only)
|
||||
intro = voicemail_dir.."/"..id.."/intro_"..uuid.."."..vm_message_ext;
|
||||
combined = voicemail_dir.."/"..id.."/intro_msg_"..uuid.."."..vm_message_ext;
|
||||
if (file_exists(intro) and file_exists(file)) then
|
||||
os.execute("sox "..intro.." "..file.." "..combined);
|
||||
end
|
||||
|
||||
--prepare the subject
|
||||
if (subject ~= nil) then
|
||||
subject = subject:gsub("${caller_id_name}", caller_id_name);
|
||||
subject = subject:gsub("${caller_id_number}", caller_id_number);
|
||||
subject = subject:gsub("${message_date}", message_date);
|
||||
subject = subject:gsub("${message_duration}", message_length_formatted);
|
||||
subject = subject:gsub("${account}", voicemail_name_formatted);
|
||||
subject = subject:gsub("${voicemail_id}", id);
|
||||
subject = subject:gsub("${voicemail_description}", voicemail_description);
|
||||
subject = subject:gsub("${voicemail_name_formatted}", voicemail_name_formatted);
|
||||
subject = subject:gsub("${domain_name}", domain_name);
|
||||
subject = subject:gsub("${new_messages}", new_messages);
|
||||
subject = trim(subject);
|
||||
else
|
||||
subject = text['label-voicemail'] .. ' ' .. caller_id_name .. ' <' .. caller_id_number .. '> ' .. message_length_formatted;
|
||||
end
|
||||
subject = '=?utf-8?B?'..base64.encode(subject)..'?=';
|
||||
|
||||
--prepare the body
|
||||
if (body ~= nil) then
|
||||
body = body:gsub("${caller_id_name}", caller_id_name);
|
||||
body = body:gsub("${caller_id_number}", caller_id_number);
|
||||
body = body:gsub("${message_date}", message_date);
|
||||
if (transcription ~= nil) then
|
||||
transcription = transcription:gsub("%%", "*");
|
||||
body = body:gsub("${message_text}", transcription);
|
||||
end
|
||||
body = body:gsub("${message_duration}", message_length_formatted);
|
||||
body = body:gsub("${account}", voicemail_name_formatted);
|
||||
body = body:gsub("${voicemail_id}", id);
|
||||
body = body:gsub("${voicemail_description}", voicemail_description);
|
||||
body = body:gsub("${voicemail_name_formatted}", voicemail_name_formatted);
|
||||
body = body:gsub("${domain_name}", domain_name);
|
||||
body = body:gsub("${sip_to_user}", id);
|
||||
if (origination_callee_id_name ~= nil) then
|
||||
body = body:gsub("${origination_callee_id_name}", origination_callee_id_name);
|
||||
end
|
||||
body = body:gsub("${dialed_user}", id);
|
||||
if (voicemail_file == "attach" and file) then
|
||||
body = body:gsub("${message}", text['label-attached']);
|
||||
elseif (voicemail_file == "link") then
|
||||
body = body:gsub("${message}", "<a href='"..link_address.."/app/voicemails/voicemail_messages.php?action=download&id="..id.."&voicemail_uuid="..db_voicemail_uuid.."&uuid="..uuid.."&t=bin'>"..text['label-download'].."</a>");
|
||||
else
|
||||
body = body:gsub("${message}", "<a href='"..link_address.."/app/voicemails/voicemail_messages.php?action=autoplay&id="..db_voicemail_uuid.."&uuid="..uuid.."&vm="..id.."'>"..text['label-listen'].."</a>");
|
||||
end
|
||||
--body = body:gsub(" ", " ");
|
||||
--body = body:gsub("%s+", "");
|
||||
--body = body:gsub(" ", " ");
|
||||
body = trim(body);
|
||||
else
|
||||
body = '<html><body>';
|
||||
if (caller_id_name ~= nil and caller_id_name ~= caller_id_number) then
|
||||
body = body .. caller_id_name .. '<br>';
|
||||
end
|
||||
body = body .. caller_id_number .. '<br>';
|
||||
body = body .. message_date .. '<br>';
|
||||
if (voicemail_file == "attach" and file) then
|
||||
body = body .. '<br>' .. text['label-attached'];
|
||||
elseif (voicemail_file == "link") then
|
||||
body = body .. "<br><a href='"..link_address.."/app/voicemails/voicemail_messages.php?action=download&id="..id.."&voicemail_uuid="..db_voicemail_uuid.."&uuid="..uuid.."&t=bin'>"..text['label-download'].."</a>";
|
||||
else
|
||||
body = body .. "<br><a href='"..link_address.."/app/voicemails/voicemail_messages.php?action=autoplay&id="..db_voicemail_uuid.."&uuid="..uuid.."&vm="..id.."'>"..text['label-listen'].."</a>";
|
||||
end
|
||||
body = body .. '</body></html>';
|
||||
end
|
||||
|
||||
--get the smtp from address and name
|
||||
smtp_from = settings:get('voicemail', 'smtp_from', 'text');
|
||||
smtp_from_name = settings:get('voicemail', 'smtp_from_name', 'text');
|
||||
if (smtp_from == nil or smtp_from == '') then
|
||||
smtp_from = settings:get('email', 'smtp_from', 'text');
|
||||
end
|
||||
if (smtp_from_name == nil or smtp_from_name == '') then
|
||||
smtp_from_name = settings:get('email', 'smtp_from_name', 'text');
|
||||
end
|
||||
if (smtp_from_name and string.len(smtp_from_name) > 0 and smtp_from and string.len(smtp_from) > 2) then
|
||||
smtp_from = smtp_from_name.."<"..smtp_from..">";
|
||||
end
|
||||
|
||||
--send the email with, or without, including the intro
|
||||
if (file_exists(combined)) then
|
||||
voicemail_path = combined
|
||||
else
|
||||
voicemail_path = file
|
||||
end
|
||||
|
||||
--send the email
|
||||
send_mail(headers,
|
||||
smtp_from,
|
||||
voicemail_mail_to,
|
||||
{subject, body},
|
||||
(voicemail_file == "attach") and voicemail_path,
|
||||
voicemail_base64
|
||||
);
|
||||
|
||||
end
|
||||
|
||||
--whether to keep the voicemail message and details local after email
|
||||
if (string.len(voicemail_mail_to) > 2 and email_queue_enabled == 'false') then
|
||||
if (voicemail_local_after_email == "false") then
|
||||
--delete the voicemail message details
|
||||
local sql = [[DELETE FROM v_voicemail_messages
|
||||
WHERE domain_uuid = :domain_uuid
|
||||
AND voicemail_uuid = :voicemail_uuid
|
||||
AND voicemail_message_uuid = :uuid]]
|
||||
local params = {domain_uuid = domain_uuid,
|
||||
voicemail_uuid = db_voicemail_uuid, uuid = uuid};
|
||||
if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||
end
|
||||
dbh:query(sql, params);
|
||||
--delete voicemail recording files
|
||||
if (file_exists(file)) then
|
||||
os.remove(file);
|
||||
end
|
||||
if (file_exists(intro)) then
|
||||
os.remove(intro);
|
||||
end
|
||||
if (file_exists(combined)) then
|
||||
os.remove(combined);
|
||||
end
|
||||
--set message waiting indicator
|
||||
message_waiting(id, domain_uuid);
|
||||
--clear the variable
|
||||
db_voicemail_uuid = '';
|
||||
elseif (storage_type == "base64") then
|
||||
--delete voicemail recording files
|
||||
if (file_exists(file)) then
|
||||
os.remove(file);
|
||||
end
|
||||
if (file_exists(intro)) then
|
||||
os.remove(intro);
|
||||
end
|
||||
if (file_exists(combined)) then
|
||||
os.remove(combined);
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -180,10 +180,6 @@
|
|||
$apps[$x]['permissions'][$y]['groups'][] = "user";
|
||||
$apps[$x]['permissions'][$y]['groups'][] = "agent";
|
||||
$y++;
|
||||
$apps[$x]['permissions'][$y]['name'] = "voicemail_local_after_forward";
|
||||
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
|
||||
$apps[$x]['permissions'][$y]['groups'][] = "admin";
|
||||
$y++;
|
||||
$apps[$x]['permissions'][$y]['name'] = "voicemail_recording_instructions";
|
||||
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
|
||||
$apps[$x]['permissions'][$y]['groups'][] = "admin";
|
||||
|
|
@ -401,6 +397,22 @@
|
|||
$apps[$x]['default_settings'][$y]['default_setting_value'] = "90";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Number of days maintenance application will retain files.";
|
||||
$y++;
|
||||
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "79d05433-a7ab-4641-ae5d-6eb7810eb560";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_category'] = "voicemail";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "use_deletion_queue";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_name'] = "boolean";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_value'] = "false";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Instead of deleting voicemails right away when pressing 7; queue them for deletion";
|
||||
$y++;
|
||||
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "b06cc9df-379e-4b45-8bda-d2d431506317";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_category'] = "voicemail";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "deletion_queue_retention_hours";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_name'] = "numeric";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_value'] = "24";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
|
||||
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Number of hours the voicemail deletion queue will retain deleted voicemails";
|
||||
//schema details
|
||||
$y=0;
|
||||
$apps[$x]['db'][$y]['table']['name'] = "v_voicemails";
|
||||
|
|
@ -475,6 +487,7 @@
|
|||
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['search'] = 'true';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Choose to keep the voicemail file after sending to forward destinations.";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = "voicemail_enabled";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
|
||||
|
|
|
|||
|
|
@ -649,33 +649,6 @@ $text['label-voicemail_local_after_email']['zh-cn'] = "保持本地";
|
|||
$text['label-voicemail_local_after_email']['ja-jp'] = "ローカルに保つ";
|
||||
$text['label-voicemail_local_after_email']['ko-kr'] = "로컬 유지";
|
||||
|
||||
$text['label-voicemail_local_after_forward']['en-us'] = "Keep Local After Forward";
|
||||
$text['label-voicemail_local_after_forward']['en-gb'] = "Keep Local After Forward";
|
||||
$text['label-voicemail_local_after_forward']['ar-eg'] = "الحفاظ على المحلية بعد الأمام";
|
||||
$text['label-voicemail_local_after_forward']['de-at'] = "Nach Weiterleitung lokal behalten";
|
||||
$text['label-voicemail_local_after_forward']['de-ch'] = "Nach Weiterleitung lokal behalten";
|
||||
$text['label-voicemail_local_after_forward']['de-de'] = "Nach Weiterleitung lokal behalten";
|
||||
$text['label-voicemail_local_after_forward']['el-gr'] = "Keep Local After Forward";
|
||||
$text['label-voicemail_local_after_forward']['es-cl'] = "Mantener local después de avanzar";
|
||||
$text['label-voicemail_local_after_forward']['es-mx'] = "Mantener local después de avanzar";
|
||||
$text['label-voicemail_local_after_forward']['fr-ca'] = "Rester local après le transfert";
|
||||
$text['label-voicemail_local_after_forward']['fr-fr'] = "Rester local après le transfert";
|
||||
$text['label-voicemail_local_after_forward']['he-il'] = "שמור על מקומי לאחר קדימה";
|
||||
$text['label-voicemail_local_after_forward']['it-it'] = "Mantieni locale dopo l'inoltro";
|
||||
$text['label-voicemail_local_after_forward']['ka-ge'] = "გადაგზავნის შემდეგ ადგილობრივად შენარჩუნება";
|
||||
$text['label-voicemail_local_after_forward']['nl-nl'] = "Lokaal behouden na doorsturen";
|
||||
$text['label-voicemail_local_after_forward']['pl-pl'] = "Zachowaj lokalny po przesłaniu dalej";
|
||||
$text['label-voicemail_local_after_forward']['pt-br'] = "Manter local depois de encaminhar";
|
||||
$text['label-voicemail_local_after_forward']['pt-pt'] = "Manter local depois de encaminhar";
|
||||
$text['label-voicemail_local_after_forward']['ro-ro'] = "Păstrați local după redirecționare";
|
||||
$text['label-voicemail_local_after_forward']['ru-ru'] = "Сохранять локальное значение после пересылки";
|
||||
$text['label-voicemail_local_after_forward']['sv-se'] = "Håll lokal efter Forward";
|
||||
$text['label-voicemail_local_after_forward']['uk-ua'] = "Зберігати локальні після пересилання";
|
||||
$text['label-voicemail_local_after_forward']['tr-tr'] = "İleriden Sonra Yerel Tut";
|
||||
$text['label-voicemail_local_after_forward']['zh-cn'] = "转发后保持本地";
|
||||
$text['label-voicemail_local_after_forward']['ja-jp'] = "転送後もローカルに保持";
|
||||
$text['label-voicemail_local_after_forward']['ko-kr'] = "전달 후 로컬 유지";
|
||||
|
||||
$text['label-voicemail_transcribe_enabled']['en-us'] = "Transcribe";
|
||||
$text['label-voicemail_transcribe_enabled']['en-gb'] = "Transcribe";
|
||||
$text['label-voicemail_transcribe_enabled']['ar-eg'] = "نسخ";
|
||||
|
|
@ -1836,33 +1809,6 @@ $text['description-voicemail_local_after_email']['zh-cn'] = "选择发送电子
|
|||
$text['description-voicemail_local_after_email']['ja-jp'] = "電子メール通知の送信後にボイスメールをシステムに保持するかどうかを選択します。";
|
||||
$text['description-voicemail_local_after_email']['ko-kr'] = "이메일 알림을 보낸 후 시스템에 음성 메일을 유지할지 여부를 선택합니다.";
|
||||
|
||||
$text['description-voicemail_local_after_forward']['en-us'] = "Choose whether to keep the voicemail in this mailbox after sending to the defined Forward Destination(s).";
|
||||
$text['description-voicemail_local_after_forward']['en-gb'] = "Choose whether to keep the voicemail in this mailbox after sending to the defined Forward Destination(s).";
|
||||
$text['description-voicemail_local_after_forward']['ar-eg'] = "اختر ما إذا كنت تريد الاحتفاظ بالبريد الصوتي في صندوق البريد هذا بعد إرساله إلى وجهة (وجهات) إعادة التوجيه المحددة.";
|
||||
$text['description-voicemail_local_after_forward']['de-at'] = "Wählen Sie, ob die Voicemail nach dem Senden an die definierten Weiterleitungsziele in dieser Mailbox bleiben soll.";
|
||||
$text['description-voicemail_local_after_forward']['de-ch'] = "Wählen Sie, ob die Voicemail nach dem Senden an die definierten Weiterleitungsziele in dieser Mailbox bleiben soll.";
|
||||
$text['description-voicemail_local_after_forward']['de-de'] = "Wählen Sie, ob die Voicemail nach dem Senden an die definierten Weiterleitungsziele in dieser Mailbox bleiben soll.";
|
||||
$text['description-voicemail_local_after_forward']['el-gr'] = "Επιλέξτε εάν θα διατηρηθεί ο τηλεφωνητής σε αυτό το γραμματοκιβώτιο μετά την αποστολή στον καθορισμένο(ους) Προορισμό(ους).";
|
||||
$text['description-voicemail_local_after_forward']['es-cl'] = "Elija si desea conservar el correo de voz en este buzón después de enviarlo a los destinos de reenvío definidos.";
|
||||
$text['description-voicemail_local_after_forward']['es-mx'] = "Elija si desea conservar el correo de voz en este buzón después de enviarlo a los destinos de reenvío definidos.";
|
||||
$text['description-voicemail_local_after_forward']['fr-ca'] = "Choisissez si vous souhaitez conserver la messagerie vocale dans cette boîte aux lettres après l'envoi vers la ou les destinations de transfert définies.";
|
||||
$text['description-voicemail_local_after_forward']['fr-fr'] = "Choisissez si vous souhaitez conserver la messagerie vocale dans cette boîte aux lettres après l'envoi vers la ou les destinations de transfert définies.";
|
||||
$text['description-voicemail_local_after_forward']['he-il'] = "בחר אם לשמור את הדואר הקולי בתיבת הדואר הזו לאחר השליחה ליעד/ים המוגדרים.";
|
||||
$text['description-voicemail_local_after_forward']['it-it'] = "Scegliere se conservare i messaggi vocali in questa casella di posta dopo l'invio alle destinazioni di inoltro definite.";
|
||||
$text['description-voicemail_local_after_forward']['ka-ge'] = "აირჩიეთ, დარჩება თუ არა ხმოვანი ფოსტა ამ საფოსტო ყუთში განსაზღვრულ დანიშნულების პუნქტებამდე გაგზავნის შემდეგ.";
|
||||
$text['description-voicemail_local_after_forward']['nl-nl'] = "Kies of u de voicemail in deze mailbox wilt bewaren na verzending naar de gedefinieerde doorstuurbestemming(en).";
|
||||
$text['description-voicemail_local_after_forward']['pl-pl'] = "Wybierz, czy poczta głosowa ma być przechowywana w tej skrzynce pocztowej po wysłaniu do określonych miejsc docelowych przekazywania.";
|
||||
$text['description-voicemail_local_after_forward']['pt-br'] = "Escolha se deseja manter o correio de voz nesta caixa postal após enviar para o(s) destino(s) de encaminhamento definido(s).";
|
||||
$text['description-voicemail_local_after_forward']['pt-pt'] = "Escolha se deseja manter o correio de voz nesta caixa postal após enviar para o(s) destino(s) de encaminhamento definido(s).";
|
||||
$text['description-voicemail_local_after_forward']['ro-ro'] = "Alegeți dacă doriți să păstrați mesageria vocală în această cutie poștală după trimiterea către destinația (destinațiile) de redirecționare definite.";
|
||||
$text['description-voicemail_local_after_forward']['ru-ru'] = "Выберите, следует ли сохранять голосовую почту в этом почтовом ящике после отправки в определенные пункты назначения пересылки.";
|
||||
$text['description-voicemail_local_after_forward']['sv-se'] = "Välj om du vill behålla röstbrevlådan i den här brevlådan efter att ha skickats till den eller de definierade vidarebefordrandestinationerna.";
|
||||
$text['description-voicemail_local_after_forward']['uk-ua'] = "Виберіть, чи зберігати голосову пошту в цій поштовій скриньці після надсилання на визначені пункти призначення.";
|
||||
$text['description-voicemail_local_after_forward']['tr-tr'] = "Tanımlanan İletme Hedef(ler)ine gönderdikten sonra sesli postanın bu posta kutusunda tutulup tutulmayacağını seçin.";
|
||||
$text['description-voicemail_local_after_forward']['zh-cn'] = "选择在发送到定义的转发目的地后是否将语音邮件保留在此邮箱中。";
|
||||
$text['description-voicemail_local_after_forward']['ja-jp'] = "定義された転送先に送信した後、ボイスメールをこのメールボックスに保持するかどうかを選択します。";
|
||||
$text['description-voicemail_local_after_forward']['ko-kr'] = "정의된 전달 대상으로 음성 메일을 보낸 후 이 사서함에 음성 메일을 보관할지 여부를 선택합니다.";
|
||||
|
||||
$text['description-voicemail_id']['en-us'] = "Enter the Voicemail ID";
|
||||
$text['description-voicemail_id']['en-gb'] = "Enter the Voicemail ID";
|
||||
$text['description-voicemail_id']['ar-eg'] = "أدخل معرف البريد الصوتي";
|
||||
|
|
@ -2726,4 +2672,4 @@ $text['message-emails_resent']['zh-cn'] = "电子邮件已重新发送";
|
|||
$text['message-emails_resent']['ja-jp'] = "再送信メール";
|
||||
$text['message-emails_resent']['ko-kr'] = "이메일 재전송";
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
@ -98,12 +98,11 @@
|
|||
$voicemail_sms_to = $_POST["voicemail_sms_to"] ?? null;
|
||||
$voicemail_transcription_enabled = $_POST["voicemail_transcription_enabled"] ?? null;
|
||||
$voicemail_file = $_POST["voicemail_file"];
|
||||
$voicemail_local_after_email = $_POST["voicemail_local_after_email"];
|
||||
$voicemail_local_after_email = $_POST["voicemail_local_after_email"] ?? null;
|
||||
$voicemail_destination = $_POST["voicemail_destination"];
|
||||
$voicemail_local_after_forward = $_POST["voicemail_local_after_forward"];
|
||||
$voicemail_enabled = $_POST["voicemail_enabled"] ?? 'false';
|
||||
$voicemail_description = $_POST["voicemail_description"];
|
||||
$voicemail_tutorial = $_POST["voicemail_tutorial"];
|
||||
$voicemail_tutorial = $_POST["voicemail_tutorial"] ?? null;
|
||||
$voicemail_recording_instructions = $_POST["voicemail_recording_instructions"] ?? null;
|
||||
$voicemail_recording_options = $_POST["voicemail_recording_options"] ?? null;
|
||||
$voicemail_options_delete = $_POST["voicemail_options_delete"] ?? null;
|
||||
|
|
@ -154,7 +153,7 @@
|
|||
$voicemail_uuid = uuid();
|
||||
//if adding a mailbox and don't have the transcription permission, set the default transcribe behavior
|
||||
if (!permission_exists('voicemail_transcription_enabled') && isset($_SESSION['voicemail']['transcription_enabled_default']['boolean'])) {
|
||||
$voicemail_transcription_enabled = $_SESSION['voicemail']['transcription_enabled_default']['boolean'];
|
||||
$voicemail_transcription_enabled = $_SESSION['voicemail']['transcription_enabled_default']['boolean'] ?? 'false';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -168,33 +167,18 @@
|
|||
$array['voicemails'][0]['voicemail_mail_to'] = $voicemail_mail_to;
|
||||
$array['voicemails'][0]['voicemail_sms_to'] = $voicemail_sms_to;
|
||||
$array['voicemails'][0]['voicemail_transcription_enabled'] = $voicemail_transcription_enabled;
|
||||
$array['voicemails'][0]['voicemail_tutorial'] = $voicemail_tutorial;
|
||||
$array['voicemails'][0]['voicemail_tutorial'] = $voicemail_tutorial ?? 'false';
|
||||
if (permission_exists('voicemail_recording_instructions')) {
|
||||
$array['voicemails'][0]['voicemail_recording_instructions'] = $voicemail_recording_instructions;
|
||||
$array['voicemails'][0]['voicemail_recording_instructions'] = $voicemail_recording_instructions ?? 'false';
|
||||
}
|
||||
if (permission_exists('voicemail_recording_options')) {
|
||||
$array['voicemails'][0]['voicemail_recording_options'] = $voicemail_recording_options;
|
||||
$array['voicemails'][0]['voicemail_recording_options'] = $voicemail_recording_options ?? 'false';
|
||||
}
|
||||
if (permission_exists('voicemail_file')) {
|
||||
$array['voicemails'][0]['voicemail_file'] = $voicemail_file;
|
||||
}
|
||||
if (permission_exists('voicemail_local_after_email') && !empty($voicemail_mail_to)) {
|
||||
$array['voicemails'][0]['voicemail_local_after_email'] = $voicemail_local_after_email;
|
||||
}
|
||||
else if (permission_exists('voicemail_local_after_forward')) {
|
||||
$array['voicemails'][0]['voicemail_local_after_email'] = $voicemail_local_after_forward;
|
||||
}
|
||||
else {
|
||||
$array['voicemails'][0]['voicemail_local_after_email'] = 'true';
|
||||
}
|
||||
if (permission_exists('voicemail_local_after_forward')) {
|
||||
$array['voicemails'][0]['voicemail_local_after_forward'] = $voicemail_local_after_forward;
|
||||
}
|
||||
else if (permission_exists('voicemail_local_after_email') && !empty($voicemail_mail_to)) {
|
||||
$array['voicemails'][0]['voicemail_local_after_forward'] = $voicemail_local_after_email;
|
||||
}
|
||||
else {
|
||||
$array['voicemails'][0]['voicemail_local_after_forward'] = 'true';
|
||||
$array['voicemails'][0]['voicemail_local_after_email'] = $voicemail_local_after_email ?? 'false';
|
||||
}
|
||||
$array['voicemails'][0]['voicemail_enabled'] = $voicemail_enabled;
|
||||
$array['voicemails'][0]['voicemail_description'] = $voicemail_description;
|
||||
|
|
@ -362,7 +346,6 @@
|
|||
$voicemail_recording_options = $row["voicemail_recording_options"];
|
||||
$voicemail_file = $row["voicemail_file"];
|
||||
$voicemail_local_after_email = $row["voicemail_local_after_email"];
|
||||
$voicemail_local_after_forward = $row["voicemail_local_after_forward"];
|
||||
$voicemail_enabled = $row["voicemail_enabled"];
|
||||
$voicemail_description = $row["voicemail_description"];
|
||||
}
|
||||
|
|
@ -371,7 +354,6 @@
|
|||
else {
|
||||
$voicemail_file = $_SESSION['voicemail']['voicemail_file']['text'];
|
||||
$voicemail_local_after_email = $_SESSION['voicemail']['keep_local']['boolean'];
|
||||
$voicemail_local_after_forward = $_SESSION['voicemail']['keep_local']['boolean'];
|
||||
}
|
||||
|
||||
//remove the spaces
|
||||
|
|
@ -381,7 +363,6 @@
|
|||
|
||||
//set the defaults
|
||||
if (empty($voicemail_local_after_email)) { $voicemail_local_after_email = 'true'; }
|
||||
if (empty($voicemail_local_after_forward)) { $voicemail_local_after_forward = 'true'; }
|
||||
if (empty($voicemail_enabled)) { $voicemail_enabled = 'true'; }
|
||||
if (empty($voicemail_transcription_enabled)) { $voicemail_transcription_enabled = $_SESSION['voicemail']['transcription_enabled_default']['boolean']; }
|
||||
if (empty($voicemail_tutorial)) { $voicemail_tutorial = 'false'; }
|
||||
|
|
@ -573,8 +554,8 @@
|
|||
echo "</td>\n";
|
||||
echo "<td width='70%' class='vtable' align='left'>\n";
|
||||
echo " <input class='formfld' type='text' name='voicemail_id' maxlength='255' autocomplete='new-password' value='".escape($voicemail_id)."'>\n";
|
||||
echo " <input type='text' style='display: none;' disabled='disabled'>\n"; //help defeat browser auto-fill
|
||||
echo " <input type='hidden' name='voicemail_id_previous' value='".escape($voicemail_id)."'>\n";
|
||||
echo " <input type='text' style='display: none;' disabled='disabled'>\n"; //help defeat browser auto-fill
|
||||
echo "<br />\n";
|
||||
echo $text['description-voicemail_id']."\n";
|
||||
echo "</td>\n";
|
||||
|
|
@ -930,28 +911,6 @@
|
|||
echo " </tr>";
|
||||
}
|
||||
|
||||
if (
|
||||
permission_exists('voicemail_forward') &&
|
||||
permission_exists('voicemail_local_after_forward') &&
|
||||
!empty($voicemail_destinations_assigned) &&
|
||||
is_array($voicemail_destinations_assigned)
|
||||
) {
|
||||
echo "<tr>\n";
|
||||
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
||||
echo " ".$text['label-voicemail_local_after_forward']."\n";
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
echo " <select class='formfld' name='voicemail_local_after_forward'>\n";
|
||||
echo " <option value='true' ".(($voicemail_local_after_forward == "true") ? "selected='selected'" : null).">".$text['label-true']."</option>\n";
|
||||
echo " <option value='false' ".(($voicemail_local_after_forward == "false") ? "selected='selected'" : null).">".$text['label-false']."</option>\n";
|
||||
echo " </select>\n";
|
||||
echo "<br />\n";
|
||||
echo $text['description-voicemail_local_after_forward']."\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
unset($voicemail_destinations_assigned);
|
||||
}
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
||||
echo " ".$text['label-voicemail_enabled']."\n";
|
||||
|
|
@ -1010,4 +969,4 @@
|
|||
//include the footer
|
||||
require_once "resources/footer.php";
|
||||
|
||||
?>
|
||||
?>
|
||||
Loading…
Reference in New Issue