From cde4a82bde833e945ea2756ddf49df536926e685 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Wed, 20 Aug 2025 18:54:30 -0600 Subject: [PATCH] Use the settings class --- app/voicemails/voicemail_edit.php | 68 ++++++++++++++++--------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/app/voicemails/voicemail_edit.php b/app/voicemails/voicemail_edit.php index 2a8459c2f2..b314229cd6 100644 --- a/app/voicemails/voicemail_edit.php +++ b/app/voicemails/voicemail_edit.php @@ -65,6 +65,10 @@ $voicemail_mail_to = ''; $transcribe_enabled = $settings->get('transcribe', 'enabled', false); +//set the domain variables + $domain_uuid = $_SESSION['domain_uuid'] ?? ''; + $domain_name = $_SESSION['domain_name'] ?? ''; + //get http variables and set them to php variables $referer_path = $_REQUEST["referer_path"] ?? ''; $referer_query = $_REQUEST["referer_query"] ?? ''; @@ -154,7 +158,7 @@ $voicemail_uuid = uuid(); //if adding a mailbox and don't have the transcription permission, set the default transcribe behavior if (!permission_exists('voicemail_transcription_enabled')) { - $voicemail_transcription_enabled = filter_var($_SESSION['voicemail']['transcription_enabled_default']['boolean'] ?? false, FILTER_VALIDATE_BOOL); + $voicemail_transcription_enabled = $settings->get('voicemail', 'transcription_enabled_default', false); } } @@ -196,7 +200,7 @@ if (is_numeric($voicemail_option["voicemail_option_param"])) { //if numeric then add tranfer $1 XML domain_name $voicemail_option['voicemail_option_action'] = "menu-exec-app"; - $voicemail_option['voicemail_option_param'] = "transfer ".$voicemail_option["voicemail_option_param"]." XML ".$_SESSION['domain_name']; + $voicemail_option['voicemail_option_param'] = "transfer ".$voicemail_option["voicemail_option_param"]." XML ".$domain_name; } else { //seperate the action and the param @@ -249,20 +253,20 @@ //create or rename voicemail directory as needed if (is_numeric($voicemail_id)) { - // old and new voicemail ids differ, old directory exists and new doesn't, rename directory if ( !empty($voicemail_id_previous) && is_numeric($voicemail_id_previous) && $voicemail_id_previous != $voicemail_id && - file_exists($_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$voicemail_id_previous) && - !file_exists($_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$voicemail_id) + file_exists($settings->get('switch', 'voicemail')."/default/".$domain_name."/".$voicemail_id_previous) && + !file_exists($settings->get('switch', 'voicemail')."/default/".$domain_name."/".$voicemail_id) ) { + // old and new voicemail ids differ, old directory exists and new doesn't, rename directory rename( - $_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$voicemail_id_previous, // previous - $_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$voicemail_id // new + $settings->get('switch', 'voicemail')."/default/".$domain_name."/".$voicemail_id_previous, // previous + $settings->get('switch', 'voicemail')."/default/".$domain_name."/".$voicemail_id // new ); } - // new directory doesn't exist, create - else if (!file_exists($_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$voicemail_id)) { - mkdir($_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$voicemail_id, 0770); + else if (!file_exists($settings->get('switch', 'voicemail')."/default/".$domain_name."/".$voicemail_id)) { + // new directory doesn't exist, create + mkdir($settings->get('switch', 'voicemail')."/default/".$domain_name."/".$voicemail_id, 0770); } } @@ -298,11 +302,11 @@ //delete record name if requested if ( (!empty($_POST['recorded_name']) && $_POST['recorded_name'] == 1) && - !empty($_SESSION['switch']['storage']['dir']) && - file_exists($_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domain_name'].'/'.$voicemail_id.'/recorded_name.wav') && + !empty($settings->get('switch', 'storage')) && + file_exists($settings->get('switch', 'storage').'/voicemail/default/'.$domain_name.'/'.$voicemail_id.'/recorded_name.wav') && (permission_exists('voicemail_greeting_play') || permission_exists('voicemail_greeting_download')) ) { - @unlink($_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domain_name'].'/'.$voicemail_id.'/recorded_name.wav'); + @unlink($settings->get('switch', 'storage').'/voicemail/default/'.$domain_name.'/'.$voicemail_id.'/recorded_name.wav'); } //set message @@ -353,8 +357,8 @@ unset($sql, $parameters, $row); } else { - $voicemail_file = $_SESSION['voicemail']['voicemail_file']['text']; - $voicemail_local_after_email = filter_var($_SESSION['voicemail']['keep_local']['boolean'] ?? false, FILTER_VALIDATE_BOOL); + $voicemail_file = $settings->get('voicemail', 'voicemail_file'); + $voicemail_local_after_email = $settings->get('voicemail', 'keep_local', false); } //remove the spaces @@ -365,7 +369,7 @@ //set the defaults if (empty($voicemail_local_after_email)) { $voicemail_local_after_email = 'true'; } if (empty($voicemail_enabled)) { $voicemail_enabled = 'true'; } - if (empty($voicemail_transcription_enabled)) { $voicemail_transcription_enabled = filter_var($_SESSION['voicemail']['transcription_enabled_default']['boolean'] ?? false, FILTER_VALIDATE_BOOL); } + if (empty($voicemail_transcription_enabled)) { $voicemail_transcription_enabled = $settings->get('voicemail', 'transcription_enabled_default', false); } if (empty($voicemail_tutorial)) { $voicemail_tutorial = 'false'; } if (empty($voicemail_recording_instructions)) { $voicemail_recording_instructions = 'true'; } if (empty($voicemail_recording_options)) { $voicemail_recording_options = 'true'; } @@ -392,7 +396,7 @@ $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and voicemail_uuid = :voicemail_uuid "; $sql .= "order by voicemail_option_digits, voicemail_option_order asc "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $domain_uuid; $parameters['voicemail_uuid'] = $voicemail_uuid; $database = new database; $voicemail_options = $database->select($sql, $parameters, 'all'); @@ -409,7 +413,7 @@ $voicemail_option_param = str_replace("XML", "", $voicemail_option_param); $voicemail_option_param = str_replace("transfer", "", $voicemail_option_param); $voicemail_option_param = str_replace("bridge", "", $voicemail_option_param); - $voicemail_option_param = str_replace($_SESSION['domain_name'], "", $voicemail_option_param); + $voicemail_option_param = str_replace($domain_name, "", $voicemail_option_param); $voicemail_option_param = str_replace("\${domain_name}", "", $voicemail_option_param); $voicemail_option_param = str_replace("\${domain}", "", $voicemail_option_param); $voicemail_option_param = ucfirst(trim($voicemail_option_param)); @@ -429,7 +433,7 @@ $sql .= "v.voicemail_enabled = 'true' and "; $sql .= "d.voicemail_uuid = :voicemail_uuid "; $sql .= "order by v.voicemail_id asc"; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $domain_uuid; $parameters['voicemail_uuid'] = $voicemail_uuid; $database = new database; $voicemail_destinations_assigned = $database->select($sql, $parameters, 'all'); @@ -453,7 +457,7 @@ $sql .= "and v.voicemail_uuid not in (".implode(',', $voicemail_destinations).") "; } $sql .= "order by v.voicemail_id asc"; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $domain_uuid; if (!empty($voicemail_uuid) && is_uuid($voicemail_uuid)) { $parameters['voicemail_uuid'] = $voicemail_uuid; } @@ -470,10 +474,10 @@ require_once "resources/header.php"; //password complexity - $password_complexity = filter_var($_SESSION['voicemail']['password_complexity']['boolean'] ?? false, FILTER_VALIDATE_BOOL); + $password_complexity = $settings->get('voicemail', 'password_complexity', false); if ($password_complexity) { echo "