diff --git a/app/ivr_menu/app_languages.php b/app/ivr_menu/app_languages.php index 213d4c1ead..e0e70762f2 100644 --- a/app/ivr_menu/app_languages.php +++ b/app/ivr_menu/app_languages.php @@ -441,7 +441,7 @@ $text['description-extension']['fr-fr'] = "Choisir le numéro d'extension."; $text['description-extension']['pt-br'] = "Atribua a extensão e números ao dispositivo"; $text['description-extension']['pl'] = "Wprowadź numer wewnętrzny. Domyślna konfiguracja pozwala na 2-7 cyfrowe numery wewnętrzne"; -$text['description-exit_sound']['en-us'] = "Played when leaving the menu."; +$text['description-exit_sound']['en-us'] = "Played when leaving the menu, after selecting an option."; $text['description-exit_sound']['es-cl'] = "Reproducir cuando se deje el menú."; $text['description-exit_sound']['pt-pt'] = "É tocado quando se abandona o menu."; $text['description-exit_sound']['fr-fr'] = "Joué lorsque l'on quitte ce menu."; diff --git a/app/ivr_menu/ivr_menu_edit.php b/app/ivr_menu/ivr_menu_edit.php index 21ec6716af..dfc1e39132 100644 --- a/app/ivr_menu/ivr_menu_edit.php +++ b/app/ivr_menu/ivr_menu_edit.php @@ -431,27 +431,25 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; } //recordings - if ($dh = opendir($_SESSION['switch']['recordings']['dir']."/")) { - $tmp_selected = false; - if (count($recordings) > 0) { - echo "\n"; - foreach ($recordings as &$row) { - $name = $row["recording_name"]; - $file = $row["recording_filename"]; - if ($ivr_menu_greet_long == $_SESSION['switch']['recordings']['dir']."/".$file && strlen($ivr_menu_greet_long) > 0) { - $tmp_selected = true; - echo " \n"; - } - else if ($ivr_menu_greet_long == $file && strlen($ivr_menu_greet_long) > 0) { - $tmp_selected = true; - echo " \n"; - } - else { - echo " \n"; - } + $tmp_selected = false; + if (count($recordings) > 0) { + echo "\n"; + foreach ($recordings as &$row) { + $recording_name = $row["recording_name"]; + $recording_filename = $row["recording_filename"]; + if ($ivr_menu_greet_long == $_SESSION['switch']['recordings']['dir']."/".$recording_filename && strlen($ivr_menu_greet_long) > 0) { + $tmp_selected = true; + echo " \n"; + } + else if ($ivr_menu_greet_long == $recording_filename && strlen($ivr_menu_greet_long) > 0) { + $tmp_selected = true; + echo " \n"; + } + else { + echo " \n"; } - echo "\n"; } + echo "\n"; } //phrases $sql = "select * from v_phrases where domain_uuid = '".$domain_uuid."' "; @@ -529,27 +527,25 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; } //recordings - if ($dh = opendir($_SESSION['switch']['recordings']['dir']."/")) { - $tmp_selected = false; - if (count($recordings) > 0) { - echo "\n"; - foreach ($recordings as &$row) { - $name = $row["recording_name"]; - $file = $row["recording_filename"]; - if ($ivr_menu_greet_short == $_SESSION['switch']['recordings']['dir']."/".$file && strlen($ivr_menu_greet_short) > 0) { - $tmp_selected = true; - echo " \n"; - } - else if ($ivr_menu_greet_short == $file && strlen($ivr_menu_greet_short) > 0) { - $tmp_selected = true; - echo " \n"; - } - else { - echo " \n"; - } + $tmp_selected = false; + if (count($recordings) > 0) { + echo "\n"; + foreach ($recordings as &$row) { + $recording_name = $row["recording_name"]; + $recording_filename = $row["recording_filename"]; + if ($ivr_menu_greet_short == $_SESSION['switch']['recordings']['dir']."/".$recording_filename && strlen($ivr_menu_greet_short) > 0) { + $tmp_selected = true; + echo " \n"; + } + else if ($ivr_menu_greet_short == $recording_filename && strlen($ivr_menu_greet_short) > 0) { + $tmp_selected = true; + echo " \n"; + } + else { + echo " \n"; } - echo "\n"; } + echo "\n"; } //phrases $sql = "select * from v_phrases where domain_uuid = '".$domain_uuid."' "; @@ -647,7 +643,9 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $ivr_menu_option_param = str_replace($_SESSION['domain_name'], "", $ivr_menu_option_param); $ivr_menu_option_param = str_replace("\${domain_name}", "", $ivr_menu_option_param); $ivr_menu_option_param = str_replace("\${domain}", "", $ivr_menu_option_param); - $ivr_menu_option_param = ucfirst(trim($ivr_menu_option_param)); + $ivr_menu_option_param = str_replace(".".$_SESSION['domain_uuid'], "", $ivr_menu_option_param); + $ivr_menu_option_param = str_replace("//", "/", $ivr_menu_option_param); + //$ivr_menu_option_param = ucfirst(trim($ivr_menu_option_param)); echo " \n"; echo " \n"; echo " ".$field['ivr_menu_option_digits']; @@ -859,7 +857,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo " ".$text['label-invalid_sound']."\n"; echo "\n"; echo "\n"; - echo "\n"; //misc optgroup if (if_group("superadmin")) { echo "\n"; @@ -869,27 +867,24 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; } //recordings - if ($dh = opendir($_SESSION['switch']['recordings']['dir']."/")) { - $tmp_selected = false; - $files = Array(); + $tmp_selected = false; + if (count($recordings) > 0) { echo "\n"; - while($file = readdir($dh)) { - if($file != "." && $file != ".." && $file[0] != '.') { - if(is_dir($_SESSION['switch']['recordings']['dir'] . "/" . $file)) { - //this is a directory - } - else { - if ($ivr_menu_invalid_sound == $_SESSION['switch']['recordings']['dir']."/".$file && strlen($ivr_menu_invalid_sound) > 0) { - $tmp_selected = true; - echo " \n"; - } - else { - echo " \n"; - } - } + foreach ($recordings as &$row) { + $recording_name = $row["recording_name"]; + $recording_filename = $row["recording_filename"]; + if ($ivr_menu_invalid_sound == $_SESSION['switch']['recordings']['dir']."/".$recording_filename && strlen($ivr_menu_invalid_sound) > 0) { + $tmp_selected = true; + echo " \n"; + } + else if ($ivr_menu_invalid_sound == $recording_filename && strlen($ivr_menu_invalid_sound) > 0) { + $tmp_selected = true; + echo " \n"; + } + else { + echo " \n"; } } - closedir($dh); echo "\n"; } //phrases @@ -957,7 +952,91 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo " ".$text['label-exit_sound']."\n"; echo "\n"; echo "\n"; - echo " \n"; + echo "\n"; echo "
\n"; echo $text['description-exit_sound']."\n"; echo "\n"; diff --git a/resources/install/scripts/ivr_menu.lua b/resources/install/scripts/ivr_menu.lua index aab1d2a5ae..8a6d633f52 100644 --- a/resources/install/scripts/ivr_menu.lua +++ b/resources/install/scripts/ivr_menu.lua @@ -182,85 +182,167 @@ if (string.sub(ivr_menu_greet_short,0,71) == "$${sounds_dir}/${default_language}/${default_dialect}/${default_voice}/") then ivr_menu_greet_short = string.sub(ivr_menu_greet_short,72); end + if (string.sub(ivr_menu_invalid_sound,0,71) == "$${sounds_dir}/${default_language}/${default_dialect}/${default_voice}/") then + ivr_menu_invalid_sound = string.sub(ivr_menu_invalid_sound,72); + end + if (string.sub(ivr_menu_exit_sound,0,71) == "$${sounds_dir}/${default_language}/${default_dialect}/${default_voice}/") then + ivr_menu_exit_sound = string.sub(ivr_menu_exit_sound,72); + end ---adjust the file path - if (ivr_menu_greet_short) then - --do nothing - else - ivr_menu_greet_short = ivr_menu_greet_long; - end - if (not file_exists(ivr_menu_greet_long)) then - if (file_exists(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/"..ivr_menu_greet_long)) then - ivr_menu_greet_long = sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/"..ivr_menu_greet_long; - elseif (file_exists(recordings_dir.."/"..ivr_menu_greet_long)) then - ivr_menu_greet_long = recordings_dir.."/"..ivr_menu_greet_long; - end - end - if (string.len(ivr_menu_greet_short) > 1) then - if (not file_exists(ivr_menu_greet_short)) then - if (file_exists(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/"..ivr_menu_greet_short)) then - ivr_menu_greet_short = sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/"..ivr_menu_greet_short; - elseif (file_exists(recordings_dir.."/"..ivr_menu_greet_short)) then - ivr_menu_greet_short = recordings_dir.."/"..ivr_menu_greet_short; - end - end - else - ivr_menu_greet_short = ivr_menu_greet_long; - end - ivr_menu_invalid_entry = sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/"..ivr_menu_invalid_sound; +--parse file names + greet_long_file_name_only = ivr_menu_greet_long:match("([^/]+)$"); + greet_short_file_name_only = ivr_menu_greet_short:match("([^/]+)$"); + invalid_sound_file_name_only = ivr_menu_invalid_sound:match("([^/]+)$"); + exit_sound_file_name_only = ivr_menu_exit_sound:match("([^/]+)$"); --get the recordings from the database + ivr_menu_greet_long_is_base64 = false; + ivr_menu_greet_short_is_base64 = false; + ivr_menu_invalid_sound_is_base64 = false; + ivr_menu_exit_sound_is_base64 = false; if (storage_type == "base64") then - if (string.len(ivr_menu_greet_long) > 1) then - sql = [[SELECT * FROM v_recordings - WHERE domain_uuid = ']] .. domain_uuid ..[[' - AND recording_filename = ']].. ivr_menu_greet_long.. [[' ]]; - if (debug["sql"]) then - freeswitch.consoleLog("notice", "[ivr_menu] SQL: " .. sql .. "\n"); + --greet long + if (string.len(ivr_menu_greet_long) > 1) then + if (not file_exists(recordings_dir.."/"..greet_long_file_name_only)) then + sql = [[SELECT * FROM v_recordings + WHERE domain_uuid = ']]..domain_uuid..[[' + AND recording_filename = ']]..greet_long_file_name_only..[[' ]]; + if (debug["sql"]) then + freeswitch.consoleLog("notice", "[ivr_menu] SQL: "..sql.."\n"); + end + status = dbh:query(sql, function(row) + --add functions + dofile(scripts_dir.."/resources/functions/base64.lua"); + --add the path to filename + ivr_menu_greet_long = recordings_dir.."/"..greet_long_file_name_only; + ivr_menu_greet_long_is_base64 = true; + --save the recording to the file system + if (string.len(row["recording_base64"]) > 32) then + local file = io.open(ivr_menu_greet_long, "w"); + file:write(base64.decode(row["recording_base64"])); + file:close(); + end + end); + end end - status = dbh:query(sql, function(row) - --add functions - dofile(scripts_dir.."/resources/functions/base64.lua"); - - --add the path to filename - ivr_menu_greet_long = recordings_dir.."/"..ivr_menu_greet_long; - - --save the recording to the file system - if (string.len(row["recording_base64"]) > 32) then - local file = io.open(ivr_menu_greet_long, "w"); - file:write(base64.decode(row["recording_base64"])); - file:close(); + --greet short + if (string.len(ivr_menu_greet_short) > 1) then + if (not file_exists(recordings_dir.."/"..greet_short_file_name_only)) then + sql = [[SELECT * FROM v_recordings + WHERE domain_uuid = ']]..domain_uuid..[[' + AND recording_filename = ']]..greet_short_file_name_only..[[' ]]; + if (debug["sql"]) then + freeswitch.consoleLog("notice", "[ivr_menu] SQL: "..sql.."\n"); end - end); - end - if (string.len(ivr_menu_greet_short) > 1) then - sql = [[SELECT * FROM v_recordings - WHERE domain_uuid = ']] .. domain_uuid ..[[' - AND recording_filename = ']].. ivr_menu_greet_short.. [[' ]]; - --if (debug["sql"]) then - freeswitch.consoleLog("notice", "[ivr_menu] SQL: " .. sql .. "\n"); - --end - status = dbh:query(sql, function(row) - --add functions - dofile(scripts_dir.."/resources/functions/base64.lua"); - - --add the path to filename - ivr_menu_greet_short = recordings_dir.."/"..ivr_menu_greet_short; - - --save the recording to the file system - if (string.len(row["recording_base64"]) > 32) then - local file = io.open(ivr_menu_greet_short, "w"); - file:write(base64.decode(row["recording_base64"])); - file:close(); + status = dbh:query(sql, function(row) + --add functions + dofile(scripts_dir.."/resources/functions/base64.lua"); + --add the path to filename + ivr_menu_greet_short = recordings_dir.."/"..greet_short_file_name_only; + ivr_menu_greet_short_is_base64 = true; + --save the recording to the file system + if (string.len(row["recording_base64"]) > 32) then + local file = io.open(ivr_menu_greet_short, "w"); + file:write(base64.decode(row["recording_base64"])); + file:close(); + end + end); + end + end + --invalid sound + if (string.len(ivr_menu_invalid_sound) > 1) then + if (not file_exists(recordings_dir.."/"..invalid_sound_file_name_only)) then + sql = [[SELECT * FROM v_recordings + WHERE domain_uuid = ']]..domain_uuid..[[' + AND recording_filename = ']]..invalid_sound_file_name_only..[[' ]]; + if (debug["sql"]) then + freeswitch.consoleLog("notice", "[ivr_menu] SQL: "..sql.."\n"); end - end); - end + status = dbh:query(sql, function(row) + --add functions + dofile(scripts_dir.."/resources/functions/base64.lua"); + --add the path to filename + ivr_menu_invalid_sound = recordings_dir.."/"..invalid_sound_file_name_only; + ivr_menu_invalid_sound_is_base64 = true; + --save the recording to the file system + if (string.len(row["recording_base64"]) > 32) then + local file = io.open(ivr_menu_invalid_sound, "w"); + file:write(base64.decode(row["recording_base64"])); + file:close(); + end + end); + end + end + --exit sound + if (string.len(ivr_menu_exit_sound) > 1) then + if (not file_exists(recordings_dir.."/"..exit_sound_file_name_only)) then + sql = [[SELECT * FROM v_recordings + WHERE domain_uuid = ']]..domain_uuid..[[' + AND recording_filename = ']]..exit_sound_file_name_only..[[' ]]; + if (debug["sql"]) then + freeswitch.consoleLog("notice", "[ivr_menu] SQL: "..sql.."\n"); + end + status = dbh:query(sql, function(row) + --add functions + dofile(scripts_dir.."/resources/functions/base64.lua"); + --add the path to filename + ivr_menu_exit_sound = recordings_dir.."/"..exit_sound_file_name_only; + ivr_menu_exit_sound_is_base64 = true; + --save the recording to the file system + if (string.len(row["recording_base64"]) > 32) then + local file = io.open(ivr_menu_exit_sound, "w"); + file:write(base64.decode(row["recording_base64"])); + file:close(); + end + end); + end + end elseif (storage_type == "http_cache") then --add the path to file name ivr_menu_greet_long = storage_path.."/"..ivr_menu_greet_long; ivr_menu_greet_short = storage_path.."/"..ivr_menu_greet_short; + ivr_menu_invalid_sound = storage_path.."/"..ivr_menu_invalid_sound; + ivr_menu_exit_sound = storage_path.."/"..ivr_menu_exit_sound; end +--adjust file paths + --greet long + if (not file_exists(ivr_menu_greet_long)) then + if (file_exists(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/"..greet_long_file_name_only)) then + ivr_menu_greet_long = sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/"..greet_long_file_name_only; + elseif (file_exists(recordings_dir.."/"..greet_long_file_name_only)) then + ivr_menu_greet_long = recordings_dir.."/"..greet_long_file_name_only; + end + end + --greet short + if (string.len(ivr_menu_greet_short) > 1) then + if (not file_exists(ivr_menu_greet_short)) then + if (file_exists(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/"..greet_short_file_name_only)) then + ivr_menu_greet_short = sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/"..greet_short_file_name_only; + elseif (file_exists(recordings_dir.."/"..greet_short_file_name_only)) then + ivr_menu_greet_short = recordings_dir.."/"..greet_short_file_name_only; + end + end + else + ivr_menu_greet_short = ivr_menu_greet_long; + end + --invalid sound + if (not file_exists(ivr_menu_invalid_sound)) then + if (file_exists(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/"..invalid_sound_file_name_only)) then + ivr_menu_invalid_sound = sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/"..invalid_sound_file_name_only; + elseif (file_exists(recordings_dir.."/"..invalid_sound_file_name_only)) then + ivr_menu_invalid_sound = recordings_dir.."/"..invalid_sound_file_name_only; + end + end + --exit sound + if (not file_exists(ivr_menu_exit_sound)) then + if (file_exists(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/"..exit_sound_file_name_only)) then + ivr_menu_exit_sound = sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/"..exit_sound_file_name_only; + elseif (file_exists(recordings_dir.."/"..exit_sound_file_name_only)) then + ivr_menu_exit_sound = recordings_dir.."/"..exit_sound_file_name_only; + end + end + --define the ivr menu function menu() --increment the tries @@ -344,6 +426,9 @@ freeswitch.consoleLog("notice", "[ivr_menu] action: " .. action .. " data: ".. data .. "\n"); end --run the action + if (ivr_menu_exit_sound ~= nil) then + session:streamFile(ivr_menu_exit_sound); + end session:execute(action, data); end end @@ -375,17 +460,30 @@ --execute if (action) then if (string.len(action) == 0) then - session:streamFile(ivr_menu_invalid_entry); + session:streamFile(ivr_menu_invalid_sound); menu(); end else - session:streamFile(ivr_menu_invalid_entry); + session:streamFile(ivr_menu_invalid_sound); menu(); end end --end function --answer the session - if ( session:ready() ) then + if (session:ready()) then session:answer(); menu(); + end + +--if base64, remove temporary audio files (increases responsiveness when files remain local) + if (storage_type == "base64") then + if (ivr_menu_greet_long_is_base64 and file_exists(ivr_menu_greet_long)) then + --os.remove(ivr_menu_greet_long); + end + if (ivr_menu_greet_short_is_base64 and file_exists(ivr_menu_greet_short)) then + --os.remove(ivr_menu_greet_short); + end + if (ivr_menu_invalid_sound_is_base64 and file_exists(ivr_menu_invalid_sound)) then + --os.remove(ivr_menu_invalid_sound); + end end \ No newline at end of file diff --git a/resources/install/scripts/streamfile.lua b/resources/install/scripts/streamfile.lua index 22668755bc..b2d83d198a 100644 --- a/resources/install/scripts/streamfile.lua +++ b/resources/install/scripts/streamfile.lua @@ -2,6 +2,68 @@ script_name = argv[0]; file_name = argv[1]; +--include config.lua + scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1)); + dofile(scripts_dir.."/resources/functions/config.lua"); + dofile(config()); + +--connect to the database + dofile(scripts_dir.."/resources/functions/database_handle.lua"); + dbh = database_handle('system'); + +--get the variables + domain_name = session:getVariable("domain_name"); + domain_uuid = session:getVariable("domain_uuid"); + +--get the sounds dir, language, dialect and voice + sounds_dir = session:getVariable("sounds_dir"); + default_language = session:getVariable("default_language"); + default_dialect = session:getVariable("default_dialect"); + default_voice = session:getVariable("default_voice"); + if (not default_language) then default_language = 'en'; end + if (not default_dialect) then default_dialect = 'us'; end + if (not default_voice) then default_voice = 'callie'; end + +--settings + dofile(scripts_dir.."/resources/functions/settings.lua"); + settings = settings(domain_uuid); + storage_type = ""; + storage_path = ""; + if (settings['recordings'] ~= nil) then + if (settings['recordings']['storage_type'] ~= nil) then + if (settings['recordings']['storage_type']['text'] ~= nil) then + storage_type = settings['recordings']['storage_type']['text']; + end + end + if (settings['recordings']['storage_path'] ~= nil) then + if (settings['recordings']['storage_path']['text'] ~= nil) then + storage_path = settings['recordings']['storage_path']['text']; + storage_path = storage_path:gsub("${domain_name}", domain_name); + storage_path = storage_path:gsub("${voicemail_id}", voicemail_id); + storage_path = storage_path:gsub("${voicemail_dir}", voicemail_dir); + end + end + end + temp_dir = ""; + if (settings['server'] ~= nil) then + if (settings['server']['temp'] ~= nil) then + if (settings['server']['temp']['dir'] ~= nil) then + temp_dir = settings['server']['temp']['dir']; + end + end + end + +--set the recordings directory + if (domain_count > 1) then + recordings_dir = recordings_dir .. "/"..domain_name; + end + +--check if a file exists + function file_exists(name) + local f=io.open(name,"r") + if f~=nil then io.close(f) return true else return false end + end + --define the on_dtmf call back function function on_dtmf(s, type, obj, arg) if (type == "dtmf") then @@ -28,10 +90,59 @@ end end ---stream the file - session:answer(); +--parse file name + file_name_only = file_name:match("([^/]+)$"); + +--if base64, get from db, create temp file + if (storage_type == "base64") then + freeswitch.consoleLog("notice", "detected base64.\n"); + if (not file_exists(recordings_dir.."/"..file_name_only)) then + sql = [[SELECT * FROM v_recordings + WHERE domain_uuid = ']] .. domain_uuid ..[[' + AND recording_filename = ']].. file_name_only.. [[' ]]; + if (debug["sql"]) then + freeswitch.consoleLog("notice", "[ivr_menu] SQL: " .. sql .. "\n"); + end + status = dbh:query(sql, function(row) + --add functions + dofile(scripts_dir.."/resources/functions/base64.lua"); + --add the path to filename + file_name = recordings_dir.."/"..file_name_only; + --save the recording to the file system + if (string.len(row["recording_base64"]) > 32) then + local file = io.open(file_name, "w"); + file:write(base64.decode(row["recording_base64"])); + file:close(); + end + end); + else + file_name = recordings_dir.."/"..file_name_only; + end + end + +--adjust file path + if (not file_exists(file_name)) then + freeswitch.consoleLog("notice", "file " .. file_name .. " doesn't exist.\n"); + if (file_exists(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/"..file_name_only)) then + freeswitch.consoleLog("notice", "file " .. file_name_only .. " found in sounds.\n"); + file_name = sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/"..file_name_only; + elseif (file_exists(recordings_dir.."/"..file_name_only)) then + freeswitch.consoleLog("notice", "file " .. file_name_only .. " found in recordings.\n"); + file_name = recordings_dir.."/"..file_name_only; + end + end + +--stream file if exists if (session:ready()) then + session:answer(); session:sleep(1000); session:setInputCallback("on_dtmf", ""); session:streamFile(file_name); end + +--if base64, remove temp file (increases responsiveness when files remain local) + if (storage_type == "base64") then + if (file_exists(file_name)) then + --os.remove(file_name); + end + end diff --git a/resources/switch.php b/resources/switch.php index 8062b47272..87484a7bf4 100644 --- a/resources/switch.php +++ b/resources/switch.php @@ -1000,16 +1000,20 @@ function switch_select_destination($select_type, $select_label, $select_name, $s if (count($result) > 0) { $options[] = ""; foreach ($result as &$row) { - $name = $row["recording_name"]; - $filename = $row["recording_filename"]; + $recording_name = $row["recording_name"]; + $recording_filename = $row["recording_filename"]; + $path_mod = ($_SESSION['recordings']['storage_type']['text'] != 'base64') ? $_SESSION['switch']['recordings']['dir'] : null; if ($select_type == "dialplan") { - $selected = ($select_value == "lua:streamfile.lua ".$_SESSION['switch']['recordings']['dir']."/".$filename || $select_value == "lua:streamfile.lua ".$filename) ? true : false; - $options[] = ""; + $execute_method = 'lua:'; } - if ($select_type == "ivr") { - $selected = ($select_value == "menu-exec-app:lua streamfile.lua ".$_SESSION['switch']['recordings']['dir']."/".$filename || $select_value == "menu-exec-app:lua streamfile.lua ".$_SESSION['switch']['recordings']['dir']."/".$filename) ? true : false; - $options[] = ""; + else if ($select_type == "ivr") { + $execute_method = 'menu-exec-app:lua '; } + $selected = ( + $select_value == $execute_method."streamfile.lua ".$_SESSION['switch']['recordings']['dir']."/".$recording_filename || + $select_value == $execute_method."streamfile.lua ".$recording_filename + ) ? true : false; + $options[] = ""; if ($selected) { $selection_found = true; } } $options[] = ""; @@ -1017,6 +1021,26 @@ function switch_select_destination($select_type, $select_label, $select_name, $s } } + //phrases + if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/phrases/app_config.php")) { + if ($select_type == "dialplan" || $select_type == "ivr") { + $sql = "select * from v_phrases where domain_uuid = '".$domain_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + if (count($result) > 0) { + $options[] = ""; + foreach ($result as &$row) { + $selected = ($select_value == "phrase:".$row["phrase_name"].".".$domain_uuid) ? true : false; + $options[] = ""; + if ($selected) { $selection_found = true; } + } + $options[] = ""; + } + unset ($prep_statement); + } + } + //ring groups if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/ring_groups/app_config.php")) { if ($select_type == "dialplan" || $select_type == "ivr") {