From 31adc0883a897ed1278cf1e75b0e226dcf3eed39 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Thu, 16 Jan 2025 19:56:32 -0700 Subject: [PATCH] Update destination_edit.php - Use the settings class to get the default settings - Use call recordings variable record_extension wav or mp3 --- app/destinations/destination_edit.php | 61 ++++++++++++++++++--------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/app/destinations/destination_edit.php b/app/destinations/destination_edit.php index ba185c3c75..ed526cba09 100644 --- a/app/destinations/destination_edit.php +++ b/app/destinations/destination_edit.php @@ -41,10 +41,13 @@ $language = new text; $text = $language->get(); -//initialize the database - $database = new database; +//initialize the database object + $database = database::new(); -//initialize the destinations object +//initialize the settings object + $settings = new settings(['database' => $database, 'domain_uuid' => $domain_uuid]); + +//initialize the destination object $destination = new destinations; //initialize the ringbacks object @@ -68,17 +71,20 @@ default: $destination_type = 'inbound'; } +//get the call recording extension + $record_extension = $settings->get('call_recordings', 'record_extension', 'wav'); + //get total destination count from the database, check limit, if defined if (!permission_exists('destination_domain')) { if ($action == 'add') { - if (!empty($_SESSION['limit']['destinations']['numeric'])) { + if (!empty($settings->get('limit', 'destinations', ''))) { $sql = "select count(*) from v_destinations where domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $total_destinations = $database->select($sql, $parameters, 'column'); unset($sql, $parameters); - if ($total_destinations >= $_SESSION['limit']['destinations']['numeric']) { - message::add($text['message-maximum_destinations'].' '.$_SESSION['limit']['destinations']['numeric'], 'negative'); + if ($total_destinations >= $settings->get('limit', 'destinations', '')) { + message::add($text['message-maximum_destinations'].' '.$settings->get('limit', 'destinations', ''), 'negative'); header('Location: destinations.php'); exit; } @@ -199,7 +205,7 @@ if (empty($destination_enabled)) { $msg .= $text['message-required']." ".$text['label-destination_enabled']."
\n"; } //check for duplicates - if ($destination_type == 'inbound' && $destination_number != $db_destination_number && $_SESSION['destinations']['unique']['boolean'] == 'true') { + if ($destination_type == 'inbound' && $destination_number != $db_destination_number && $settings->get('destinations', 'unique', '')) { $sql = "select count(*) from v_destinations "; $sql .= "where (destination_number = :destination_number or destination_prefix || destination_number = :destination_number) "; $sql .= "and destination_type = 'inbound' "; @@ -448,15 +454,15 @@ if (!empty($destination_condition_field)) { $dialplan_detail_type = $destination_condition_field; } - elseif (!empty($_SESSION['dialplan']['destination']['text'])) { - $dialplan_detail_type = $_SESSION['dialplan']['destination']['text']; + elseif (!empty($settings->get('dialplan', 'destination', ''))) { + $dialplan_detail_type = $settings->get('dialplan', 'destination', ''); } else { $dialplan_detail_type = "destination_number"; } //authorized specific dialplan_detail_type that are safe, sanitize all other values - $dialplan_detail_type = $_SESSION['dialplan']['destination']['text']; + $dialplan_detail_type = $settings->get('dialplan', 'destination', ''); switch ($dialplan_detail_type) { case 'destination_number': break; @@ -534,10 +540,11 @@ } if (!empty($destination_record) && $destination_record == 'true') { $dialplan["dialplan_xml"] .= " \n"; - $dialplan["dialplan_xml"] .= " \n"; + $dialplan["dialplan_xml"] .= " \n"; $dialplan["dialplan_xml"] .= " \n"; $dialplan["dialplan_xml"] .= " \n"; $dialplan["dialplan_xml"] .= " \n"; + $dialplan["dialplan_xml"] .= " \n"; $dialplan["dialplan_xml"] .= " \n"; } if (!empty($destination_hold_music)) { @@ -596,7 +603,7 @@ $dialplan["dialplan_xml"] .= "\n"; //dialplan details - if ($_SESSION['destinations']['dialplan_details']['boolean'] == "true") { + if ($settings->get('destinations', 'dialplan_details', '')) { //set initial value of the row id $y=0; @@ -637,8 +644,8 @@ if (!empty($destination_condition_field)) { $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $destination_condition_field; } - elseif (!empty($_SESSION['dialplan']['destination']['text'])) { - $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $_SESSION['dialplan']['destination']['text']; + elseif (!empty($settings->get('dialplan', 'destination', ''))) { + $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $settings->get('dialplan', 'destination', ''); } else { $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "regex"; @@ -697,8 +704,8 @@ if (!empty($destination_condition_field)) { $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $destination_condition_field; } - elseif (!empty($_SESSION['dialplan']['destination']['text'])) { - $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $_SESSION['dialplan']['destination']['text']; + elseif (!empty($settings->get('dialplan', 'destination', ''))) { + $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $settings->get('dialplan', 'destination', ''); } else { $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "destination_number"; @@ -946,7 +953,7 @@ $dialplan["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set"; - $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "record_name=\${uuid}.\${record_ext}"; + $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "record_name=\${uuid}.".$record_extension; $dialplan["dialplan_details"][$y]["dialplan_detail_inline"] = "true"; $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = $dialplan_detail_group; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order; @@ -983,6 +990,20 @@ //increment the dialplan detail order $dialplan_detail_order = $dialplan_detail_order + 10; + //add a variable + $dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid; + $dialplan["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid; + $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; + $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set"; + $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "record_stereo_swap=true"; + $dialplan["dialplan_details"][$y]["dialplan_detail_inline"] = "true"; + $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = $dialplan_detail_group; + $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order; + $y++; + + //increment the dialplan detail order + $dialplan_detail_order = $dialplan_detail_order + 10; + //add a variable $dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_uuid"] = $dialplan_uuid; @@ -1164,10 +1185,10 @@ //clear the cache $cache = new cache; - if ($_SESSION['destinations']['dialplan_mode']['text'] == 'multiple') { + if ($settings->get('destinations', 'dialplan_mode', '') == 'multiple') { $cache->delete("dialplan:".$destination_context); } - if ($_SESSION['destinations']['dialplan_mode']['text'] == 'single') { + if ($settings->get('destinations', 'dialplan_mode', '') == 'single') { if (isset($destination_prefix) && is_numeric($destination_prefix) && isset($destination_number) && is_numeric($destination_number)) { $cache->delete("dialplan:".$destination_context.":".$destination_prefix.$destination_number); $cache->delete("dialplan:".$destination_context.":+".$destination_prefix.$destination_number); @@ -2081,7 +2102,7 @@ echo " ".$text['label-destination_enabled']."\n"; echo "\n"; echo "\n"; - if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') { + if (substr($settings->get('theme', 'input_toggle_style', ''), 0, 6) == 'switch') { echo "