Add. Use params in do_not_disturb.lua (#2115)
This commit is contained in:
committed by
FusionPBX
parent
45c3202d97
commit
904d52407a
@@ -70,17 +70,24 @@
|
|||||||
session:sleep(1000);
|
session:sleep(1000);
|
||||||
|
|
||||||
--connect to the database
|
--connect to the database
|
||||||
require "resources.functions.database_handle";
|
local Database = require "resources.functions.database";
|
||||||
dbh = database_handle('system');
|
dbh = Database.new('system');
|
||||||
|
|
||||||
|
--include json library
|
||||||
|
local json
|
||||||
|
if (debug["sql"]) then
|
||||||
|
json = require "resources.functions.lunajson"
|
||||||
|
end
|
||||||
|
|
||||||
--determine whether to update the dial string
|
--determine whether to update the dial string
|
||||||
sql = "select * from v_extensions ";
|
local sql = "select * 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};
|
||||||
if (debug["sql"]) then
|
if (debug["sql"]) then
|
||||||
freeswitch.consoleLog("notice", "[do_not_disturb] "..sql.."\n");
|
freeswitch.consoleLog("notice", "[do_not_disturb] " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||||
end
|
end
|
||||||
status = dbh:query(sql, function(row)
|
dbh:query(sql, params, function(row)
|
||||||
extension = row.extension;
|
extension = row.extension;
|
||||||
number_alias = row.number_alias or '';
|
number_alias = row.number_alias or '';
|
||||||
accountcode = row.accountcode;
|
accountcode = row.accountcode;
|
||||||
@@ -124,43 +131,46 @@
|
|||||||
--disable follow me
|
--disable follow me
|
||||||
if (follow_me_uuid ~= nil) then
|
if (follow_me_uuid ~= nil) then
|
||||||
if (string.len(follow_me_uuid) > 0 and enabled == "true") then
|
if (string.len(follow_me_uuid) > 0 and enabled == "true") then
|
||||||
sql = "update v_follow_me set ";
|
local sql = "update v_follow_me set ";
|
||||||
sql = sql .. "follow_me_enabled = 'false' ";
|
sql = sql .. "follow_me_enabled = 'false' ";
|
||||||
sql = sql .. "where domain_uuid = '"..domain_uuid.."' ";
|
sql = sql .. "where domain_uuid = :domain_uuid ";
|
||||||
sql = sql .. "and follow_me_uuid = '"..follow_me_uuid.."' ";
|
sql = sql .. "and follow_me_uuid = :follow_me_uuid ";
|
||||||
|
local params = {domain_uuid = domain_uuid, follow_me_uuid = follow_me_uuid};
|
||||||
if (debug["sql"]) then
|
if (debug["sql"]) then
|
||||||
freeswitch.consoleLog("notice", "[do_not_disturb] "..sql.."\n");
|
freeswitch.consoleLog("notice", "[do_not_disturb] "..sql.."; params:" .. json.encode(params) .. "\n");
|
||||||
end
|
end
|
||||||
dbh:query(sql);
|
dbh:query(sql, params);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--update the extension
|
--update the extension
|
||||||
sql = "update v_extensions set ";
|
sql = "update v_extensions set ";
|
||||||
if (enabled == "true") then
|
if (enabled == "true") then
|
||||||
sql = sql .. "dial_string = '"..dial_string.."', ";
|
sql = sql .. "dial_string = :dial_string, ";
|
||||||
sql = sql .. "do_not_disturb = 'true', ";
|
sql = sql .. "do_not_disturb = 'true', ";
|
||||||
else
|
else
|
||||||
sql = sql .. "dial_string = null, ";
|
sql = sql .. "dial_string = null, ";
|
||||||
sql = sql .. "do_not_disturb = 'false', ";
|
sql = sql .. "do_not_disturb = 'false', ";
|
||||||
end
|
end
|
||||||
sql = sql .. "forward_all_enabled = 'false' ";
|
sql = sql .. "forward_all_enabled = 'false' ";
|
||||||
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 = {dial_string = dial_string, domain_uuid = domain_uuid, extension_uuid = extension_uuid};
|
||||||
if (debug["sql"]) then
|
if (debug["sql"]) then
|
||||||
freeswitch.consoleLog("notice", "[do_not_disturb] "..sql.."\n");
|
freeswitch.consoleLog("notice", "[do_not_disturb] "..sql.."; params:" .. json.encode(params) .. "\n");
|
||||||
end
|
end
|
||||||
dbh:query(sql);
|
dbh:query(sql, params);
|
||||||
|
|
||||||
--determine whether to update the dial string
|
--determine whether to update the dial string
|
||||||
sql = "select * from v_extension_users as e, v_users as u ";
|
sql = "select * from v_extension_users as e, v_users as u ";
|
||||||
sql = sql .. "where e.extension_uuid = '"..extension_uuid.."' ";
|
sql = sql .. "where e.extension_uuid = :extension_uuid ";
|
||||||
sql = sql .. "and e.user_uuid = u.user_uuid ";
|
sql = sql .. "and e.user_uuid = u.user_uuid ";
|
||||||
sql = sql .. "and e.domain_uuid = '"..domain_uuid.."' ";
|
sql = sql .. "and e.domain_uuid = :domain_uuid ";
|
||||||
|
local params = {domain_uuid = domain_uuid, extension_uuid = extension_uuid};
|
||||||
if (debug["sql"]) then
|
if (debug["sql"]) then
|
||||||
freeswitch.consoleLog("notice", "[do_not_disturb] "..sql.."\n");
|
freeswitch.consoleLog("notice", "[do_not_disturb] "..sql.."; params:" .. json.encode(params) .. "\n");
|
||||||
end
|
end
|
||||||
status = dbh:query(sql, function(row)
|
dbh:query(sql, params, function(row)
|
||||||
--update the call center status
|
--update the call center status
|
||||||
if (enabled == "true") then
|
if (enabled == "true") then
|
||||||
user_status = "Logged Out";
|
user_status = "Logged Out";
|
||||||
@@ -173,12 +183,13 @@
|
|||||||
else
|
else
|
||||||
user_status = "Available";
|
user_status = "Available";
|
||||||
end
|
end
|
||||||
sql = "update v_users set ";
|
local sql = "update v_users set ";
|
||||||
sql = sql .. "user_status = '"..user_status.."' ";
|
sql = sql .. "user_status = :user_status ";
|
||||||
sql = sql .. "where domain_uuid = '"..domain_uuid.."' ";
|
sql = sql .. "where domain_uuid = :domain_uuid ";
|
||||||
sql = sql .. "and user_uuid = '"..row.user_uuid.."' ";
|
sql = sql .. "and user_uuid = :user_uuid ";
|
||||||
|
local params = {user_status = user_status, domain_uuid = domain_uuid, user_uuid = row.user_uuid};
|
||||||
if (debug["sql"]) then
|
if (debug["sql"]) then
|
||||||
freeswitch.consoleLog("notice", "[do_not_disturb] "..sql.."\n");
|
freeswitch.consoleLog("notice", "[do_not_disturb] "..sql.."; params:" .. json.encode(params) .. "\n");
|
||||||
end
|
end
|
||||||
dbh:query(sql);
|
dbh:query(sql);
|
||||||
end);
|
end);
|
||||||
|
|||||||
Reference in New Issue
Block a user