From 9612d41b5d654f866d2a847e53de5e5ce4510a23 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Fri, 11 Apr 2025 10:36:32 -0600 Subject: [PATCH] Replace the SESSION with settings get --- app/ivr_menus/ivr_menu_edit.php | 96 +++++++++++++++++---------------- 1 file changed, 50 insertions(+), 46 deletions(-) diff --git a/app/ivr_menus/ivr_menu_edit.php b/app/ivr_menus/ivr_menu_edit.php index b6fd64cf61..d798a4e9bf 100644 --- a/app/ivr_menus/ivr_menu_edit.php +++ b/app/ivr_menus/ivr_menu_edit.php @@ -59,6 +59,10 @@ //initialize the ringbacks object $ringbacks = new ringbacks; +//get the list of domains + $domains_object = new domains; + $domains = $domains_object->all(false); + //validate the ringback if (!$ringbacks->valid($ivr_menu_ringback)) { //set to default when it is not valid @@ -78,14 +82,14 @@ } //get total ivr menu count from the database, check limit, if defined - if (!empty($_SESSION['limit']['ivr_menus']['numeric'])) { + if (!empty($settings->get('limit', 'ivr_menus'))) { $sql = "select count(*) as num_rows from v_ivr_menus where domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $domain_uuid; $total_ivr_menus = $database->select($sql, $parameters, 'column'); unset($sql, $parameters); - if ($action == 'add' && $total_ivr_menus >= $_SESSION['limit']['ivr_menus']['numeric']) { - message::add($text['message-maximum_ivr_menus'].' '.$_SESSION['limit']['ivr_menus']['numeric'], 'negative'); + if ($action == 'add' && $total_ivr_menus >= $settings->get('limit', 'ivr_menus')) { + message::add($text['message-maximum_ivr_menus'].' '.$settings->get('limit', 'ivr_menus'), 'negative'); header('Location: ivr_menus.php'); exit; } @@ -349,7 +353,7 @@ $dialplan_xml = "\n"; $dialplan_xml .= " \n"; $dialplan_xml .= " \n"; - if (filter_var($_SESSION['ivr_menu']['answer']['boolean'] ?? false, FILTER_VALIDATE_BOOL)) { + if ($settings->get('ivr_menu', 'answer', false)) { $dialplan_xml .= " \n"; } $dialplan_xml .= " \n"; @@ -368,7 +372,7 @@ } $dialplan_xml .= " \n"; - if (!empty($_SESSION['ivr_menu']['application']['text']) && $_SESSION['ivr_menu']['application']['text'] == "lua") { + if (!empty($settings->get('ivr_menu', 'application')) && $settings->get('ivr_menu', 'application') == "lua") { $dialplan_xml .= " \n"; } else { @@ -550,12 +554,12 @@ //add an empty row to the options array if (count($ivr_menu_options) == 0) { - $rows = $_SESSION['ivr_menu']['option_add_rows']['numeric']; + $rows = $settings->get('ivr_menu', 'option_add_rows'); $id = 0; $show_option_delete = false; } if (count($ivr_menu_options) > 0) { - $rows = $_SESSION['ivr_menu']['option_edit_rows']['numeric']; + $rows = $settings->get('ivr_menu', 'option_edit_rows'); $id = count($ivr_menu_options)+1; $show_option_delete = true; } @@ -577,32 +581,32 @@ if (empty($ivr_menu_tts_engine)) { $ivr_menu_tts_engine = 'flite'; } if (empty($ivr_menu_tts_voice)) { $ivr_menu_tts_voice = 'rms'; } if (empty($ivr_menu_confirm_attempts)) { - if (!empty($_SESSION['ivr_menu']['confirm_attempts']['numeric'])) { - $ivr_menu_confirm_attempts = $_SESSION['ivr_menu']['confirm_attempts']['numeric']; + if (!empty($settings->get('ivr_menu', 'confirm_attempts'))) { + $ivr_menu_confirm_attempts = $settings->get('ivr_menu', 'confirm_attempts'); } else { $ivr_menu_confirm_attempts = '1'; } } if (empty($ivr_menu_inter_digit_timeout)) { - if (!empty($_SESSION['ivr_menu']['inter_digit_timeout']['numeric'])) { - $ivr_menu_inter_digit_timeout = $_SESSION['ivr_menu']['inter_digit_timeout']['numeric']; + if (!empty($settings->get('ivr_menu', 'inter_digit_timeout'))) { + $ivr_menu_inter_digit_timeout = $settings->get('ivr_menu', 'inter_digit_timeout'); } else { $ivr_menu_inter_digit_timeout = '2000'; } } if (empty($ivr_menu_max_failures)) { - if (!empty($_SESSION['ivr_menu']['max_failures']['numeric'])) { - $ivr_menu_max_failures = $_SESSION['ivr_menu']['max_failures']['numeric']; + if (!empty($settings->get('ivr_menu', 'max_failures'))) { + $ivr_menu_max_failures = $settings->get('ivr_menu', 'max_failures'); } else { $ivr_menu_max_failures = '1'; } } if (empty($ivr_menu_max_timeouts)) { - if (!empty($_SESSION['ivr_menu']['max_timeouts']['numeric'])) { - $ivr_menu_max_timeouts = $_SESSION['ivr_menu']['max_timeouts']['numeric']; + if (!empty($settings->get('ivr_menu', 'max_timeouts'))) { + $ivr_menu_max_timeouts = $settings->get('ivr_menu', 'max_timeouts'); } else { $ivr_menu_max_timeouts = '1'; @@ -615,14 +619,14 @@ if (!isset($ivr_menu_exit_action)) { $ivr_menu_exit_action = ''; } //get installed languages - $language_paths = glob($_SESSION["switch"]['sounds']['dir']."/*/*/*"); + $language_paths = glob($settings->get('switch', 'sounds')."/*/*/*"); foreach ($language_paths as $key => $path) { - $path = str_replace($_SESSION["switch"]['sounds']['dir'].'/', "", $path); + $path = str_replace($settings->get('switch', 'sounds').'/', "", $path); $path_array = explode('/', $path); if (count($path_array) <> 3 || strlen($path_array[0]) <> 2 || strlen($path_array[1]) <> 2) { unset($language_paths[$key]); } - $language_paths[$key] = str_replace($_SESSION["switch"]['sounds']['dir']."/","",$language_paths[$key] ?? ''); + $language_paths[$key] = str_replace($settings->get('switch', 'sounds')."/","",$language_paths[$key] ?? ''); if (empty($language_paths[$key])) { unset($language_paths[$key]); } @@ -730,24 +734,24 @@ echo "
\n"; echo "
".$text['header-ivr_menu']."
\n"; echo "
\n"; - echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','link'=>'ivr_menus.php']); + echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back'),'id'=>'btn_back','link'=>'ivr_menus.php']); if ($action == "update") { - if (permission_exists('ivr_menu_add') && (empty($_SESSION['limit']['ivr_menus']['numeric']) || $total_ivr_menus < $_SESSION['limit']['ivr_menus']['numeric'])) { + if (permission_exists('ivr_menu_add') && (empty($settings->get('limit', 'ivr_menus')) || $total_ivr_menus < $settings->get('limit', 'ivr_menus'))) { $button_margin = 'margin-left: 15px;'; - echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'name'=>'btn_copy','style'=>$button_margin,'onclick'=>"modal_open('modal-copy','btn_copy');"]); + echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$settings->get('theme', 'button_icon_copy'),'name'=>'btn_copy','style'=>$button_margin,'onclick'=>"modal_open('modal-copy','btn_copy');"]); } if (permission_exists('ivr_menu_delete') || permission_exists('ivr_menu_option_delete')) { $button_margin = 'margin-left: 0px;'; - echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'btn_delete','style'=>$button_margin,'onclick'=>"modal_open('modal-delete','btn_delete');"]); + echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$settings->get('theme', 'button_icon_delete'),'name'=>'btn_delete','style'=>$button_margin,'onclick'=>"modal_open('modal-delete','btn_delete');"]); } } - echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','style'=>'margin-left: 15px']); + echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$settings->get('theme', 'button_icon_save'),'id'=>'btn_save','style'=>'margin-left: 15px']); echo "
\n"; echo "
\n"; echo "
\n"; if ($action == "update") { - if (permission_exists('ivr_menu_add') && (empty($_SESSION['limit']['ivr_menus']['numeric']) || $total_ivr_menus < $_SESSION['limit']['ivr_menus']['numeric'])) { + if (permission_exists('ivr_menu_add') && (empty($settings->get('limit', 'ivr_menus')) || $total_ivr_menus < $settings->get('limit', 'ivr_menus'))) { echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'copy','onclick'=>"modal_close();"])]); } if (permission_exists('ivr_menu_delete') || permission_exists('ivr_menu_option_delete')) { @@ -776,7 +780,7 @@ echo " ".$text['label-extension']."\n"; echo "\n"; echo "\n"; - echo " \n"; + echo " get('ivr_menu', 'extension_range') ?? '')."\">\n"; echo "
\n"; echo $text['description-extension']."\n"; echo "\n"; @@ -852,8 +856,8 @@ if ($key == 'recordings') { if ( !empty($instance_value) && - ($instance_value == $row["value"] || $instance_value == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.$row["value"]) && - file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME)) + ($instance_value == $row["value"] || $instance_value == $settings->get('switch', 'recordings')."/".$_SESSION['domain_name'].'/'.$row["value"]) && + file_exists($settings->get('switch', 'recordings')."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME)) ) { $selected = "selected='selected'"; $playable = '../recordings/recordings.php?action=download&type=rec&filename='.pathinfo($row["value"], PATHINFO_BASENAME); @@ -906,7 +910,7 @@ case 'ogg' : $mime_type = 'audio/ogg'; break; } echo ""; - echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$_SESSION['theme']['button_icon_play'],'id'=>'recording_button_'.$instance_id,'style'=>'display: '.(!empty($mime_type) ? 'inline' : 'none'),'onclick'=>"recording_play('".$instance_id."', document.getElementById('".$instance_id."').value, document.getElementById('".$instance_id."').options[document.getElementById('".$instance_id."').selectedIndex].parentNode.getAttribute('data-type'));"]); + echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$settings->get('theme', 'button_icon_play'),'id'=>'recording_button_'.$instance_id,'style'=>'display: '.(!empty($mime_type) ? 'inline' : 'none'),'onclick'=>"recording_play('".$instance_id."', document.getElementById('".$instance_id."').value, document.getElementById('".$instance_id."').options[document.getElementById('".$instance_id."').selectedIndex].parentNode.getAttribute('data-type'));"]); unset($playable, $mime_type); } echo "
\n"; @@ -935,8 +939,8 @@ if ($key == 'recordings') { if ( !empty($instance_value) && - ($instance_value == $row["value"] || $instance_value == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.$row["value"]) && - file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME)) + ($instance_value == $row["value"] || $instance_value == $settings->get('switch', 'recordings')."/".$_SESSION['domain_name'].'/'.$row["value"]) && + file_exists($settings->get('switch', 'recordings')."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME)) ) { $selected = "selected='selected'"; $playable = '../recordings/recordings.php?action=download&type=rec&filename='.pathinfo($row["value"], PATHINFO_BASENAME); @@ -989,7 +993,7 @@ case 'ogg' : $mime_type = 'audio/ogg'; break; } echo ""; - echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$_SESSION['theme']['button_icon_play'],'id'=>'recording_button_'.$instance_id,'style'=>'display: '.(!empty($mime_type) ? 'inline' : 'none'),'onclick'=>"recording_play('".$instance_id."', document.getElementById('".$instance_id."').value, document.getElementById('".$instance_id."').options[document.getElementById('".$instance_id."').selectedIndex].parentNode.getAttribute('data-type'));"]); + echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$settings->get('theme', 'button_icon_play'),'id'=>'recording_button_'.$instance_id,'style'=>'display: '.(!empty($mime_type) ? 'inline' : 'none'),'onclick'=>"recording_play('".$instance_id."', document.getElementById('".$instance_id."').value, document.getElementById('".$instance_id."').options[document.getElementById('".$instance_id."').selectedIndex].parentNode.getAttribute('data-type'));"]); unset($playable, $mime_type); } echo "
\n"; @@ -1025,7 +1029,7 @@ echo "\n"; if (empty($field['ivr_menu_option_uuid'])) { // new record - if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') { + if (substr($settings->get('theme', 'input_toggle_style'), 0, 6) == 'switch') { $onkeyup = "onkeyup=\"document.getElementById('ivr_menu_options_".$x."_ivr_menu_option_enabled').checked = (this.value != '' ? true : false);\""; // switch } else { @@ -1067,7 +1071,7 @@ echo "\n"; echo "\n"; // switch - if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') { + if (substr($settings->get('theme', 'input_toggle_style'), 0, 6) == 'switch') { echo "