diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/configuration/ivr.conf.lua b/resources/install/scripts/app/xml_handler/resources/scripts/configuration/ivr.conf.lua index 4f7c500011..726ff1a7d2 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/configuration/ivr.conf.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/configuration/ivr.conf.lua @@ -24,6 +24,9 @@ -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. +--get the ivr name + ivr_menu_uuid = params:getHeader("Menu-Name"); + --get the cache hostname = trim(api:execute("switchname", "")); if (trim(api:execute("module_exists", "mod_memcache")) == "true") then @@ -33,8 +36,7 @@ end --set the cache - if (XML_STRING == "-ERR NOT FOUND") or (XML_STRING == "-ERR CONNECTION FAILURE") then - + if (XML_STRING == "-ERR NOT FOUND" or XML_STRING == "-ERR CONNECTION FAILURE") then --connect to the database require "resources.functions.database_handle"; dbh = database_handle('system'); @@ -49,6 +51,7 @@ if (debug["sql"]) then freeswitch.consoleLog("notice", "[ivr_menu] SQL: " .. sql .. "\n"); end + status = dbh:query(sql, function(row) domain_uuid = row["domain_uuid"]; ivr_menu_name = row["ivr_menu_name"]; @@ -69,7 +72,6 @@ ivr_menu_max_failures = row["ivr_menu_max_failures"]; ivr_menu_max_timeouts = row["ivr_menu_max_timeouts"]; ivr_menu_digit_len = row["ivr_menu_digit_len"]; - ivr_menu_direct_dial = row["ivr_menu_direct_dial"]; ivr_menu_ringback = row["ivr_menu_ringback"]; ivr_menu_cid_prefix = row["ivr_menu_cid_prefix"]; @@ -77,7 +79,6 @@ end); --recording path - --start the xml array local xml = {} @@ -85,61 +86,55 @@ table.insert(xml, [[]]); table.insert(xml, [[
]]); table.insert(xml, [[ ]]); - table.insert(xml, [[ ]]); - dbh:query(sql, function(row) + table.insert(xml, [[ ]]); - --build the xml - table.insert(xml, [[ ]]); + --get the ivr menu options + sql = [[SELECT * FROM v_ivr_menu_options WHERE ivr_menu_uuid = ']] .. ivr_menu_uuid ..[[' ORDER BY ivr_menu_option_order asc ]]; + if (debug["sql"]) then + freeswitch.consoleLog("notice", "[ivr_menu] SQL: " .. sql .. "\n"); + end + status = dbh:query(sql, function(r) + ivr_menu_option_digits = r.ivr_menu_option_digits + ivr_menu_option_action = r.ivr_menu_option_action + ivr_menu_option_param = r.ivr_menu_option_param + ivr_menu_option_description = row.ivr_menu_option_description + table.insert(xml, [[]]); + end); - --get the ivr menu options - sql = [[SELECT * FROM v_ivr_menu_options WHERE ivr_menu_uuid = ']] .. ivr_menu_uuid ..[[' ORDER BY ivr_menu_option_order asc ]]; - if (debug["sql"]) then - freeswitch.consoleLog("notice", "[ivr_menu] SQL: " .. sql .. "\n"); - end - status = dbh:query(sql, function(r) - dbh:query(sql, function(r) - ivr_menu_option_digits = r.ivr_menu_option_digits - ivr_menu_option_action = r.ivr_menu_option_action - ivr_menu_option_param = r.ivr_menu_option_param - ivr_menu_option_description = row.ivr_menu_option_description - table.insert(xml, [[]]); - end) - - --direct dial - if (ivr_menu_direct_dial == "true") then - table.insert(xml, [[\n"); - end - end) - table.insert(xml, [[ ]]); + --direct dial + if (ivr_menu_direct_dial == "true") then + table.insert(xml, [[\n]]); + end --close the extension tag if it was left open - table.insert(xml, [[ ]]); - table.insert(xml, [[
]]); - table.insert(xml, [[
]]); - XML_STRING = table.concat(xml, "\n"); - if (debug["xml_string"]) then - freeswitch.consoleLog("notice", "[xml_handler] XML_STRING: " .. XML_STRING .. "\n"); - end + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[]]); + XML_STRING = table.concat(xml, "\n"); + if (debug["xml_string"]) then + freeswitch.consoleLog("notice", "[xml_handler] XML_STRING: " .. XML_STRING .. "\n"); + end --close the database connection - dbh:release(); - --freeswitch.consoleLog("notice", "[xml_handler]"..api:execute("eval ${dsn}")); + dbh:release(); + --freeswitch.consoleLog("notice", "[xml_handler]"..api:execute("eval ${dsn}")); --set the cache result = trim(api:execute("memcache", "set configuration:ivr.conf:" .. hostname .." '"..XML_STRING:gsub("'", "'").."' ".."expire['ivr.conf']")); @@ -155,6 +150,7 @@ if (debug["cache"]) then freeswitch.consoleLog("notice", "[xml_handler] configuration:ivr.conf:" .. hostname .." source: database\n"); end + else --replace the ' back to a single quote XML_STRING = XML_STRING:gsub("'", "'");