diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/directory/action/domains.lua b/resources/install/scripts/app/xml_handler/resources/scripts/directory/action/domains.lua index 10df751dcb..dda1b9617f 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/directory/action/domains.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/directory/action/domains.lua @@ -31,18 +31,212 @@ --exits the script if we didn't connect properly assert(dbh:connected()); ---process when the sip profile is rescanned, sofia is reloaded, or sip redirect +--set the variables as a string + number_alias = ""; + number_alias_string = ""; + +--build the xml local xml = {} table.insert(xml, [[]]); table.insert(xml, [[]]); table.insert(xml, [[
]]); - sql = "SELECT * FROM v_domains "; + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + +--process when the sip profile is rescanned, sofia is reloaded, or sip redirect + sql = "SELECT * FROM v_domains as d, v_extensions as e "; + if (domain_name ~= nil) then + sql = sql .. "where d.domain_name = '"..domain_name.."' "; + sql = sql .. "and d.domain_uuid = e.domain_uuid "; + end + --freeswitch.consoleLog("notice", "[xml_handler-directory.lua] sql "..sql.."\n"); dbh:query(sql, function(row) - table.insert(xml, [[ ]]); + + --variables + cidr = ""; + if (string.len(row.cidr) > 0) then + cidr = [[ cidr="]] .. row.cidr .. [["]]; + end + if (string.len(row.number_alias) > 0) then + number_alias = row.number_alias; + number_alias_string = [[ number-alias="]] .. row.number_alias .. [["]]; + end + row.sip_from_user = row.extension; + row.sip_from_number = (#number_alias > 0) and number_alias or row.extension; + + --continue building the xml + if (number_alias) then + if (cidr) then + table.insert(xml, [[ ]]); + else + table.insert(xml, [[ ]]); + end + else + if (cidr) then + table.insert(xml, [[ ]]); + else + table.insert(xml, [[ ]]); + end + end + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + --table.insert(xml, [[ ]]); + --if (string.len(vm_mailto) > 0) then + -- table.insert(xml, [[ ]]); + -- table.insert(xml, [[ ]]); + -- table.insert(xml, [[ ]]); + -- table.insert(xml, [[ ]]); + -- table.insert(xml, [[ ]]); + --end + if (string.len(row.mwi_account) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.auth_acl) > 0) then + table.insert(xml, [[ ]]); + end + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + if (string.len(row.call_group) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.call_screen_enabled) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.user_record) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.hold_music) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.toll_allow) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.accountcode) > 0) then + table.insert(xml, [[ ]]); + end + table.insert(xml, [[ ]]); + if (string.len(row.effective_caller_id_name) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.effective_caller_id_number) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.outbound_caller_id_name) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.outbound_caller_id_number) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.emergency_caller_id_name) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.emergency_caller_id_number) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.missed_call_app) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.missed_call_data) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.directory_full_name) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.directory_visible) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.directory_exten_visible) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.limit_max) > 0) then + table.insert(xml, [[ ]]); + else + table.insert(xml, [[ ]]); + end + if (string.len(row.limit_destination) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.sip_force_contact) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.sip_force_expires) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.nibble_account) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.absolute_codec_string) > 0) then + table.insert(xml, [[ ]]); + end + if (row.sip_bypass_media == "bypass-media") then + table.insert(xml, [[ ]]); + end + + if (row.sip_bypass_media == "bypass-media-after-bridge") then + table.insert(xml, [[ ]]); + end + if (row.sip_bypass_media == "proxy-media") then + table.insert(xml, [[ ]]); + end + if (string.len(row.forward_all_enabled) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.forward_all_destination) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.forward_busy_enabled) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.forward_busy_destination) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.forward_no_answer_enabled) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.forward_no_answer_destination) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.forward_user_not_registered_enabled) > 0) then + table.insert(xml, [[ ]]); + end + if (string.len(row.forward_user_not_registered_destination) > 0) then + table.insert(xml, [[ ]]); + end + + if (string.len(row.do_not_disturb) > 0) then + table.insert(xml, [[ ]]); + end + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); end); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); table.insert(xml, [[
]]); table.insert(xml, [[
]]); XML_STRING = table.concat(xml, "\n"); + --freeswitch.consoleLog("notice", "[xml_handler-directory.lua] XML_STRING "..XML_STRING.."\n"); --close the database connection dbh:release(); diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/directory/directory.lua b/resources/install/scripts/app/xml_handler/resources/scripts/directory/directory.lua index 88ec1808ca..e2a3e5e1db 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/directory/directory.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/directory/directory.lua @@ -57,6 +57,8 @@ dofile(scripts_dir.."/app/xml_handler/resources/scripts/directory/action/reverse-auth-lookup.lua"); elseif (params:getHeader("Event-Calling-Function") == "switch_xml_locate_domain") then dofile(scripts_dir.."/app/xml_handler/resources/scripts/directory/action/domains.lua"); + elseif (params:getHeader("Event-Calling-Function") == "switch_load_network_lists") then + dofile(scripts_dir.."/app/xml_handler/resources/scripts/directory/action/domains.lua"); else --handle action --all other directory actions: sip_auth, user_call