Add. Use parameters in group_call.lua (#2093)

This commit is contained in:
Alexey Melnichuk
2016-11-18 10:22:33 -07:00
committed by FusionPBX
parent 1dc5a22f9a
commit 3440b8a15a
@@ -34,8 +34,14 @@
--set the cache --set the cache
if (XML_STRING == "-ERR NOT FOUND") then if (XML_STRING == "-ERR NOT FOUND") then
--connect to the database --connect to the database
require "resources.functions.database_handle"; local Database = require "resources.functions.database";
dbh = database_handle('system'); local dbh = Database.new('system');
--include json library
local json
if (debug["sql"]) then
json = require "resources.functions.lunajson"
end
--exits the script if we didn't connect properly --exits the script if we didn't connect properly
assert(dbh:connected()); assert(dbh:connected());
@@ -44,17 +50,23 @@
if (domain_uuid == nil) then if (domain_uuid == nil) then
--get the domain_uuid --get the domain_uuid
if (domain_name ~= nil) then if (domain_name ~= nil) then
sql = "SELECT domain_uuid FROM v_domains "; local sql = "SELECT domain_uuid FROM v_domains ";
sql = sql .. "WHERE domain_name = '" .. domain_name .."' "; sql = sql .. "WHERE domain_name = :domain_name";
local params = {domain_name = domain_name};
if (debug["sql"]) then if (debug["sql"]) then
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n"); freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
end end
status = dbh:query(sql, function(rows) dbh:query(sql, params, function(rows)
domain_uuid = rows["domain_uuid"]; domain_uuid = rows["domain_uuid"];
end); end);
end end
end end
if not domain_uuid then
freeswitch.consoleLog("warning", "[xml_handler] Can not find domain name: " .. tostring(domain_name) .. "\n");
return
end
--build the call group array --build the call group array
sql = [[ sql = [[
select * from v_extensions select * from v_extensions
@@ -65,7 +77,7 @@
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n"); freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n");
end end
call_group_array = {}; call_group_array = {};
status = dbh:query(sql, function(row) dbh:query(sql, function(row)
call_group = row['call_group']; call_group = row['call_group'];
--call_group = str_replace(";", ",", call_group); --call_group = str_replace(";", ",", call_group);
tmp_array = explode(",", call_group); tmp_array = explode(",", call_group);