\n";
echo "
".$text['title-ring_groups']."".number_format($num_rows)."
\n";
echo "
\n";
- if (permission_exists('ring_group_add') && (!isset($_SESSION['limit']['ring_groups']['numeric']) || ($total_ring_groups < $_SESSION['limit']['ring_groups']['numeric']))) {
+ if (permission_exists('ring_group_add') && (empty($settings->get('limit', 'ring_groups', 0)) || ($total_ring_groups < $settings->get('limit', 'ring_groups')))) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','link'=>'ring_group_edit.php']);
}
- if (permission_exists('ring_group_add') && $ring_groups && (!isset($_SESSION['limit']['ring_groups']['numeric']) || ($total_ring_groups < $_SESSION['limit']['ring_groups']['numeric']))) {
+ if (permission_exists('ring_group_add') && $ring_groups && (empty($settings->get('limit', 'ring_groups', 0)) || ($total_ring_groups < $settings->get('limit', 'ring_groups')))) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$settings->get('theme', 'button_icon_copy'),'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
}
if (permission_exists('ring_group_edit') && $ring_groups) {
@@ -215,7 +215,7 @@
echo "
\n";
echo "
\n";
- if (permission_exists('ring_group_add') && $ring_groups && (!isset($_SESSION['limit']['ring_groups']['numeric']) || ($total_ring_groups < $_SESSION['limit']['ring_groups']['numeric']))) {
+ if (permission_exists('ring_group_add') && $ring_groups && (empty($settings->get('limit', 'ring_groups', 0)) || ($total_ring_groups < $settings->get('limit', 'ring_groups')))) {
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('copy'); list_form_submit('form_list');"])]);
}
if (permission_exists('ring_group_edit') && $ring_groups) {
diff --git a/app/ring_groups/waveform.php b/app/ring_groups/waveform.php
index 8b760cd949..e65e25191c 100644
--- a/app/ring_groups/waveform.php
+++ b/app/ring_groups/waveform.php
@@ -46,20 +46,20 @@
if ($_GET['type'] == 'recordings') {
$slash = substr($_GET['data'],0,1) != '/' ? '/' : null;
- $full_file_path = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].$slash.str_replace($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'], '', $_GET['data']);
+ $full_file_path = $settings->get('switch', 'recordings')."/".$_SESSION['domain_name'].$slash.str_replace($settings->get('switch', 'recordings')."/".$_SESSION['domain_name'], '', $_GET['data']);
}
else if ($_GET['type'] == 'sounds') {
//get first installed language (like en/us/callie)
- $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]);
}
@@ -69,7 +69,7 @@
//determine the path for sound file
$filename_parts = explode('/', str_replace('..', '', $_GET['data']));
if (!is_array($filename_parts) || @sizeof($filename_parts) != 2) { exit; }
- $path = $_SESSION['switch']['sounds']['dir'].'/'.$language_path.'/'.$filename_parts[0].'/8000/';
+ $path = $settings->get('switch', 'sounds').'/'.$language_path.'/'.$filename_parts[0].'/8000/';
//build full path to sound file
$full_file_path = $path.$filename_parts[1];
@@ -91,13 +91,13 @@
$waveform = new Waveform($full_file_path);
Waveform::$linesPerPixel = 1; // default: 8
Waveform::$samplesPerLine = 512; // default: 512
- Waveform::$colorA = !empty($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color
- Waveform::$colorB = !empty($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color
- Waveform::$backgroundColor = !empty($_SESSION['theme']['audio_player_waveform_color_background']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_background']['text']) : [0,0,0,0]; // array rgba, default: transparent
- Waveform::$axisColor = !empty($_SESSION['theme']['audio_player_waveform_color_axis']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_axis']['text']) : [0,0,0,0.3]; // array rgba
- Waveform::$singlePhase = filter_var($_SESSION['theme']['audio_player_waveform_single_phase']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom
- Waveform::$singleAxis = filter_var($_SESSION['theme']['audio_player_waveform_single_axis']['boolean'] ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis
- $height = !empty($_SESSION['theme']['audio_player_waveform_height']['text']) && is_numeric(str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text'])) ? 2.2 * (int) str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text']) : null;
+ Waveform::$colorA = !empty($settings->get('theme', 'audio_player_waveform_color_a_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_a_leg')) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color
+ Waveform::$colorB = !empty($settings->get('theme', 'audio_player_waveform_color_b_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_b_leg')) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color
+ Waveform::$backgroundColor = !empty($settings->get('theme', 'audio_player_waveform_color_background')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_background')) : [0,0,0,0]; // array rgba, default: transparent
+ Waveform::$axisColor = !empty($settings->get('theme', 'audio_player_waveform_color_axis')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_axis')) : [0,0,0,0.3]; // array rgba
+ Waveform::$singlePhase = filter_var($settings->get('theme', 'audio_player_waveform_single_phase') ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom
+ Waveform::$singleAxis = filter_var($settings->get('theme', 'audio_player_waveform_single_axis') ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis
+ $height = !empty($settings->get('theme', 'audio_player_waveform_height')) && is_numeric(str_replace('px','',$settings->get('theme', 'audio_player_waveform_height'))) ? 2.2 * (int) str_replace('px','',$settings->get('theme', 'audio_player_waveform_height')) : null;
$wf = $waveform->getWaveform($temp_filename, 1600, $height ?? 180); // input: png filename returns boolean true/false, or 'base64' returns base64 string
}
diff --git a/app/sip_profiles/resources/classes/sip_profiles.php b/app/sip_profiles/resources/classes/sip_profiles.php
index c3439cd3ae..6357fbb780 100644
--- a/app/sip_profiles/resources/classes/sip_profiles.php
+++ b/app/sip_profiles/resources/classes/sip_profiles.php
@@ -34,9 +34,32 @@
const app_uuid = 'a6a7c4c5-340a-43ce-bcbc-2ed9bab8659d';
/**
- * declare private variables
+ * Set in the constructor. Must be a database object and cannot be null.
+ * @var database Database Object
*/
private $database;
+
+ /**
+ * Settings object set in the constructor. Must be a settings object and cannot be null.
+ * @var settings Settings Object
+ */
+ private $settings;
+
+ /**
+ * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
+ */
+ private $user_uuid;
+
+ /**
+ * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
+ */
+ private $domain_uuid;
+
+ /**
+ * declare private variables
+ */
private $permission_prefix;
private $list_page;
private $table;
@@ -52,7 +75,14 @@
/**
* called when the object is created
*/
- public function __construct() {
+ public function __construct(array $setting_array = []) {
+ //set domain and user UUIDs
+ $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? '';
+ $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? '';
+
+ //set objects
+ $this->database = $setting_array['database'] ?? database::new();
+ $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]);
//assign private variables
$this->permission_prefix = 'sip_profile_';
@@ -61,12 +91,6 @@
$this->uuid_prefix = 'sip_profile_';
$this->toggle_field = 'sip_profile_enabled';
$this->toggle_values = ['true','false'];
-
- //connect to the database
- if (empty($this->database)) {
- $this->database = database::new();
- }
-
}
/**
@@ -135,9 +159,10 @@
$p->delete('sip_profile_setting_delete', 'temp');
//delete the xml sip profile and directory
+ $switch_conf_dir = $this->settings->get('switch', 'conf');
foreach ($sip_profiles as $sip_profile_uuid => $sip_profile) {
- @unlink($_SESSION['switch']['conf']['dir']."/sip_profiles/".$sip_profile['name'].".xml");
- @unlink($_SESSION['switch']['conf']['dir']."/sip_profiles/".$sip_profile['name']);
+ @unlink($switch_conf_dir."/sip_profiles/".$sip_profile['name'].".xml");
+ @unlink($switch_conf_dir."/sip_profiles/".$sip_profile['name']);
}
//save the sip profile xml
diff --git a/app/sip_profiles/sip_profile_edit.php b/app/sip_profiles/sip_profile_edit.php
index 3912881541..9d5de6d718 100644
--- a/app/sip_profiles/sip_profile_edit.php
+++ b/app/sip_profiles/sip_profile_edit.php
@@ -171,7 +171,7 @@
else {
$sip_profile_domain_uuid = uuid();
}
- if (!empty($row["sip_profile_domain_alias"])) {
+ if (!empty($row["sip_profile_domain_name"])) {
$array['sip_profiles'][0]['sip_profile_domains'][$y]["sip_profile_uuid"] = $sip_profile_uuid;
$array['sip_profiles'][0]['sip_profile_domains'][$y]["sip_profile_domain_uuid"] = $sip_profile_domain_uuid;
$array['sip_profiles'][0]['sip_profile_domains'][$y]["sip_profile_domain_name"] = $row["sip_profile_domain_name"];
diff --git a/app/sip_profiles/sip_profiles.php b/app/sip_profiles/sip_profiles.php
index 56c90a7868..e21d63b9b4 100644
--- a/app/sip_profiles/sip_profiles.php
+++ b/app/sip_profiles/sip_profiles.php
@@ -102,7 +102,7 @@
$num_rows = $database->select($sql, $parameters ?? null, 'column');
//prepare to page the results
- $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50;
+ $rows_per_page = $settings->get('domain', 'paging', 50);
$param = $search ? "&search=".$search : null;
$page = !empty($_GET['page']) ? $_GET['page'] : 0;
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
@@ -189,9 +189,6 @@
$list_row_url = '';
if (permission_exists('sip_profile_edit')) {
$list_row_url = "sip_profile_edit.php?id=".urlencode($row['sip_profile_uuid']);
- if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) {
- $list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true';
- }
}
echo "
\n";
if (permission_exists('sip_profile_add') || permission_exists('sip_profile_edit') || permission_exists('sip_profile_delete')) {
@@ -241,4 +238,3 @@
require_once "resources/footer.php";
?>
-
diff --git a/app/sip_status/sip_status.php b/app/sip_status/sip_status.php
index 8e1f065d32..97a3d2e626 100644
--- a/app/sip_status/sip_status.php
+++ b/app/sip_status/sip_status.php
@@ -172,7 +172,7 @@
foreach ($xml->profile as $row) {
unset($list_row_url);
$profile_name = (string) $row->name;
- $list_row_url = is_uuid($sip_profiles[$profile_name]) && permission_exists('sip_profile_edit') ? PROJECT_PATH."/app/sip_profiles/sip_profile_edit.php?id=".$sip_profiles[$profile_name] : null;
+ $list_row_url = is_uuid($sip_profiles[$profile_name] ?? '') && permission_exists('sip_profile_edit') ? PROJECT_PATH."/app/sip_profiles/sip_profile_edit.php?id=".$sip_profiles[$profile_name] : null;
echo "
\n";
echo " ";
if ($list_row_url) {
diff --git a/app/sofia_global_settings/resources/classes/sofia_global_settings.php b/app/sofia_global_settings/resources/classes/sofia_global_settings.php
index ae18c4f790..5e5b62743d 100644
--- a/app/sofia_global_settings/resources/classes/sofia_global_settings.php
+++ b/app/sofia_global_settings/resources/classes/sofia_global_settings.php
@@ -39,6 +39,7 @@
* declare the variables
*/
private $database;
+
private $name;
private $table;
private $toggle_field;
@@ -46,10 +47,13 @@
private $description_field;
private $location;
- /**
+ /**
* called when the object is created
*/
- public function __construct() {
+ public function __construct(array $setting_array = []) {
+ //set objects
+ $this->database = $setting_array['database'] ?? database::new();
+
//assign the variables
$this->name = 'sofia_global_setting';
$this->table = 'sofia_global_settings';
@@ -57,11 +61,6 @@
$this->toggle_values = ['true','false'];
$this->description_field = 'global_setting_description';
$this->location = 'sofia_global_settings.php';
-
- //connect to the database
- if (empty($this->database)) {
- $this->database = database::new();
- }
}
/**
diff --git a/app/sofia_global_settings/sofia_global_settings.php b/app/sofia_global_settings/sofia_global_settings.php
index 2e864c2ee6..be4088deaa 100644
--- a/app/sofia_global_settings/sofia_global_settings.php
+++ b/app/sofia_global_settings/sofia_global_settings.php
@@ -210,7 +210,7 @@
$list_row_url = '';
if (permission_exists('sofia_global_setting_edit')) {
$list_row_url = "sofia_global_setting_edit.php?id=".urlencode($row['sofia_global_setting_uuid']);
- if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) {
+ if (!empty($row['domain_uuid']) && $row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) {
$list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true';
}
}
diff --git a/app/streams/resources/classes/streams.php b/app/streams/resources/classes/streams.php
index 09c11581de..cdabef3be0 100644
--- a/app/streams/resources/classes/streams.php
+++ b/app/streams/resources/classes/streams.php
@@ -33,11 +33,45 @@
const app_name = 'streams';
const app_uuid = 'ffde6287-aa18-41fc-9a38-076d292e0a38';
+ /**
+ * Set in the constructor. Must be a database object and cannot be null.
+ * @var database Database Object
+ */
+ private $database;
+
+ /**
+ * Settings object set in the constructor. Must be a settings object and cannot be null.
+ * @var settings Settings Object
+ */
+ private $settings;
+
+ /**
+ * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
+ */
+ private $user_uuid;
+
+ /**
+ * Username set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
+ */
+ private $username;
+
+ /**
+ * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
+ */
+ private $domain_uuid;
+
+ /**
+ * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
+ */
+ private $domain_name;
+
/**
* declare private variables
*/
-
- private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -48,7 +82,12 @@
/**
* called when the object is created
*/
- public function __construct() {
+ public function __construct(array $setting_array = []) {
+ //set domain and user UUIDs
+ $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? '';
+
+ //set objects
+ $this->database = $setting_array['database'] ?? database::new();
//assign private variables
$this->permission_prefix = 'stream_';
@@ -57,12 +96,6 @@
$this->uuid_prefix = 'stream_';
$this->toggle_field = 'stream_enabled';
$this->toggle_values = ['true','false'];
-
- //connect to the database
- if (empty($this->database)) {
- $this->database = database::new();
- }
-
}
/**
@@ -139,7 +172,7 @@
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
- $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
+ $parameters['domain_uuid'] = $this->domain_uuid;
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
@@ -207,7 +240,7 @@
$sql = "select * from v_".$this->table." ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
- $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
+ $parameters['domain_uuid'] = $this->domain_uuid;
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $x => $row) {
diff --git a/app/streams/streams.php b/app/streams/streams.php
index 795324c728..813c25bd46 100644
--- a/app/streams/streams.php
+++ b/app/streams/streams.php
@@ -115,7 +115,7 @@
unset($parameters);
//prepare to page the results
- $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50;
+ $rows_per_page = $settings->get('domain', 'paging', 50);
$param = "&search=".$search;
$param = ($show == 'all' && permission_exists('stream_all')) ? "&show=all" : null;
$page = isset($_GET['page']) ? $_GET['page'] : 0;
@@ -252,7 +252,7 @@
$list_row_url = '';
if (permission_exists('stream_edit')) {
$list_row_url = "stream_edit.php?id=".urlencode($row['stream_uuid']);
- if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) {
+ if (!empty($row['domain_uuid']) && $row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) {
$list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true';
}
}
diff --git a/app/switch/resources/classes/presence.php b/app/switch/resources/classes/presence.php
index c645f8eac4..ad0ac4cbbb 100644
--- a/app/switch/resources/classes/presence.php
+++ b/app/switch/resources/classes/presence.php
@@ -57,6 +57,7 @@
* show presence
*/
public function show() {
+ $array = [];
$json = event_socket::api('show calls as json');
$call_array = json_decode($json, true);
if (isset($call_array['rows'])) {
diff --git a/app/switch/resources/classes/ringbacks.php b/app/switch/resources/classes/ringbacks.php
index 6b6343268a..684ae10eb7 100644
--- a/app/switch/resources/classes/ringbacks.php
+++ b/app/switch/resources/classes/ringbacks.php
@@ -34,11 +34,46 @@
const app_uuid = 'b63db353-e1c6-4401-8f10-101a6ee73b74';
/**
- * declare public variables
+ * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
*/
public $domain_uuid;
+
+ /**
+ * declare public variables
+ */
public $ringtones_list;
+ /**
+ * Set in the constructor. Must be a database object and cannot be null.
+ * @var database Database Object
+ */
+ private $database;
+
+ /**
+ * Settings object set in the constructor. Must be a settings object and cannot be null.
+ * @var settings Settings Object
+ */
+ private $settings;
+
+ /**
+ * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
+ */
+ private $user_uuid;
+
+ /**
+ * Username set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
+ */
+ private $username;
+
+ /**
+ * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
+ */
+ private $domain_name;
+
/**
* declare private variables
*/
@@ -51,14 +86,15 @@
/**
* called when the object is created
*/
- public function __construct() {
- //set the domain_uuid
- $this->domain_uuid = $_SESSION['domain_uuid'];
+ public function __construct(array $setting_array = []) {
+ //set domain and user UUIDs
+ $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? '';
+ $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? '';
+ $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? '';
+ $this->username = $setting_array['username'] ?? $_SESSION['username'] ?? '';
- //connect to the database
- if (empty($this->database)) {
- $this->database = database::new();
- }
+ //set objects
+ $this->database = $setting_array['database'] ?? database::new();
//add multi-lingual support
$language = new text;
@@ -142,7 +178,7 @@
foreach($this->music_list as $row) {
$name = '';
if (!empty($row['domain_uuid'])) {
- $name = $row['domain_name'].'/';
+ $name = $row['domain_name'].'/';
}
$name .= $row['music_on_hold_name'];
if ($value == "local_stream://".$name) {
@@ -182,7 +218,7 @@
if ($previous_name != $row['music_on_hold_name']) {
$name = '';
if (!empty($row['domain_uuid'])) {
- $name = $row['domain_name'].'/';
+ $name = $row['domain_name'].'/';
}
$name .= $row['music_on_hold_name'];
$select .= " \n";
diff --git a/app/switch/resources/classes/switch_files.php b/app/switch/resources/classes/switch_files.php
index c98091a624..ae8416a3a5 100644
--- a/app/switch/resources/classes/switch_files.php
+++ b/app/switch/resources/classes/switch_files.php
@@ -29,11 +29,14 @@
*/
class switch_files {
- /**
+ private $config;
+
+ /**
* Called when the object is created
*/
- public function __construct() {
-
+ public function __construct(array $setting_array = []) {
+ //set objects
+ $this->config = $setting_array['config'] ?? config::load();
}
/**
@@ -55,9 +58,6 @@
*/
public function copy_scripts() {
- //include files
- require dirname(__DIR__, 4) . "/resources/require.php";
-
//get the source directory
if (file_exists('/usr/share/examples/fusionpbx/scripts')) {
$source_directory = '/usr/share/examples/fusionpbx/scripts';
@@ -73,8 +73,8 @@
}
//get the destination directory
- if (file_exists($conf['switch.scripts.dir'])) {
- $destination_directory = $conf['switch.scripts.dir'];
+ if (file_exists($this->config->get('switch.scripts.dir'))) {
+ $destination_directory = $this->config->get('switch.scripts.dir');
}
elseif (file_exists('/etc/freeswitch/scripts')) {
$destination_directory = '/etc/freeswitch/scripts';
@@ -110,9 +110,6 @@
*/
public function copy_languages() {
- //include files
- require dirname(__DIR__, 4) . "/resources/require.php";
-
//get the source directory
if (file_exists('/usr/share/examples/freeswitch/conf/languages')) {
$source_directory = '/usr/share/examples/fusionpbx/conf/languages';
@@ -128,8 +125,8 @@
}
//get the destination directory
- if (file_exists($conf['switch.scripts.dir'])) {
- $destination_directory = $conf['switch.conf.dir'].'/languages';
+ if (file_exists($this->config->get('switch.conf.dir').'/languages')) {
+ $destination_directory = $this->config->get('switch.conf.dir').'/languages';
}
elseif (file_exists('/etc/freeswitch/languages')) {
$destination_directory = '/usr/local/share/freeswitch/languages';
diff --git a/app/switch/resources/dashboard/switch_status.php b/app/switch/resources/dashboard/switch_status.php
index a18b5ab5cc..6a0e7628a9 100644
--- a/app/switch/resources/dashboard/switch_status.php
+++ b/app/switch/resources/dashboard/switch_status.php
@@ -15,7 +15,7 @@
//add multi-lingual support
$language = new text;
- $text = $language->get($_SESSION['domain']['language']['code'], 'app/switch');
+ $text = $language->get($settings->get('domain', 'language', 'en-us'), 'app/switch');
//switch status
echo "\n";
diff --git a/app/switch/sounds.php b/app/switch/sounds.php
index a054c901f3..c3f27ae3bd 100644
--- a/app/switch/sounds.php
+++ b/app/switch/sounds.php
@@ -47,14 +47,14 @@
if ($action == "download") {
//get first installed language (like en/us/callie)
- $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]);
}
@@ -64,7 +64,7 @@
//determine the path for sound file
$filename_parts = explode('/', str_replace('..', '', $_GET['filename']));
if (!is_array($filename_parts) || @sizeof($filename_parts) != 2) { exit; }
- $path = $_SESSION['switch']['sounds']['dir'].'/'.$language_path.'/'.$filename_parts[0].'/8000/';
+ $path = $settings->get('switch', 'sounds').'/'.$language_path.'/'.$filename_parts[0].'/8000/';
//set sound filename
$sound_filename = $filename_parts[1];
diff --git a/app/system/resources/dashboard/system_counts.php b/app/system/resources/dashboard/system_counts.php
index 2caf130121..527bc3f5f8 100644
--- a/app/system/resources/dashboard/system_counts.php
+++ b/app/system/resources/dashboard/system_counts.php
@@ -15,7 +15,7 @@
//add multi-lingual support
$language = new text;
- $text = $language->get($_SESSION['domain']['language']['code'], 'core/user_settings');
+ $text = $language->get($settings->get('domain', 'language', 'en-us'), 'core/user_settings');
//system counts
//domains
diff --git a/app/system/resources/dashboard/system_cpu_status.php b/app/system/resources/dashboard/system_cpu_status.php
index 36a0d59bae..3da68be77d 100644
--- a/app/system/resources/dashboard/system_cpu_status.php
+++ b/app/system/resources/dashboard/system_cpu_status.php
@@ -15,7 +15,7 @@
//add multi-lingual support
$language = new text;
- $text = $language->get($_SESSION['domain']['language']['code'], 'app/system');
+ $text = $language->get($settings->get('domain', 'language', 'en-us'), 'app/system');
//system cpu status
echo " \n";
diff --git a/app/system/resources/dashboard/system_disk_usage.php b/app/system/resources/dashboard/system_disk_usage.php
index 9b72700998..90fffdd3b3 100644
--- a/app/system/resources/dashboard/system_disk_usage.php
+++ b/app/system/resources/dashboard/system_disk_usage.php
@@ -15,7 +15,7 @@
//add multi-lingual support
$language = new text;
- $text = $language->get($_SESSION['domain']['language']['code'], 'core/user_settings');
+ $text = $language->get($settings->get('domain', 'language', 'en-us'), 'core/user_settings');
//system status
echo " \n";
diff --git a/app/system/resources/dashboard/system_network_status.php b/app/system/resources/dashboard/system_network_status.php
index 999f0a3aa6..6deab09644 100644
--- a/app/system/resources/dashboard/system_network_status.php
+++ b/app/system/resources/dashboard/system_network_status.php
@@ -14,7 +14,7 @@
//add multi-lingual support
$language = new text;
- $text = $language->get($_SESSION['domain']['language']['code'], 'app/system');
+ $text = $language->get($settings->get('domain', 'language', 'en-us'), 'app/system');
//set the row style class names
$c = 0;
diff --git a/app/system/resources/dashboard/system_status.php b/app/system/resources/dashboard/system_status.php
index de7aa06ff0..26d182692b 100644
--- a/app/system/resources/dashboard/system_status.php
+++ b/app/system/resources/dashboard/system_status.php
@@ -15,7 +15,7 @@
//add multi-lingual support
$language = new text;
- $text = $language->get($_SESSION['domain']['language']['code'], 'core/user_settings');
+ $text = $language->get($settings->get('domain', 'language', 'en-us'), 'core/user_settings');
//system status
echo " \n";
@@ -222,7 +222,7 @@
//pbx version
echo " \n";
- echo "| ".(isset($_SESSION['theme']['title']['text'])?$_SESSION['theme']['title']['text']:'FusionPBX')." | \n";
+ echo "".$settings->get('theme', 'title', 'FusionPBX')." | \n";
echo "".software::version()." | \n";
echo " \n";
$c = ($c) ? 0 : 1;
diff --git a/app/system/system.php b/app/system/system.php
index f78e45c0c8..fb34ddd0ff 100644
--- a/app/system/system.php
+++ b/app/system/system.php
@@ -47,11 +47,11 @@ Con Portions created by the Initial Developer are Copyright (C) 2008-2025
//load editor preferences/defaults
if (permission_exists("system_view_support")) {
- $setting_size = !empty($_SESSION["editor"]["font_size"]["text"]) ? $_SESSION["editor"]["font_size"]["text"] : '12px';
- $setting_theme = !empty($_SESSION["editor"]["theme"]["text"]) ? $_SESSION["editor"]["theme"]["text"] : 'cobalt';
- $setting_invisibles = isset($_SESSION['editor']['invisibles']['text']) ? $_SESSION['editor']['invisibles']["text"] : 'false';
- $setting_indenting = isset($_SESSION['editor']['indent_guides']['text']) ? $_SESSION['editor']['indent_guides']["text"]: 'false';
- $setting_numbering = isset($_SESSION['editor']['line_numbers']['text']) ? $_SESSION['editor']['line_numbers']["text"] : 'true';
+ $setting_size = !empty($settings->get('editor', 'font_size')) ? $settings->get('editor', 'font_size') : '12px';
+ $setting_theme = !empty($settings->get('editor', 'theme')) ? $settings->get('editor', 'theme') : 'cobalt';
+ $setting_invisibles = $settings->get('editor', 'invisibles', 'false');
+ $setting_indenting = $settings->get('editor', 'indent_guides', 'false');
+ $setting_numbering = $settings->get('editor', 'line_numbers', 'true');
}
//additional includes
diff --git a/app/time_conditions/resources/classes/time_conditions.php b/app/time_conditions/resources/classes/time_conditions.php
index e6c83d5404..c6038bc29c 100644
--- a/app/time_conditions/resources/classes/time_conditions.php
+++ b/app/time_conditions/resources/classes/time_conditions.php
@@ -33,12 +33,45 @@
const app_name = 'time_conditions';
const app_uuid = '4b821450-926b-175a-af93-a03c441818b1';
+ /**
+ * Set in the constructor. Must be a database object and cannot be null.
+ * @var database Database Object
+ */
+ private $database;
+
+ /**
+ * Settings object set in the constructor. Must be a settings object and cannot be null.
+ * @var settings Settings Object
+ */
+ private $settings;
+
+ /**
+ * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
+ */
+ private $user_uuid;
+
+ /**
+ * Username set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
+ */
+ private $username;
+
+ /**
+ * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
+ */
+ private $domain_uuid;
+
+ /**
+ * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
+ */
+ private $domain_name;
+
/**
* declare public/private properties
*/
- private $app_name;
- private $app_uuid;
- private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -46,8 +79,13 @@
private $toggle_field;
private $toggle_values;
- //class constructor
- public function __construct() {
+ public function __construct(array $setting_array = []) {
+ //set domain and user UUIDs
+ $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? '';
+
+ //set objects
+ $this->database = $setting_array['database'] ?? database::new();
+
//set the default value
$this->dialplan_global = false;
@@ -58,11 +96,6 @@
$this->uuid_prefix = 'dialplan_';
$this->toggle_field = 'dialplan_enabled';
$this->toggle_values = ['true','false'];
-
- //connect to the database
- if (empty($this->database)) {
- $this->database = database::new();
- }
}
/**
@@ -174,7 +207,7 @@
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, dialplan_context from v_".$this->table." ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
- $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
+ $parameters['domain_uuid'] = $this->domain_uuid;
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
diff --git a/app/time_conditions/time_condition_edit.php b/app/time_conditions/time_condition_edit.php
index 4ae778df09..e19d2f9e97 100644
--- a/app/time_conditions/time_condition_edit.php
+++ b/app/time_conditions/time_condition_edit.php
@@ -45,7 +45,7 @@
$destination = new destinations;
//load available presets
- $preset_region = "preset_".$_SESSION['time_conditions']['region']['text'];
+ $preset_region = "preset_".$settings->get('time_conditions', 'region');
if (is_array($_SESSION['time_conditions'][$preset_region])) {
foreach ($_SESSION['time_conditions'][$preset_region] as $json) {
$json_array = json_decode($json, true);
@@ -809,7 +809,7 @@
case 'hour': //hours of day
get('domain', 'time_format') == "24h") {
for ($h = 0; $h <= 23; $h++) {
echo "sel_start.options[sel_start.options.length] = new Option(".$h.", ".$h.");\n";
@@ -828,7 +828,7 @@
case 'time-of-day': //time of day
get('domain', 'time_format') == "24h") {
for ($h = 0; $h <= 23; $h++) {
for ($m = 0; $m <= 59; $m++) {
@@ -986,7 +986,7 @@ echo " \n";
echo " ".$text['label-extension']."\n";
echo " | \n";
echo " \n";
-echo " \n";
+echo " get('time_conditions', 'extension_range') ?? '')."\">\n";
echo " \n";
echo " ".$text['description-extension']." \n";
echo " | \n";
diff --git a/app/vars/resources/classes/vars.php b/app/vars/resources/classes/vars.php
index a5292e7255..3456c6814e 100644
--- a/app/vars/resources/classes/vars.php
+++ b/app/vars/resources/classes/vars.php
@@ -48,7 +48,9 @@
/**
* called when the object is created
*/
- public function __construct() {
+ public function __construct(array $setting_array = []) {
+ //set objects
+ $this->database = $setting_array['database'] ?? database::new();
//assign private variables
$this->permission_prefix = 'var_';
@@ -57,11 +59,6 @@
$this->uuid_prefix = 'var_';
$this->toggle_field = 'var_enabled';
$this->toggle_values = ['true','false'];
-
- //connect to the database
- if (empty($this->database)) {
- $this->database = database::new();
- }
}
/**
diff --git a/app/vars/vars.php b/app/vars/vars.php
index 297b358914..e7506894a4 100644
--- a/app/vars/vars.php
+++ b/app/vars/vars.php
@@ -222,20 +222,18 @@
$previous_category = '';
foreach ($vars as $x => $row) {
//write category and column headings
- if ($previous_category != $row["var_category"]) {
- echo " \n";
- echo "\n";
- echo ($previous_category != '' ? ' ' : null)."".$row["var_category"]."";
- echo " | \n";
- echo " \n";
- write_header($row["var_category"]);
- }
+ if ($previous_category != $row["var_category"]) {
+ echo " \n";
+ echo "\n";
+ echo ($previous_category != '' ? ' ' : null)."".$row["var_category"]."";
+ echo " | \n";
+ echo " \n";
+ write_header($row["var_category"]);
+ }
+
$list_row_url = '';
if (permission_exists('var_edit')) {
$list_row_url = "var_edit.php?id=".urlencode($row['var_uuid']);
- if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) {
- $list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true';
- }
}
echo " \n";
if (permission_exists('var_add') || permission_exists('var_edit') || permission_exists('var_delete')) {
@@ -292,4 +290,4 @@
//include the footer
require_once "resources/footer.php";
-?>
\ No newline at end of file
+?>
diff --git a/app/voicemail_greetings/resources/classes/voicemail_greetings.php b/app/voicemail_greetings/resources/classes/voicemail_greetings.php
index 58d507e94b..e15991e8cc 100644
--- a/app/voicemail_greetings/resources/classes/voicemail_greetings.php
+++ b/app/voicemail_greetings/resources/classes/voicemail_greetings.php
@@ -33,11 +33,39 @@
const app_name = 'voicemail_greetings';
const app_uuid = 'e4b4fbee-9e4d-8e46-3810-91ba663db0c2';
+ /**
+ * Set in the constructor. Must be a database object and cannot be null.
+ * @var database Database Object
+ */
+ private $database;
+
+ /**
+ * Settings object set in the constructor. Must be a settings object and cannot be null.
+ * @var settings Settings Object
+ */
+ private $settings;
+
+ /**
+ * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
+ */
+ private $user_uuid;
+
+ /**
+ * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
+ */
+ private $domain_uuid;
+
+ /**
+ * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
+ */
+ private $domain_name;
+
/**
* declare private variables
*/
-
- private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -51,7 +79,15 @@
/**
* called when the object is created
*/
- public function __construct() {
+ public function __construct(array $setting_array = []) {
+ //set domain and user UUIDs
+ $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? '';
+ $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? '';
+ $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? '';
+
+ //set objects
+ $this->database = $setting_array['database'] ?? database::new();
+ $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]);
//assign private variables
$this->permission_prefix = 'voicemail_greeting_';
@@ -63,12 +99,6 @@
}
$this->table = 'voicemail_greetings';
$this->uuid_prefix = 'voicemail_greeting_';
-
- //connect to the database
- if (empty($this->database)) {
- $this->database = database::new();
- }
-
}
/**
@@ -120,7 +150,7 @@
}
//set the greeting directory
- $greeting_directory = $_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name'].'/'.$this->voicemail_id;
+ $greeting_directory = $this->settings->get('switch', 'storage').'/voicemail/default/'.$this->domain_name.'/'.$this->voicemail_id;
//loop through greetings
if (is_array($greeting_filenames) && @sizeof($greeting_filenames) != 0) {
@@ -130,7 +160,7 @@
@unlink($greeting_directory.'/'.$greeting_filename);
//build the delete array
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $voicemail_greeting_uuid;
- $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
+ $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid;
$x++;
}
}
@@ -143,7 +173,7 @@
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and voicemail_id = :voicemail_id ";
$sql .= "and greeting_id = :greeting_id ";
- $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
+ $parameters['domain_uuid'] = $this->domain_uuid;
$parameters['voicemail_id'] = $voicemail_id;
$parameters['greeting_id'] = $greeting_id;
$this->database->execute($sql, $parameters);
diff --git a/app/voicemail_greetings/voicemail_greetings.php b/app/voicemail_greetings/voicemail_greetings.php
index 09d4a9768a..5fa2cbbb68 100644
--- a/app/voicemail_greetings/voicemail_greetings.php
+++ b/app/voicemail_greetings/voicemail_greetings.php
@@ -82,7 +82,7 @@
unset($sql, $parameters);
//define greeting directory
- $greeting_dir = $_SESSION['switch']['voicemail']['dir'].'/default/'.$_SESSION['domains'][$domain_uuid]['domain_name'].'/'.$voicemail_id;
+ $greeting_dir = $settings->get('switch', 'voicemail').'/default/'.$_SESSION['domains'][$domain_uuid]['domain_name'].'/'.$voicemail_id;
//download the greeting
if (!empty($_GET['a']) && $_GET['a'] == "download" && (permission_exists('voicemail_greeting_play') || permission_exists('voicemail_greeting_download'))) {
@@ -102,7 +102,7 @@
if (is_array($row) && @sizeof($row) != 0) {
$greeting_filename = $row['greeting_filename'];
$greeting_id = $row['greeting_id'];
- if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64' && $row['greeting_base64'] != '') {
+ if (!empty($settings->get('voicemail', 'storage_type')) && $settings->get('voicemail', 'storage_type') == 'base64' && $row['greeting_base64'] != '') {
$greeting_decoded = base64_decode($row['greeting_base64']);
file_put_contents($greeting_dir.'/'.$greeting_filename, $greeting_decoded);
}
@@ -142,7 +142,7 @@
}
//if base64, remove temp greeting file (if not currently selected greeting)
- if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64' && $row['greeting_base64'] != '') {
+ if (!empty($settings->get('voicemail', 'storage_type')) && $settings->get('voicemail', 'storage_type') == 'base64' && $row['greeting_base64'] != '') {
if ($greeting_id != $selected_greeting_id) {
@unlink($greeting_dir.'/'.$greeting_filename);
}
@@ -203,7 +203,7 @@
$array['voicemail_greetings'][$x]['greeting_name'] = $text['label-greeting'].' '.$greeting_id;
$array['voicemail_greetings'][$x]['greeting_filename'] = $greeting_file_name;
$array['voicemail_greetings'][$x]['greeting_description'] = '';
- if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64') {
+ if (!empty($settings->get('voicemail', 'storage_type')) && $settings->get('voicemail', 'storage_type') == 'base64') {
$array['voicemail_greetings'][$x]['greeting_base64'] = base64_encode(file_get_contents($greeting_dir.'/'.$file_name));
}
@@ -296,7 +296,7 @@
}
//get the greetings list
- if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64') {
+ if (!empty($settings->get('voicemail', 'storage_type')) && $settings->get('voicemail', 'storage_type') == 'base64') {
switch ($db_type) {
case 'pgsql': $sql_file_size = ", length(decode(greeting_base64,'base64')) as greeting_size "; break;
case 'mysql': $sql_file_size = ", length(from_base64(greeting_base64)) as greeting_size "; break;
@@ -393,7 +393,7 @@
$col_count++;
echo th_order_by('greeting_name', $text['label-name'], $order_by, $order, null, null, "id=".urlencode($voicemail_id));
$col_count++;
- if (empty($_SESSION['voicemail']['storage_type']['text']) || $_SESSION['voicemail']['storage_type']['text'] != 'base64') {
+ if (empty($settings->get('voicemail', 'storage_type')) || $settings->get('voicemail', 'storage_type') != 'base64') {
echo th_order_by('greeting_filename', $text['label-filename'], $order_by, $order, null, "class='hide-sm-dn'", "id=".urlencode($voicemail_id));
$col_count++;
}
@@ -403,7 +403,7 @@
}
echo "| ".$text['label-size']." | \n";
$col_count++;
- if (empty($_SESSION['voicemail']['storage_type']['text']) || $_SESSION['voicemail']['storage_type']['text'] != 'base64') {
+ if (empty($settings->get('voicemail', 'storage_type')) || $settings->get('voicemail', 'storage_type') != 'base64') {
echo "".$text['label-uploaded']." | \n";
$col_count++;
}
@@ -449,7 +449,7 @@
echo escape($row['greeting_name']);
}
echo " \n";
- if (empty($_SESSION['voicemail']['storage_type']['text']) || $_SESSION['voicemail']['storage_type']['text'] != 'base64') {
+ if (empty($settings->get('voicemail', 'storage_type')) || $settings->get('voicemail', 'storage_type') != 'base64') {
echo " ".escape($row['greeting_filename'])." | \n";
}
if (permission_exists('voicemail_greeting_play') || permission_exists('voicemail_greeting_download')) {
@@ -471,13 +471,19 @@
}
echo " \n";
}
- if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64') {
+
+ if (!empty($settings->get('voicemail', 'storage_type')) && $settings->get('voicemail', 'storage_type') == 'base64') {
$file_size = byte_convert($row['greeting_size']);
echo " ".$file_size." | \n";
}
else {
- $file_size = byte_convert(filesize($greeting_dir.'/'.$row['greeting_filename']));
- $file_date = date("M d, Y H:i:s", filemtime($greeting_dir.'/'.$row['greeting_filename']));
+ if (file_exists($greeting_dir.'/'.$row['greeting_filename'])) {
+ $file_size = byte_convert(filesize($greeting_dir.'/'.$row['greeting_filename']));
+ $file_date = date("M d, Y H:i:s", filemtime($greeting_dir.'/'.$row['greeting_filename']));
+ } else {
+ $file_size = 0;
+ $file_date = '';
+ }
echo " ".$file_size." | \n";
echo " ".$file_date." | \n";
}
diff --git a/app/voicemail_greetings/waveform.php b/app/voicemail_greetings/waveform.php
index 6da66eb002..6fb95642c2 100644
--- a/app/voicemail_greetings/waveform.php
+++ b/app/voicemail_greetings/waveform.php
@@ -58,7 +58,7 @@
unset($sql, $parameters);
//define greeting directory
- $greeting_dir = $_SESSION['switch']['voicemail']['dir'].'/default/'.$_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name'].'/'.$voicemail_id;
+ $greeting_dir = $settings->get('switch', 'voicemail').'/default/'.$_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name'].'/'.$voicemail_id;
//get voicemail greeting details from db
$sql = "select greeting_filename, greeting_base64, greeting_id ";
@@ -71,7 +71,7 @@
if (!empty($row) && is_array($row) && @sizeof($row) != 0) {
$greeting_filename = $row['greeting_filename'];
$greeting_id = $row['greeting_id'];
- if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64' && !empty($row['greeting_base64'])) {
+ if (!empty($settings->get('voicemail', 'storage_type')) && $settings->get('voicemail', 'storage_type') == 'base64' && !empty($row['greeting_base64'])) {
$greeting_decoded = base64_decode($row['greeting_base64']);
file_put_contents($greeting_dir.'/'.$greeting_filename, $greeting_decoded);
}
@@ -96,13 +96,13 @@
$waveform = new Waveform($full_file_path);
Waveform::$linesPerPixel = 1; // default: 8
Waveform::$samplesPerLine = 512; // default: 512
- Waveform::$colorA = !empty($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color
- Waveform::$colorB = !empty($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color
- Waveform::$backgroundColor = !empty($_SESSION['theme']['audio_player_waveform_color_background']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_background']['text']) : [0,0,0,0]; // array rgba, default: transparent
- Waveform::$axisColor = !empty($_SESSION['theme']['audio_player_waveform_color_axis']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_axis']['text']) : [0,0,0,0.3]; // array rgba
- Waveform::$singlePhase = filter_var($_SESSION['theme']['audio_player_waveform_single_phase']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom
- Waveform::$singleAxis = filter_var($_SESSION['theme']['audio_player_waveform_single_axis']['boolean'] ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis
- $height = !empty($_SESSION['theme']['audio_player_waveform_height']['text']) && is_numeric(str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text'])) ? 2.2 * (int) str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text']) : null;
+ Waveform::$colorA = !empty($settings->get('theme', 'audio_player_waveform_color_a_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_a_leg')) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color
+ Waveform::$colorB = !empty($settings->get('theme', 'audio_player_waveform_color_b_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_b_leg')) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color
+ Waveform::$backgroundColor = !empty($settings->get('theme', 'audio_player_waveform_color_background')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_background')) : [0,0,0,0]; // array rgba, default: transparent
+ Waveform::$axisColor = !empty($settings->get('theme', 'audio_player_waveform_color_axis')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_axis')) : [0,0,0,0.3]; // array rgba
+ Waveform::$singlePhase = filter_var($settings->get('theme', 'audio_player_waveform_single_phase') ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom
+ Waveform::$singleAxis = filter_var($settings->get('theme', 'audio_player_waveform_single_axis') ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis
+ $height = !empty($settings->get('theme', 'audio_player_waveform_height')) && is_numeric(str_replace('px','',$settings->get('theme', 'audio_player_waveform_height'))) ? 2.2 * (int) str_replace('px','',$settings->get('theme', 'audio_player_waveform_height')) : null;
$wf = $waveform->getWaveform($greeting_dir.'/'.$temp_filename, 1600, $height ?? 180); // input: png filename returns boolean true/false, or 'base64' returns base64 string
}
@@ -129,7 +129,7 @@
}
//if base64, remove temp file
- if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64' && !empty($row['greeting_base64'])) {
+ if (!empty($settings->get('voicemail', 'storage_type')) && $settings->get('voicemail', 'storage_type') == 'base64' && !empty($row['greeting_base64'])) {
if ($greeting_id != $selected_greeting_id) {
@unlink($greeting_dir.'/'.$greeting_filename);
}
diff --git a/app/voicemails/resources/classes/voicemail.php b/app/voicemails/resources/classes/voicemail.php
index 2f85ad3534..4be6d99a87 100644
--- a/app/voicemails/resources/classes/voicemail.php
+++ b/app/voicemails/resources/classes/voicemail.php
@@ -34,29 +34,34 @@
const app_uuid = 'b523c2d2-64cd-46f1-9520-ca4b4098e044';
/**
- * declare public variables
- */
+ * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
+ */
public $domain_uuid;
+
+ /**
+ * Domain name set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
+ */
public $domain_name;
+
+ /**
+ * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
+ */
+ public $user_uuid;
+
+ /**
+ * declare additional public variables
+ */
public $voicemail_uuid;
public $voicemail_id;
public $voicemail_message_uuid;
- public $user_uuid;
public $order_by;
public $order;
public $offset;
public $type;
- /**
- * declare private variables
- */
- private $permission_prefix;
- private $list_page;
- private $table;
- private $uuid_prefix;
- private $toggle_field;
- private $toggle_values;
-
/**
* Internal array structure that is populated from the database
* @var array Array of settings loaded from Default Settings
@@ -69,36 +74,32 @@
*/
private $database;
- public function __construct(array $params = []) {
+ /**
+ * Username set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
+ */
+ private $username;
- //set the domain_uuid if not provided
- if (!empty($params['domain_uuid']) && is_uuid($params['domain_uuid'])) {
- $this->domain_uuid = $params['domain_uuid'];
- } else {
- $this->domain_uuid = $_SESSION['domain_uuid'] ?? '';
- }
+ /**
+ * declare private variables
+ */
+ private $permission_prefix;
+ private $list_page;
+ private $table;
+ private $uuid_prefix;
+ private $toggle_field;
+ private $toggle_values;
- //set the user_uuid if not provided
- if (!empty($params['user_uuid']) && is_uuid($params['user_uuid'])) {
- $this->user_uuid = $params['user_uuid'];
- } else {
- $this->user_uuid = $_SESSION['user_uuid'] ?? '';
- }
+ public function __construct(array $setting_array = []) {
+ //set domain and user UUIDs
+ $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? '';
+ $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? '';
+ $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? '';
+ $this->username = $setting_array['username'] ?? $_SESSION['username'] ?? '';
- //database connection
- if (empty($params['database'])) {
- $this->database = database::new();
- } else {
- $this->database = $params['database'];
- }
-
- //assign the settings object
- if (empty($params['settings'])) {
- $this->settings = new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]);
- }
- else {
- $this->settings = $params['settings'];
- }
+ //set objects
+ $this->database = $setting_array['database'] ?? database::new();
+ $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]);
//assign private variables
$this->permission_prefix = 'voicemail_';
@@ -317,7 +318,7 @@
if (is_array($result)) {
foreach ($result as $i => $row) {
//set the greeting directory
- $path = $this->settings->get('switch', 'voicemail', '/var/lib/freeswitch/storage').'/default/'.$_SESSION['domain_name'].'/'.$row['voicemail_id'];
+ $path = $this->settings->get('switch', 'voicemail', '/var/lib/freeswitch/storage').'/default/'.$this->domain_name.'/'.$row['voicemail_id'];
if (file_exists($path.'/msg_'.$row['voicemail_message_uuid'].'.wav')) {
$result[$i]['file_path'] = $path.'/msg_'.$row['voicemail_message_uuid'].'.wav';
}
@@ -387,7 +388,7 @@
//delete voicemail message recording and greeting files
if (is_numeric($voicemail_id)) {
- $file_path = $_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$voicemail_id;
+ $file_path = $this->settings->get('switch', 'voicemail')."/default/".$this->domain_name."/".$voicemail_id;
foreach (glob($file_path."/*.*") as $file_name) {
@unlink($file_name);
}
@@ -658,7 +659,7 @@
$esl = event_socket::create();
if ($esl->is_connected()) {
- $switch_cmd = "luarun app.lua voicemail mwi ".$this->voicemail_id."@".$_SESSION['domain_name'];
+ $switch_cmd = "luarun app.lua voicemail mwi ".$this->voicemail_id."@".$this->domain_name;
$switch_result = event_socket::api($switch_cmd);
}
}
@@ -678,7 +679,7 @@
}
//delete the recording
- $file_path = $_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$this->voicemail_id;
+ $file_path = $this->settings->get('switch', 'voicemail')."/default/".$this->domain_name."/".$this->voicemail_id;
if (is_uuid($this->voicemail_message_uuid)) {
foreach (glob($file_path."/intro_msg_".$this->voicemail_message_uuid.".*") as $file_name) {
unlink($file_name);
@@ -1032,7 +1033,7 @@
unset($sql, $parameters);
//define voicemail message file path
- $voicemail_message_path = $switch_voicemail.'/default/'.$_SESSION['domain_name'].'/'.$this->voicemail_id;
+ $voicemail_message_path = $switch_voicemail.'/default/'.$this->domain_name.'/'.$this->voicemail_id;
//determine voicemail message file properties (decode if base64)
if (
@@ -1143,9 +1144,7 @@
public function message_intro_download(string $domain_name = '') {
//check domain name
- if (empty($domain_name)) {
- $domain_name = $_SESSION['domain_name'] ?? '';
- }
+ $domain_name = $this->domain_name;
//check if for valid input
if (!is_numeric($this->voicemail_id)
@@ -1251,9 +1250,7 @@
public function message_download(string $domain_name = '') {
//check domain name
- if (empty($domain_name)) {
- $domain_name = $_SESSION['domain_name'] ?? '';
- }
+ $domain_name = $this->domain_name ?? '';
//check if for valid input
if (!is_numeric($this->voicemail_id)
diff --git a/app/voicemails/resources/dashboard/voicemails.php b/app/voicemails/resources/dashboard/voicemails.php
index 3a6140a152..65c4d76933 100644
--- a/app/voicemails/resources/dashboard/voicemails.php
+++ b/app/voicemails/resources/dashboard/voicemails.php
@@ -15,10 +15,10 @@
//add multi-lingual support
$language = new text;
- $text = $language->get($_SESSION['domain']['language']['code'], 'core/user_settings');
+ $text = $language->get($settings->get('domain', 'language', 'en-us'), 'core/user_settings');
//used for missed and recent calls
- $theme_image_path = $_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/";
+ $theme_image_path = $_SERVER["DOCUMENT_ROOT"]."/themes/".$settings->get('domain', 'template')."/images/";
//voicemail
echo "\n";
diff --git a/app/voicemails/voicemail_edit.php b/app/voicemails/voicemail_edit.php
index 0d22b4e339..d339d2b499 100644
--- a/app/voicemails/voicemail_edit.php
+++ b/app/voicemails/voicemail_edit.php
@@ -417,7 +417,7 @@
if (!empty($voicemail_options)) {
foreach ($voicemail_options as $x => $field) {
$voicemail_option_param = $field['voicemail_option_param'];
- if (empty(trim($voicemail_option_param))) {
+ if (empty(trim($voicemail_option_param ?? ''))) {
$voicemail_option_param = $field['voicemail_option_action'];
}
$voicemail_option_param = str_replace("menu-", "", $voicemail_option_param);
@@ -1014,4 +1014,4 @@
//include the footer
require_once "resources/footer.php";
-?>
\ No newline at end of file
+?>
diff --git a/app/voicemails/voicemail_messages.php b/app/voicemails/voicemail_messages.php
index 4ee6e3bd40..24d6c30704 100644
--- a/app/voicemails/voicemail_messages.php
+++ b/app/voicemails/voicemail_messages.php
@@ -279,7 +279,7 @@
$total_rows = $num_rows;
//prepare to page the results
- $rows_per_page = $_SESSION['domain']['paging']['numeric'] != '' ? $_SESSION['domain']['paging']['numeric'] : 50;
+ $rows_per_page = $settings->get('domain', 'paging') != '' ? $settings->get('domain', 'paging') : 50;
$page = empty($_GET['page']) ? 0 : $_GET['page'];
$param = 'id='.urlencode($_REQUEST['id']).'&back='.$_SESSION['back'][$_SERVER['PHP_SELF']];
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
@@ -417,7 +417,7 @@
$col_count++;
echo th_order_by('message_length', $text['label-message_length'], $order_by, $order, null, "class='hide-xs right pct-15'");
$col_count++;
- if (empty($_SESSION['voicemail']['storage_type']['text']) || $_SESSION['voicemail']['storage_type']['text'] != 'base64') {
+ if (empty($settings->get('voicemail', 'storage_type')) || $settings->get('voicemail', 'storage_type') != 'base64') {
echo " ".$text['label-message_size']." | \n";
$col_count++;
}
@@ -448,9 +448,9 @@
echo " ";
echo "";
if (
- ($_SESSION['voicemail']['storage_type']['text'] == 'base64' && !empty($row['message_intro_base64'])) ||
- file_exists($_SESSION['switch']['voicemail']['dir'].'/default/'.$_SESSION['domain_name'].'/'.$field['voicemail_id'].'/intro_'.$row['voicemail_message_uuid'].'.wav') ||
- file_exists($_SESSION['switch']['voicemail']['dir'].'/default/'.$_SESSION['domain_name'].'/'.$field['voicemail_id'].'/intro_'.$row['voicemail_message_uuid'].'.mp3')
+ ($settings->get('voicemail', 'storage_type') == 'base64' && !empty($row['message_intro_base64'])) ||
+ file_exists($settings->get('switch', 'voicemail').'/default/'.$_SESSION['domain_name'].'/'.$field['voicemail_id'].'/intro_'.$row['voicemail_message_uuid'].'.wav') ||
+ file_exists($settings->get('switch', 'voicemail').'/default/'.$_SESSION['domain_name'].'/'.$field['voicemail_id'].'/intro_'.$row['voicemail_message_uuid'].'.mp3')
) {
echo "";
echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'].' '.$text['label-introduction'],'icon'=>$settings->get('theme', 'button_icon_comment'),'id'=>'recording_button_intro_'.escape($row['voicemail_message_uuid']),'onclick'=>"recording_play('intro_".escape($row['voicemail_message_uuid'])."','".$row['voicemail_id'].'|'.$row['voicemail_uuid']."','message_intro');"]);
@@ -462,7 +462,7 @@
}
echo " | \n";
echo " ".escape($row['message_length_label'])." | \n";
- if (empty($_SESSION['voicemail']['storage_type']['text']) || $_SESSION['voicemail']['storage_type']['text'] != 'base64') {
+ if (empty($settings->get('voicemail', 'storage_type')) || $settings->get('voicemail', 'storage_type') != 'base64') {
echo " ".escape($row['file_size_label'])." | \n";
}
echo " \n";
diff --git a/app/voicemails/voicemail_name.php b/app/voicemails/voicemail_name.php
index 237c7a273f..ee005fd694 100644
--- a/app/voicemails/voicemail_name.php
+++ b/app/voicemails/voicemail_name.php
@@ -48,8 +48,8 @@
}
//define name recording directory
- if (!empty($_SESSION['switch']['storage']['dir'])) {
- $recording_dir = $_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domains'][$domain_uuid]['domain_name'].'/'.$voicemail_id;
+ if (!empty($settings->get('switch', 'storage'))) {
+ $recording_dir = $settings->get('switch', 'storage').'/voicemail/default/'.$_SESSION['domains'][$domain_uuid]['domain_name'].'/'.$voicemail_id;
}
//download the name recording
diff --git a/app/voicemails/waveform.php b/app/voicemails/waveform.php
index 557aa8ca68..14131e50ec 100644
--- a/app/voicemails/waveform.php
+++ b/app/voicemails/waveform.php
@@ -59,15 +59,15 @@
unset($data);
//set source folder path
- $path = $_SESSION['switch']['voicemail']['dir'].'/default/'.$_SESSION['domain_name'].'/'.$voicemail_id;
+ $path = $settings->get('switch', 'voicemail').'/default/'.$_SESSION['domain_name'].'/'.$voicemail_id;
//prepare base64 content from db, if enabled
if (
is_numeric($voicemail_id) &&
is_uuid($voicemail_uuid) &&
is_uuid($_GET['id']) &&
- !empty($_SESSION['voicemail']['storage_type']['text']) &&
- $_SESSION['voicemail']['storage_type']['text'] == 'base64'
+ !empty($settings->get('voicemail', 'storage_type')) &&
+ $settings->get('voicemail', 'storage_type') == 'base64'
) {
$sql = "select message_base64 ";
@@ -152,9 +152,9 @@
!empty($_GET['data']) &&
is_numeric($_GET['data']) &&
extension_assigned($_GET['data']) &&
- !empty($_SESSION['switch']['storage']['dir'])
+ !empty($settings->get('switch', 'storage'))
) {
- $full_file_path = $_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name'].'/'.$_GET['data'].'/recorded_name.wav';
+ $full_file_path = $settings->get('switch', 'storage').'/voicemail/default/'.$_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name'].'/'.$_GET['data'].'/recorded_name.wav';
}
break;
@@ -176,7 +176,7 @@
unset($sql, $parameters);
//define greeting directory
- $greeting_dir = $_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name'].'/'.$voicemail_id;
+ $greeting_dir = $settings->get('switch', 'storage').'/voicemail/default/'.$_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name'].'/'.$voicemail_id;
//get voicemail greeting details from db
$sql = "select greeting_filename, greeting_base64, greeting_id ";
@@ -189,7 +189,7 @@
if (!empty($row) && is_array($row) && @sizeof($row) != 0) {
$greeting_filename = $row['greeting_filename'];
$greeting_id = $row['greeting_id'];
- if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64' && !empty($row['greeting_base64'])) {
+ if (!empty($settings->get('voicemail', 'storage_type')) && $settings->get('voicemail', 'storage_type') == 'base64' && !empty($row['greeting_base64'])) {
$greeting_decoded = base64_decode($row['greeting_base64']);
file_put_contents($greeting_dir.'/'.$greeting_filename, $greeting_decoded);
}
@@ -217,13 +217,13 @@
$waveform = new Waveform($full_file_path);
Waveform::$linesPerPixel = 1; // default: 8
Waveform::$samplesPerLine = 512; // default: 512
- Waveform::$colorA = !empty($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color
- Waveform::$colorB = !empty($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color
- Waveform::$backgroundColor = !empty($_SESSION['theme']['audio_player_waveform_color_background']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_background']['text']) : [0,0,0,0]; // array rgba, default: transparent
- Waveform::$axisColor = !empty($_SESSION['theme']['audio_player_waveform_color_axis']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_axis']['text']) : [0,0,0,0.3]; // array rgba
- Waveform::$singlePhase = filter_var($_SESSION['theme']['audio_player_waveform_single_phase']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom
- Waveform::$singleAxis = filter_var($_SESSION['theme']['audio_player_waveform_single_axis']['boolean'] ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis
- $height = !empty($_SESSION['theme']['audio_player_waveform_height']['text']) && is_numeric(str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text'])) ? 2.2 * (int) str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text']) : null;
+ Waveform::$colorA = !empty($settings->get('theme', 'audio_player_waveform_color_a_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_a_leg')) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color
+ Waveform::$colorB = !empty($settings->get('theme', 'audio_player_waveform_color_b_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_b_leg')) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color
+ Waveform::$backgroundColor = !empty($settings->get('theme', 'audio_player_waveform_color_background')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_background')) : [0,0,0,0]; // array rgba, default: transparent
+ Waveform::$axisColor = !empty($settings->get('theme', 'audio_player_waveform_color_axis')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_axis')) : [0,0,0,0.3]; // array rgba
+ Waveform::$singlePhase = filter_var($settings->get('theme', 'audio_player_waveform_single_phase') ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom
+ Waveform::$singleAxis = filter_var($settings->get('theme', 'audio_player_waveform_single_axis') ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis
+ $height = !empty($settings->get('theme', 'audio_player_waveform_height')) && is_numeric(str_replace('px','',$settings->get('theme', 'audio_player_waveform_height'))) ? 2.2 * (int) str_replace('px','',$settings->get('theme', 'audio_player_waveform_height')) : null;
$wf = $waveform->getWaveform($temp_filename, 1600, $height ?? 180); // input: png filename returns boolean true/false, or 'base64' returns base64 string
}
@@ -259,7 +259,7 @@
break;
case 'greeting':
- if (!empty($_SESSION['voicemail']['storage_type']['text']) && $_SESSION['voicemail']['storage_type']['text'] == 'base64' && !empty($row['greeting_base64'])) {
+ if (!empty($settings->get('voicemail', 'storage_type')) && $settings->get('voicemail', 'storage_type') == 'base64' && !empty($row['greeting_base64'])) {
if ($greeting_id != $selected_greeting_id) {
@unlink($greeting_dir.'/'.$greeting_filename);
}
diff --git a/app/xml_cdr/app_defaults.php b/app/xml_cdr/app_defaults.php
index bc8994d58d..fb55f69d5a 100644
--- a/app/xml_cdr/app_defaults.php
+++ b/app/xml_cdr/app_defaults.php
@@ -28,10 +28,10 @@
if ($domains_processed == 1) {
/*
- $file_contents = file_get_contents($_SESSION['switch']['conf']['dir']."/autoload_configs/xml_cdr.conf.xml");
+ $file_contents = file_get_contents($settings->get('switch', 'conf')."/autoload_configs/xml_cdr.conf.xml");
$file_contents_new = str_replace("param name=\"prefix-a-leg\" value=\"false\"/", "param name=\"prefix-a-leg\" value=\"true\"/", $file_contents);
if ($file_contents != $file_contents_new) {
- $fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/xml_cdr.conf.xml","w");
+ $fout = fopen($settings->get('switch', 'conf')."/autoload_configs/xml_cdr.conf.xml","w");
fwrite($fout, $file_contents_new);
fclose($fout);
if ($display_type == "text") {
diff --git a/app/xml_cdr/resources/classes/xml_cdr.php b/app/xml_cdr/resources/classes/xml_cdr.php
index c7f4e4dfad..e7a11bf5e3 100644
--- a/app/xml_cdr/resources/classes/xml_cdr.php
+++ b/app/xml_cdr/resources/classes/xml_cdr.php
@@ -35,13 +35,18 @@
const app_name = 'xml_cdr';
const app_uuid = '4a085c51-7635-ff03-f67b-86e834422848';
+ /**
+ * Domain UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
+ */
+ public $domain_uuid;
+
/**
* declare public variables
*/
public $array;
public $fields;
public $setting;
- public $domain_uuid;
public $call_details;
public $call_direction;
public $status;
@@ -63,6 +68,12 @@
*/
public $file;
+ /**
+ * Set in the constructor. Must be a database object and cannot be null.
+ * @var database Database Object
+ */
+ private $database;
+
/**
* Internal array structure that is populated from the database
* @var array Array of settings loaded from Default Settings
@@ -70,10 +81,16 @@
private $settings;
/**
- * Set in the constructor. Must be a database object and cannot be null.
- * @var database Database Object
+ * User UUID set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
*/
- private $database;
+ private $user_uuid;
+
+ /**
+ * Username set in the constructor. This can be passed in through the $settings_array associative array or set in the session global array
+ * @var string
+ */
+ private $username;
/**
* Set in the constructor. This can be null.
@@ -93,24 +110,20 @@
/**
* additional private variables
*/
- private $username;
private $password;
private $json;
/**
* Called when the object is created
*/
- public function __construct($setting_array = []) {
+ public function __construct(array $setting_array = []) {
+ //set domain and user UUIDs
+ $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? '';
+ $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? '';
- //open a database connection
- $this->database = database::new();
-
- //get the settings object
- if (empty($setting_array['settings'])) {
- $this->settings = new settings(['database' => $this->database]);
- } else {
- $this->settings = $setting_array['settings'];
- }
+ //set objects
+ $this->database = $setting_array['database'] ?? database::new();
+ $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]);
//set the directory
$this->xml_cdr_dir = $this->settings->get('switch', 'log', '/var/log/freeswitch').'/xml_cdr';
@@ -1189,12 +1202,7 @@
public function call_flow_summary($call_flow_array) {
//set the time zone
- if (!empty($this->settings->get('domain', 'time_zone'))) {
- $time_zone = $this->settings->get('domain', 'time_zone');
- }
- else {
- $time_zone = date_default_timezone_get();
- }
+ $time_zone = $this->settings->get('domain', 'time_zone', date_default_timezone_get());
//set the time zone for php
date_default_timezone_set($time_zone);
@@ -1420,6 +1428,7 @@
}
//build the application urls
+ $application_url = '';
if (!empty($app['application'])) {
//build the source url
$source_url = '';
@@ -1766,12 +1775,7 @@
public function user_summary() {
//set the time zone
- if (!empty($this->settings->get('domain', 'time_zone'))) {
- $time_zone = $this->settings->get('domain', 'time_zone');
- }
- else {
- $time_zone = date_default_timezone_get();
- }
+ $time_zone = $this->settings->get('domain', 'time_zone', date_default_timezone_get());
//set the time zone for php
date_default_timezone_set($time_zone);
diff --git a/app/xml_cdr/resources/dashboard/missed_calls.php b/app/xml_cdr/resources/dashboard/missed_calls.php
index eb53d51001..1fd793d228 100644
--- a/app/xml_cdr/resources/dashboard/missed_calls.php
+++ b/app/xml_cdr/resources/dashboard/missed_calls.php
@@ -15,7 +15,7 @@
//add multi-lingual support
$language = new text;
- $text = $language->get($_SESSION['domain']['language']['code'], 'core/user_settings');
+ $text = $language->get($settings->get('domain', 'language', 'en-us'), 'core/user_settings');
//create assigned extensions array
if (is_array($_SESSION['user']['extension'])) {
@@ -30,8 +30,8 @@
//set the sql time format
$sql_time_format = 'DD Mon HH12:MI am';
- if (!empty($_SESSION['domain']['time_format']['text'])) {
- $sql_time_format = $_SESSION['domain']['time_format']['text'] == '12h' ? "DD Mon HH12:MI am" : "DD Mon HH24:MI";
+ if (!empty($settings->get('domain', 'time_format'))) {
+ $sql_time_format = $settings->get('domain', 'time_format') == '12h' ? "DD Mon HH12:MI am" : "DD Mon HH24:MI";
}
//get the missed calls from call detail records
@@ -173,7 +173,7 @@
foreach ($result as $index => $row) {
$start_date_time = str_replace('/0','/', ltrim($row['start_date_time'], '0'));
- if (!empty($_SESSION['domain']['time_format']) && $_SESSION['domain']['time_format']['text'] == '12h') {
+ if (!empty($_SESSION['domain']['time_format']) && $settings->get('domain', 'time_format') == '12h') {
$start_date_time = str_replace(' 0',' ', $start_date_time);
}
//set click-to-call variables
@@ -185,9 +185,9 @@
"&dest_cid_number=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_number'] ?? '').
"&src=".urlencode($_SESSION['user']['extension'][0]['user'] ?? '').
"&dest=".urlencode($row['caller_id_number'] ?? '').
- "&rec=".(filter_var($_SESSION['click_to_call']['record']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? "true" : "false").
- "&ringback=".(isset($_SESSION['click_to_call']['ringback']['text']) ? $_SESSION['click_to_call']['ringback']['text'] : "us-ring").
- "&auto_answer=".(filter_var($_SESSION['click_to_call']['auto_answer']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? "true" : "false").
+ "&rec=".(filter_var($settings->get('click_to_call', 'record') ?? false, FILTER_VALIDATE_BOOL) ? "true" : "false").
+ "&ringback=".$settings->get('click_to_call', 'ringback', 'us-ring').
+ "&auto_answer=".(filter_var($settings->get('click_to_call', 'auto_answer') ?? false, FILTER_VALIDATE_BOOL) ? "true" : "false").
"');\" ".
"style='cursor: pointer;'";
}
@@ -196,7 +196,7 @@
if ($theme_cdr_images_exist) {
$call_result = $row['status'];
if (isset($row['direction'])) {
- echo "  \n";
+ echo "  \n";
}
}
echo " | \n";
diff --git a/app/xml_cdr/resources/dashboard/recent_calls.php b/app/xml_cdr/resources/dashboard/recent_calls.php
index fd099aff4f..6fe412f785 100644
--- a/app/xml_cdr/resources/dashboard/recent_calls.php
+++ b/app/xml_cdr/resources/dashboard/recent_calls.php
@@ -15,7 +15,7 @@
//add multi-lingual support
$language = new text;
- $text = $language->get($_SESSION['domain']['language']['code'], 'core/user_settings');
+ $text = $language->get($settings->get('domain', 'language', 'en-us'), 'core/user_settings');
//create assigned extensions array
if (is_array($_SESSION['user']['extension'])) {
@@ -30,8 +30,8 @@
//set the sql time format
$sql_time_format = 'DD Mon HH12:MI am';
- if (!empty($_SESSION['domain']['time_format']['text'])) {
- $sql_time_format = $_SESSION['domain']['time_format']['text'] == '12h' ? "DD Mon HH12:MI am" : "DD Mon HH24:MI";
+ if (!empty($settings->get('domain', 'time_format'))) {
+ $sql_time_format = $settings->get('domain', 'time_format') == '12h' ? "DD Mon HH12:MI am" : "DD Mon HH24:MI";
}
//get the recent calls from call detail records
@@ -179,7 +179,7 @@
foreach ($result as $index => $row) {
$start_date_time = str_replace('/0','/', ltrim($row['start_date_time'], '0'));
- if (!empty($_SESSION['domain']['time_format']) && $_SESSION['domain']['time_format']['text'] == '12h') {
+ if (!empty($_SESSION['domain']['time_format']) && $settings->get('domain', 'time_format') == '12h') {
$start_date_time = str_replace(' 0',' ', $start_date_time);
}
@@ -203,9 +203,9 @@
"&dest_cid_number=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_number'] ?? '').
"&src=".urlencode($_SESSION['user']['extension'][0]['user'] ?? '').
"&dest=".urlencode($dest ?? '').
- "&rec=".(filter_var($_SESSION['click_to_call']['record']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? 'true' : 'false').
- "&ringback=".(isset($_SESSION['click_to_call']['ringback']['text']) ? $_SESSION['click_to_call']['ringback']['text'] : "us-ring").
- "&auto_answer=".(filter_var($_SESSION['click_to_call']['auto_answer']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? 'true' : 'false').
+ "&rec=".(filter_var($settings->get('click_to_call', 'record') ?? false, FILTER_VALIDATE_BOOL) ? 'true' : 'false').
+ "&ringback=".$settings->get('click_to_call', 'ringback', 'us-ring').
+ "&auto_answer=".(filter_var($settings->get('click_to_call', 'auto_answer') ?? false, FILTER_VALIDATE_BOOL) ? 'true' : 'false').
"');\" ".
"style='cursor: pointer;'";
}
@@ -215,7 +215,7 @@
if ($theme_cdr_images_exist) {
$call_result = $row['status'];
if (isset($row['direction'])) {
- echo "
\n";
+ echo "
\n";
}
}
echo "\n";
diff --git a/app/xml_cdr/waveform.php b/app/xml_cdr/waveform.php
index 5a67a6e165..9df607cff3 100644
--- a/app/xml_cdr/waveform.php
+++ b/app/xml_cdr/waveform.php
@@ -44,7 +44,7 @@
//get call recording details from database
$sql = "select call_recording_name, call_recording_path ";
- if (!empty($_SESSION['call_recordings']['storage_type']['text']) && $_SESSION['call_recordings']['storage_type']['text'] == 'base64' && !empty($row['call_recording_base64'])) {
+ if (!empty($settings->get('call_recordings', 'storage_type')) && $settings->get('call_recordings', 'storage_type') == 'base64' && !empty($row['call_recording_base64'])) {
$sql = ", call_recording_base64 ";
}
$sql .= "from view_call_recordings ";
@@ -54,7 +54,7 @@
if (is_array($row) && @sizeof($row) != 0) {
$call_recording_name = $row['call_recording_name'];
$call_recording_path = $row['call_recording_path'];
- if (!empty($_SESSION['call_recordings']['storage_type']['text']) && $_SESSION['call_recordings']['storage_type']['text'] == 'base64' && !empty($row['call_recording_base64'])) {
+ if (!empty($settings->get('call_recordings', 'storage_type')) && $settings->get('call_recordings', 'storage_type') == 'base64' && !empty($row['call_recording_base64'])) {
file_put_contents($call_recording_path.'/'.$call_recording_name, base64_decode($row['call_recording_base64']));
}
}
@@ -78,13 +78,13 @@
$waveform = new Waveform($full_recording_path);
Waveform::$linesPerPixel = 1; // default: 8
Waveform::$samplesPerLine = 512; // default: 512
- Waveform::$colorA = !empty($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_a_leg']['text']) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color
- Waveform::$colorB = !empty($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_b_leg']['text']) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color
- Waveform::$backgroundColor = !empty($_SESSION['theme']['audio_player_waveform_color_background']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_background']['text']) : [0,0,0,0]; // array rgba, default: transparent
- Waveform::$axisColor = !empty($_SESSION['theme']['audio_player_waveform_color_axis']['text']) ? color_to_rgba_array($_SESSION['theme']['audio_player_waveform_color_axis']['text']) : [0,0,0,0.3]; // array rgba
- Waveform::$singlePhase = filter_var($_SESSION['theme']['audio_player_waveform_single_phase']['boolean'] ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom
- Waveform::$singleAxis = filter_var($_SESSION['theme']['audio_player_waveform_single_axis']['boolean'] ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis
- $height = !empty($_SESSION['theme']['audio_player_waveform_height']['text']) && is_numeric(str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text'])) ? 2.2 * (int) str_replace('px','',$_SESSION['theme']['audio_player_waveform_height']['text']) : null;
+ Waveform::$colorA = !empty($settings->get('theme', 'audio_player_waveform_color_a_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_a_leg')) : [32,134,37,0.6]; // array rgba, left (a-leg) wave color
+ Waveform::$colorB = !empty($settings->get('theme', 'audio_player_waveform_color_b_leg')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_b_leg')) : [0,125,232,0.6]; // array rgba, right (b-leg) wave color
+ Waveform::$backgroundColor = !empty($settings->get('theme', 'audio_player_waveform_color_background')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_background')) : [0,0,0,0]; // array rgba, default: transparent
+ Waveform::$axisColor = !empty($settings->get('theme', 'audio_player_waveform_color_axis')) ? color_to_rgba_array($settings->get('theme', 'audio_player_waveform_color_axis')) : [0,0,0,0.3]; // array rgba
+ Waveform::$singlePhase = filter_var($settings->get('theme', 'audio_player_waveform_single_phase') ?? false, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // positive phase only - left (a-leg) top, right (b-leg) bottom
+ Waveform::$singleAxis = filter_var($settings->get('theme', 'audio_player_waveform_single_axis') ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis
+ $height = !empty($settings->get('theme', 'audio_player_waveform_height')) && is_numeric(str_replace('px','',$settings->get('theme', 'audio_player_waveform_height'))) ? 2.2 * (int) str_replace('px','',$settings->get('theme', 'audio_player_waveform_height')) : null;
$wf = $waveform->getWaveform($temp_filename, 1600, $height ?? 180); // input: png filename returns boolean true/false, or 'base64' returns base64 string
}
@@ -111,7 +111,7 @@
}
//if base64, remove temp recording file
- if (!empty($_SESSION['call_recordings']['storage_type']['text']) && $_SESSION['call_recordings']['storage_type']['text'] == 'base64' && !empty($row['call_recording_base64'])) {
+ if (!empty($settings->get('call_recordings', 'storage_type')) && $settings->get('call_recordings', 'storage_type') == 'base64' && !empty($row['call_recording_base64'])) {
@unlink($full_recording_path);
}
unset($row);
diff --git a/app/xml_cdr/xml_cdr.php b/app/xml_cdr/xml_cdr.php
index 247a980cb3..32955b8870 100644
--- a/app/xml_cdr/xml_cdr.php
+++ b/app/xml_cdr/xml_cdr.php
@@ -829,7 +829,7 @@
if (is_array($result)) {
//determine if theme images exist
- $theme_image_path = $_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/";
+ $theme_image_path = $_SERVER["DOCUMENT_ROOT"]."/themes/".$settings->get('domain', 'template')."/images/";
$theme_cdr_images_exist = (
file_exists($theme_image_path."icon_cdr_inbound_answered.png") &&
file_exists($theme_image_path."icon_cdr_inbound_no_answer.png") &&
@@ -966,7 +966,7 @@
}
$image_name .= ".png";
if (file_exists($theme_image_path.$image_name)) {
- $content .= "
\n";
+ $content .= "
\n";
}
else { $content .= " "; }
}
diff --git a/app/xml_cdr/xml_cdr_details.php b/app/xml_cdr/xml_cdr_details.php
index 3cbdc7c321..0e13e1a685 100644
--- a/app/xml_cdr/xml_cdr_details.php
+++ b/app/xml_cdr/xml_cdr_details.php
@@ -75,6 +75,7 @@
$start_stamp = trim($row["start_stamp"] ?? '');
$xml_string = trim($row["xml"] ?? '');
$json_string = trim($row["json"] ?? '');
+ $leg = trim($row["leg"] ?? '');
$call_flow = trim($row["call_flow"] ?? '');
$direction = trim($row["direction"] ?? '');
$call_direction = trim($row["direction"] ?? '');
@@ -203,7 +204,7 @@
$tmp_year = date("Y", $tmp_time);
$tmp_month = date("M", $tmp_time);
$tmp_day = date("d", $tmp_time);
- $tmp_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day;
+ $tmp_dir = $settings->get('switch', 'log').'/xml_cdr/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day;
if (file_exists($tmp_dir.'/'.$uuid.'.json')) {
$format = "json";
$json_string = file_get_contents($tmp_dir.'/'.$uuid.'.json');
@@ -382,7 +383,7 @@
if (permission_exists('xml_cdr_call_log') && $call_log_enabled && isset($log_content) && !empty($log_content)) {
echo button::create(['type'=>'button','label'=>$text['button-call_log'],'icon'=>$settings->get('theme', 'button_icon_search'),'style'=>'margin-left: 15px;','link'=>'xml_cdr_log.php?id='.$uuid]);
}
- if ($transcribe_enabled && !empty($transcribe_engine) && empty($record_transcription)) {
+ if ($transcribe_enabled && !empty($transcribe_engine) && empty($record_transcription) && !empty($record_path) && !empty($record_name) && file_exists($record_path.'/'.$record_name)) {
echo button::create(['type'=>'button','label'=>$text['button-transcribe'],'icon'=>'quote-right','id'=>'btn_transcribe','name'=>'btn_transcribe','collapse'=>'hide-xs','style'=>'margin-left: 15px;','onclick'=>"window.location.href='?id=".$uuid."&action=transcribe';"]);
}
echo "\n";
@@ -448,18 +449,18 @@
echo " \n";
if (!empty($call_direction)) {
$image_name = "icon_cdr_" . $call_direction . "_" . $status;
- if ($row['leg'] == 'b') {
+ if ($leg == 'b') {
$image_name .= '_b';
}
$image_name .= ".png";
- echo " \n";
+ echo " \n";
}
echo " | \n";
echo " ".escape($direction)." | \n";
//echo " ".$language." | \n";
//echo " ".$context." | \n";
echo " ";
- if (file_exists($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$uuid.'.wav')) {
+ if (file_exists($settings->get('switch', 'recordings').'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$uuid.'.wav')) {
//echo " \n";
//echo " ";
@@ -473,7 +474,7 @@
}
echo " | \n";
echo " ";
- if (file_exists($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$uuid.'.wav')) {
+ if (file_exists($settings->get('switch', 'recordings').'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$uuid.'.wav')) {
echo " \n";
echo escape($caller_id_number).' ';
echo " ";
@@ -519,8 +520,9 @@
echo " |
\n";
$i = 1;
foreach ($call_flow_summary as $row) {
+ $application_icon = $row["application_icon"][$row["application_name"] ?? ''] ?? '';
echo "
\n";
- echo " | ";
+ echo " | ";
echo " ".escape($row["application_label"])." | \n";
if ($call_direction == 'local' || $call_direction == 'outbound') {
echo " ".escape($row["source_number"])." | \n";
@@ -725,7 +727,7 @@
if ($key == "bridge_uuid" || $key == "signal_bond") {
echo " \n";
echo " ".escape($value)." \n";
- $tmp_dir = $_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day;
+ $tmp_dir = $settings->get('switch', 'recordings').'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day;
$tmp_name = '';
if (file_exists($tmp_dir.'/'.$value.'.wav')) {
$tmp_name = $value.".wav";
@@ -739,12 +741,12 @@
else if (file_exists($tmp_dir.'/'.$value.'_1.mp3')) {
$tmp_name = $value."_1.mp3";
}
- if (!empty($tmp_name) && file_exists($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) {
+ if (!empty($tmp_name) && file_exists($settings->get('switch', 'recordings').'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) {
echo " \n";
echo " play";
echo " ";
}
- if (!empty($tmp_name) && file_exists($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) {
+ if (!empty($tmp_name) && file_exists($settings->get('switch', 'recordings').'/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) {
echo " \n";
echo " download";
echo " ";
@@ -784,7 +786,7 @@
echo " |
\n";
//foreach($array["variables"] as $key => $value) {
- if (is_array($array["app_log"]["application"])) {
+ if (!empty($array["app_log"]["application"])) {
foreach ($array["app_log"]["application"] as $key=>$row) {
//single app
if ($key === "@attributes") {
diff --git a/app/xml_cdr/xml_cdr_export.php b/app/xml_cdr/xml_cdr_export.php
index 83a4af48da..5070c9e4c2 100644
--- a/app/xml_cdr/xml_cdr_export.php
+++ b/app/xml_cdr/xml_cdr_export.php
@@ -152,7 +152,7 @@
require_once "resources/fpdi/fpdi.php";
//determine page size
- switch ($_SESSION['fax']['page_size']['text']) {
+ switch ($settings->get('fax', 'page_size')) {
case 'a4':
$page_width = 11.7; //in
$page_height = 8.3; //in
diff --git a/app/xml_cdr/xml_cdr_inc.php b/app/xml_cdr/xml_cdr_inc.php
index 8e3683924f..a8c3351622 100644
--- a/app/xml_cdr/xml_cdr_inc.php
+++ b/app/xml_cdr/xml_cdr_inc.php
@@ -270,7 +270,7 @@
//count the records in the database
/*
- if ($_SESSION['cdr']['limit']['numeric'] == 0) {
+ if ($settings->get('cdr', 'limit') == 0) {
$sql = "select count(*) from v_xml_cdr ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= ".$sql_where;
@@ -281,12 +281,12 @@
*/
//limit the number of results
- if (!empty($_SESSION['cdr']['limit']['numeric']) && $_SESSION['cdr']['limit']['numeric'] > 0) {
- $num_rows = $_SESSION['cdr']['limit']['numeric'];
+ if (!empty($settings->get('cdr', 'limit')) && $settings->get('cdr', 'limit') > 0) {
+ $num_rows = $settings->get('cdr', 'limit');
}
//set the default paging
- //$rows_per_page = $_SESSION['domain']['paging']['numeric'];
+ //$rows_per_page = $settings->get('domain', 'paging');
//prepare to page the results
//$rows_per_page = $settings->get('domain', 'paging', 50); //set on the page that includes this page
@@ -303,8 +303,8 @@
//set the sql time format
$sql_time_format = 'HH12:MI am';
- if (!empty($_SESSION['domain']['time_format']['text'])) {
- $sql_time_format = $_SESSION['domain']['time_format']['text'] == '12h' ? "HH12:MI am" : "HH24:MI";
+ if (!empty($settings->get('domain', 'time_format'))) {
+ $sql_time_format = $settings->get('domain', 'time_format') == '12h' ? "HH12:MI am" : "HH24:MI";
}
//get the results from the db
@@ -637,7 +637,7 @@
if ($export_format !== "csv" && $export_format !== "pdf") {
if ($rows_per_page == 0) {
$sql .= " limit :limit offset 0 \n";
- $parameters['limit'] = $_SESSION['cdr']['limit']['numeric'];
+ $parameters['limit'] = $settings->get('cdr', 'limit');
}
else {
$sql .= " limit :limit offset :offset \n";
diff --git a/core/authentication/resources/classes/authentication.php b/core/authentication/resources/classes/authentication.php
index e81532f845..e03048a9ef 100644
--- a/core/authentication/resources/classes/authentication.php
+++ b/core/authentication/resources/classes/authentication.php
@@ -45,8 +45,8 @@ class authentication {
/**
* Called when the object is created
*/
- public function __construct() {
- $this->database = database::new();
+ public function __construct(array $setting_array = []) {
+ $this->database = $setting_array['database'] ?? database::new();
$this->user_uuid = null;
}
diff --git a/core/authentication/resources/classes/plugins/email.php b/core/authentication/resources/classes/plugins/email.php
index 65413c3c8d..a74f9983b5 100644
--- a/core/authentication/resources/classes/plugins/email.php
+++ b/core/authentication/resources/classes/plugins/email.php
@@ -221,7 +221,7 @@ class plugin_email {
//$response = ob_get_clean();
//get the language code
- $language_code = $_SESSION['domain']['language']['code'];
+ $language_code = $settings->get('domain', 'language', 'en-us');
//get the email template from the database
$sql = "select template_subject, template_body ";
diff --git a/core/contacts/app_config.php b/core/contacts/app_config.php
index 03d5862101..4eaff669af 100644
--- a/core/contacts/app_config.php
+++ b/core/contacts/app_config.php
@@ -1222,5 +1222,20 @@
$apps[$x]['default_settings'][$y]['default_setting_value'] = "false";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "";
-
+ $y++;
+ $apps[$x]['default_settings'][$y]['default_setting_uuid'] = "b28a0d3d-64d4-4306-b38b-07fbf07d53b6";
+ $apps[$x]['default_settings'][$y]['default_setting_category'] = "contact";
+ $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "default_sort_column";
+ $apps[$x]['default_settings'][$y]['default_setting_name'] = "text";
+ $apps[$x]['default_settings'][$y]['default_setting_value'] = "last_mod_date";
+ $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
+ $apps[$x]['default_settings'][$y]['default_setting_description'] = "Order by field name used in list";
+ $y++;
+ $apps[$x]['default_settings'][$y]['default_setting_uuid'] = "d7652f7f-1521-4e17-87a8-21d436e497ec";
+ $apps[$x]['default_settings'][$y]['default_setting_category'] = "contact";
+ $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "default_sort_order";
+ $apps[$x]['default_settings'][$y]['default_setting_name'] = "text";
+ $apps[$x]['default_settings'][$y]['default_setting_value'] = "desc";
+ $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
+ $apps[$x]['default_settings'][$y]['default_setting_description'] = "Options: asc, desc";
?>
diff --git a/core/contacts/contact_address_edit.php b/core/contacts/contact_address_edit.php
index 3fff4e40b2..b370bb1ec1 100644
--- a/core/contacts/contact_address_edit.php
+++ b/core/contacts/contact_address_edit.php
@@ -218,7 +218,7 @@
}
//set the defaults
- if ($address_primary === null) { $address_primary = false; }
+ $address_primary = $address_primary ?? false;
//create token
$object = new token;
diff --git a/core/contacts/contact_attachment.php b/core/contacts/contact_attachment.php
index 5fd4c1bd03..c720c007a7 100644
--- a/core/contacts/contact_attachment.php
+++ b/core/contacts/contact_attachment.php
@@ -52,7 +52,7 @@
//determine mime type
$content_type = 'application/octet-stream'; //set default
- $allowed_attachment_types = json_decode($_SESSION['contact']['allowed_attachment_types']['text'] ?? '', true);
+ $allowed_attachment_types = json_decode($settings->get('contact', 'allowed_attachment_types') ?? '', true);
if (!empty($allowed_attachment_types)) {
if ($allowed_attachment_types[$attachment_type] != '') {
$content_type = $allowed_attachment_types[$attachment_type];
diff --git a/core/contacts/contact_attachment_edit.php b/core/contacts/contact_attachment_edit.php
index db1c00072a..cd24e96968 100644
--- a/core/contacts/contact_attachment_edit.php
+++ b/core/contacts/contact_attachment_edit.php
@@ -91,7 +91,7 @@
}
//get the allowed extensions
- $allowed_extensions = array_keys(json_decode($_SESSION['contact']['allowed_attachment_types']['text'], true));
+ $allowed_extensions = array_keys(json_decode($settings->get('contact', 'allowed_attachment_types'), true));
//check the allowed extensions
if ($attachment['error'] == '0' && in_array($attachment_extension, $allowed_extensions)) {
@@ -183,7 +183,7 @@
}
//set the defaults
- if ($attachment_primary === null) { $attachment_primary = false; }
+ $attachment_primary = $attachment_primary ?? false;
//create token
$object = new token;
@@ -236,7 +236,7 @@
}
}
else {
- $allowed_attachment_types = json_decode($_SESSION['contact']['allowed_attachment_types']['text'], true);
+ $allowed_attachment_types = json_decode($settings->get('contact', 'allowed_attachment_types'), true);
echo "
\n";
echo "
".strtoupper(implode(', ', array_keys($allowed_attachment_types)))."";
}
diff --git a/core/contacts/contact_auth.php b/core/contacts/contact_auth.php
index e43356017f..07c1e7d4ae 100644
--- a/core/contacts/contact_auth.php
+++ b/core/contacts/contact_auth.php
@@ -66,7 +66,7 @@ if ($_SESSION['contact_auth']['source'] == 'google') {
}
if ($_GET['code'] == '') {
- header("Location: https://accounts.google.com/o/oauth2/auth?client_id=".$_SESSION['contact']['google_oauth_client_id']['text']."&redirect_uri=".(($_SERVER["HTTPS"] == "on") ? "https" : "http")."://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."&scope=https://www.google.com/m8/feeds/&response_type=code");
+ header("Location: https://accounts.google.com/o/oauth2/auth?client_id=".$settings->get('contact', 'google_oauth_client_id')."&redirect_uri=".(($_SERVER["HTTPS"] == "on") ? "https" : "http")."://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."&scope=https://www.google.com/m8/feeds/&response_type=code");
exit;
}
else {
@@ -78,8 +78,8 @@ if ($_SESSION['contact_auth']['source'] == 'google') {
$fields = array(
'code' => urlencode($auth_code),
- 'client_id' => urlencode($_SESSION['contact']['google_oauth_client_id']['text']),
- 'client_secret' => urlencode($_SESSION['contact']['google_oauth_client_secret']['text']),
+ 'client_id' => urlencode($settings->get('contact', 'google_oauth_client_id')),
+ 'client_secret' => urlencode($settings->get('contact', 'google_oauth_client_secret')),
'redirect_uri' => urlencode((($_SERVER["HTTPS"] == "on") ? "https" : "http")."://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']),
'grant_type' => urlencode('authorization_code')
);
diff --git a/core/contacts/contact_edit.php b/core/contacts/contact_edit.php
index 97c8ed0446..5bcef0513c 100644
--- a/core/contacts/contact_edit.php
+++ b/core/contacts/contact_edit.php
@@ -55,7 +55,7 @@
$contact_attachments = [];
//set from session variables
- $body_text_color = !empty($_SESSION['theme']['body_text_color']['text']) ? $_SESSION['theme']['body_text_color']['text'] : 'false';
+ $body_text_color = !empty($settings->get('theme', 'body_text_color')) ? $settings->get('theme', 'body_text_color') : 'false';
//action add or update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
@@ -991,29 +991,29 @@
";
+ if (!empty($settings->get('theme', 'qr_brand_image')) && $settings->get('theme', 'qr_brand_type') == 'image') {
+ echo "

";
$qr_option = "image: $('#img-buffer')[0],";
$qr_mode = '4';
$qr_size = '0.2';
}
- elseif (empty($_SESSION['theme']['qr_brand_image']['text']) && !empty($_SESSION['theme']['qr_brand_type']['text']) && $_SESSION['theme']['qr_brand_type']['text'] == 'image') {
+ elseif (empty($settings->get('theme', 'qr_brand_image')) && !empty($settings->get('theme', 'qr_brand_type')) && $settings->get('theme', 'qr_brand_type') == 'image') {
$qr_option = '';
$qr_mode = '3';
$qr_size = '0';
}
- elseif (!empty($_SESSION['theme']['qr_brand_image']['text']) && $_SESSION['theme']['qr_brand_type']['text'] == 'text') {
- $qr_option = 'label: "'.$_SESSION['theme']['qr_brand_text']['text'].'"';
+ elseif (!empty($settings->get('theme', 'qr_brand_image')) && $settings->get('theme', 'qr_brand_type') == 'text') {
+ $qr_option = 'label: "'.$settings->get('theme', 'qr_brand_text').'"';
$qr_mode = '2';
$qr_size = '0.05';
}
- elseif (!empty($_SESSION['theme']['qr_brand_image']['text']) && $_SESSION['theme']['qr_brand_type']['text'] == 'none') {
+ elseif (!empty($settings->get('theme', 'qr_brand_image')) && $settings->get('theme', 'qr_brand_type') == 'none') {
$qr_option = '';
$qr_mode = '3';
$qr_size = '0';
}
else {
- echo "

";
+ echo "

";
$qr_option = "image: $('#img-buffer')[0],";
$qr_mode = '4';
$qr_size = '0.2';
@@ -2561,7 +2561,7 @@ if (permission_exists('contact_attachment_view')) {
}
//}
//else {
- // $allowed_attachment_types = json_decode($_SESSION['contact']['allowed_attachment_types']['text'], true);
+ // $allowed_attachment_types = json_decode($settings->get('contact', 'allowed_attachment_types'), true);
// echo "
\n";
// echo "
".strtoupper(implode(', ', array_keys($allowed_attachment_types)))."";
//}
diff --git a/core/contacts/contact_email_edit.php b/core/contacts/contact_email_edit.php
index 8c7f3d6aea..0eff7600e0 100644
--- a/core/contacts/contact_email_edit.php
+++ b/core/contacts/contact_email_edit.php
@@ -181,7 +181,7 @@ if (!empty($_GET["contact_uuid"]) && is_uuid($_GET["contact_uuid"])) {
}
//set the defaults
- if ($email_primary === null) { $email_primary = false; }
+ $email_primary = $email_primary ?? false;
//create token
$object = new token;
diff --git a/core/contacts/contact_import.php b/core/contacts/contact_import.php
index 4aee9a78b0..cace77a2a5 100644
--- a/core/contacts/contact_import.php
+++ b/core/contacts/contact_import.php
@@ -64,7 +64,7 @@
//save the data to the csv file
if (isset($_POST['data'])) {
- $file = $_SESSION['server']['temp']['dir']."/contacts-".$_SESSION['domain_name'].".csv";
+ $file = $settings->get('server', 'temp')."/contacts-".$_SESSION['domain_name'].".csv";
file_put_contents($file, $_POST['data']);
$_SESSION['file'] = $file;
}
@@ -73,10 +73,10 @@
//$_POST['submit'] == "Upload" &&
if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('contact_upload')) {
if ($_POST['type'] == 'csv') {
- move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']);
- $save_msg = "Uploaded file to ".$_SESSION['server']['temp']['dir']."/". htmlentities($_FILES['ulfile']['name']);
- //system('chmod -R 744 '.$_SESSION['server']['temp']['dir'].'*');
- $file = $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name'];
+ move_uploaded_file($_FILES['ulfile']['tmp_name'], $settings->get('server', 'temp').'/'.$_FILES['ulfile']['name']);
+ $save_msg = "Uploaded file to ".$settings->get('server', 'temp')."/". htmlentities($_FILES['ulfile']['name']);
+ //system('chmod -R 744 '.$settings->get('server', 'temp').'*');
+ $file = $settings->get('server', 'temp').'/'.$_FILES['ulfile']['name'];
$_SESSION['file'] = $file;
}
}
@@ -510,7 +510,7 @@
echo "
\n";
echo "