mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
Use SQL to cast to boolean
This commit is contained in:
@@ -543,7 +543,26 @@
|
|||||||
pin_number = get_pin_number(domain_uuid, conference_center_greeting);
|
pin_number = get_pin_number(domain_uuid, conference_center_greeting);
|
||||||
end
|
end
|
||||||
if (pin_number ~= nil) then
|
if (pin_number ~= nil) then
|
||||||
local sql = [[SELECT * FROM v_conference_rooms
|
local sql = [[SELECT
|
||||||
|
conference_room_uuid,
|
||||||
|
conference_room_name,
|
||||||
|
cast(record as text),
|
||||||
|
profile,
|
||||||
|
max_members,
|
||||||
|
cast(wait_mod as text),
|
||||||
|
cast(moderator_endconf as text),
|
||||||
|
moderator_pin,
|
||||||
|
participant_pin,
|
||||||
|
cast(announce_name as text),
|
||||||
|
cast(announce_count as text),
|
||||||
|
cast(announce_recording as text),
|
||||||
|
cast(mute as text),
|
||||||
|
cast(sounds as text),
|
||||||
|
created,
|
||||||
|
created_by,
|
||||||
|
cast(enabled as text),
|
||||||
|
description
|
||||||
|
FROM v_conference_rooms
|
||||||
WHERE domain_uuid = :domain_uuid
|
WHERE domain_uuid = :domain_uuid
|
||||||
AND conference_center_uuid = :conference_center_uuid
|
AND conference_center_uuid = :conference_center_uuid
|
||||||
AND (moderator_pin = :pin_number or participant_pin = :pin_number)
|
AND (moderator_pin = :pin_number or participant_pin = :pin_number)
|
||||||
@@ -560,7 +579,6 @@
|
|||||||
dbh:query(sql, params, function(row)
|
dbh:query(sql, params, function(row)
|
||||||
conference_room_uuid = string.lower(row["conference_room_uuid"]);
|
conference_room_uuid = string.lower(row["conference_room_uuid"]);
|
||||||
conference_room_name = string.lower(row["conference_room_name"]);
|
conference_room_name = string.lower(row["conference_room_name"]);
|
||||||
--meeting_uuid = string.lower(row["meeting_uuid"]);
|
|
||||||
record = row["record"];
|
record = row["record"];
|
||||||
profile = string.lower(row["profile"]);
|
profile = string.lower(row["profile"]);
|
||||||
max_members = row["max_members"];
|
max_members = row["max_members"];
|
||||||
@@ -582,18 +600,6 @@
|
|||||||
freeswitch.consoleLog("INFO","conference_room_uuid: " .. conference_room_uuid .. "\n");
|
freeswitch.consoleLog("INFO","conference_room_uuid: " .. conference_room_uuid .. "\n");
|
||||||
end
|
end
|
||||||
|
|
||||||
--set the boolean settings to a true or false string
|
|
||||||
record = record and "true" or "false";
|
|
||||||
wait_mod = wait_mod and "true" or "false";
|
|
||||||
sounds = sounds and "true" or "false";
|
|
||||||
mute = mute and "true" or "false";
|
|
||||||
enabled = enabled and "true" or "false";
|
|
||||||
announce_name = announce_name and "true" or "false";
|
|
||||||
announce_count = announce_count and "true" or "false";
|
|
||||||
announce_recording = announce_recording and "true" or "false";
|
|
||||||
moderator_endconf = moderator_endconf and "true" or "false";
|
|
||||||
|
|
||||||
|
|
||||||
--set the member type
|
--set the member type
|
||||||
if (pin_number == moderator_pin) then
|
if (pin_number == moderator_pin) then
|
||||||
member_type = "moderator";
|
member_type = "moderator";
|
||||||
|
|||||||
@@ -16,15 +16,31 @@ function feature_event_notify.get_db_values(user, domain_name)
|
|||||||
end);
|
end);
|
||||||
|
|
||||||
--get extension information
|
--get extension information
|
||||||
local sql = "select * from v_extensions ";
|
local sql = "select ";
|
||||||
|
sql = sql .. " extension_uuid, ";
|
||||||
|
sql = sql .. " extension, ";
|
||||||
|
sql = sql .. " number_alias, ";
|
||||||
|
sql = sql .. " accountcode, ";
|
||||||
|
sql = sql .. " follow_me_uuid, ";
|
||||||
|
sql = sql .. " cast(do_not_disturb as text), ";
|
||||||
|
sql = sql .. " cast(forward_all_enabled as text), ";
|
||||||
|
sql = sql .. " forward_all_destination, ";
|
||||||
|
sql = sql .. " cast(forward_busy_enabled as text), ";
|
||||||
|
sql = sql .. " forward_busy_destination, ";
|
||||||
|
sql = sql .. " cast(forward_no_answer_enabled as text), ";
|
||||||
|
sql = sql .. " forward_no_answer_destination, ";
|
||||||
|
sql = sql .. " cast(forward_user_not_registered_enabled as text), ";
|
||||||
|
sql = sql .. " forward_user_not_registered_destination, ";
|
||||||
|
sql = sql .. " toll_allow, ";
|
||||||
|
sql = sql .. " call_timeout ";
|
||||||
|
sql = sql .. "from v_extensions ";
|
||||||
sql = sql .. "where domain_uuid = :domain_uuid ";
|
sql = sql .. "where domain_uuid = :domain_uuid ";
|
||||||
sql = sql .. "and (extension = :extension or number_alias = :extension) ";
|
sql = sql .. "and (extension = :extension or number_alias = :extension) ";
|
||||||
sql = sql .. "and enabled true ";
|
sql = sql .. "and enabled true ";
|
||||||
local params = {domain_uuid = domain_uuid, extension = user};
|
local params = {domain_uuid = domain_uuid, extension = user};
|
||||||
-- if (debug["sql"]) then
|
-- if (debug["sql"]) then
|
||||||
-- freeswitch.consoleLog("notice", "[feature_event] " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
-- freeswitch.consoleLog("notice", "[feature_event] " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||||
-- end
|
-- end
|
||||||
|
|
||||||
dbh:query(sql, params, function(row)
|
dbh:query(sql, params, function(row)
|
||||||
extension_uuid = row.extension_uuid;
|
extension_uuid = row.extension_uuid;
|
||||||
extension = row.extension;
|
extension = row.extension;
|
||||||
@@ -47,12 +63,6 @@ function feature_event_notify.get_db_values(user, domain_name)
|
|||||||
end);
|
end);
|
||||||
|
|
||||||
--set some defaults if values in database are NULL
|
--set some defaults if values in database are NULL
|
||||||
forward_all_enabled = forward_all_enabled and "true" or "false";
|
|
||||||
forward_busy_enabled = forward_busy_enabled and "true" or "false";
|
|
||||||
forward_no_answer_enabled = forward_no_answer_enabled and "true" or "false";
|
|
||||||
forward_user_not_registered_enabled = forward_user_not_registered_enabled and "true" or "false";
|
|
||||||
follow_me_enabled = follow_me_enabled and "true" or "false";
|
|
||||||
do_not_disturb = do_not_disturb and "true" or "false";
|
|
||||||
if (call_timeout == "") then call_timeout = "30"; end
|
if (call_timeout == "") then call_timeout = "30"; end
|
||||||
|
|
||||||
return do_not_disturb, forward_all_enabled, forward_all_destination, forward_busy_enabled, forward_busy_destination, forward_no_answer_enabled, forward_no_answer_destination, call_timeout
|
return do_not_disturb, forward_all_enabled, forward_all_destination, forward_busy_enabled, forward_busy_destination, forward_no_answer_enabled, forward_no_answer_destination, call_timeout
|
||||||
|
|||||||
@@ -288,9 +288,20 @@
|
|||||||
if (voicemail_id ~= nil) then
|
if (voicemail_id ~= nil) then
|
||||||
if (session ~= nil and session:ready()) then
|
if (session ~= nil and session:ready()) then
|
||||||
--get the information from the database
|
--get the information from the database
|
||||||
local sql = [[SELECT * FROM v_voicemails
|
local sql = [[SELECT
|
||||||
WHERE domain_uuid = :domain_uuid
|
voicemail_uuid,
|
||||||
AND voicemail_id = :voicemail_id
|
voicemail_password,
|
||||||
|
greeting_id,
|
||||||
|
voicemail_alternate_greet_id,
|
||||||
|
voicemail_mail_to,
|
||||||
|
cast(voicemail_attach_file as text),
|
||||||
|
cast(voicemail_local_after_email as text),
|
||||||
|
cast(voicemail_local_after_forward as text),
|
||||||
|
cast(voicemail_transcription_enabled as text),
|
||||||
|
cast(voicemail_tutorial as text)
|
||||||
|
FROM v_voicemails
|
||||||
|
WHERE domain_uuid = :domain_uuid
|
||||||
|
AND voicemail_id = :voicemail_id
|
||||||
AND voicemail_enabled = true ]];
|
AND voicemail_enabled = true ]];
|
||||||
local params = {domain_uuid = domain_uuid, voicemail_id = voicemail_id};
|
local params = {domain_uuid = domain_uuid, voicemail_id = voicemail_id};
|
||||||
if (debug["sql"]) then
|
if (debug["sql"]) then
|
||||||
@@ -309,12 +320,6 @@
|
|||||||
voicemail_tutorial = row["voicemail_tutorial"];
|
voicemail_tutorial = row["voicemail_tutorial"];
|
||||||
end);
|
end);
|
||||||
|
|
||||||
--set boolean values as a string
|
|
||||||
voicemail_attach_file = voicemail_attach_file and "true" or "false";
|
|
||||||
voicemail_local_after_email = voicemail_local_after_email and "true" or "false";
|
|
||||||
voicemail_local_after_forward = voicemail_local_after_forward and "true" or "false";
|
|
||||||
voicemail_tutorial = voicemail_tutorial and "true" or "false";
|
|
||||||
|
|
||||||
--valid voicemail
|
--valid voicemail
|
||||||
if (voicemail_uuid ~= nil and string.len(voicemail_uuid) > 0) then
|
if (voicemail_uuid ~= nil and string.len(voicemail_uuid) > 0) then
|
||||||
--answer the session
|
--answer the session
|
||||||
@@ -400,9 +405,16 @@
|
|||||||
|
|
||||||
--get voicemail message details
|
--get voicemail message details
|
||||||
if (voicemail_id) then
|
if (voicemail_id) then
|
||||||
local sql = [[SELECT * FROM v_voicemails
|
local sql = "SELECT ";
|
||||||
WHERE domain_uuid = :domain_uuid
|
sql = sql .. " cast(voicemail_local_after_email as text), ";
|
||||||
AND voicemail_id = :voicemail_id]]
|
sql = sql .. " cast(voicemail_local_after_forward as text), ";
|
||||||
|
sql = sql .. " cast(voicemail_attach_file as text), ";
|
||||||
|
sql = sql .. " voicemail_password, ";
|
||||||
|
sql = sql .. " voicemail_mail_to, ";
|
||||||
|
sql = sql .. " cast(voicemail_enabled as text) ";
|
||||||
|
sql = sql .. "FROM v_voicemails ";
|
||||||
|
sql = sql .. "WHERE domain_uuid = :domain_uuid ";
|
||||||
|
sql = sql .. "AND voicemail_id = :voicemail_id ";
|
||||||
local params = {domain_uuid = domain_uuid, voicemail_id = voicemail_id};
|
local params = {domain_uuid = domain_uuid, voicemail_id = voicemail_id};
|
||||||
if (debug["sql"]) then
|
if (debug["sql"]) then
|
||||||
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||||
@@ -412,11 +424,6 @@
|
|||||||
voicemail_local_after_forward = row["voicemail_local_after_forward"];
|
voicemail_local_after_forward = row["voicemail_local_after_forward"];
|
||||||
end);
|
end);
|
||||||
|
|
||||||
--set the boolean values as a string
|
|
||||||
voicemail_local_after_email = voicemail_local_after_email and "true" or "false";
|
|
||||||
voicemail_local_after_forward = voicemail_local_after_forward and "true" or "false";
|
|
||||||
voicemail_local_after_forward = voicemail_local_after_forward and "true" or "false";
|
|
||||||
|
|
||||||
--get the message count and send the mwi event
|
--get the message count and send the mwi event
|
||||||
if (voicemail_local_after_email == 'true' or voicemail_local_after_forward == 'true') then
|
if (voicemail_local_after_email == 'true' or voicemail_local_after_forward == 'true') then
|
||||||
message_waiting(voicemail_id, domain_uuid);
|
message_waiting(voicemail_id, domain_uuid);
|
||||||
|
|||||||
@@ -38,7 +38,14 @@ function send_email(id, uuid)
|
|||||||
local email_queue_enabled = "true";
|
local email_queue_enabled = "true";
|
||||||
|
|
||||||
--get voicemail message details
|
--get voicemail message details
|
||||||
local sql = [[SELECT * FROM v_voicemails
|
local sql = [[SELECT
|
||||||
|
voicemail_uuid,
|
||||||
|
voicemail_mail_to,
|
||||||
|
cast(voicemail_transcription_enabled as text),
|
||||||
|
voicemail_file,
|
||||||
|
cast(voicemail_local_after_email as text),
|
||||||
|
voicemail_description
|
||||||
|
FROM v_voicemails
|
||||||
WHERE domain_uuid = :domain_uuid
|
WHERE domain_uuid = :domain_uuid
|
||||||
AND voicemail_id = :voicemail_id]]
|
AND voicemail_id = :voicemail_id]]
|
||||||
local params = {domain_uuid = domain_uuid, voicemail_id = id};
|
local params = {domain_uuid = domain_uuid, voicemail_id = id};
|
||||||
@@ -61,9 +68,6 @@ function send_email(id, uuid)
|
|||||||
voicemail_file = "listen";
|
voicemail_file = "listen";
|
||||||
end
|
end
|
||||||
|
|
||||||
--set the boolean values as a string
|
|
||||||
voicemail_local_after_email = voicemail_local_after_email and "true" or "false";
|
|
||||||
|
|
||||||
--require the email address to send the email
|
--require the email address to send the email
|
||||||
if (string.len(voicemail_mail_to) > 2) then
|
if (string.len(voicemail_mail_to) > 2) then
|
||||||
--include languages file
|
--include languages file
|
||||||
@@ -204,9 +208,6 @@ function send_email(id, uuid)
|
|||||||
--get the link_address
|
--get the link_address
|
||||||
link_address = http_protocol.."://"..domain_name..project_path;
|
link_address = http_protocol.."://"..domain_name..project_path;
|
||||||
|
|
||||||
--set the boolean values as a string
|
|
||||||
voicemail_local_after_email = voicemail_local_after_email and "true" or "false";
|
|
||||||
|
|
||||||
--set proper delete status
|
--set proper delete status
|
||||||
local local_after_email = '';
|
local local_after_email = '';
|
||||||
if (voicemail_local_after_email == "false") then
|
if (voicemail_local_after_email == "false") then
|
||||||
|
|||||||
@@ -123,7 +123,17 @@
|
|||||||
--determine whether to update the dial string
|
--determine whether to update the dial string
|
||||||
if not session:ready() then return end
|
if not session:ready() then return end
|
||||||
|
|
||||||
local sql = "select * from v_extensions ";
|
local sql = "select ";
|
||||||
|
sql = sql .. " extension_uuid, ";
|
||||||
|
sql = sql .. " extension, ";
|
||||||
|
sql = sql .. " number_alias, ";
|
||||||
|
sql = sql .. " accountcode, ";
|
||||||
|
sql = sql .. " cast(forward_all_enabled as text), ";
|
||||||
|
sql = sql .. " forward_all_destination, ";
|
||||||
|
sql = sql .. " toll_allow, ";
|
||||||
|
sql = sql .. " outbound_caller_id_name, ";
|
||||||
|
sql = sql .. " outbound_caller_id_number ";
|
||||||
|
sql = sql .. "from v_extensions ";
|
||||||
sql = sql .. "where domain_uuid = :domain_uuid ";
|
sql = sql .. "where domain_uuid = :domain_uuid ";
|
||||||
local params = {domain_uuid = domain_uuid};
|
local params = {domain_uuid = domain_uuid};
|
||||||
if (extension_uuid ~= nil) then
|
if (extension_uuid ~= nil) then
|
||||||
@@ -143,7 +153,7 @@
|
|||||||
extension = row.extension;
|
extension = row.extension;
|
||||||
local number_alias = row.number_alias or '';
|
local number_alias = row.number_alias or '';
|
||||||
local accountcode = row.accountcode;
|
local accountcode = row.accountcode;
|
||||||
local forward_all_enabled = row.forward_all_enabled and "true" or "false";
|
local forward_all_enabled = row.forward_all_enabled;
|
||||||
local last_forward_all_destination = row.forward_all_destination;
|
local last_forward_all_destination = row.forward_all_destination;
|
||||||
local toll_allow = row.toll_allow or '';
|
local toll_allow = row.toll_allow or '';
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,19 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
--determine whether to update the dial string
|
--determine whether to update the dial string
|
||||||
local sql = "select * from v_extensions ";
|
local sql = "select ";
|
||||||
|
sql = sql .. " extension_uuid, ";
|
||||||
|
sql = sql .. " extension, ";
|
||||||
|
sql = sql .. " number_alias, ";
|
||||||
|
sql = sql .. " accountcode, ";
|
||||||
|
sql = sql .. " cast(do_not_disturb as text), ";
|
||||||
|
sql = sql .. " cast(forward_all_enabled as text), ";
|
||||||
|
sql = sql .. " forward_all_destination, ";
|
||||||
|
sql = sql .. " toll_allow, ";
|
||||||
|
sql = sql .. " context, ";
|
||||||
|
sql = sql .. " outbound_caller_id_name, ";
|
||||||
|
sql = sql .. " outbound_caller_id_number ";
|
||||||
|
sql = sql .. "from v_extensions ";
|
||||||
sql = sql .. "where domain_uuid = :domain_uuid ";
|
sql = sql .. "where domain_uuid = :domain_uuid ";
|
||||||
sql = sql .. "and extension_uuid = :extension_uuid ";
|
sql = sql .. "and extension_uuid = :extension_uuid ";
|
||||||
local params = {domain_uuid = domain_uuid, extension_uuid = extension_uuid};
|
local params = {domain_uuid = domain_uuid, extension_uuid = extension_uuid};
|
||||||
@@ -106,9 +118,6 @@
|
|||||||
context = row.user_context;
|
context = row.user_context;
|
||||||
end);
|
end);
|
||||||
|
|
||||||
forward_all_enabled = forward_all_enabled and "true" or "false";
|
|
||||||
do_not_disturb = do_not_disturb and "true" or "false";
|
|
||||||
|
|
||||||
--send information to the console
|
--send information to the console
|
||||||
if (session:ready()) then
|
if (session:ready()) then
|
||||||
freeswitch.consoleLog("NOTICE", "[do_not_disturb] do_not_disturb "..do_not_disturb.."\n");
|
freeswitch.consoleLog("NOTICE", "[do_not_disturb] do_not_disturb "..do_not_disturb.."\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user