From 38c43217ceba3ec4e3623cc79739ba9d3a6c9de9 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Thu, 12 May 2016 23:06:45 -0600 Subject: [PATCH 1/2] Update intercept.lua Account for core.db in intercept.lua --- resources/install/scripts/intercept.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/resources/install/scripts/intercept.lua b/resources/install/scripts/intercept.lua index 0322a731de..689dc79b9b 100644 --- a/resources/install/scripts/intercept.lua +++ b/resources/install/scripts/intercept.lua @@ -247,6 +247,13 @@ --connect to FS database --local dbh = Database.new('switch') + if (file_exists(database_dir.."/core.db")) then + --dbh = freeswitch.Dbh("core:core"); -- when using sqlite + dbh = freeswitch.Dbh("sqlite://"..database_dir.."/core.db"); + else + dofile(scripts_dir.."/resources/functions/database_handle.lua"); + dbh = database_handle('switch'); + end --check the database to get the uuid of a ringing call call_hostname = ""; @@ -280,9 +287,6 @@ log.notice("sql "..sql); end local is_child - - require "resources.functions.database_handle"; - local dbh = database_handle('switch'); dbh:query(sql, function(row) -- for key, val in pairs(row) do -- log.notice("row "..key.." "..val); From 619912324c630c7ec8804ec55ec69c53338d796b Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Fri, 13 May 2016 17:03:48 +0300 Subject: [PATCH 2/2] Fix. Use correct database for Call Center while FS load. (#1597) Problem that `mod_commands` may load after than `mod_callcenter` and there no function `global_getvar` So current code just create database with name `INVALID COMMAND!.db`. --- .../scripts/configuration/callcenter.conf.lua | 19 +++++++++++-------- resources/switch.php | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/configuration/callcenter.conf.lua b/resources/install/scripts/app/xml_handler/resources/scripts/configuration/callcenter.conf.lua index a7169c70ab..33cc0dfc03 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/configuration/callcenter.conf.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/configuration/callcenter.conf.lua @@ -46,8 +46,13 @@ assert(dbh:connected()); --get the variables - dsn = trim(api:execute("global_getvar", "dsn")); - dsn_callcenter = trim(api:execute("global_getvar", "dsn_callcenter")); + dsn = trim(api:execute("global_getvar", "dsn")) or ''; + dsn_callcenter = trim(api:execute("global_getvar", "dsn_callcenter")) or ''; + + if dsn:find("INVALID COMMAND", nil, true) then + freeswitch.consoleLog('err', '[xml_handler] Can not correctly load mod_callcenter becase mod_commands not loaded\n') + dsn, dsn_callcenter = '', '' + end --start the xml array local xml = {} @@ -56,14 +61,12 @@ table.insert(xml, [[
]]); table.insert(xml, [[ ]]); table.insert(xml, [[ ]]); - if (dsn_callcenter) then + if #dsn_callcenter > 0 then table.insert(xml, [[ ]]); - else - if (string.len(dsn) > 0) then - table.insert(xml, [[ ]]); - end + elseif #dsn > 0 then + table.insert(xml, [[ ]]); end - --table.insert(xml, [[ ]]); + -- table.insert(xml, [[ ]]); table.insert(xml, [[ ]]); --write the queues diff --git a/resources/switch.php b/resources/switch.php index c4c1ddcfc3..4881b81f21 100644 --- a/resources/switch.php +++ b/resources/switch.php @@ -391,7 +391,7 @@ function save_module_xml() { $xml .= "\n"; $xml .= " \n"; - $sql = "select * from v_modules order by module_category = 'Languages' OR module_category = 'Loggers' DESC, module_category "; + $sql = "select * from v_modules order by module_name='mod_commands' OR module_category = 'Languages' OR module_category = 'Loggers' DESC, module_category "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $prev_module_cat = '';