Refactor PHP code (#7574)

* Use settings-get method
- get default, domain and user settings
- Replace _SESSION

* Simplify get domain paging

* Change isset using empty

* Fix token name and hash

* Add new default settings category: contact, name: default_sort_column, and default_sort_order

* Update app_config.php

* Update footer.php

* Fix require.php and core/dashboard/index.php (#7563)

* Fix require.php and core/dashboard/index.php

* Fix require.php and core/dashboard/index.php

* Fix require.php and core/dashboard/index.php

* Fix require.php and core/dashboard/index.php

* Fix require.php and core/dashboard/index.php

* Fix require.php and core/dashboard/index.php

* Fix require.php and core/dashboard/index.php

* Fix require.php and core/dashboard/index.php

* Fix require.php and core/dashboard/index.php

* Update destinations.php

* Update permission.php

* Update require.php

---------

Co-authored-by: FusionPBX <markjcrane@gmail.com>
Co-authored-by: FusionPBX <mark@fusionpbx.com>

* Update header.php

* Use settings get classes (#7567)

* access_control

* azure

* azure

* basic_operator_panel

* bridges

* call_block

* call_broadcast

* call_center

* call_flows

* call_forward

* call_recordings

* do_not_disturb

* feature_event_notify

* follow_me

* remove unused object properties

* fix esl command

* fix esl command

* conference_centers

* conference_centers - remove whitespace

* conference_controls

* conference_profiles

* conference_profiles

* Delete core/websockets/resources/classes/socket_exception.php.original~

* Delete core/websockets/resources/classes/websocket_server.php.original~

* conferences

* destinations

* device

* dialplan

* email_queue

* event_guard

* extension_settings

* extension

* fax

* fax_queue

* fifo

* gateways

* ivr_menu

* modules

* switch_music_on_hold

* number_translations

* phrases

* pin_numbers

* provision

* switch_recordings

* registrations

* ring_groups

* sip_profiles

* sofia_global_settings

* streams

* presence

* switch_files

* time_conditions

* vars

* voicemail_greetings

* voicemail

* ringbacks

* contacts

* xml_cdr

* authentication

* dashboard

* default_settings

* domain_settings

* email_templates

* permission

* user_logs

* user_settings

* users

* button

* cache

* captcha

* remove cli_option

* remove directory.php for switch_directory class

* email

* file

* groups

* event_socket use config object

* Use intval to give an integer port

* switch_settings

* tones

* fix object used before initialization

* menu

* fix copy paste error for switch_files.php

* always include require.php for framework files

* Fix missing properties

* set the action

* Use the $database object

* Add missing class properties

* Fix the domain_name

* Use public scope for domain_uuid and domain_name

* Add missing parameters

* Correct the user_uuid parameter

* Add json_validate and use it in the dashboard
update indentation on functions.php

* Intialize the active_registrations variable

* Define the $parameters

* Set a default value for user_setting_enabled

* Add condition domain_uuid not empty

* Add not empty condition for domain_uuid

* Declare the global variables

* Update how the defaults are set use ??

* Use ?? to set the default values

* Update call_center_queue_edit.php

* Prevent an error

* Add domain_name property

* Fix the null coalescing operator

* Removed domain_uuid from the URL

* Change condition to check sip_profile_domain_name

* Refactor domain_uuid declaration and comments

Removed redundant domain_uuid declaration and updated comments.

* Account for an empty value

* Refactor constructor to use settings array

Updated constructor to accept settings array for domain UUID and database initialization.

* Refactor xml_cdr.php to improve variable organization

Removed duplicate domain_uuid declaration and reorganized private variables for better structure.

* Enhance transcription button logic and icon display

Updated transcription button visibility conditions and improved application icon handling in the call flow summary.

* Refactor settings initialization in domains.php

Updated settings initialization to include domain_uuid and user_uuid.

* Modify domain change condition in require.php

Updated condition to check if 'domain_change' is not empty before proceeding.

* Set default_setting_enabled to true by default

* Enhance domain UUID check in access controls

* Enhance domain UUID check in settings list

* Refactor category display logic in vars.php

* Simplify list row URL generation

Removed domain UUID check from list row URL construction.

* Refactor module category display logic

* Fix SQL query by removing parameters variable

* Initialize result_count variable for call recordings

* Refactor leg variable usage in xml_cdr_details.php

* Update conference_room_edit.php

* Change GET to REQUEST for order and search variables

* Set timezone and SQL time format in recordings.php

Added timezone and SQL time format settings.

* Set default for ring group greeting

* Improve domain UUID check in stream listing

* Handle null voicemail_option_param safely

* Add file existence check for greeting files

Check if greeting file exists before getting size and date.

* Improve domain UUID check in email templates

* Update FIFO strategy dropdown and description text

* Add multilingual agent descriptions

Added multilingual descriptions for agents in the app_languages.php file.

* Add music on hold descriptions

* Add the chime list description

Updated copyright year from 2024 to 2025.

* Fix domain UUID check and handle email subject decoding

* Add null coalescing for $value in email_test.php

Ensure $value is not null by providing a default empty string.

* Handle undefined dialplan_uuid in input field

* Add translations for 'Status' label in multiple languages

* Fix typo in config instance check

---------

Co-authored-by: frytimo <tim@fusionpbx.com>
This commit is contained in:
FusionPBX
2025-10-15 21:24:59 -06:00
committed by GitHub
parent e4ca0bf47d
commit dda18481ec
249 changed files with 5180 additions and 4798 deletions

View File

@@ -64,7 +64,7 @@
//save the data to the csv file //save the data to the csv file
if (isset($_POST['data'])) { if (isset($_POST['data'])) {
$file = $_SESSION['server']['temp']['dir']."/access_control_nodes-".$_SESSION['domain_name'].".csv"; $file = $settings->get('server', 'temp')."/access_control_nodes-".$_SESSION['domain_name'].".csv";
if (file_put_contents($file, $_POST['data'])) { if (file_put_contents($file, $_POST['data'])) {
$_SESSION['file'] = $file; $_SESSION['file'] = $file;
} }
@@ -74,7 +74,7 @@
//$_POST['submit'] == "Upload" && //$_POST['submit'] == "Upload" &&
if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('access_control_node_add')) { if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('access_control_node_add')) {
if (!empty($_POST['type']) &&$_POST['type'] == 'csv') { if (!empty($_POST['type']) &&$_POST['type'] == 'csv') {
$file = $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']; $file = $settings->get('server', 'temp').'/'.$_FILES['ulfile']['name'];
if (move_uploaded_file($_FILES['ulfile']['tmp_name'], $file)) { if (move_uploaded_file($_FILES['ulfile']['tmp_name'], $file)) {
$_SESSION['file'] = $file; $_SESSION['file'] = $file;
} }

View File

@@ -207,7 +207,7 @@
$list_row_url = ''; $list_row_url = '';
if (permission_exists('access_control_view')) { if (permission_exists('access_control_view')) {
$list_row_url = "access_control_edit.php?id=".urlencode($row['access_control_uuid']); $list_row_url = "access_control_edit.php?id=".urlencode($row['access_control_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'; $list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true';
} }
} }

View File

@@ -12,9 +12,32 @@
const app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd'; const app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
/** /**
* declare private variables * Set in the constructor. Must be a database object and cannot be null.
* @var database Database Object
*/ */
private $database; 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 $permission_prefix;
private $list_page; private $list_page;
private $table; private $table;
@@ -23,15 +46,17 @@
/** /**
* called when the object is created * 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
$config = $setting_array['config'] ?? config::load();
$this->database = $setting_array['database'] ?? database::new(['config' => $config]);
//assign private variables //assign private variables
$this->list_page = 'access_controls.php'; $this->list_page = 'access_controls.php';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
} }
/** /**

View File

@@ -44,7 +44,7 @@ $row_style["1"] = "row_style1";
$widget_icon = 'fa-solid fa-phone'; $widget_icon = 'fa-solid fa-phone';
//add multi-lingual support //add multi-lingual support
$text = (new text)->get($_SESSION['domain']['language']['code'], 'app/active_calls'); $text = (new text)->get($settings->get('domain', 'language', 'en-us'), 'app/active_calls');
//show the widget //show the widget
echo "<div class='hud_box'>\n"; echo "<div class='hud_box'>\n";

View File

@@ -119,6 +119,17 @@ class azure{
) )
); );
public function __construct(array $setting_array = []) {
//set domain and user UUIDs
$domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? '';
$user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? '';
//set objects
$config = $setting_array['config'] ?? config::load();
$this->database = $setting_array['database'] ?? database::new(['config' => $config]);
$this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $domain_uuid, 'user_uuid' => $user_uuid]);
}
private static function getTokenUrl(){ private static function getTokenUrl(){
return "https://api.cognitive.microsoft.com/sts/v1.0/issueToken"; return "https://api.cognitive.microsoft.com/sts/v1.0/issueToken";
} }
@@ -127,13 +138,13 @@ class azure{
return "https://speech.platform.bing.com/synthesize"; return "https://speech.platform.bing.com/synthesize";
} }
private static function getSubscriptionKey(){ private static function getSubscriptionKey(settings $settings){
return $_SESSION['azure']['key']['text']; return $settings->get('azure', 'key');
} }
private static function _getToken(){ private static function _getToken(settings $settings){
$url = self::getTokenUrl(); $url = self::getTokenUrl();
$subscriptionKey = self::getSubscriptionKey(); $subscriptionKey = self::getSubscriptionKey($settings);
$headers = array(); $headers = array();
$headers[] = 'Ocp-Apim-Subscription-Key: '. $subscriptionKey; $headers[] = 'Ocp-Apim-Subscription-Key: '. $subscriptionKey;
@@ -156,12 +167,12 @@ class azure{
return $response; return $response;
} }
public static function synthesize($data,$formate_key){ public static function synthesize(settings $settings, $data, $format_key){
$lang = self::$formats[$formate_key]['lang']; $lang = self::$formats[$format_key]['lang'];
$gender = self::$formats[$formate_key]['gender']; $gender = self::$formats[$format_key]['gender'];
$name = self::$formats[$formate_key]['name']; $name = self::$formats[$format_key]['name'];
$token = self::_getToken(); $token = self::_getToken($settings);
$url = self::getApiUrl(); $url = self::getApiUrl();

View File

@@ -72,7 +72,7 @@ if (count($_GET) > 0) {
} }
else if ($switch_cmd == 'uuid_record') { else if ($switch_cmd == 'uuid_record') {
$uuid = preg_replace($uuid_pattern,'',$_GET['uuid']); $uuid = preg_replace($uuid_pattern,'',$_GET['uuid']);
$api_cmd = 'uuid_record ' . $uuid . ' start ' . $_SESSION['switch']['recordings']['dir'] . '/' . $_SESSION['domain_name'] . '/archive/' . date('Y/M/d') . '/' . $uuid . '.wav'; $api_cmd = 'uuid_record ' . $uuid . ' start ' . $settings->get('switch', 'recordings') . '/' . $_SESSION['domain_name'] . '/archive/' . date('Y/M/d') . '/' . $uuid . '.wav';
} }
else if ($switch_cmd == 'uuid_transfer') { else if ($switch_cmd == 'uuid_transfer') {
$uuid = preg_replace($uuid_pattern,'',$_GET['uuid']); $uuid = preg_replace($uuid_pattern,'',$_GET['uuid']);
@@ -108,13 +108,13 @@ if (count($_GET) > 0) {
$x=0; $x=0;
while (true) { while (true) {
if ($x > 0) { if ($x > 0) {
$dest_file = $_SESSION['switch']['recordings']['dir']."/archive/".date("Y")."/".date("M")."/".date("d")."/".$_GET["uuid"]."_".$x.".wav"; $dest_file = $settings->get('switch', 'recordings')."/archive/".date("Y")."/".date("M")."/".date("d")."/".$_GET["uuid"]."_".$x.".wav";
} }
else { else {
$dest_file = $_SESSION['switch']['recordings']['dir']."/archive/".date("Y")."/".date("M")."/".date("d")."/".$_GET["uuid"].".wav"; $dest_file = $settings->get('switch', 'recordings')."/archive/".date("Y")."/".date("M")."/".date("d")."/".$_GET["uuid"].".wav";
} }
if (!file_exists($dest_file)) { if (!file_exists($dest_file)) {
rename($_SESSION['switch']['recordings']['dir']."/archive/".date("Y")."/".date("M")."/".date("d")."/".$_GET["uuid"].".wav", $dest_file); rename($settings->get('switch', 'recordings')."/archive/".date("Y")."/".date("M")."/".date("d")."/".$_GET["uuid"].".wav", $dest_file);
break; break;
} }
$x++; $x++;

View File

@@ -162,10 +162,10 @@
//delete extension from the cache //delete extension from the cache
$cache = new cache; $cache = new cache;
if (!empty($extension)) { if (!empty($extension)) {
$cache->delete("directory:".$extension."@".$this->domain_name); $cache->delete("directory:".$extension."@".$domain_name);
} }
if (!empty($number_alias)) { if (!empty($number_alias)) {
$cache->delete("directory:".$number_alias."@".$this->domain_name); $cache->delete("directory:".$number_alias."@".$domain_name);
} }
} }
@@ -195,7 +195,7 @@
<?php <?php
//determine refresh rate //determine refresh rate
$refresh_default = 1500; //milliseconds $refresh_default = 1500; //milliseconds
$refresh = is_numeric($_SESSION['operator_panel']['refresh']['numeric']) ? $_SESSION['operator_panel']['refresh']['numeric'] : $refresh_default; $refresh = is_numeric($settings->get('operator_panel', 'refresh')) ? $settings->get('operator_panel', 'refresh') : $refresh_default;
if ($refresh >= 0.5 && $refresh <= 120) { //convert seconds to milliseconds if ($refresh >= 0.5 && $refresh <= 120) { //convert seconds to milliseconds
$refresh = $refresh * 1000; $refresh = $refresh * 1000;
} }

View File

@@ -36,28 +36,50 @@
const app_uuid = 'dd3d173a-5d51-4231-ab22-b18c5b712bb2'; const app_uuid = 'dd3d173a-5d51-4231-ab22-b18c5b712bb2';
/** /**
* declare public variables * Set in the constructor. Must be a database object and cannot be null.
*/ * @var database Database Object
public $domain_uuid;
/**
* declare private variables
*/ */
private $database; private $database;
/**
* Settings object set in the constructor. Must be a settings object and cannot be null.
* @var settings Settings Object
*/
private $settings;
/**
* 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;
/**
* 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 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;
/** /**
* Called when the object is created * Called when the object is created
*/ */
public function __construct() { public function __construct(array $setting_array = []) {
//assign public variables //set domain and user UUIDs
if (!isset($this->domain_uuid)) { $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? '';
$this->domain_uuid = $_SESSION['domain_uuid']; $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? '';
}
//connect to the database //set domain_name
if (empty($this->database)) { $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? '';
$this->database = database::new();
} //set objects
$config = $setting_array['config'] ?? config::load();
$this->database = $setting_array['database'] ?? database::new(['config' => $config]);
$this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]);
} }
/** /**
@@ -87,7 +109,7 @@
$sql .= "e.domain_uuid = :domain_uuid "; $sql .= "e.domain_uuid = :domain_uuid ";
$sql .= "order by "; $sql .= "order by ";
$sql .= "e.extension asc "; $sql .= "e.extension asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $this->domain_uuid;
$extensions = $this->database->select($sql, $parameters); $extensions = $this->database->select($sql, $parameters);
//store extension status by user uuid //store extension status by user uuid
@@ -164,7 +186,7 @@
$presence_id = $presence[0]; $presence_id = $presence[0];
$presence_domain = $presence[1] ?? ''; $presence_domain = $presence[1] ?? '';
if ($user == $presence_id) { if ($user == $presence_id) {
if ($presence_domain == $_SESSION['domain_name']) { if ($presence_domain == $this->domain_name) {
$found = true; $found = true;
break; break;
} }

View File

@@ -74,29 +74,29 @@ if ($valet_info !== false) {
} }
//view_array($valet_matches, false); //view_array($valet_matches, false);
//unset($_SESSION['valet']); //unset($valet);
foreach($valet_matches as $row) { foreach($valet_matches as $row) {
if (!isset($_SESSION['valet']['uuid']['caller_id_name'])) { if (!isset($valet['uuid']['caller_id_name'])) {
$_SESSION['valet'][$row[1]]['caller_id_name'] = event_socket::api('uuid_getvar '.$row[1].' caller_id_name'); $valet[$row[1]]['caller_id_name'] = event_socket::api('uuid_getvar '.$row[1].' caller_id_name');
} }
if (!isset($_SESSION['valet']['uuid']['caller_id_number'])) { if (!isset($valet['uuid']['caller_id_number'])) {
$_SESSION['valet'][$row[1]]['caller_id_number'] = event_socket::api('uuid_getvar '.$row[1].' caller_id_number'); $valet[$row[1]]['caller_id_number'] = event_socket::api('uuid_getvar '.$row[1].' caller_id_number');
} }
} }
//unset the array //unset the array
//view_array($_SESSION['valet']); //view_array($valet);
//reformat the array and add the caller ID name and numbers //reformat the array and add the caller ID name and numbers
$x = 0; $x = 0;
foreach($valet_matches as $row) { foreach($valet_matches as $row) {
$valet_array[$x]['uuid'] = $row[1]; $valet_array[$x]['uuid'] = $row[1];
$valet_array[$x]['extension'] = $row[2]; $valet_array[$x]['extension'] = $row[2];
if (isset($_SESSION['valet'][$row[1]]['caller_id_name'])) { if (isset($valet[$row[1]]['caller_id_name'])) {
$valet_array[$x]['caller_id_name'] = $_SESSION['valet'][$row[1]]['caller_id_name']; $valet_array[$x]['caller_id_name'] = $valet[$row[1]]['caller_id_name'];
} }
if (isset($_SESSION['valet'][$row[1]]['caller_id_number'])) { if (isset($valet[$row[1]]['caller_id_number'])) {
$valet_array[$x]['caller_id_number'] = $_SESSION['valet'][$row[1]]['caller_id_number']; $valet_array[$x]['caller_id_number'] = $valet[$row[1]]['caller_id_number'];
} }
$x++; $x++;
} }
@@ -475,7 +475,7 @@ if (is_array($activity)) {
//record //record
if (permission_exists('operator_panel_record') && $ext_state == 'active') { if (permission_exists('operator_panel_record') && $ext_state == 'active') {
$call_identifier_record = $ext['call_uuid']; $call_identifier_record = $ext['call_uuid'];
$rec_file = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/archive/".date("Y")."/".date("M")."/".date("d")."/".escape($call_identifier_record).".wav"; $rec_file = $settings->get('switch', 'recordings')."/".$_SESSION['domain_name']."/archive/".date("Y")."/".date("M")."/".date("d")."/".escape($call_identifier_record).".wav";
if (file_exists($rec_file)) { if (file_exists($rec_file)) {
$block .= "<img src='resources/images/recording.png' style='width: 12px; height: 12px; border: none; margin: 4px 0px 0px 5px; cursor: help;' title=\"".$text['label-recording']."\" ".$onhover_pause_refresh.">\n"; $block .= "<img src='resources/images/recording.png' style='width: 12px; height: 12px; border: none; margin: 4px 0px 0px 5px; cursor: help;' title=\"".$text['label-recording']."\" ".$onhover_pause_refresh.">\n";
} }

View File

@@ -64,7 +64,7 @@
//save the data to the csv file //save the data to the csv file
if (isset($_POST['data'])) { if (isset($_POST['data'])) {
$file = $_SESSION['server']['temp']['dir']."/bridges-".$_SESSION['domain_name'].".csv"; $file = $settings->get('server', 'temp')."/bridges-".$_SESSION['domain_name'].".csv";
file_put_contents($file, $_POST['data']); file_put_contents($file, $_POST['data']);
$_SESSION['file'] = $file; $_SESSION['file'] = $file;
} }
@@ -72,11 +72,11 @@
//copy the csv file //copy the csv file
if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('bridge_import')) { if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('bridge_import')) {
if ($_POST['type'] == 'csv') { if ($_POST['type'] == 'csv') {
move_uploaded_file($_FILES['ulfile']['tmp_name'], $_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 ".$_SESSION['server']['temp']['dir']."/". htmlentities($_FILES['ulfile']['name']); $save_msg = "Uploaded file to ".$settings->get('server', 'temp')."/". htmlentities($_FILES['ulfile']['name']);
//system('chmod -R 744 '.$_SESSION['server']['temp']['dir'].'*'); //system('chmod -R 744 '.$settings->get('server', 'temp').'*');
unset($_POST['txtCommand']); unset($_POST['txtCommand']);
$file = $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']; $file = $settings->get('server', 'temp').'/'.$_FILES['ulfile']['name'];
$_SESSION['file'] = $file; $_SESSION['file'] = $file;
} }
} }

View File

@@ -34,9 +34,32 @@
const app_uuid = 'a6a7c4c5-340a-43ce-bcbc-2ed9bab8659d'; 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; 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 $permission_prefix;
private $list_page; private $list_page;
private $table; private $table;
@@ -47,7 +70,15 @@
/** /**
* called when the object is created * 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
$config = $setting_array['config'] ?? config::load();
$this->database = $setting_array['database'] ?? database::new(['config' => $config]);
$this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]);
//assign private variables //assign private variables
@@ -58,11 +89,6 @@
$this->toggle_field = 'bridge_enabled'; $this->toggle_field = 'bridge_enabled';
$this->toggle_values = ['true','false']; $this->toggle_values = ['true','false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
} }
/** /**
@@ -90,7 +116,7 @@
foreach ($records as $x => $record) { foreach ($records as $x => $record) {
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) { if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid;
} }
} }
@@ -145,7 +171,7 @@
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $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 .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -218,7 +244,7 @@
$sql = "select * from v_".$this->table." "; $sql = "select * from v_".$this->table." ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $x => $row) { foreach ($rows as $x => $row) {

View File

@@ -135,7 +135,7 @@
unset($parameters); unset($parameters);
//prepare to page the results //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 = "&search=".$search;
if ($show == "all" && permission_exists('call_block_all')) { if ($show == "all" && permission_exists('call_block_all')) {
$param .= "&show=all"; $param .= "&show=all";
@@ -151,7 +151,7 @@
$sql .= " call_block_country_code, call_block_number, extension, number_alias, call_block_count, "; $sql .= " call_block_country_code, call_block_number, extension, number_alias, call_block_count, ";
$sql .= " call_block_app, call_block_data, "; $sql .= " call_block_app, call_block_data, ";
$sql .= " to_char(timezone(:time_zone, insert_date), 'DD Mon YYYY') as date_formatted, \n"; $sql .= " to_char(timezone(:time_zone, insert_date), 'DD Mon YYYY') as date_formatted, \n";
if (date(!empty($_SESSION['domain']['time_format']['text']) == '12h')) { if (date(!empty($settings->get('domain', 'time_format')) == '12h')) {
$sql .= " to_char(timezone(:time_zone, insert_date), 'HH12:MI:SS am') as time_formatted, \n"; $sql .= " to_char(timezone(:time_zone, insert_date), 'HH12:MI:SS am') as time_formatted, \n";
} }
else { else {
@@ -336,8 +336,8 @@
} }
echo " <td class='center'>"; echo " <td class='center'>";
switch ($row['call_block_direction']) { switch ($row['call_block_direction']) {
case "inbound": echo "<img src='/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_inbound_answered.png' style='border: none;' title='".$text['label-inbound']."'>\n"; break; case "inbound": echo "<img src='/themes/".$settings->get('domain', 'template')."/images/icon_cdr_inbound_answered.png' style='border: none;' title='".$text['label-inbound']."'>\n"; break;
case "outbound": echo "<img src='/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_outbound_answered.png' style='border: none;' title='".$text['label-outbound']."'>\n"; break; case "outbound": echo "<img src='/themes/".$settings->get('domain', 'template')."/images/icon_cdr_outbound_answered.png' style='border: none;' title='".$text['label-outbound']."'>\n"; break;
} }
echo " </td>\n"; echo " </td>\n";
echo " <td class='center'>"; echo " <td class='center'>";

View File

@@ -618,7 +618,7 @@ if (permission_exists('call_block_all') || permission_exists('call_block_ring_gr
$sql .= "and direction <> 'local' "; $sql .= "and direction <> 'local' ";
$sql .= $sql_where ?? null; $sql .= $sql_where ?? null;
$sql .= "order by start_stamp desc "; $sql .= "order by start_stamp desc ";
$sql .= limit_offset($_SESSION['call_block']['recent_call_limit']['text']); $sql .= limit_offset($settings->get('call_block', 'recent_call_limit'));
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$recent_calls = $database->select($sql, $parameters); $recent_calls = $database->select($sql, $parameters);
unset($sql, $parameters); unset($sql, $parameters);
@@ -685,7 +685,7 @@ if (permission_exists('call_block_all') || permission_exists('call_block_ring_gr
$list_row_onclick_uncheck = "if (!this.checked) { document.getElementById('checkbox_all_".$direction."').checked = false; }"; $list_row_onclick_uncheck = "if (!this.checked) { document.getElementById('checkbox_all_".$direction."').checked = false; }";
$list_row_onclick_toggle = "onclick=\"document.getElementById('checkbox_".$x."').checked = document.getElementById('checkbox_".$x."').checked ? false : true; ".$list_row_onclick_uncheck."\""; $list_row_onclick_toggle = "onclick=\"document.getElementById('checkbox_".$x."').checked = document.getElementById('checkbox_".$x."').checked ? false : true; ".$list_row_onclick_uncheck."\"";
if (strlen($row['caller_id_number']) >= 7) { if (strlen($row['caller_id_number']) >= 7) {
if (!empty($_SESSION['domain']['time_format']['text']) && $_SESSION['domain']['time_format']['text'] == '24h') { if (!empty($settings->get('domain', 'time_format')) && $settings->get('domain', 'time_format') == '24h') {
$tmp_start_epoch = date('j M Y', $row['start_epoch'])." <span class='hide-sm-dn'>".date('H:i:s', $row['start_epoch']).'</span>'; $tmp_start_epoch = date('j M Y', $row['start_epoch'])." <span class='hide-sm-dn'>".date('H:i:s', $row['start_epoch']).'</span>';
} }
else { else {
@@ -697,10 +697,10 @@ if (permission_exists('call_block_all') || permission_exists('call_block_ring_gr
echo " <input type='hidden' name='xml_cdrs[$x][uuid]' value='".escape($row['xml_cdr_uuid'])."' />\n"; echo " <input type='hidden' name='xml_cdrs[$x][uuid]' value='".escape($row['xml_cdr_uuid'])."' />\n";
echo " </td>\n"; echo " </td>\n";
if ( if (
file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_inbound_voicemail.png") && file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$settings->get('domain', 'template')."/images/icon_cdr_inbound_voicemail.png") &&
file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_inbound_answered.png") && file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$settings->get('domain', 'template')."/images/icon_cdr_inbound_answered.png") &&
file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_outbound_failed.png") && file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$settings->get('domain', 'template')."/images/icon_cdr_outbound_failed.png") &&
file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_outbound_answered.png") file_exists($_SERVER["DOCUMENT_ROOT"]."/themes/".$settings->get('domain', 'template')."/images/icon_cdr_outbound_answered.png")
) { ) {
$title_mod = null; $title_mod = null;
echo " <td class='center' ".$list_row_onclick_toggle.">"; echo " <td class='center' ".$list_row_onclick_toggle.">";
@@ -713,7 +713,7 @@ if (permission_exists('call_block_all') || permission_exists('call_block_ring_gr
else { else {
$file_mod = "_answered"; $file_mod = "_answered";
} }
echo "<img src='/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_inbound".$file_mod.".png' style='border: none;' title='".$text['label-inbound'].$title_mod."'>\n"; echo "<img src='/themes/".$settings->get('domain', 'template')."/images/icon_cdr_inbound".$file_mod.".png' style='border: none;' title='".$text['label-inbound'].$title_mod."'>\n";
break; break;
case "outbound": case "outbound":
if ($row['billsec'] == 0) { if ($row['billsec'] == 0) {
@@ -723,7 +723,7 @@ if (permission_exists('call_block_all') || permission_exists('call_block_ring_gr
else { else {
$file_mod = "_answered"; $file_mod = "_answered";
} }
echo "<img src='/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_outbound".$file_mod.".png' style='border: none;' title='".$text['label-outbound'].$title_mod."'>\n"; echo "<img src='/themes/".$settings->get('domain', 'template')."/images/icon_cdr_outbound".$file_mod.".png' style='border: none;' title='".$text['label-outbound'].$title_mod."'>\n";
break; break;
} }
echo " </td>\n"; echo " </td>\n";

View File

@@ -12,9 +12,38 @@
const app_uuid = '9ed63276-e085-4897-839c-4f2e36d92d6c'; const app_uuid = '9ed63276-e085-4897-839c-4f2e36d92d6c';
/** /**
* declare private variables * Set in the constructor. Must be a database object and cannot be null.
* @var database Database Object
*/ */
private $database; 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 $permission_prefix; private $permission_prefix;
private $list_page; private $list_page;
private $table; private $table;
@@ -33,7 +62,16 @@
/** /**
* called when the object is created * 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
$config = $setting_array['config'] ?? config::load();
$this->database = $setting_array['database'] ?? database::new(['config' => $config]);
$this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]);
//assign private variables //assign private variables
$this->permission_prefix = 'call_block_'; $this->permission_prefix = 'call_block_';
@@ -42,12 +80,6 @@
$this->uuid_prefix = 'call_block_'; $this->uuid_prefix = 'call_block_';
$this->toggle_field = 'call_block_enabled'; $this->toggle_field = 'call_block_enabled';
$this->toggle_values = ['true','false']; $this->toggle_values = ['true','false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
} }
/** /**
@@ -88,7 +120,7 @@
} }
$sql .= ") "; $sql .= ") ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -103,7 +135,7 @@
foreach ($call_block_numbers as $call_block_uuid => $call_block_number) { foreach ($call_block_numbers as $call_block_uuid => $call_block_number) {
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $call_block_uuid; $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $call_block_uuid;
if (!permission_exists('call_block_domain')) { if (!permission_exists('call_block_domain')) {
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid;
} }
$x++; $x++;
} }
@@ -118,7 +150,7 @@
//clear the cache //clear the cache
$cache = new cache; $cache = new cache;
foreach ($call_block_numbers as $call_block_number) { foreach ($call_block_numbers as $call_block_number) {
$cache->delete("app:call_block:".$_SESSION['domain_name'].":".$call_block_number); $cache->delete("app:call_block:".$this->domain_name.":".$call_block_number);
} }
//set message //set message
@@ -160,7 +192,7 @@
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, call_block_number from v_".$this->table." "; $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, call_block_number from v_".$this->table." ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -190,7 +222,7 @@
//clear the cache //clear the cache
$cache = new cache; $cache = new cache;
foreach ($call_block_numbers as $call_block_number) { foreach ($call_block_numbers as $call_block_number) {
$cache->delete("app:call_block:".$_SESSION['domain_name'].":".$call_block_number); $cache->delete("app:call_block:".$this->domain_name.":".$call_block_number);
} }
//set message //set message
@@ -235,7 +267,7 @@
$sql = "select * from v_".$this->table." "; $sql = "select * from v_".$this->table." ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $x => $row) { foreach ($rows as $x => $row) {
@@ -307,7 +339,7 @@
} }
//get the caller id info from call detail records //get the caller id info from call detail records
if (isset($_SESSION['domain_uuid']) && is_uuid($_SESSION['domain_uuid'])) { if (is_uuid($this->domain_uuid)) {
//get the destination country code //get the destination country code
$sql = "select distinct(destination_prefix), "; $sql = "select distinct(destination_prefix), ";
$sql .= "(select count(destination_prefix) from v_destinations where domain_uuid = :domain_uuid and destination_prefix = d.destination_prefix) as count "; $sql .= "(select count(destination_prefix) from v_destinations where domain_uuid = :domain_uuid and destination_prefix = d.destination_prefix) as count ";
@@ -316,7 +348,7 @@
$sql .= "and destination_prefix <> '' "; $sql .= "and destination_prefix <> '' ";
$sql .= "and destination_enabled = true "; $sql .= "and destination_enabled = true ";
$sql .= "order by count desc limit 1; "; $sql .= "order by count desc limit 1; ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $this->domain_uuid;
$destination_country_code = $this->database->select($sql, $parameters ?? null, 'column'); $destination_country_code = $this->database->select($sql, $parameters ?? null, 'column');
unset($sql, $parameters); unset($sql, $parameters);
@@ -331,14 +363,14 @@
if (!permission_exists('call_block_extension')) { if (!permission_exists('call_block_extension')) {
$sql = "select extension_uuid from v_extension_users "; $sql = "select extension_uuid from v_extension_users ";
$sql .= "where user_uuid = :user_uuid "; $sql .= "where user_uuid = :user_uuid ";
$parameters['user_uuid'] = $_SESSION['user_uuid']; $parameters['user_uuid'] = $this->user_uuid;
$user_extensions = $this->database->select($sql, $parameters ?? null, 'all'); $user_extensions = $this->database->select($sql, $parameters ?? null, 'all');
unset($sql, $parameters); unset($sql, $parameters);
} }
//get the country code from default settings //get the country code from default settings
if (!empty($_SESSION['domain']['country_code']['numeric'])) { if ($this->settings->get('domain', 'country_code', null) !== null) {
$country_code = $_SESSION['domain']['country_code']['numeric']; $country_code = $this->settings->get('domain', 'country_code');
} }
//loop through records //loop through records
@@ -361,7 +393,7 @@
//build insert array //build insert array
if (permission_exists('call_block_extension')) { if (permission_exists('call_block_extension')) {
$array['call_block'][$x]['call_block_uuid'] = uuid(); $array['call_block'][$x]['call_block_uuid'] = uuid();
$array['call_block'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['call_block'][$x]['domain_uuid'] = $this->domain_uuid;
$array['call_block'][$x]['call_block_direction'] = $this->call_block_direction; $array['call_block'][$x]['call_block_direction'] = $this->call_block_direction;
if (is_uuid($this->extension_uuid)) { if (is_uuid($this->extension_uuid)) {
$array['call_block'][$x]['extension_uuid'] = $this->extension_uuid; $array['call_block'][$x]['extension_uuid'] = $this->extension_uuid;
@@ -387,7 +419,7 @@
foreach ($user_extensions as $field) { foreach ($user_extensions as $field) {
if (is_uuid($field['extension_uuid'])) { if (is_uuid($field['extension_uuid'])) {
$array['call_block'][$x]['call_block_uuid'] = uuid(); $array['call_block'][$x]['call_block_uuid'] = uuid();
$array['call_block'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['call_block'][$x]['domain_uuid'] = $this->domain_uuid;
$array['call_block'][$x]['call_block_direction'] = $this->call_block_direction; $array['call_block'][$x]['call_block_direction'] = $this->call_block_direction;
$array['call_block'][$x]['extension_uuid'] = $field['extension_uuid']; $array['call_block'][$x]['extension_uuid'] = $field['extension_uuid'];
if ($this->call_block_direction == 'inbound') { if ($this->call_block_direction == 'inbound') {
@@ -421,7 +453,7 @@
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and app_uuid = '".self::app_uuid."' "; $sql .= "and app_uuid = '".self::app_uuid."' ";
$sql .= "and dialplan_enabled <> true "; $sql .= "and dialplan_enabled <> true ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $this->domain_uuid;
$rows = $this->database->select($sql, $parameters); $rows = $this->database->select($sql, $parameters);
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $x => $row) { foreach ($rows as $x => $row) {

View File

@@ -107,7 +107,7 @@
//prepare the paging //prepare the paging
$param = ''; $param = '';
$rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; $rows_per_page = $settings->get('domain', 'paging', 50);
if (!empty($search)) { if (!empty($search)) {
$param .= "&search=".urlencode($search); $param .= "&search=".urlencode($search);
} }

View File

@@ -202,7 +202,7 @@
$response = event_socket::command($cmd); $response = event_socket::command($cmd);
//method 2 //method 2
//cmd_async($_SESSION['switch']['bin']['dir']."/fs_cli -x \"".$cmd."\";"); //cmd_async($settings->get('switch', 'bin')."/fs_cli -x \"".$cmd."\";");
//spread the calls out so that they are scheduled with different times //spread the calls out so that they are scheduled with different times
if (strlen($broadcast_concurrent_limit) > 0 && !empty($broadcast_timeout)) { if (strlen($broadcast_concurrent_limit) > 0 && !empty($broadcast_timeout)) {

View File

@@ -36,11 +36,27 @@
const app_name = 'call_broadcast'; const app_name = 'call_broadcast';
const app_uuid = 'efc11f6b-ed73-9955-4d4d-3a1bed75a056'; const app_uuid = 'efc11f6b-ed73-9955-4d4d-3a1bed75a056';
/**
* Set in the constructor. Must be a database object and cannot be null.
* @var database Database Object
*/
private $database;
/**
* 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 * declare private variables
*/ */
private $database;
private $permission_prefix; private $permission_prefix;
private $list_page; private $list_page;
private $table; private $table;
@@ -49,19 +65,19 @@
/** /**
* called when the object is created * 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();
//assign private variables //assign private variables
$this->permission_prefix = 'call_broadcast_'; $this->permission_prefix = 'call_broadcast_';
$this->list_page = 'call_broadcast.php'; $this->list_page = 'call_broadcast.php';
$this->table = 'call_broadcasts'; $this->table = 'call_broadcasts';
$this->uuid_prefix = 'call_broadcast_'; $this->uuid_prefix = 'call_broadcast_';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
} }
/** /**
@@ -89,7 +105,7 @@
foreach($records as $x => $record) { foreach($records as $x => $record) {
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) { if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid;
} }
} }
@@ -141,7 +157,7 @@
$sql = "select * from v_".$this->table." "; $sql = "select * from v_".$this->table." ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $x => $row) { foreach ($rows as $x => $row) {

View File

@@ -118,7 +118,7 @@
//determine refresh rate //determine refresh rate
$refresh_default = 1500; //milliseconds $refresh_default = 1500; //milliseconds
$refresh = is_numeric($_SESSION['call_center']['refresh']['numeric']) ? $_SESSION['call_center']['refresh']['numeric'] : $refresh_default; $refresh = is_numeric($settings->get('call_center', 'refresh')) ? $settings->get('call_center', 'refresh') : $refresh_default;
if ($refresh >= 0.5 && $refresh <= 120) { //convert seconds to milliseconds if ($refresh >= 0.5 && $refresh <= 120) { //convert seconds to milliseconds
$refresh = $refresh * 1000; $refresh = $refresh * 1000;
} }

View File

@@ -122,13 +122,13 @@
} }
//set default values //set default values
if (empty($agent_call_timeout)) { $agent_call_timeout = "20"; } $agent_call_timeout = $agent_call_timeout ?? "20";
if (empty($agent_max_no_answer)) { $agent_max_no_answer = "0"; } $agent_max_no_answer = $agent_max_no_answer ?? "0";
if (empty($agent_wrap_up_time)) { $agent_wrap_up_time = "10"; } $agent_wrap_up_time = $agent_wrap_up_time ?? "10";
if (empty($agent_no_answer_delay_time)) { $agent_no_answer_delay_time = "30"; } $agent_no_answer_delay_time = $agent_no_answer_delay_time ?? "30";
if (empty($agent_reject_delay_time)) { $agent_reject_delay_time = "90"; } $agent_reject_delay_time = $agent_reject_delay_time ?? "90";
if (empty($agent_busy_delay_time)) { $agent_busy_delay_time = "90"; } $agent_busy_delay_time = $agent_busy_delay_time ?? "90";
if ($agent_record === null) { $agent_record = false; } $agent_record = $agent_record ?? false;
//add the call_center_agent_uuid //add the call_center_agent_uuid
if (empty($call_center_agent_uuid)) { if (empty($call_center_agent_uuid)) {
@@ -136,7 +136,7 @@
} }
//change the contact string to loopback - Not recommended added for backwards comptability causes multiple problems //change the contact string to loopback - Not recommended added for backwards comptability causes multiple problems
if ($_SESSION['call_center']['agent_contact_method']['text'] == 'loopback') { if ($settings->get('call_center', 'agent_contact_method') == 'loopback') {
$agent_contact = str_replace("user/", "loopback/", $agent_contact); $agent_contact = str_replace("user/", "loopback/", $agent_contact);
$agent_contact = str_replace("@", "/", $agent_contact); $agent_contact = str_replace("@", "/", $agent_contact);
} }

View File

@@ -47,7 +47,7 @@
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$tiers = $database->select($sql, $parameters, 'all'); $tiers = $database->select($sql, $parameters, 'all');
if (!empty($_SESSION['call_center']['queue_login']['text']) && $_SESSION['call_center']['queue_login']['text'] == 'dynamic') { if (!empty($settings->get('call_center', 'queue_login')) && $settings->get('call_center', 'queue_login') == 'dynamic') {
$per_queue_login = true; $per_queue_login = true;
} }
else { else {

View File

@@ -94,7 +94,7 @@
$num_rows = $database->select($sql, $parameters ?? null, 'column'); $num_rows = $database->select($sql, $parameters ?? null, 'column');
//prepare to page the results //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=".urlencode($search); $param = "&search=".urlencode($search);
if ($show == "all" && permission_exists('call_center_all')) { if ($show == "all" && permission_exists('call_center_all')) {
$param .= "&show=all"; $param .= "&show=all";

View File

@@ -685,21 +685,21 @@
unset($sounds); unset($sounds);
} }
//set default values //set the default values
if (empty($queue_strategy)) { $queue_strategy = "longest-idle-agent"; } $queue_strategy = $queue_strategy ?? "longest-idle-agent";
if (empty($queue_moh_sound)) { $queue_moh_sound = "\$\${hold_music}"; } $queue_moh_sound = $queue_moh_sound ?? "\$\${hold_music}";
if (empty($queue_time_base_score)) { $queue_time_base_score = "system"; } $queue_time_base_score = $queue_time_base_score ?? "system";
if (empty($queue_max_wait_time)) { $queue_max_wait_time = "0"; } $queue_max_wait_time = $queue_max_wait_time ?? "0";
if (empty($queue_max_wait_time_with_no_agent)) { $queue_max_wait_time_with_no_agent = "90"; } $queue_max_wait_time_with_no_agent = $queue_max_wait_time_with_no_agent ?? "90";
if (empty($queue_max_wait_time_with_no_agent_time_reached)) { $queue_max_wait_time_with_no_agent_time_reached = "30"; } $queue_max_wait_time_with_no_agent_time_reached = $queue_max_wait_time_with_no_agent_time_reached ?? "30";
if (empty($queue_tier_rule_wait_second)) { $queue_tier_rule_wait_second = "30"; } $queue_tier_rule_wait_second = $queue_tier_rule_wait_second ?? "30";
if (empty($queue_discard_abandoned_after)) { $queue_discard_abandoned_after = "900"; } $queue_discard_abandoned_after = $queue_discard_abandoned_after ?? "900";
if (empty($queue_context)) { $queue_context = $domain_name; } $queue_context = $queue_context ?? $domain_name;
if ($queue_record_template === null) { $queue_record_template = 'false'; } $queue_record_template = $queue_record_template ?? 'false';
if ($queue_tier_rules_apply === null) { $queue_tier_rules_apply = false; } $queue_tier_rules_apply = $queue_tier_rules_apply ?? false;
if ($queue_tier_rule_wait_multiply_level === null) { $queue_tier_rule_wait_multiply_level = true; } $queue_tier_rule_wait_multiply_level = $queue_tier_rule_wait_multiply_level ?? true;
if ($queue_tier_rule_no_agent_no_wait === null) { $queue_tier_rule_no_agent_no_wait = true; } $queue_tier_rule_no_agent_no_wait = $queue_tier_rule_no_agent_no_wait ?? true;
if ($queue_abandoned_resume_allowed === null) { $queue_abandoned_resume_allowed = false; } $queue_abandoned_resume_allowed = $queue_abandoned_resume_allowed ?? false;
//create token //create token
$object = new token; $object = new token;

View File

@@ -144,11 +144,11 @@
echo button::create(['type'=>'button','label'=>$text['button-wallboard'],'icon'=>'th','link'=>PROJECT_PATH.'/app/call_center_wallboard/call_center_wallboard.php']); echo button::create(['type'=>'button','label'=>$text['button-wallboard'],'icon'=>'th','link'=>PROJECT_PATH.'/app/call_center_wallboard/call_center_wallboard.php']);
} }
$margin_left = permission_exists('call_center_agent_view') || permission_exists('call_center_wallboard') ? 'margin-left: 15px;' : null; $margin_left = permission_exists('call_center_agent_view') || permission_exists('call_center_wallboard') ? 'margin-left: 15px;' : null;
if (permission_exists('call_center_queue_add') && (!is_numeric($_SESSION['limit']['call_center_queues']['numeric'] ?? '') || $num_rows <= $_SESSION['limit']['call_center_queues']['numeric'])) { if (permission_exists('call_center_queue_add') && (!is_numeric($settings->get('limit', 'call_center_queues') ?? '') || $num_rows <= $settings->get('limit', 'call_center_queues'))) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','style'=>$margin_left,'link'=>'call_center_queue_edit.php']); echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','style'=>$margin_left,'link'=>'call_center_queue_edit.php']);
unset($margin_left); unset($margin_left);
} }
if (permission_exists('call_center_queue_add') && $result && (!is_numeric($_SESSION['limit']['call_center_queues']['numeric'] ?? '') || $num_rows <= $_SESSION['limit']['call_center_queues']['numeric'])) { if (permission_exists('call_center_queue_add') && $result && (!is_numeric($settings->get('limit', 'call_center_queues') ?? '') || $num_rows <= $settings->get('limit', 'call_center_queues'))) {
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; '.!empty($margin_left),'onclick'=>"modal_open('modal-copy','btn_copy');"]); 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; '.!empty($margin_left),'onclick'=>"modal_open('modal-copy','btn_copy');"]);
unset($margin_left); unset($margin_left);
} }
@@ -176,7 +176,7 @@
echo " <div style='clear: both;'></div>\n"; echo " <div style='clear: both;'></div>\n";
echo "</div>\n"; echo "</div>\n";
if (permission_exists('call_center_queue_add') && $result && (!is_numeric($_SESSION['limit']['call_center_queues']['numeric'] ?? '') || $num_rows <= $_SESSION['limit']['call_center_queues']['numeric'])) { if (permission_exists('call_center_queue_add') && $result && (!is_numeric($settings->get('limit', 'call_center_queues') ?? '') || $num_rows <= $settings->get('limit', 'call_center_queues'))) {
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');"])]); 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('call_center_queue_delete') && $result) { if (permission_exists('call_center_queue_delete') && $result) {

View File

@@ -37,9 +37,14 @@
const app_uuid = '95788e50-9500-079e-2807-fd530b0ea370'; const app_uuid = '95788e50-9500-079e-2807-fd530b0ea370';
/** /**
* define 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; public $domain_uuid;
/**
* define public variables
*/
public $call_center_queue_uuid; public $call_center_queue_uuid;
public $dialplan_uuid; public $dialplan_uuid;
public $queue_name; public $queue_name;
@@ -47,10 +52,27 @@
public $destination_number; public $destination_number;
public $queue_cc_exit_keys; public $queue_cc_exit_keys;
/**
* Set in the constructor. Must be a database object and cannot be null.
* @var database Database Object
*/
private $database;
/**
* 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 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 * declare private variables
*/ */
private $database;
private $permission_prefix; private $permission_prefix;
private $list_page; private $list_page;
private $table; private $table;
@@ -59,11 +81,14 @@
/** /**
* Called when the object is created * Called when the object is created
*/ */
public function __construct() { public function __construct(array $setting_array = []) {
//connect to the database //set domain and user UUIDs
if (empty($this->database)) { $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? '';
$this->database = database::new(); $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();
} }
/** /**
@@ -100,7 +125,7 @@
$dialplan["domain_uuid"] = $this->domain_uuid; $dialplan["domain_uuid"] = $this->domain_uuid;
$dialplan["dialplan_name"] = ($this->queue_name != '') ? $this->queue_name : format_phone($this->destination_number); $dialplan["dialplan_name"] = ($this->queue_name != '') ? $this->queue_name : format_phone($this->destination_number);
$dialplan["dialplan_number"] = $this->destination_number; $dialplan["dialplan_number"] = $this->destination_number;
$dialplan["dialplan_context"] = $_SESSION['domain_name']; $dialplan["dialplan_context"] = $this->domain_name;
$dialplan["dialplan_continue"] = false; $dialplan["dialplan_continue"] = false;
$dialplan["dialplan_order"] = "210"; $dialplan["dialplan_order"] = "210";
$dialplan["dialplan_enabled"] = true; $dialplan["dialplan_enabled"] = true;
@@ -190,7 +215,7 @@
$dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid; $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
$dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
$dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "callcenter"; $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "callcenter";
$dialplan["dialplan_details"][$y]["dialplan_detail_data"] = $this->queue_name.'@'.$_SESSION["domain_name"]; $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = $this->queue_name.'@'.$this->domain_name;
$dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "2"; $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "2";
$dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
$y++; $y++;
@@ -252,7 +277,7 @@
//clear the cache //clear the cache
$cache = new cache; $cache = new cache;
$cache->delete("dialplan:".$_SESSION['domain_name']); $cache->delete("dialplan:".$this->domain_name);
//return the dialplan_uuid //return the dialplan_uuid
return $dialplan_response; return $dialplan_response;
@@ -299,7 +324,7 @@
$sql = "select ".$this->uuid_prefix."uuid as uuid, dialplan_uuid, queue_name, queue_extension from v_".$this->table." "; $sql = "select ".$this->uuid_prefix."uuid as uuid, dialplan_uuid, queue_name, queue_extension from v_".$this->table." ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in ('".implode("','", $uuids)."') "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -315,16 +340,16 @@
$x = 0; $x = 0;
foreach ($call_center_queues as $call_center_queue_uuid => $call_center_queue) { foreach ($call_center_queues as $call_center_queue_uuid => $call_center_queue) {
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $call_center_queue_uuid; $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $call_center_queue_uuid;
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid;
$array['dialplans'][$x]['dialplan_uuid'] = $call_center_queue['dialplan_uuid']; $array['dialplans'][$x]['dialplan_uuid'] = $call_center_queue['dialplan_uuid'];
$array['dialplans'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['domain_uuid'] = $this->domain_uuid;
$array['dialplan_details'][$x]['dialplan_uuid'] = $call_center_queue['dialplan_uuid']; $array['dialplan_details'][$x]['dialplan_uuid'] = $call_center_queue['dialplan_uuid'];
$array['dialplan_details'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplan_details'][$x]['domain_uuid'] = $this->domain_uuid;
$array['call_center_tiers'][$x][$this->uuid_prefix.'uuid'] = $call_center_queue_uuid; $array['call_center_tiers'][$x][$this->uuid_prefix.'uuid'] = $call_center_queue_uuid;
$array['call_center_tiers'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['call_center_tiers'][$x]['domain_uuid'] = $this->domain_uuid;
$x++; $x++;
$array['call_center_tiers'][$x]['queue_name'] = $call_center_queue['queue_extension']."@".$_SESSION['domain_name']; $array['call_center_tiers'][$x]['queue_name'] = $call_center_queue['queue_extension']."@".$this->domain_name;
$array['call_center_tiers'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['call_center_tiers'][$x]['domain_uuid'] = $this->domain_uuid;
$x++; $x++;
} }
@@ -337,7 +362,7 @@
//delete the queue in the switch //delete the queue in the switch
if ($esl->is_connected()) { if ($esl->is_connected()) {
foreach ($uuids as $uuid) { foreach ($uuids as $uuid) {
$cmd = "callcenter_config queue unload ".$call_center_queues[$uuid]['queue_extension']."@".$_SESSION['domain_name']; $cmd = "callcenter_config queue unload ".$call_center_queues[$uuid]['queue_extension']."@".$this->domain_name;
$response = event_socket::api($cmd); $response = event_socket::api($cmd);
} }
} }
@@ -359,7 +384,7 @@
//clear the cache //clear the cache
$cache = new cache; $cache = new cache;
$cache->delete("dialplan:".$_SESSION["domain_name"]); $cache->delete("dialplan:".$this->domain_name);
remove_config_from_cache('configuration:callcenter.conf'); remove_config_from_cache('configuration:callcenter.conf');
//clear the destinations session array //clear the destinations session array
@@ -417,9 +442,9 @@
if (is_array($uuids) && @sizeof($uuids) != 0) { if (is_array($uuids) && @sizeof($uuids) != 0) {
foreach ($uuids as $x => $uuid) { foreach ($uuids as $x => $uuid) {
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $uuid; $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $uuid;
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid;
$array['call_center_tiers'][$x]['call_center_agent_uuid'] = $uuid; $array['call_center_tiers'][$x]['call_center_agent_uuid'] = $uuid;
$array['call_center_tiers'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['call_center_tiers'][$x]['domain_uuid'] = $this->domain_uuid;
} }
} }
@@ -580,7 +605,7 @@
//clear the cache //clear the cache
$cache = new cache; $cache = new cache;
$cache->delete("dialplan:".$_SESSION["domain_name"]); $cache->delete("dialplan:".$this->domain_name);
//set message //set message
message::add($text['message-copy']); message::add($text['message-copy']);

View File

@@ -39,7 +39,7 @@
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get($_SESSION['domain']['language']['code'], 'app/call_centers'); $text = $language->get($settings->get('domain', 'language', 'en-us'), 'app/call_centers');
//get http variables and set as php variables //get http variables and set as php variables
$order_by = $_GET["order_by"] ?? null; $order_by = $_GET["order_by"] ?? null;

View File

@@ -46,20 +46,20 @@
if ($_GET['type'] == 'recordings') { if ($_GET['type'] == 'recordings') {
$slash = substr($_GET['data'],0,1) != '/' ? '/' : null; $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') { else if ($_GET['type'] == 'sounds') {
//get first installed language (like en/us/callie) //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) { 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); $path_array = explode('/', $path);
if (count($path_array) <> 3 || strlen($path_array[0]) <> 2 || strlen($path_array[1]) <> 2) { if (count($path_array) <> 3 || strlen($path_array[0]) <> 2 || strlen($path_array[1]) <> 2) {
unset($language_paths[$key]); 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])) { if (empty($language_paths[$key])) {
unset($language_paths[$key]); unset($language_paths[$key]);
} }
@@ -69,7 +69,7 @@
//determine the path for sound file //determine the path for sound file
$filename_parts = explode('/', str_replace('..', '', $_GET['data'])); $filename_parts = explode('/', str_replace('..', '', $_GET['data']));
if (!is_array($filename_parts) || @sizeof($filename_parts) != 2) { exit; } 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 //build full path to sound file
$full_file_path = $path.$filename_parts[1]; $full_file_path = $path.$filename_parts[1];
@@ -91,13 +91,13 @@
$waveform = new Waveform($full_file_path); $waveform = new Waveform($full_file_path);
Waveform::$linesPerPixel = 1; // default: 8 Waveform::$linesPerPixel = 1; // default: 8
Waveform::$samplesPerLine = 512; // default: 512 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::$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($_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::$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($_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::$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($_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::$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($_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::$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($_SESSION['theme']['audio_player_waveform_single_axis']['boolean'] ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis 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($_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; $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 $wf = $waveform->getWaveform($temp_filename, 1600, $height ?? 180); // input: png filename returns boolean true/false, or 'base64' returns base64 string
} }

View File

@@ -470,7 +470,7 @@
echo " ".$text['label-call_flow_extension']."\n"; echo " ".$text['label-call_flow_extension']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='call_flow_extension' maxlength='255' value=\"".escape($call_flow_extension)."\" required='required' placeholder=\"".($_SESSION['call_flow']['extension_range']['text'] ?? '')."\">\n"; echo " <input class='formfld' type='text' name='call_flow_extension' maxlength='255' value=\"".escape($call_flow_extension)."\" required='required' placeholder=\"".($settings->get('call_flow', 'extension_range') ?? '')."\">\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-call_flow_extension']."\n"; echo $text['description-call_flow_extension']."\n";
echo "</td>\n"; echo "</td>\n";
@@ -575,8 +575,8 @@
if ($key == 'recordings') { if ($key == 'recordings') {
if ( if (
!empty($instance_value) && !empty($instance_value) &&
($instance_value == $row["value"] || $instance_value == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.$row["value"]) && ($instance_value == $row["value"] || $instance_value == $settings->get('switch', 'recordings')."/".$_SESSION['domain_name'].'/'.$row["value"]) &&
file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME)) file_exists($settings->get('switch', 'recordings')."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME))
) { ) {
$selected = "selected='selected'"; $selected = "selected='selected'";
$playable = '../recordings/recordings.php?action=download&type=rec&filename='.pathinfo($row["value"], PATHINFO_BASENAME); $playable = '../recordings/recordings.php?action=download&type=rec&filename='.pathinfo($row["value"], PATHINFO_BASENAME);
@@ -677,8 +677,8 @@
if ($key == 'recordings') { if ($key == 'recordings') {
if ( if (
!empty($instance_value) && !empty($instance_value) &&
($instance_value == $row["value"] || $instance_value == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.$row["value"]) && ($instance_value == $row["value"] || $instance_value == $settings->get('switch', 'recordings')."/".$_SESSION['domain_name'].'/'.$row["value"]) &&
file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME)) file_exists($settings->get('switch', 'recordings')."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME))
) { ) {
$selected = "selected='selected'"; $selected = "selected='selected'";
$playable = '../recordings/recordings.php?action=download&type=rec&filename='.pathinfo($row["value"], PATHINFO_BASENAME); $playable = '../recordings/recordings.php?action=download&type=rec&filename='.pathinfo($row["value"], PATHINFO_BASENAME);

View File

@@ -118,7 +118,7 @@
$num_rows = $database->select($sql, $parameters ?? null, 'column'); $num_rows = $database->select($sql, $parameters ?? null, 'column');
//prepare to page the results //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=".urlencode($search); $param = "&search=".urlencode($search);
if ($show == "all" && permission_exists('call_flow_all')) { if ($show == "all" && permission_exists('call_flow_all')) {
$param .= "&show=all"; $param .= "&show=all";

View File

@@ -38,11 +38,39 @@
const app_name = 'call_flows'; const app_name = 'call_flows';
const app_uuid = 'b1b70f85-6b42-429b-8c5a-60c8b02b7d14'; const app_uuid = 'b1b70f85-6b42-429b-8c5a-60c8b02b7d14';
/**
* 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 * declare private variables
*/ */
private $database;
private $permission_prefix; private $permission_prefix;
private $list_page; private $list_page;
private $table; private $table;
@@ -52,7 +80,14 @@
/** /**
* called when the object is created * 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();
//assign private variables //assign private variables
$this->permission_prefix = 'call_flow_'; $this->permission_prefix = 'call_flow_';
@@ -60,12 +95,6 @@
$this->table = 'call_flows'; $this->table = 'call_flows';
$this->uuid_prefix = 'call_flow_'; $this->uuid_prefix = 'call_flow_';
$this->toggle_values = ['true','false']; $this->toggle_values = ['true','false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
} }
/** /**
@@ -101,7 +130,7 @@
$sql = "select ".$this->uuid_prefix."uuid as uuid, dialplan_uuid, call_flow_context from v_".$this->table." "; $sql = "select ".$this->uuid_prefix."uuid as uuid, dialplan_uuid, call_flow_context from v_".$this->table." ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -116,11 +145,11 @@
$x = 0; $x = 0;
foreach ($call_flows as $call_flow_uuid => $call_flow) { foreach ($call_flows as $call_flow_uuid => $call_flow) {
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $call_flow_uuid; $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $call_flow_uuid;
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid;
$array['dialplans'][$x]['dialplan_uuid'] = $call_flow['dialplan_uuid']; $array['dialplans'][$x]['dialplan_uuid'] = $call_flow['dialplan_uuid'];
$array['dialplans'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['domain_uuid'] = $this->domain_uuid;
$array['dialplan_details'][$x]['dialplan_uuid'] = $call_flow['dialplan_uuid']; $array['dialplan_details'][$x]['dialplan_uuid'] = $call_flow['dialplan_uuid'];
$array['dialplan_details'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplan_details'][$x]['domain_uuid'] = $this->domain_uuid;
$x++; $x++;
} }
@@ -197,7 +226,7 @@
$sql .= "dialplan_uuid, call_flow_feature_code, call_flow_context from v_".$this->table." "; $sql .= "dialplan_uuid, call_flow_feature_code, call_flow_context from v_".$this->table." ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (!empty($rows)) { if (!empty($rows)) {
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -265,8 +294,8 @@
//prepare the event //prepare the event
$cmd = "sendevent PRESENCE_IN\n"; $cmd = "sendevent PRESENCE_IN\n";
$cmd .= "proto: flow\n"; $cmd .= "proto: flow\n";
$cmd .= "login: ".$row['call_flow_feature_code']."@".$_SESSION['domain_name']."\n"; $cmd .= "login: ".$row['call_flow_feature_code']."@".$this->domain_name."\n";
$cmd .= "from: ".$row['call_flow_feature_code']."@".$_SESSION['domain_name']."\n"; $cmd .= "from: ".$row['call_flow_feature_code']."@".$this->domain_name."\n";
$cmd .= "status: Active (1 waiting)\n"; $cmd .= "status: Active (1 waiting)\n";
$cmd .= "rpid: unknown\n"; $cmd .= "rpid: unknown\n";
$cmd .= "event_type: presence\n"; $cmd .= "event_type: presence\n";
@@ -327,7 +356,7 @@
$sql = "select * from v_".$this->table." "; $sql = "select * from v_".$this->table." ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $x => $row) { foreach ($rows as $x => $row) {

View File

@@ -46,20 +46,20 @@
if ($_GET['type'] == 'recordings') { if ($_GET['type'] == 'recordings') {
$slash = substr($_GET['data'],0,1) != '/' ? '/' : null; $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') { else if ($_GET['type'] == 'sounds') {
//get first installed language (like en/us/callie) //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) { 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); $path_array = explode('/', $path);
if (count($path_array) <> 3 || strlen($path_array[0]) <> 2 || strlen($path_array[1]) <> 2) { if (count($path_array) <> 3 || strlen($path_array[0]) <> 2 || strlen($path_array[1]) <> 2) {
unset($language_paths[$key]); 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])) { if (empty($language_paths[$key])) {
unset($language_paths[$key]); unset($language_paths[$key]);
} }
@@ -69,7 +69,7 @@
//determine the path for sound file //determine the path for sound file
$filename_parts = explode('/', str_replace('..', '', $_GET['data'])); $filename_parts = explode('/', str_replace('..', '', $_GET['data']));
if (!is_array($filename_parts) || @sizeof($filename_parts) != 2) { exit; } 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 //build full path to sound file
$full_file_path = $path.$filename_parts[1]; $full_file_path = $path.$filename_parts[1];
@@ -91,13 +91,13 @@
$waveform = new Waveform($full_file_path); $waveform = new Waveform($full_file_path);
Waveform::$linesPerPixel = 1; // default: 8 Waveform::$linesPerPixel = 1; // default: 8
Waveform::$samplesPerLine = 512; // default: 512 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::$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($_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::$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($_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::$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($_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::$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($_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::$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($_SESSION['theme']['audio_player_waveform_single_axis']['boolean'] ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis 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($_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; $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 $wf = $waveform->getWaveform($temp_filename, 1600, $height ?? 180); // input: png filename returns boolean true/false, or 'base64' returns base64 string
} }

View File

@@ -44,7 +44,7 @@
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get($_SESSION['domain']['language']['code'], 'app/call_forward'); $text = $language->get($settings->get('domain', 'language', 'en-us'), 'app/call_forward');
//get posted data and set defaults //get posted data and set defaults
$action = $_POST['action'] ?? ''; $action = $_POST['action'] ?? '';
@@ -127,7 +127,7 @@
unset($parameters); unset($parameters);
//prepare the paging //prepare the paging
$rows_per_page = !empty($_SESSION['domain']['paging']['numeric']) ? $_SESSION['domain']['paging']['numeric'] : 50; $rows_per_page = !empty($settings->get('domain', 'paging')) ? $settings->get('domain', 'paging') : 50;
if ($search) { if ($search) {
$params[] = "search=" . $search; $params[] = "search=" . $search;

View File

@@ -37,12 +37,22 @@
const app_name = 'call_forward'; const app_name = 'call_forward';
const app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d'; const app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d';
/**
* 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;
/** /**
* declare public variables * declare public variables
*/ */
public $debug; public $debug;
public $domain_uuid;
public $domain_name;
public $extension_uuid; public $extension_uuid;
public $forward_all_destination; public $forward_all_destination;
public $forward_all_enabled; public $forward_all_enabled;
@@ -50,11 +60,27 @@
public $outbound_caller_id_name; public $outbound_caller_id_name;
public $outbound_caller_id_number; public $outbound_caller_id_number;
/**
* 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;
/** /**
* declare private variables * declare private variables
*/ */
private $database;
private $extension; private $extension;
private $number_alias; private $number_alias;
private $toll_allow; private $toll_allow;
@@ -62,15 +88,19 @@
/** /**
* called when the object is created * 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 //assign private variables
$this->toggle_field = 'forward_all_enabled'; $this->toggle_field = 'forward_all_enabled';
$this->toggle_values = ['true', 'false']; $this->toggle_values = ['true', 'false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
} }
public function set() { public function set() {
@@ -166,7 +196,7 @@
$sql .= "from v_extensions "; $sql .= "from v_extensions ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and extension_uuid in (" . implode(', ', $uuids) . ") "; $sql .= "and extension_uuid in (" . implode(', ', $uuids) . ") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $this->domain_uuid;
$rows = $this->database->select($sql, $parameters, 'all'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -235,7 +265,7 @@
if ($settings->get('device', 'feature_sync', false)) { if ($settings->get('device', 'feature_sync', false)) {
foreach ($extensions as $uuid => $extension) { foreach ($extensions as $uuid => $extension) {
$feature_event_notify = new feature_event_notify; $feature_event_notify = new feature_event_notify;
$feature_event_notify->domain_name = $_SESSION['domain_name']; $feature_event_notify->domain_name = $this->domain_name;
$feature_event_notify->extension = $extension['extension']; $feature_event_notify->extension = $extension['extension'];
$feature_event_notify->do_not_disturb = $extension['do_not_disturb']; $feature_event_notify->do_not_disturb = $extension['do_not_disturb'];
$feature_event_notify->ring_count = ceil($extension['call_timeout'] / 6); $feature_event_notify->ring_count = ceil($extension['call_timeout'] / 6);
@@ -252,7 +282,7 @@
} }
//synchronize configuration //synchronize configuration
if (!empty($_SESSION['switch']['extensions']['dir']) && is_readable($_SESSION['switch']['extensions']['dir'])) { if (!empty($this->settings->get('switch', 'extensions')) && is_readable($this->settings->get('switch', 'extensions'))) {
$ext = new extension; $ext = new extension;
$ext->xml(); $ext->xml();
unset($ext); unset($ext);
@@ -261,9 +291,9 @@
//clear the cache //clear the cache
$cache = new cache; $cache = new cache;
foreach ($extensions as $uuid => $extension) { foreach ($extensions as $uuid => $extension) {
$cache->delete("directory:" . $extension['extension'] . "@" . $_SESSION['domain_name']); $cache->delete("directory:" . $extension['extension'] . "@" . $this->domain_name);
if ($extension['number_alias'] != '') { if ($extension['number_alias'] != '') {
$cache->delete("directory:" . $extension['number_alias'] . "@" . $_SESSION['domain_name']); $cache->delete("directory:" . $extension['number_alias'] . "@" . $this->domain_name);
} }
} }

View File

@@ -33,32 +33,73 @@
const app_name = 'call_forward'; const app_name = 'call_forward';
const app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d'; const app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d';
/**
* 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;
/** /**
* declare public variables * declare public variables
*/ */
public $debug; public $debug;
public $domain_uuid;
public $domain_name;
public $extension_uuid; public $extension_uuid;
public $extension; public $extension;
public $enabled; public $enabled;
/**
* 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;
/** /**
* declare private variables * declare private variables
*/ */
private $permission;
private $database; private $list_page;
private $table;
private $uuid_prefix;
private $toggle_field;
private $toggle_values;
/** /**
* called when the object is created * called when the object is created
*/ */
public function __construct() { public function __construct(array $setting_array = []) {
//set domain and user UUIDs
//connect to the database $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? '';
if (empty($this->database)) { $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? '';
$this->database = database::new(); $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? '';
} $this->username = $setting_array['username'] ?? $_SESSION['username'] ?? '';
//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]);
} }
//update the user_status //update the user_status
@@ -69,8 +110,8 @@
$user_status = "Logged Out"; $user_status = "Logged Out";
$esl = event_socket::create(); $esl = event_socket::create();
if ($esl->is_connected()) { if ($esl->is_connected()) {
$switch_cmd .= "callcenter_config agent set status ".$_SESSION['username']."@".$this->domain_name." '".$user_status."'"; $switch_cmd .= "callcenter_config agent set status ".$this->username."@".$this->domain_name." '".$user_status."'";
$switch_result = event_socket::api($switch_cmd); $esl->request('api '.$switch_cmd);
} }
//update the database user_status //update the database user_status
@@ -81,7 +122,7 @@
$sql .= "and username = :username "; $sql .= "and username = :username ";
$parameters['user_status'] = "Do Not Disturb"; $parameters['user_status'] = "Do Not Disturb";
$parameters['domain_uuid'] = $this->domain_uuid; $parameters['domain_uuid'] = $this->domain_uuid;
$parameters['username'] = $_SESSION['username']; $parameters['username'] = $this->username;
$this->database->execute($sql); $this->database->execute($sql);
} }
} }
@@ -140,18 +181,7 @@
} //function } //function
/** /**
* declare private variables
*/
private $permission;
private $list_page;
private $table;
private $uuid_prefix;
private $toggle_field;
private $toggle_values;
/**
* toggle records * toggle records
*/ */
public function toggle($records) { public function toggle($records) {
@@ -197,7 +227,7 @@
$sql .= "from v_".$this->table." "; $sql .= "from v_".$this->table." ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -257,10 +287,10 @@
$p->delete('extension_edit', 'temp'); $p->delete('extension_edit', 'temp');
//send feature event notify to the phone //send feature event notify to the phone
if ($settings->get('device', 'feature_sync', false)) { if ($this->settings->get('device', 'feature_sync', false)) {
foreach ($extensions as $uuid => $extension) { foreach ($extensions as $uuid => $extension) {
$feature_event_notify = new feature_event_notify; $feature_event_notify = new feature_event_notify;
$feature_event_notify->domain_name = $_SESSION['domain_name']; $feature_event_notify->domain_name = $this->domain_name;
$feature_event_notify->extension = $extension['extension']; $feature_event_notify->extension = $extension['extension'];
$feature_event_notify->do_not_disturb = $extension['do_not_disturb'] == "true" ? "false" : "true"; $feature_event_notify->do_not_disturb = $extension['do_not_disturb'] == "true" ? "false" : "true";
$feature_event_notify->ring_count = ceil($extension['call_timeout'] / 6); $feature_event_notify->ring_count = ceil($extension['call_timeout'] / 6);
@@ -277,7 +307,7 @@
} }
//synchronize configuration //synchronize configuration
if (!empty($_SESSION['switch']['extensions']['dir']) && is_readable($_SESSION['switch']['extensions']['dir'])) { if (!empty($this->settings->get('switch', 'extensions')) && is_readable($this->settings->get('switch', 'extensions'))) {
$ext = new extension; $ext = new extension;
$ext->xml(); $ext->xml();
unset($ext); unset($ext);
@@ -286,9 +316,9 @@
//clear the cache //clear the cache
$cache = new cache; $cache = new cache;
foreach ($extensions as $uuid => $extension) { foreach ($extensions as $uuid => $extension) {
$cache->delete("directory:".$extension['extension']."@".$_SESSION['domain_name']); $cache->delete("directory:".$extension['extension']."@".$this->domain_name);
if ($extension['number_alias'] != '') { if ($extension['number_alias'] != '') {
$cache->delete("directory:".$extension['number_alias']."@".$_SESSION['domain_name']); $cache->delete("directory:".$extension['number_alias']."@".$this->domain_name);
} }
} }

View File

@@ -38,9 +38,14 @@
const app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d'; const app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d';
/** /**
* 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; public $domain_uuid;
/**
* declare public variables
*/
public $db_type; public $db_type;
public $follow_me_uuid; public $follow_me_uuid;
public $cid_name_prefix; public $cid_name_prefix;
@@ -85,23 +90,52 @@
public $destination_order = 1; public $destination_order = 1;
/** /**
* declare private variables * Set in the constructor. Must be a database object and cannot be null.
* @var database Database Object
*/ */
private $database; private $database;
private $toll_allow;
/**
* 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 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; private $domain_name;
/**
* declare private variables
*/
private $extension; private $extension;
private $number_alias; private $permission;
private $list_page;
private $table;
private $uuid_prefix;
private $toggle_field;
private $toggle_values;
/** /**
* called when the object is created * 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'] ?? '';
//connect to the database //set objects
if (empty($this->database)) { $this->database = $setting_array['database'] ?? database::new();
$this->database = database::new(); $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]);
}
} }
public function add() { public function add() {
@@ -270,18 +304,7 @@
} //function } //function
/** /**
* declare private variables
*/
private $permission;
private $list_page;
private $table;
private $uuid_prefix;
private $toggle_field;
private $toggle_values;
/**
* toggle records * toggle records
*/ */
public function toggle($records) { public function toggle($records) {
@@ -327,7 +350,7 @@
$sql .= "from v_".$this->table." "; $sql .= "from v_".$this->table." ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -410,7 +433,7 @@
if ($settings->get('device', 'feature_sync', false)) { if ($settings->get('device', 'feature_sync', false)) {
foreach ($extensions as $uuid => $extension) { foreach ($extensions as $uuid => $extension) {
$feature_event_notify = new feature_event_notify; $feature_event_notify = new feature_event_notify;
$feature_event_notify->domain_name = $_SESSION['domain_name']; $feature_event_notify->domain_name = $this->domain_name;
$feature_event_notify->extension = $extension['extension']; $feature_event_notify->extension = $extension['extension'];
$feature_event_notify->do_not_disturb = $extension['do_not_disturb']; $feature_event_notify->do_not_disturb = $extension['do_not_disturb'];
$feature_event_notify->ring_count = ceil($extension['call_timeout'] / 6); $feature_event_notify->ring_count = ceil($extension['call_timeout'] / 6);
@@ -427,7 +450,7 @@
} }
//synchronize configuration //synchronize configuration
if (!empty($_SESSION['switch']['extensions']['dir']) && is_readable($_SESSION['switch']['extensions']['dir'])) { if (!empty($this->settings->get('switch', 'extensions')) && is_readable($this->settings->get('switch', 'extensions'))) {
$ext = new extension; $ext = new extension;
$ext->xml(); $ext->xml();
unset($ext); unset($ext);
@@ -436,9 +459,9 @@
//clear the cache //clear the cache
$cache = new cache; $cache = new cache;
foreach ($extensions as $uuid => $extension) { foreach ($extensions as $uuid => $extension) {
$cache->delete("directory:".$extension['extension']."@".$_SESSION['domain_name']); $cache->delete("directory:".$extension['extension']."@".$this->domain_name);
if ($extension['number_alias'] != '') { if ($extension['number_alias'] != '') {
$cache->delete("directory:".$extension['number_alias']."@".$_SESSION['domain_name']); $cache->delete("directory:".$extension['number_alias']."@".$this->domain_name);
} }
} }

View File

@@ -15,7 +15,7 @@
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get($_SESSION['domain']['language']['code'], 'app/call_forward'); $text = $language->get($settings->get('domain', 'language', 'en-us'), 'app/call_forward');
//extensions link //extensions link
$extension_link = '#'; $extension_link = '#';

View File

@@ -50,6 +50,7 @@
//set additional variables //set additional variables
$search = $_GET["search"] ?? ''; $search = $_GET["search"] ?? '';
$show = $_GET["show"] ?? ''; $show = $_GET["show"] ?? '';
$result_count = 0;
//get the http post data //get the http post data
if (!empty($_POST['call_recordings']) && is_array($_POST['call_recordings'])) { if (!empty($_POST['call_recordings']) && is_array($_POST['call_recordings'])) {
@@ -100,7 +101,7 @@
$parameters['time_zone'] = $time_zone; $parameters['time_zone'] = $time_zone;
//prepare some of the paging values //prepare some of the paging values
$rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; $rows_per_page = $settings->get('domain', 'paging', 50);
$page = $_GET['page'] ?? ''; $page = $_GET['page'] ?? '';
if (empty($page)) { $page = 0; $_GET['page'] = 0; } if (empty($page)) { $page = 0; $_GET['page'] = 0; }
$offset = $rows_per_page * $page; $offset = $rows_per_page * $page;
@@ -145,8 +146,8 @@
} }
//limit the number of results //limit the number of results
if (!empty($_SESSION['cdr']['limit']['numeric']) && $_SESSION['cdr']['limit']['numeric'] > 0) { if (!empty($settings->get('cdr', 'limit')) && $settings->get('cdr', 'limit') > 0) {
$num_rows = $_SESSION['cdr']['limit']['numeric']; $num_rows = $settings->get('cdr', 'limit');
} }
//prepare to page the results //prepare to page the results

View File

@@ -35,11 +35,45 @@
const app_name = 'follow_me'; const app_name = 'follow_me';
const app_uuid = 'b1b70f85-6b42-429b-8c5a-60c8b02b7d14'; const app_uuid = 'b1b70f85-6b42-429b-8c5a-60c8b02b7d14';
/**
* 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 the variables * declare the variables
*/ */
private $settings;
private $database;
private $name; private $name;
private $table; private $table;
private $description_field; private $description_field;
@@ -50,18 +84,21 @@
/** /**
* called when the object is created * 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 the variables //assign the variables
$this->name = 'call_recording'; $this->name = 'call_recording';
$this->table = 'call_recordings'; $this->table = 'call_recordings';
$this->description_field = 'call_recording_description'; $this->description_field = 'call_recording_description';
$this->location = 'call_recordings.php'; $this->location = 'call_recordings.php';
//allow global
$this->database = database::new();
//initialize the settings object
$this->settings = new settings(["domain_uuid" => $_SESSION['domain_uuid'], "user_uuid" => $_SESSION['user_uuid']]);
} }
/** /**

View File

@@ -44,7 +44,7 @@
//get call recording details from database //get call recording details from database
$sql = "select call_recording_name, call_recording_path "; $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 = ", call_recording_base64 ";
} }
$sql .= "from view_call_recordings "; $sql .= "from view_call_recordings ";
@@ -54,7 +54,7 @@
if (is_array($row) && @sizeof($row) != 0) { if (is_array($row) && @sizeof($row) != 0) {
$call_recording_name = $row['call_recording_name']; $call_recording_name = $row['call_recording_name'];
$call_recording_path = $row['call_recording_path']; $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'])); 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 = new Waveform($full_recording_path);
Waveform::$linesPerPixel = 1; // default: 8 Waveform::$linesPerPixel = 1; // default: 8
Waveform::$samplesPerLine = 512; // default: 512 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::$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($_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::$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($_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::$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($_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::$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($_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::$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($_SESSION['theme']['audio_player_waveform_single_axis']['boolean'] ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis 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($_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; $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 $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 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); @unlink($full_recording_path);
} }
unset($row); unset($row);

View File

@@ -210,7 +210,7 @@
} }
function get_record_cmd(uuid, prefix, name) { function get_record_cmd(uuid, prefix, name) {
cmd = \"uuid_record \"+uuid+\" start ".$_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/archive/".date("Y")."/".date("M")."/".date("d")."/\"+uuid+\".wav\"; cmd = \"uuid_record \"+uuid+\" start ".$settings->get('switch', 'recordings')."/".$_SESSION['domain_name']."/archive/".date("Y")."/".date("M")."/".date("d")."/\"+uuid+\".wav\";
return escape(cmd); return escape(cmd);
} }
*/ */

View File

@@ -273,7 +273,7 @@
echo " </table>\n"; echo " </table>\n";
echo "</div>\n"; echo "</div>\n";
echo "<input type='hidden' name='".$_SESSION['app']['calls_active']['token']['name']."' value='".$_SESSION['app']['calls_active']['token']['hash']."'>\n"; echo "<input type='hidden' name='".$settings->get('app', 'calls_active')['name']."' value='".$settings->get('app', 'calls_active')['hash']."'>\n";
echo "</form>\n"; echo "</form>\n";
?> ?>

View File

@@ -101,16 +101,16 @@
//add record path and name //add record path and name
if ($rec == "true") { if ($rec == "true") {
$record_path = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/archive/".date("Y")."/".date("M")."/".date("d"); $record_path = $settings->get('switch', 'recordings')."/".$_SESSION['domain_name']."/archive/".date("Y")."/".date("M")."/".date("d");
if (isset($_SESSION['recordings']['extension']['text'])) { if (!empty($settings->get('recordings', 'extension'))) {
$record_extension = $_SESSION['recordings']['extension']['text']; $record_extension = $settings->get('recordings', 'extension');
} }
else { else {
$record_extension = 'wav'; $record_extension = 'wav';
} }
if (isset($_SESSION['recordings']['template']['text'])) { if (!empty($settings->get('recordings', 'template'))) {
//${year}${month}${day}-${caller_id_number}-${caller_destination}-${uuid}.${record_extension} //${year}${month}${day}-${caller_id_number}-${caller_destination}-${uuid}.${record_extension}
$record_name = $_SESSION['recordings']['template']['text']; $record_name = $settings->get('recordings', 'template');
$record_name = str_replace('${year}', date("Y"), $record_name); $record_name = str_replace('${year}', date("Y"), $record_name);
$record_name = str_replace('${month}', date("M"), $record_name); $record_name = str_replace('${month}', date("M"), $record_name);
$record_name = str_replace('${day}', date("d"), $record_name); $record_name = str_replace('${day}', date("d"), $record_name);

View File

@@ -352,7 +352,7 @@
echo " ".$text['label-conference_center_extension']."\n"; echo " ".$text['label-conference_center_extension']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='conference_center_extension' maxlength='255' value=\"".escape($conference_center_extension)."\" required='required' placeholder=\"".($_SESSION['conference_center']['extension_range']['text'] ?? '')."\">\n"; echo " <input class='formfld' type='text' name='conference_center_extension' maxlength='255' value=\"".escape($conference_center_extension)."\" required='required' placeholder=\"".($settings->get('conference_center', 'extension_range') ?? '')."\">\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-conference_center_extension']."\n"; echo $text['description-conference_center_extension']."\n";
echo "</td>\n"; echo "</td>\n";
@@ -379,8 +379,8 @@
if ($key == 'recordings') { if ($key == 'recordings') {
if ( if (
!empty($instance_value) && !empty($instance_value) &&
($instance_value == $row["value"] || $instance_value == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.$row["value"]) && ($instance_value == $row["value"] || $instance_value == $settings->get('switch', 'recordings')."/".$_SESSION['domain_name'].'/'.$row["value"]) &&
file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME)) file_exists($settings->get('switch', 'recordings')."/".$_SESSION['domain_name'].'/'.pathinfo($row["value"], PATHINFO_BASENAME))
) { ) {
$selected = "selected='selected'"; $selected = "selected='selected'";
$playable = '../recordings/recordings.php?action=download&type=rec&filename='.pathinfo($row["value"], PATHINFO_BASENAME); $playable = '../recordings/recordings.php?action=download&type=rec&filename='.pathinfo($row["value"], PATHINFO_BASENAME);

View File

@@ -112,7 +112,7 @@
$num_rows = $database->select($sql, $parameters ?? null, 'column'); $num_rows = $database->select($sql, $parameters ?? null, 'column');
//prepare to page the results //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=".urlencode($search); $param = "&search=".urlencode($search);
if ($show == "all" && permission_exists('conference_center_all')) { if ($show == "all" && permission_exists('conference_center_all')) {
$param .= "&show=all"; $param .= "&show=all";

View File

@@ -90,6 +90,10 @@
$participant_pin = preg_replace('{\D}', '', $participant_pin); $participant_pin = preg_replace('{\D}', '', $participant_pin);
} }
//set the default values
$profile = $profile ?? 'default';
$max_members = $max_members ?? 0;
//get the conference centers array and set a default conference center //get the conference centers array and set a default conference center
$sql = "select * from v_conference_centers "; $sql = "select * from v_conference_centers ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
@@ -141,7 +145,7 @@
$default_language = 'en'; $default_language = 'en';
$default_dialect = 'us'; $default_dialect = 'us';
$default_voice = 'callie'; $default_voice = 'callie';
$switch_cmd = "conference ".$conference_room_uuid."@".$_SESSION['domain_name']." play ".$_SESSION['switch']['sounds']['dir']."/".$default_language."/".$default_dialect."/".$default_voice."/ivr/ivr-recording_started.wav"; $switch_cmd = "conference ".$conference_room_uuid."@".$_SESSION['domain_name']." play ".$settings->get('switch', 'sounds')."/".$default_language."/".$default_dialect."/".$default_voice."/ivr/ivr-recording_started.wav";
//connect to event socket //connect to event socket
$esl = event_socket::create(); $esl = event_socket::create();
@@ -296,10 +300,6 @@
if (empty($_POST["persistformvar"])) { if (empty($_POST["persistformvar"])) {
if ($action == "add" && permission_exists('conference_room_add')) { if ($action == "add" && permission_exists('conference_room_add')) {
//set default values
if (empty($profile)) { $profile = 'default'; }
if (empty($max_members)) { $max_members = 0; }
//add a conference room //add a conference room
$conference_room_uuid = uuid(); $conference_room_uuid = uuid();
$array['conference_rooms'][0]['conference_room_uuid'] = $conference_room_uuid; $array['conference_rooms'][0]['conference_room_uuid'] = $conference_room_uuid;

View File

@@ -96,7 +96,7 @@
$default_language = 'en'; $default_language = 'en';
$default_dialect = 'us'; $default_dialect = 'us';
$default_voice = 'callie'; $default_voice = 'callie';
$switch_cmd = "conference ".$meeting_uuid."@".$_SESSION['domain_name']." play ".$_SESSION['switch']['sounds']['dir']."/".$default_language."/".$default_dialect."/".$default_voice."/ivr/ivr-recording_started.wav"; $switch_cmd = "conference ".$meeting_uuid."@".$_SESSION['domain_name']." play ".$settings->get('switch', 'sounds')."/".$default_language."/".$default_dialect."/".$default_voice."/ivr/ivr-recording_started.wav";
//connect to event socket //connect to event socket
$esl = event_socket::create(); $esl = event_socket::create();
if ($esl) { if ($esl) {
@@ -178,7 +178,7 @@
$num_rows = $conference_center->room_count(); $num_rows = $conference_center->room_count();
//prepare to page the results //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 = !empty($search) ? "&search=".$search : null; $param = !empty($search) ? "&search=".$search : null;
if (isset($_GET['page'])) { if (isset($_GET['page'])) {
$page = is_numeric($_GET['page']) ? $_GET['page'] : 0; $page = is_numeric($_GET['page']) ? $_GET['page'] : 0;

View File

@@ -85,7 +85,7 @@
unset($sql, $parameters); unset($sql, $parameters);
//prepare to page the results //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 = ''; $param = '';
$page = isset($_GET['page']) ? $_GET['page'] : 0; $page = isset($_GET['page']) ? $_GET['page'] : 0;
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
@@ -111,7 +111,7 @@
echo " <div class='heading'><b>".$text['title-conference_session_details']."</b><div class='count'>".number_format($num_rows)."</div></div>\n"; echo " <div class='heading'><b>".$text['title-conference_session_details']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
echo " <div class='actions'>\n"; echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back'),'id'=>'btn_back','link'=>'conference_sessions.php']); echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back'),'id'=>'btn_back','link'=>'conference_sessions.php']);
$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 = ''; $tmp_name = '';
if (!empty($row['conference_session_uuid']) && file_exists($tmp_dir.'/'.$row['conference_session_uuid'].'.mp3')) { if (!empty($row['conference_session_uuid']) && file_exists($tmp_dir.'/'.$row['conference_session_uuid'].'.mp3')) {
$tmp_name = $row['conference_session_uuid'].".mp3"; $tmp_name = $row['conference_session_uuid'].".mp3";

View File

@@ -88,7 +88,7 @@
unset($sql, $parameters); unset($sql, $parameters);
//prepare to page the results //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 = ''; $param = '';
$page = isset($_GET['page']) ? $_GET['page'] : 0; $page = isset($_GET['page']) ? $_GET['page'] : 0;
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);

View File

@@ -50,7 +50,7 @@
$event .= "login: agent+".$this->agent_name."@".$this->domain_name."\n"; $event .= "login: agent+".$this->agent_name."@".$this->domain_name."\n";
$event .= "unique-id: ".$this->agent_uuid."\n"; $event .= "unique-id: ".$this->agent_uuid."\n";
$event .= "answer-state: ".$this->answer_state."\n"; $event .= "answer-state: ".$this->answer_state."\n";
event_socket::command($event); $esl->request('api ' . $event);
//echo $event."<br />"; //echo $event."<br />";
} }
} //function } //function

View File

@@ -35,9 +35,14 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
const app_uuid = '8d083f5a-f726-42a8-9ffa-8d28f848f10e'; const app_uuid = '8d083f5a-f726-42a8-9ffa-8d28f848f10e';
/** /**
* 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; public $domain_uuid;
/**
* declare public variables
*/
public $conference_room_uuid; public $conference_room_uuid;
public $order_by; public $order_by;
public $order; public $order;
@@ -48,11 +53,39 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
public $created_by; public $created_by;
public $toggle_field; public $toggle_field;
/**
* 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 * declare private variables
*/ */
private $database;
private $permission_prefix; private $permission_prefix;
private $list_page; private $list_page;
private $table; private $table;
@@ -63,13 +96,15 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
/** /**
* Called when the object is created * Called when the object is created
*/ */
public function __construct() { public function __construct(array $setting_array = []) {
//set domain and user UUIDs
//connect to the database $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? '';
if (empty($this->database)) { $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? '';
$this->database = database::new(); $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]);
} }
/** /**
@@ -147,7 +182,7 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
if ($not_admin) { if ($not_admin) {
$sql .= "and r.conference_room_uuid = u.conference_room_uuid "; $sql .= "and r.conference_room_uuid = u.conference_room_uuid ";
$sql .= "and u.user_uuid = :user_uuid "; $sql .= "and u.user_uuid = :user_uuid ";
$parameters['user_uuid'] = $_SESSION["user_uuid"]; $parameters['user_uuid'] = $this->user_uuid;
} }
if (!empty($this->search)) { if (!empty($this->search)) {
$sql .= "and ("; $sql .= "and (";
@@ -240,7 +275,7 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
} }
//set the path for the directory //set the path for the directory
$default_path = $_SESSION['switch']['call_recordings']['dir']."/".$_SESSION['domain_name']; $default_path = $this->settings->get('switch', 'call_recordings')."/".$this->domain_name;
//get the file path and name //get the file path and name
$record_path = dirname($recording); $record_path = dirname($recording);
@@ -288,7 +323,7 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
} }
//if base64, remove temp recording file //if base64, remove temp recording file
//if ($_SESSION['conference']['storage_type']['text'] == 'base64' && $row['conference_recording_base64'] != '') { //if ($this->settings->get('conference', 'storage_type') == 'base64' && $row['conference_recording_base64'] != '') {
// @unlink($record_path.'/'.$record_name); // @unlink($record_path.'/'.$record_name);
//} //}
} }
@@ -330,18 +365,18 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
$sql = "select dialplan_uuid from v_conference_centers "; $sql = "select dialplan_uuid from v_conference_centers ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and conference_center_uuid = :conference_center_uuid "; $sql .= "and conference_center_uuid = :conference_center_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $this->domain_uuid;
$parameters['conference_center_uuid'] = $record['uuid']; $parameters['conference_center_uuid'] = $record['uuid'];
$dialplan_uuid = $this->database->select($sql, $parameters, 'column'); $dialplan_uuid = $this->database->select($sql, $parameters, 'column');
unset($sql, $parameters); unset($sql, $parameters);
//create array //create array
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid;
$array['dialplan_details'][$x]['dialplan_uuid'] = $dialplan_uuid; $array['dialplan_details'][$x]['dialplan_uuid'] = $dialplan_uuid;
$array['dialplan_details'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplan_details'][$x]['domain_uuid'] = $this->domain_uuid;
$array['dialplans'][$x]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['dialplan_uuid'] = $dialplan_uuid;
$array['dialplans'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['domain_uuid'] = $this->domain_uuid;
} }
} }
@@ -363,7 +398,7 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
//clear the cache //clear the cache
$cache = new cache; $cache = new cache;
$cache->delete("dialplan:".$_SESSION["domain_name"]); $cache->delete("dialplan:".$this->domain_name);
//clear the destinations session array //clear the destinations session array
if (isset($_SESSION['destinations']['array'])) { if (isset($_SESSION['destinations']['array'])) {
@@ -412,9 +447,9 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
//create array //create array
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid;
$array['conference_room_users'][$x]['conference_room_uuid'] = $record['uuid']; $array['conference_room_users'][$x]['conference_room_uuid'] = $record['uuid'];
$array['conference_room_users'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['conference_room_users'][$x]['domain_uuid'] = $this->domain_uuid;
} }
} }
@@ -473,9 +508,9 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
//create array //create array
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid;
$array['conference_session_details'][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; $array['conference_session_details'][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
$array['conference_session_details'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['conference_session_details'][$x]['domain_uuid'] = $this->domain_uuid;
} }
} }
@@ -543,7 +578,7 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, dialplan_uuid from v_".$this->table." "; $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, dialplan_uuid from v_".$this->table." ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (!empty($rows)) { if (!empty($rows)) {
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -584,7 +619,7 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
//clear the cache //clear the cache
$cache = new cache; $cache = new cache;
$cache->delete("dialplan:".$_SESSION["domain_name"]); $cache->delete("dialplan:".$this->domain_name);
//clear the destinations session array //clear the destinations session array
if (isset($_SESSION['destinations']['array'])) { if (isset($_SESSION['destinations']['array'])) {
@@ -646,7 +681,7 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $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 .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (!empty($rows)) { if (!empty($rows)) {
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -669,9 +704,9 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
$default_language = 'en'; $default_language = 'en';
$default_dialect = 'us'; $default_dialect = 'us';
$default_voice = 'callie'; $default_voice = 'callie';
// $recording_dir = $_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.date("Y").'/'.date("M").'/'.date("d"); // $recording_dir = $this->settings->get('switch', 'recordings').'/'.$this->domain_name.'/archive/'.date("Y").'/'.date("M").'/'.date("d");
// $switch_cmd_record = "conference ".$meeting_uuid[$uuid]."@".$_SESSION['domain_name']." record ".$recording_dir.'/'.$meeting_uuid[$uuid].'.wav'; // $switch_cmd_record = "conference ".$meeting_uuid[$uuid]."@".$this->domain_name." record ".$recording_dir.'/'.$meeting_uuid[$uuid].'.wav';
$switch_cmd_notice = "conference ".$meeting_uuid[$uuid]."@".$_SESSION['domain_name']." play ".$_SESSION['switch']['sounds']['dir']."/".$default_language."/".$default_dialect."/".$default_voice."/ivr/ivr-recording_started.wav"; $switch_cmd_notice = "conference ".$meeting_uuid[$uuid]."@".$this->domain_name." play ".$this->settings->get('switch', 'sounds')."/".$default_language."/".$default_dialect."/".$default_voice."/ivr/ivr-recording_started.wav";
//execute api commands //execute api commands
// if (!file_exists($recording_dir.'/'.$meeting_uuid[$uuid].'.wav')) { // if (!file_exists($recording_dir.'/'.$meeting_uuid[$uuid].'.wav')) {
$esl = event_socket::create(); $esl = event_socket::create();
@@ -744,7 +779,7 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
$sql = "select * from v_".$this->table." "; $sql = "select * from v_".$this->table." ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (!empty($rows)) { if (!empty($rows)) {
foreach ($rows as $x => $row) { foreach ($rows as $x => $row) {
@@ -787,7 +822,7 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
//example conference center //example conference center
/* /*
$conference_center = new conference_centers; $conference_center = new conference_centers;
$conference_center->domain_uuid = $_SESSION['domain_uuid']; $conference_center->domain_uuid = $this->domain_uuid;
$conference_center->rows_per_page = 150; $conference_center->rows_per_page = 150;
$conference_center->offset = 0; $conference_center->offset = 0;
$conference_center->created_by = uuid; $conference_center->created_by = uuid;

View File

@@ -46,20 +46,20 @@
if ($_GET['type'] == 'recordings') { if ($_GET['type'] == 'recordings') {
$slash = substr($_GET['data'],0,1) != '/' ? '/' : null; $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') { else if ($_GET['type'] == 'sounds') {
//get first installed language (like en/us/callie) //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) { 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); $path_array = explode('/', $path);
if (count($path_array) <> 3 || strlen($path_array[0]) <> 2 || strlen($path_array[1]) <> 2) { if (count($path_array) <> 3 || strlen($path_array[0]) <> 2 || strlen($path_array[1]) <> 2) {
unset($language_paths[$key]); 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])) { if (empty($language_paths[$key])) {
unset($language_paths[$key]); unset($language_paths[$key]);
} }
@@ -69,7 +69,7 @@
//determine the path for sound file //determine the path for sound file
$filename_parts = explode('/', str_replace('..', '', $_GET['data'])); $filename_parts = explode('/', str_replace('..', '', $_GET['data']));
if (!is_array($filename_parts) || @sizeof($filename_parts) != 2) { exit; } 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 //build full path to sound file
$full_file_path = $path.$filename_parts[1]; $full_file_path = $path.$filename_parts[1];
@@ -91,13 +91,13 @@
$waveform = new Waveform($full_file_path); $waveform = new Waveform($full_file_path);
Waveform::$linesPerPixel = 1; // default: 8 Waveform::$linesPerPixel = 1; // default: 8
Waveform::$samplesPerLine = 512; // default: 512 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::$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($_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::$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($_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::$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($_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::$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($_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::$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($_SESSION['theme']['audio_player_waveform_single_axis']['boolean'] ?? true, FILTER_VALIDATE_BOOL) ? 'true': 'false'; // combine channels into single axis 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($_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; $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 $wf = $waveform->getWaveform($temp_filename, 1600, $height ?? 180); // input: png filename returns boolean true/false, or 'base64' returns base64 string
} }

View File

@@ -101,7 +101,7 @@
unset($sql, $parameters); unset($sql, $parameters);
//prepare to page the results //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 = "&id=".!empty($conference_control_uuid); $param = "&id=".!empty($conference_control_uuid);
if (isset($_GET['page'])) { if (isset($_GET['page'])) {
$page = isset($_GET['page']) ? $_GET['page'] : 0; $page = isset($_GET['page']) ? $_GET['page'] : 0;

View File

@@ -100,7 +100,7 @@
unset($sql); unset($sql);
//prepare to page the results //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; $param = $search ? "&search=".$search : null;
$page = isset($_GET['page']) ? $_GET['page'] : 0; $page = isset($_GET['page']) ? $_GET['page'] : 0;
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);

View File

@@ -55,11 +55,9 @@
/** /**
* called when the object is created * called when the object is created
*/ */
public function __construct() { public function __construct(array $setting_array = []) {
//connect to the database //set objects
if (empty($this->database)) { $this->database = $setting_array['database'] ?? database::new();
$this->database = database::new();
}
} }
/** /**

View File

@@ -88,7 +88,7 @@
unset($sql, $parameters); unset($sql, $parameters);
//prepare to page the results //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 = "&id=".$conference_profile_uuid; $param = "&id=".$conference_profile_uuid;
if (isset($_GET['page'])) { if (isset($_GET['page'])) {
$page = isset($_GET['page']) ? $_GET['page'] : 0; $page = isset($_GET['page']) ? $_GET['page'] : 0;

View File

@@ -45,6 +45,7 @@
private $toggle_values; private $toggle_values;
private $description_field; private $description_field;
private $location; private $location;
private $database;
/** /**
* declare public variables * declare public variables
@@ -54,11 +55,9 @@
/** /**
* called when the object is created * called when the object is created
*/ */
public function __construct() { public function __construct(array $setting_array = []) {
//connect to the database //set objects
if (empty($this->database)) { $this->database = $setting_array['database'] ?? database::new();
$this->database = database::new();
}
} }
/** /**

View File

@@ -404,7 +404,7 @@
echo " ".$text['label-extension']."\n"; echo " ".$text['label-extension']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='conference_extension' maxlength='255' value=\"".escape($conference_extension)."\" required='required' placeholder=\"".($_SESSION['conference']['extension_range']['text'] ?? '')."\">\n"; echo " <input class='formfld' type='text' name='conference_extension' maxlength='255' value=\"".escape($conference_extension)."\" required='required' placeholder=\"".($settings->get('conference', 'extension_range') ?? '')."\">\n";
echo "<br />\n"; echo "<br />\n";
echo "".$text['description-extension']."\n"; echo "".$text['description-extension']."\n";
echo "</td>\n"; echo "</td>\n";

View File

@@ -121,7 +121,7 @@
$num_rows = $database->select($sql, $parameters ?? null, 'column'); $num_rows = $database->select($sql, $parameters ?? null, 'column');
//prepare to page the results //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=".urlencode($search); $param = "&search=".urlencode($search);
if ($show == "all" && permission_exists('conference_all')) { if ($show == "all" && permission_exists('conference_all')) {
$param .= "&show=all"; $param .= "&show=all";

View File

@@ -33,11 +33,33 @@
const app_name = 'conferences'; const app_name = 'conferences';
const app_uuid = 'b81412e8-7253-91f4-e48e-42fc2c9a38d9'; const app_uuid = 'b81412e8-7253-91f4-e48e-42fc2c9a38d9';
/**
* Set in the constructor. Must be a database object and cannot be null.
* @var database Database Object
*/
private $database;
/**
* 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 * declare private variables
*/ */
private $database;
private $permission_prefix; private $permission_prefix;
private $list_page; private $list_page;
private $table; private $table;
@@ -48,7 +70,15 @@
/** /**
* called when the object is created * 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();
//assign private variables //assign private variables
$this->permission_prefix = 'conference_'; $this->permission_prefix = 'conference_';
$this->list_page = 'conferences.php'; $this->list_page = 'conferences.php';
@@ -56,11 +86,6 @@
$this->uuid_prefix = 'conference_'; $this->uuid_prefix = 'conference_';
$this->toggle_field = 'conference_enabled'; $this->toggle_field = 'conference_enabled';
$this->toggle_values = ['true','false']; $this->toggle_values = ['true','false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
} }
/** /**
@@ -92,20 +117,20 @@
$sql = "select dialplan_uuid from v_conferences "; $sql = "select dialplan_uuid from v_conferences ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and conference_uuid = :conference_uuid "; $sql .= "and conference_uuid = :conference_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $this->domain_uuid;
$parameters['conference_uuid'] = $record['uuid']; $parameters['conference_uuid'] = $record['uuid'];
$dialplan_uuid = $this->database->select($sql, $parameters, 'column'); $dialplan_uuid = $this->database->select($sql, $parameters, 'column');
unset($sql, $parameters); unset($sql, $parameters);
//build array //build array
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid;
$array['conference_users'][$x]['conference_uuid'] = $record['uuid']; $array['conference_users'][$x]['conference_uuid'] = $record['uuid'];
$array['conference_users'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['conference_users'][$x]['domain_uuid'] = $this->domain_uuid;
$array['dialplans'][$x]['dialplan_uuid'] = $dialplan_uuid; $array['dialplans'][$x]['dialplan_uuid'] = $dialplan_uuid;
$array['dialplans'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['domain_uuid'] = $this->domain_uuid;
$array['dialplan_details'][$x]['dialplan_uuid'] = $dialplan_uuid; $array['dialplan_details'][$x]['dialplan_uuid'] = $dialplan_uuid;
$array['dialplan_details'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplan_details'][$x]['domain_uuid'] = $this->domain_uuid;
} }
} }
@@ -133,7 +158,7 @@
//clear the cache //clear the cache
$cache = new cache; $cache = new cache;
$cache->delete("dialplan:".$_SESSION["domain_name"]); $cache->delete("dialplan:".$this->domain_name);
//clear the destinations session array //clear the destinations session array
if (isset($_SESSION['destinations']['array'])) { if (isset($_SESSION['destinations']['array'])) {
@@ -180,7 +205,7 @@
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, dialplan_uuid from v_".$this->table." "; $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, dialplan_uuid from v_".$this->table." ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -221,7 +246,7 @@
//clear the cache //clear the cache
$cache = new cache; $cache = new cache;
$cache->delete("dialplan:".$_SESSION["domain_name"]); $cache->delete("dialplan:".$this->domain_name);
//clear the destinations session array //clear the destinations session array
if (isset($_SESSION['destinations']['array'])) { if (isset($_SESSION['destinations']['array'])) {
@@ -270,7 +295,7 @@
$sql = "select * from v_".$this->table." "; $sql = "select * from v_".$this->table." ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
$y = 0; $y = 0;
@@ -291,7 +316,7 @@
$sql_2 .= "where conference_uuid = :conference_uuid "; $sql_2 .= "where conference_uuid = :conference_uuid ";
$sql_2 .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql_2 .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters_2['conference_uuid'] = $row['conference_uuid']; $parameters_2['conference_uuid'] = $row['conference_uuid'];
$parameters_2['domain_uuid'] = $_SESSION['domain_uuid']; $parameters_2['domain_uuid'] = $this->domain_uuid;
$conference_users = $this->database->select($sql_2, $parameters_2, 'all'); $conference_users = $this->database->select($sql_2, $parameters_2, 'all');
if (is_array($conference_users) && @sizeof($conference_users) != 0) { if (is_array($conference_users) && @sizeof($conference_users) != 0) {
foreach ($conference_users as $conference_user) { foreach ($conference_users as $conference_user) {
@@ -356,7 +381,7 @@
//clear the cache //clear the cache
$cache = new cache; $cache = new cache;
$cache->delete("dialplan:".$_SESSION["domain_name"]); $cache->delete("dialplan:".$this->domain_name);
//set message //set message
message::add($text['message-copy']); message::add($text['message-copy']);

View File

@@ -218,7 +218,7 @@
$switch_result = event_socket::api($switch_cmd.' '.$tmp_value); $switch_result = event_socket::api($switch_cmd.' '.$tmp_value);
} }
elseif ($data == "record") { elseif ($data == "record") {
$recording_dir = $_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.date("Y").'/'.date("M").'/'.date("d"); $recording_dir = $settings->get('switch', 'recordings').'/'.$_SESSION['domain_name'].'/archive/'.date("Y").'/'.date("M").'/'.date("d");
$switch_cmd .= $recording_dir."/{$uuid}.wav"; $switch_cmd .= $recording_dir."/{$uuid}.wav";
if (!file_exists($switch_cmd)) { if (!file_exists($switch_cmd)) {
$switch_result = event_socket::api($switch_cmd); $switch_result = event_socket::api($switch_cmd);
@@ -226,7 +226,7 @@
} }
elseif ($data == "norecord") { elseif ($data == "norecord") {
//stop recording and rename the file //stop recording and rename the file
$recording_dir = $_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.date("Y").'/'.date("M").'/'.date("d"); $recording_dir = $settings->get('switch', 'recordings').'/'.$_SESSION['domain_name'].'/archive/'.date("Y").'/'.date("M").'/'.date("d");
$switch_cmd .= $recording_dir."/".$uuid.".wav"; $switch_cmd .= $recording_dir."/".$uuid.".wav";
$switch_result = event_socket::api($switch_cmd); $switch_result = event_socket::api($switch_cmd);
} }

View File

@@ -115,7 +115,7 @@
echo "<div style='float: right;'>\n"; echo "<div style='float: right;'>\n";
$recording_dir = $_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/archive/'.date("Y").'/'.date("M").'/'.date("d"); $recording_dir = $settings->get('switch', 'recordings').'/'.$_SESSION['domain_name'].'/archive/'.date("Y").'/'.date("M").'/'.date("d");
$recording_name = ''; $recording_name = '';
if (!empty($recording_dir) && !empty($row['uuid'])) { if (!empty($recording_dir) && !empty($row['uuid'])) {
if (file_exists($recording_dir.'/'.$row['uuid'].'.wav')) { if (file_exists($recording_dir.'/'.$row['uuid'].'.wav')) {

View File

@@ -90,7 +90,7 @@
unset($parameters); unset($parameters);
//prepare to page the results //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 = "search=".$search;
$page = empty($_GET['page']) ? $page = 0 : $page = $_GET['page']; $page = empty($_GET['page']) ? $page = 0 : $page = $_GET['page'];
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);

View File

@@ -72,7 +72,7 @@
//save the data to the csv file //save the data to the csv file
if (isset($_POST['data'])) { if (isset($_POST['data'])) {
$file = $_SESSION['server']['temp']['dir']."/destinations-".$_SESSION['domain_name'].".csv"; $file = $settings->get('server', 'temp')."/destinations-".$_SESSION['domain_name'].".csv";
file_put_contents($file, $_POST['data']); file_put_contents($file, $_POST['data']);
$_SESSION['file'] = $file; $_SESSION['file'] = $file;
$_SESSION['file_name'] = $_FILES['ulfile']['name']; $_SESSION['file_name'] = $_FILES['ulfile']['name'];
@@ -82,11 +82,11 @@
//$_POST['submit'] == "Upload" && //$_POST['submit'] == "Upload" &&
if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('destination_upload')) { if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('destination_upload')) {
if ($_POST['type'] == 'csv') { if ($_POST['type'] == 'csv') {
move_uploaded_file($_FILES['ulfile']['tmp_name'], $_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 ".$_SESSION['server']['temp']['dir']."/". htmlentities($_FILES['ulfile']['name']); $save_msg = "Uploaded file to ".$settings->get('server', 'temp')."/". htmlentities($_FILES['ulfile']['name']);
//system('chmod -R 744 '.$_SESSION['server']['temp']['dir'].'*'); //system('chmod -R 744 '.$settings->get('server', 'temp').'*');
unset($_POST['txtCommand']); unset($_POST['txtCommand']);
$file = $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']; $file = $settings->get('server', 'temp').'/'.$_FILES['ulfile']['name'];
$_SESSION['file'] = $file; $_SESSION['file'] = $file;
} }
} }
@@ -277,8 +277,8 @@
$dialplan_detail_order = $dialplan_detail_order + 10; $dialplan_detail_order = $dialplan_detail_order + 10;
//set the dialplan detail type //set the dialplan detail type
if (!empty($_SESSION['dialplan']['destination']['text'])) { if (!empty($settings->get('dialplan', 'destination'))) {
$dialplan_detail_type = $_SESSION['dialplan']['destination']['text']; $dialplan_detail_type = $settings->get('dialplan', 'destination');
} }
else { else {
$dialplan_detail_type = "destination_number"; $dialplan_detail_type = "destination_number";
@@ -339,8 +339,8 @@
//check the destination number //check the destination number
$array["dialplans"][$row_id]["dialplan_details"][$y]["domain_uuid"] = $domain_uuid; $array["dialplans"][$row_id]["dialplan_details"][$y]["domain_uuid"] = $domain_uuid;
$array["dialplans"][$row_id]["dialplan_details"][$y]["dialplan_detail_tag"] = "condition"; $array["dialplans"][$row_id]["dialplan_details"][$y]["dialplan_detail_tag"] = "condition";
if (!empty($_SESSION['dialplan']['destination']['text'])) { if (!empty($settings->get('dialplan', 'destination'))) {
$array["dialplans"][$row_id]["dialplan_details"][$y]["dialplan_detail_type"] = $_SESSION['dialplan']['destination']['text']; $array["dialplans"][$row_id]["dialplan_details"][$y]["dialplan_detail_type"] = $settings->get('dialplan', 'destination');
} }
else { else {
$array["dialplans"][$row_id]["dialplan_details"][$y]["dialplan_detail_type"] = "destination_number"; $array["dialplans"][$row_id]["dialplan_details"][$y]["dialplan_detail_type"] = "destination_number";

View File

@@ -89,6 +89,7 @@
//function to return the action names in the order defined //function to return the action names in the order defined
function action_name($destination_array, $destination_actions) { function action_name($destination_array, $destination_actions) {
global $settings;
$actions = []; $actions = [];
if (!empty($destination_array) && is_array($destination_array)) { if (!empty($destination_array) && is_array($destination_array)) {
if (!empty($destination_actions) && is_array($destination_actions)) { if (!empty($destination_actions) && is_array($destination_actions)) {
@@ -102,7 +103,7 @@
if (!isset($language2) && !isset($text2)) { if (!isset($language2) && !isset($text2)) {
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/dialplans/app_languages.php")) { if (file_exists($_SERVER["PROJECT_ROOT"]."/app/dialplans/app_languages.php")) {
$language2 = new text; $language2 = new text;
$text2 = $language2->get($_SESSION['domain']['language']['code'], 'app/dialplans'); $text2 = $language2->get($settings->get('domain', 'language', 'en-us'), 'app/dialplans');
} }
} }
$actions[] = trim($text2['title-other'].' &#x203A; '.$text2['option-'.str_replace('&lowbar;','_',$key)]); $actions[] = trim($text2['title-other'].' &#x203A; '.$text2['option-'.str_replace('&lowbar;','_',$key)]);
@@ -110,7 +111,7 @@
else { else {
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/".$group."/app_languages.php")) { if (file_exists($_SERVER["PROJECT_ROOT"]."/app/".$group."/app_languages.php")) {
$language3 = new text; $language3 = new text;
$text3 = $language3->get($_SESSION['domain']['language']['code'], 'app/'.$group); $text3 = $language3->get($settings->get('domain', 'language', 'en-us'), 'app/'.$group);
$actions[] = trim($text3['title-'.$group].' &#x203A; '.$key); $actions[] = trim($text3['title-'.$group].' &#x203A; '.$key);
} }
} }

View File

@@ -35,16 +35,44 @@
const app_name = 'destinations'; const app_name = 'destinations';
const app_uuid = '5ec89622-b19c-3559-64f0-afde802ab139'; const app_uuid = '5ec89622-b19c-3559-64f0-afde802ab139';
/**
* 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;
/** /**
* declare public variables * declare public variables
*/ */
public $destinations; public $destinations;
public $domain_uuid;
public $domain_name;
public $start_stamp_begin; public $start_stamp_begin;
public $start_stamp_end; public $start_stamp_end;
public $quick_select; public $quick_select;
/**
* 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;
/** /**
* declare private variables * declare private variables
*/ */
@@ -54,31 +82,19 @@
private $list_page; private $list_page;
private $table; private $table;
private $uuid_prefix; private $uuid_prefix;
private $database;
private $settings;
/** /**
* Called when the object is created * 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->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? '';
$this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? '';
//open a database connection //set objects
if (empty($setting_array['database'])) { $this->database = $setting_array['database'] ?? database::new();
$this->database = database::new(); $this->settings = $setting_array['settings'] ?? new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]);
} else {
$this->database = $setting_array['database'];
}
//set the domain details
$this->domain_uuid = $_SESSION['domain_uuid'] ?? '';
$this->user_uuid = $_SESSION['user_uuid'] ?? '';
//get the settings object
if (empty($setting_array['settings'])) {
$this->settings = new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]);
} else {
$this->settings = $setting_array['settings'];
}
//assign private variables //assign private variables
$this->permission_prefix = 'destination_'; $this->permission_prefix = 'destination_';
@@ -553,7 +569,7 @@
public function all($destination_type) { public function all($destination_type) {
//set the global variables //set the global variables
global $db_type; global $db_type, $settings;
//set default values //set default values
$destination_name = ''; $destination_name = '';
@@ -575,7 +591,7 @@
try { try {
include($config_path); include($config_path);
} }
catch (Exception $e) { catch (Throwable $e) {
//echo 'Caught exception: ', $e->getMessage(), "\n"; //echo 'Caught exception: ', $e->getMessage(), "\n";
} }
$x++; $x++;
@@ -764,7 +780,7 @@
public function get($destination_type) { public function get($destination_type) {
//set the global variables //set the global variables
global $db_type; global $db_type, $settings;
//get the domain_name //get the domain_name
$sql = "select domain_name from v_domains "; $sql = "select domain_name from v_domains ";

View File

@@ -540,7 +540,7 @@
unset($sql, $parameters); unset($sql, $parameters);
//set the defaults //set the defaults
if ($device_enabled === null) { $device_enabled = true; } $device_enabled = $device_enabled ?? true;
//use the device address to get the vendor //use the device address to get the vendor
if (empty($device_vendor)) { if (empty($device_vendor)) {

View File

@@ -64,7 +64,7 @@
//save the data to the csv file //save the data to the csv file
if (isset($_POST['data'])) { if (isset($_POST['data'])) {
$file = $_SESSION['server']['temp']['dir']."/devices-".$_SESSION['domain_name'].".csv"; $file = $settings->get('server', 'temp')."/devices-".$_SESSION['domain_name'].".csv";
if (file_put_contents($file, $_POST['data'])) { if (file_put_contents($file, $_POST['data'])) {
$_SESSION['file'] = $file; $_SESSION['file'] = $file;
} }
@@ -74,7 +74,7 @@
//$_POST['submit'] == "Upload" && //$_POST['submit'] == "Upload" &&
if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('device_import')) { if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('device_import')) {
if ($_POST['type'] == 'csv') { if ($_POST['type'] == 'csv') {
$file = $_SESSION['server']['temp']['dir']."/devices-".$_SESSION['domain_name'].".csv"; $file = $settings->get('server', 'temp')."/devices-".$_SESSION['domain_name'].".csv";
if (move_uploaded_file($_FILES['ulfile']['tmp_name'], $file)) { if (move_uploaded_file($_FILES['ulfile']['tmp_name'], $file)) {
$_SESSION['file'] = $file; $_SESSION['file'] = $file;
} }
@@ -443,7 +443,7 @@
//view_array($message); //view_array($message);
} }
if (!empty($_SESSION['provision']['path']['text'])) { if (!empty($settings->get('provision', 'path'))) {
$prov = new provision; $prov = new provision;
$prov->domain_uuid = $domain_uuid; $prov->domain_uuid = $domain_uuid;
$response = $prov->write(); $response = $prov->write();

View File

@@ -313,11 +313,11 @@
//add an empty row //add an empty row
if (empty($device_profile_keys) || !is_array($device_profile_keys) || count($device_profile_keys) == 0) { if (empty($device_profile_keys) || !is_array($device_profile_keys) || count($device_profile_keys) == 0) {
$rows = $_SESSION['devices']['profile_key_add_rows']['numeric']; $rows = $settings->get('devices', 'profile_key_add_rows');
$id = 0; $id = 0;
} }
if (!empty($device_profile_keys) && is_array($device_profile_keys) && count($device_profile_keys) > 0) { if (!empty($device_profile_keys) && is_array($device_profile_keys) && count($device_profile_keys) > 0) {
$rows = $_SESSION['devices']['profile_key_edit_rows']['numeric']; $rows = $settings->get('devices', 'profile_key_edit_rows');
$id = count($device_profile_keys)+1; $id = count($device_profile_keys)+1;
} }
for ($x = 0; $x < $rows; $x++) { for ($x = 0; $x < $rows; $x++) {
@@ -371,7 +371,7 @@
} }
//set the defaults //set the defaults
if ($device_profile_enabled === null) { $device_profile_enabled = true; } $device_profile_enabled = $device_profile_enabled ?? true;
//create token //create token
$object = new token; $object = new token;

View File

@@ -137,7 +137,7 @@
} }
//set the defaults //set the defaults
if ($enabled === null) { $enabled = true; } $enabled = $enabled ?? true;
//create token //create token
$object = new token; $object = new token;

View File

@@ -269,7 +269,7 @@
unset($sql, $parameters, $sql_where, $index); unset($sql, $parameters, $sql_where, $index);
//set the defaults //set the defaults
if ($enabled === null) { $enabled = true; } $enabled = $enabled ?? true;
//create token //create token
$object = new token; $object = new token;

View File

@@ -220,7 +220,7 @@
$list_row_url = ''; $list_row_url = '';
if (permission_exists('device_vendor_function_edit')) { if (permission_exists('device_vendor_function_edit')) {
$list_row_url = "device_vendor_function_edit.php?device_vendor_uuid=".urlencode($row['device_vendor_uuid'])."&id=".urlencode($row['device_vendor_function_uuid']); $list_row_url = "device_vendor_function_edit.php?device_vendor_uuid=".urlencode($row['device_vendor_uuid'])."&id=".urlencode($row['device_vendor_function_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'; $list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true';
} }
} }

View File

@@ -191,7 +191,7 @@
$list_row_url = ''; $list_row_url = '';
if (permission_exists('device_vendor_edit')) { if (permission_exists('device_vendor_edit')) {
$list_row_url = "device_vendor_edit.php?id=".urlencode($row['device_vendor_uuid']); $list_row_url = "device_vendor_edit.php?id=".urlencode($row['device_vendor_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'; $list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true';
} }
} }

View File

@@ -103,6 +103,7 @@
//get the devices profiles //get the devices profiles
$sql = "select * from v_device_profiles "; $sql = "select * from v_device_profiles ";
$sql .= "where true "; $sql .= "where true ";
$parameters = [];
if (!permission_exists('device_profile_all')) { if (!permission_exists('device_profile_all')) {
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $domain_uuid; $parameters['domain_uuid'] = $domain_uuid;
@@ -321,7 +322,7 @@
echo button::create(['type'=>'button','label'=>$text['button-profiles'],'icon'=>'clone','link'=>'device_profiles.php']); echo button::create(['type'=>'button','label'=>$text['button-profiles'],'icon'=>'clone','link'=>'device_profiles.php']);
} }
$margin_left = permission_exists('device_import') || permission_exists('device_export') || permission_exists('device_vendor_view') || permission_exists('device_profile_view') ? "margin-left: 15px;" : null; $margin_left = permission_exists('device_import') || permission_exists('device_export') || permission_exists('device_vendor_view') || permission_exists('device_profile_view') ? "margin-left: 15px;" : null;
if (permission_exists('device_add') && (empty($_SESSION['limit']['devices']['numeric']) || ($total_devices < $_SESSION['limit']['devices']['numeric']))) { if (permission_exists('device_add') && (empty($settings->get('limit', 'devices')) || ($total_devices < $settings->get('limit', 'devices')))) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','style'=>$margin_left,'link'=>'device_edit.php']); echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','style'=>$margin_left,'link'=>'device_edit.php']);
unset($margin_left); unset($margin_left);
} }

View File

@@ -34,14 +34,49 @@
const app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e'; const app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e';
/** /**
* 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; public $domain_uuid;
/**
* declare public variables
*/
public $template_dir; public $template_dir;
public $device_uuid; public $device_uuid;
public $device_vendor_uuid; public $device_vendor_uuid;
public $device_profile_uuid; public $device_profile_uuid;
/**
* 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 * declare private variables
*/ */
@@ -52,12 +87,6 @@
private $toggle_field; private $toggle_field;
private $toggle_values; private $toggle_values;
/**
* Set in the constructor. Must be a database object and cannot be null.
* @var database Database Object
*/
private $database;
/** /**
* Create a settings object using key/value pairs in the $setting_array. * Create a settings object using key/value pairs in the $setting_array.
* *
@@ -66,16 +95,15 @@
* @depends database::new() * @depends database::new()
* @access public * @access public
*/ */
public function __construct($setting_array = []) { public function __construct(array $setting_array = []) {
//set domain and user UUIDs
//open a database connection $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? '';
if (empty($setting_array['database'])) { $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? '';
$this->database = database::new(); $this->user_uuid = $setting_array['user_uuid'] ?? $_SESSION['user_uuid'] ?? '';
} else {
$this->database = $setting_array['database'];
}
//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]);
} }
public function get_domain_uuid() { public function get_domain_uuid() {
@@ -471,8 +499,8 @@
} }
//check to see if the domain name sub directory exists //check to see if the domain name sub directory exists
if (is_dir($this->template_dir."/".$_SESSION["domain_name"])) { if (is_dir($this->template_dir."/".$this->domain_name)) {
$this->template_dir = $this->template_dir."/".$_SESSION["domain_name"]; $this->template_dir = $this->template_dir."/".$this->domain_name;
} }
//return the template directory //return the template directory
@@ -541,9 +569,9 @@
$p->delete('device_key_delete', 'temp'); $p->delete('device_key_delete', 'temp');
//write the provision files //write the provision files
if (!empty($_SESSION['provision']['path']['text'])) { if (!empty($this->settings->get('provision', 'path'))) {
$prov = new provision; $prov = new provision;
$prov->domain_uuid = $_SESSION['domain_uuid']; $prov->domain_uuid = $this->domain_uuid;
$response = $prov->write(); $response = $prov->write();
} }
@@ -994,7 +1022,7 @@
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $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 .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -1021,9 +1049,9 @@
unset($array); unset($array);
//write the provision files //write the provision files
if (!empty($_SESSION['provision']['path']['text'])) { if (!empty($this->settings->get('provision', 'path'))) {
$prov = new provision; $prov = new provision;
$prov->domain_uuid = $_SESSION['domain_uuid']; $prov->domain_uuid = $this->domain_uuid;
$response = $prov->write(); $response = $prov->write();
} }
@@ -1288,7 +1316,7 @@
$sql = "select * from v_".$this->table." "; $sql = "select * from v_".$this->table." ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
$y = $z = 0; $y = $z = 0;

View File

@@ -28,7 +28,7 @@
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get($_SESSION['domain']['language']['code'], 'app/devices'); $text = $language->get($settings->get('domain', 'language', 'en-us'), 'app/devices');
//get the vendor functions //get the vendor functions
$sql = "select v.name as vendor_name, f.type, f.value "; $sql = "select v.name as vendor_name, f.type, f.value ";
@@ -270,7 +270,7 @@
} }
//write the provision files //write the provision files
if (!empty($_SESSION['provision']['path']['text'])) { if (!empty($settings->get('provision', 'path'))) {
$prov = new provision; $prov = new provision;
$prov->domain_uuid = $domain_uuid; $prov->domain_uuid = $domain_uuid;
$response = $prov->write(); $response = $prov->write();

View File

@@ -174,11 +174,11 @@
$text = $language->get(); $text = $language->get();
// load editor preferences/defaults // load editor preferences/defaults
$setting_size = !empty($_SESSION["editor"]["font_size"]["text"]) ? $_SESSION["editor"]["font_size"]["text"] : '12px'; $setting_size = !empty($settings->get('editor', 'font_size')) ? $settings->get('editor', 'font_size') : '12px';
$setting_theme = !empty($_SESSION["editor"]["theme"]["text"]) ? $_SESSION["editor"]["theme"]["text"] : 'cobalt'; $setting_theme = !empty($settings->get('editor', 'theme')) ? $settings->get('editor', 'theme') : 'cobalt';
$setting_invisibles = isset($_SESSION['editor']['invisibles']['text']) ? $_SESSION['editor']['invisibles']["text"] : 'false'; $setting_invisibles = $settings->get('editor', 'invisibles', 'false');
$setting_indenting = isset($_SESSION['editor']['indent_guides']['text']) ? $_SESSION['editor']['indent_guides']["text"]: 'false'; $setting_indenting = $settings->get('editor', 'indent_guides', 'false');
$setting_numbering = isset($_SESSION['editor']['line_numbers']['text']) ? $_SESSION['editor']['line_numbers']["text"] : 'true'; $setting_numbering = $settings->get('editor', 'line_numbers', 'true');
//create token //create token
$object = new token; $object = new token;

View File

@@ -574,7 +574,7 @@
) { ) {
$list_row_url = "dialplan_edit.php?id=".urlencode($row['dialplan_uuid']).(is_uuid($app_uuid) ? "&app_uuid=".urlencode($app_uuid) : null); $list_row_url = "dialplan_edit.php?id=".urlencode($row['dialplan_uuid']).(is_uuid($app_uuid) ? "&app_uuid=".urlencode($app_uuid) : null);
if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) { if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) {
$list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true'; $list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid'] ?? '').'&domain_change=true';
} }
} }
else { else {

View File

@@ -34,9 +34,14 @@
const app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db'; const app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
/** /**
* 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; public $domain_uuid;
/**
* declare public variables
*/
public $dialplan_uuid; public $dialplan_uuid;
public $dialplan_detail_uuid; public $dialplan_detail_uuid;
public $xml; public $xml;
@@ -73,6 +78,24 @@
public $array; public $array;
public $list_page; public $list_page;
/**
* 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;
/** /**
* declare private variables * declare private variables
*/ */
@@ -82,14 +105,16 @@
private $toggle_field; private $toggle_field;
private $toggle_values; private $toggle_values;
/** //class constructor
* Set in the constructor. Must be a database object and cannot be null. public function __construct(array $setting_array = []) {
* @var database Database Object //set domain and user UUIDs
*/ $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? '';
private $database; $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]);
//class constructor
public function __construct() {
//set the default value //set the default value
$this->dialplan_global = false; $this->dialplan_global = false;
@@ -100,13 +125,6 @@
$this->uuid_prefix = 'dialplan_'; $this->uuid_prefix = 'dialplan_';
$this->toggle_field = 'dialplan_enabled'; $this->toggle_field = 'dialplan_enabled';
$this->toggle_values = ['true','false']; $this->toggle_values = ['true','false'];
//open a database connection
if (empty($setting_array['database'])) {
$this->database = database::new();
} else {
$this->database = $setting_array['database'];
}
} }
@@ -138,7 +156,7 @@
//prepare the xml //prepare the xml
if (!empty($xml_string)) { if (!empty($xml_string)) {
//replace the variables //replace the variables
$length = (is_numeric($_SESSION["security"]["pin_length"]["var"])) ? $_SESSION["security"]["pin_length"]["var"] : 8; $length = (is_numeric($this->settings->get('security', 'pin_length'))) ? $this->settings->get('security', 'pin_length') : 8;
$xml_string = str_replace("{v_context}", $domain['domain_name'], $xml_string); $xml_string = str_replace("{v_context}", $domain['domain_name'], $xml_string);
$xml_string = str_replace("{v_pin_number}", generate_password($length, 1), $xml_string); $xml_string = str_replace("{v_pin_number}", generate_password($length, 1), $xml_string);
//convert the xml string to an xml object //convert the xml string to an xml object
@@ -179,7 +197,7 @@
//prepare the xml //prepare the xml
if (!empty($xml_string)) { if (!empty($xml_string)) {
//replace the variables //replace the variables
$length = (!empty($_SESSION["security"]["pin_length"]["var"])) ? $_SESSION["security"]["pin_length"]["var"] : 8; $length = (!empty($this->settings->get('security', 'pin_length'))) ? $this->settings->get('security', 'pin_length') : 8;
$xml_string = str_replace("{v_context}", $domain['domain_name'], $xml_string); $xml_string = str_replace("{v_context}", $domain['domain_name'], $xml_string);
$xml_string = str_replace("{v_pin_number}", generate_password($length, 1), $xml_string); $xml_string = str_replace("{v_pin_number}", generate_password($length, 1), $xml_string);
@@ -418,7 +436,7 @@
$destination_number = trim($destination_number); $destination_number = trim($destination_number);
//check the session array if it doesn't exist then build the array //check the session array if it doesn't exist then build the array
if (empty($_SESSION[$_SESSION['domain_uuid']]['outbound_routes'])) { if (empty($_SESSION[$this->domain_uuid]['outbound_routes'])) {
//get the outbound routes from the database //get the outbound routes from the database
$sql = "select * "; $sql = "select * ";
$sql .= "from v_dialplans as d, "; $sql .= "from v_dialplans as d, ";
@@ -479,12 +497,12 @@
} }
//set the session array //set the session array
$_SESSION[$_SESSION['domain_uuid']]['outbound_routes'] = $array; $_SESSION[$this->domain_uuid]['outbound_routes'] = $array;
} }
//find the matching outbound routes //find the matching outbound routes
if (isset($_SESSION[$_SESSION['domain_uuid']]['outbound_routes'])) { if (isset($_SESSION[$this->domain_uuid]['outbound_routes'])) {
foreach ($_SESSION[$_SESSION['domain_uuid']]['outbound_routes'] as $row) { foreach ($_SESSION[$this->domain_uuid]['outbound_routes'] as $row) {
if (isset($row['dialplan_details'])) { if (isset($row['dialplan_details'])) {
foreach ($row['dialplan_details'] as $field) { foreach ($row['dialplan_details'] as $field) {
if ($field['dialplan_detail_tag'] == "condition") { if ($field['dialplan_detail_tag'] == "condition") {
@@ -1232,7 +1250,7 @@
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
if (!permission_exists('dialplan_all')) { if (!permission_exists('dialplan_all')) {
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $this->domain_uuid;
} }
$rows = $this->database->select($sql, $parameters ?? null, 'all'); $rows = $this->database->select($sql, $parameters ?? null, 'all');
if (!empty($rows)) { if (!empty($rows)) {

View File

@@ -39,7 +39,7 @@
//add multi-lingual support //add multi-lingual support
$language = new text; $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');
//clear initial stat //clear initial stat
unset($hud_stat); unset($hud_stat);
@@ -52,10 +52,6 @@
$row_style["0"] = "row_style0"; $row_style["0"] = "row_style0";
$row_style["1"] = "row_style1"; $row_style["1"] = "row_style1";
//set default values
if (!isset($_SESSION['limit']['extensions']['numeric'])) { $_SESSION['limit']['extensions']['numeric'] = 0; }
if (!isset($_SESSION['limit']['destinations']['numeric'])) { $_SESSION['limit']['destinations']['numeric'] = 0; }
//caller id //caller id
echo "<div class='hud_box'>\n"; echo "<div class='hud_box'>\n";
@@ -95,13 +91,13 @@
if (permission_exists('extension_view')) { if (permission_exists('extension_view')) {
$onclick = "onclick=\"document.location.href='".PROJECT_PATH."/app/extensions/extensions.php'\""; $onclick = "onclick=\"document.location.href='".PROJECT_PATH."/app/extensions/extensions.php'\"";
$hud_stat_used = $usage['extensions']; $hud_stat_used = $usage['extensions'];
$hud_stat_remaining = $_SESSION['limit']['extensions']['numeric'] - $usage['extensions']; $hud_stat_remaining = $settings->get('limit', 'extensions', 0) - $usage['extensions'];
$hud_stat_title = $text['label-extensions']; $hud_stat_title = $text['label-extensions'];
} }
else if (permission_exists('destination_view')) { else if (permission_exists('destination_view')) {
$onclick = "onclick=\"document.location.href='".PROJECT_PATH."/app/destinations/destinations.php'\""; $onclick = "onclick=\"document.location.href='".PROJECT_PATH."/app/destinations/destinations.php'\"";
$hud_stat_used = $usage['destinations']; $hud_stat_used = $usage['destinations'];
$hud_stat_remaining = $_SESSION['limit']['destinations']['numeric'] - $usage['destinations']; $hud_stat_remaining = $settings->get('limit', 'destinations', 0) - $usage['destinations'];
$hud_stat_title = $text['label-destinations']; $hud_stat_title = $text['label-destinations'];
} }

View File

@@ -321,7 +321,7 @@
$list_row_url = ''; $list_row_url = '';
if (permission_exists('email_queue_edit')) { if (permission_exists('email_queue_edit')) {
$list_row_url = "email_queue_edit.php?id=".urlencode($row['email_queue_uuid']); $list_row_url = "email_queue_edit.php?id=".urlencode($row['email_queue_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'; $list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true';
} }
} }
@@ -348,7 +348,7 @@
echo " <td class='hide-md-dn'>".escape($row['hostname'])."</td>\n"; echo " <td class='hide-md-dn'>".escape($row['hostname'])."</td>\n";
echo " <td class='shrink hide-md-dn'>".escape($row['email_from'])."</td>\n"; echo " <td class='shrink hide-md-dn'>".escape($row['email_from'])."</td>\n";
echo " <td class='overflow' style='width: 20%; max-width: 200px;'>".escape($row['email_to'])."</td>\n"; echo " <td class='overflow' style='width: 20%; max-width: 200px;'>".escape($row['email_to'])."</td>\n";
echo " <td class='overflow' style='width: 30%; max-width: 200px;'>".iconv_mime_decode($row['email_subject'])."</td>\n"; echo " <td class='overflow' style='width: 30%; max-width: 200px;'>".iconv_mime_decode($row['email_subject'] ?? '')."</td>\n";
// echo " <td class='hide-md-dn'>".escape($row['email_body'])."</td>\n"; // echo " <td class='hide-md-dn'>".escape($row['email_body'])."</td>\n";
echo " <td>".ucwords($text['label-'.$row['email_status']])."</td>\n"; echo " <td>".ucwords($text['label-'.$row['email_status']])."</td>\n";
echo " <td>".escape($row['email_retry_count'])."</td>\n"; echo " <td>".escape($row['email_retry_count'])."</td>\n";

View File

@@ -227,11 +227,11 @@
} }
//load editor preferences/defaults //load editor preferences/defaults
$setting_size = !empty($_SESSION["editor"]["font_size"]["text"]) ? $_SESSION["editor"]["font_size"]["text"] : '12px'; $setting_size = !empty($settings->get('editor', 'font_size')) ? $settings->get('editor', 'font_size') : '12px';
$setting_theme = !empty($_SESSION["editor"]["theme"]["text"]) ? $_SESSION["editor"]["theme"]["text"] : 'cobalt'; $setting_theme = !empty($settings->get('editor', 'theme')) ? $settings->get('editor', 'theme') : 'cobalt';
$setting_invisibles = isset($_SESSION['editor']['invisibles']['text']) ? $_SESSION['editor']['invisibles']["text"] : 'false'; $setting_invisibles = $settings->get('editor', 'invisibles', 'false');
$setting_indenting = isset($_SESSION['editor']['indent_guides']['text']) ? $_SESSION['editor']['indent_guides']["text"]: 'false'; $setting_indenting = $settings->get('editor', 'indent_guides', 'false');
$setting_numbering = isset($_SESSION['editor']['line_numbers']['text']) ? $_SESSION['editor']['line_numbers']["text"] : 'true'; $setting_numbering = $settings->get('editor', 'line_numbers', 'true');
//create token //create token
$object = new token; $object = new token;

View File

@@ -76,8 +76,8 @@
$email_body .= "If you received this message, your current SMTP settings are valid.<br /><br />\n"; $email_body .= "If you received this message, your current SMTP settings are valid.<br /><br />\n";
} }
$email_from_address = $_SESSION['email']['smtp_from']['text']; $email_from_address = $settings->get('email', 'smtp_from');
$email_from_name = $_SESSION['email']['smtp_from_name']['text']; $email_from_name = $settings->get('email', 'smtp_from_name');
//send email //send email
$sent = 0; $sent = 0;
@@ -118,6 +118,7 @@
echo "<table>\n"; echo "<table>\n";
foreach ($_SESSION['email'] as $name => $setting) { foreach ($_SESSION['email'] as $name => $setting) {
foreach ($setting as $type => $value) { foreach ($setting as $type => $value) {
$value = $value ?? '';
echo "<tr>\n"; echo "<tr>\n";
if ($type == 'uuid') { $uuid = $value; continue; } if ($type == 'uuid') { $uuid = $value; continue; }
if ($name == 'smtp_password') { $value = str_repeat('*', strlen($value)); } if ($name == 'smtp_password') { $value = str_repeat('*', strlen($value)); }
@@ -138,7 +139,7 @@
echo "<b>".$text['header-connection']."</b>\n"; echo "<b>".$text['header-connection']."</b>\n";
echo "<br><br>\n"; echo "<br><br>\n";
echo "<div style='width: 100%; max-height: 250px; overflow: auto; border: 1px solid ".($_SESSION['theme']['table_row_border_color']['text'] ?? '#c5d1e5')."; padding: 12px 15px; background-color: ".($_SESSION['theme']['table_row_background_color_light']['text'] ?? '#fff')."; font-family: monospace; font-size: 85%;'>\n"; echo "<div style='width: 100%; max-height: 250px; overflow: auto; border: 1px solid ".($settings->get('theme', 'table_row_border_color') ?? '#c5d1e5')."; padding: 12px 15px; background-color: ".($settings->get('theme', 'table_row_background_color_light') ?? '#fff')."; font-family: monospace; font-size: 85%;'>\n";
if (!empty($email_response) && is_array($email_response) && @sizeof($email_response) != 0) { if (!empty($email_response) && is_array($email_response) && @sizeof($email_response) != 0) {
echo implode("<br>\n<hr style='margin: 3px 0;'>\n", $email_response); echo implode("<br>\n<hr style='margin: 3px 0;'>\n", $email_response);

View File

@@ -11,10 +11,33 @@
const app_name = 'email_queue'; const app_name = 'email_queue';
const app_uuid = '5befdf60-a242-445f-91b3-2e9ee3e0ddf7'; const app_uuid = '5befdf60-a242-445f-91b3-2e9ee3e0ddf7';
/**
* 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 the variables * declare the variables
*/ */
private $database;
private $name; private $name;
private $table; private $table;
private $toggle_field; private $toggle_field;
@@ -24,18 +47,21 @@
/** /**
* called when the object is created * 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 the variables //assign the variables
$this->name = 'email_queue'; $this->name = 'email_queue';
$this->table = 'email_queue'; $this->table = 'email_queue';
$this->toggle_field = ''; $this->toggle_field = '';
$this->toggle_values = ['true','false']; $this->toggle_values = ['true','false'];
$this->location = 'email_queue.php'; $this->location = 'email_queue.php';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
} }
/** /**
@@ -65,7 +91,7 @@
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
$array[$this->table][$x][$this->name.'_uuid'] = $record['uuid']; $array[$this->table][$x][$this->name.'_uuid'] = $record['uuid'];
$array['email_queue_attachments'][$x][$this->name.'_uuid'] = $record['uuid']; $array['email_queue_attachments'][$x][$this->name.'_uuid'] = $record['uuid'];
//$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; //$array[$this->table][$x]['domain_uuid'] = $this->domain_uuid;
} }
//increment the id //increment the id
@@ -165,7 +191,7 @@
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $this->domain_uuid;
$rows = $this->database->select($sql, $parameters, 'all'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -234,7 +260,7 @@
$sql = "select * from v_".$this->table." "; $sql = "select * from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $this->domain_uuid;
$rows = $this->database->select($sql, $parameters, 'all'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
$x = 0; $x = 0;

View File

@@ -35,10 +35,33 @@
const app_name = 'event_guard'; const app_name = 'event_guard';
const app_uuid = 'c5b86612-1514-40cb-8e2c-3f01a8f6f637'; const app_uuid = 'c5b86612-1514-40cb-8e2c-3f01a8f6f637';
/**
* 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 the variables * declare the variables
*/ */
private $database;
private $name; private $name;
private $table; private $table;
private $toggle_field; private $toggle_field;
@@ -48,18 +71,20 @@
/** /**
* called when the object is created * 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();
//assign the variables //assign the variables
$this->name = 'event_guard_log'; $this->name = 'event_guard_log';
$this->table = 'event_guard_logs'; $this->table = 'event_guard_logs';
$this->toggle_field = ''; $this->toggle_field = '';
$this->toggle_values = ['block','pending']; $this->toggle_values = ['block','pending'];
$this->location = 'event_guard_logs.php'; $this->location = 'event_guard_logs.php';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
} }
/** /**

View File

@@ -35,10 +35,33 @@
const app_name = 'extension_settings'; const app_name = 'extension_settings';
const app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd'; const app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
/**
* 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 the variables * declare the variables
*/ */
private $database;
private $name; private $name;
private $table; private $table;
private $toggle_field; private $toggle_field;
@@ -49,7 +72,14 @@
/** /**
* called when the object is created * 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();
//assign the variables //assign the variables
$this->name = 'extension_setting'; $this->name = 'extension_setting';
$this->table = 'extension_settings'; $this->table = 'extension_settings';
@@ -58,10 +88,6 @@
$this->description_field = 'extension_setting_description'; $this->description_field = 'extension_setting_description';
$this->location = 'extension_settings.php'; $this->location = 'extension_settings.php';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
} }
/** /**
@@ -90,7 +116,7 @@
//add to the array //add to the array
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) { if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
$array[$this->table][$x][$this->name.'_uuid'] = $record['uuid']; $array[$this->table][$x][$this->name.'_uuid'] = $record['uuid'];
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid;
} }
//increment the id //increment the id
@@ -150,7 +176,7 @@
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle, extension_uuid from v_".$this->table." "; $sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle, extension_uuid from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $this->domain_uuid;
$rows = $this->database->select($sql, $parameters, 'all'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
$extension_uuid = $rows[0]['extension_uuid']; $extension_uuid = $rows[0]['extension_uuid'];
@@ -229,7 +255,7 @@
$sql = "select * from v_".$this->table." "; $sql = "select * from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $this->domain_uuid;
$rows = $this->database->select($sql, $parameters, 'all'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $x => $row) { foreach ($rows as $x => $row) {

View File

@@ -113,7 +113,7 @@
$array['extensions'][0]['extension_uuid'] = uuid(); $array['extensions'][0]['extension_uuid'] = uuid();
$array['extensions'][0]['extension'] = $extension_new; $array['extensions'][0]['extension'] = $extension_new;
$array['extensions'][0]['number_alias'] = $number_alias_new; $array['extensions'][0]['number_alias'] = $number_alias_new;
$array['extensions'][0]['password'] = generate_password($_SESSION["extension"]["password_length"]["numeric"], $_SESSION["extension"]["password_strength"]["numeric"]); $array['extensions'][0]['password'] = generate_password($settings->get('extension', 'password_length'), $settings->get('extension', 'password_strength'));
$array['extensions'][0]['accountcode'] = $password; $array['extensions'][0]['accountcode'] = $password;
$array['extensions'][0]['effective_caller_id_name'] = $effective_caller_id_name; $array['extensions'][0]['effective_caller_id_name'] = $effective_caller_id_name;
$array['extensions'][0]['effective_caller_id_number'] = $effective_caller_id_number; $array['extensions'][0]['effective_caller_id_number'] = $effective_caller_id_number;
@@ -187,7 +187,7 @@
} }
//synchronize configuration //synchronize configuration
if (is_writable($_SESSION['switch']['extensions']['dir'])) { if (is_writable($settings->get('switch', 'extensions'))) {
$ext = new extension; $ext = new extension;
$ext->xml(); $ext->xml();
unset($ext); unset($ext);

View File

@@ -61,7 +61,7 @@
//save the data to the csv file //save the data to the csv file
if (isset($_POST['data'])) { if (isset($_POST['data'])) {
$file = $_SESSION['server']['temp']['dir']."/extensions-".$_SESSION['domain_name'].".csv"; $file = $settings->get('server', 'temp')."/extensions-".$_SESSION['domain_name'].".csv";
file_put_contents($file, $_POST['data']); file_put_contents($file, $_POST['data']);
$_SESSION['file'] = $file; $_SESSION['file'] = $file;
} }
@@ -70,11 +70,11 @@
//$_POST['submit'] == "Upload" && //$_POST['submit'] == "Upload" &&
if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('extension_import')) { if (!empty($_FILES['ulfile']['tmp_name']) && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('extension_import')) {
if ($_POST['type'] == 'csv') { if ($_POST['type'] == 'csv') {
move_uploaded_file($_FILES['ulfile']['tmp_name'], $_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 ".$_SESSION['server']['temp']['dir']."/". htmlentities($_FILES['ulfile']['name']); $save_msg = "Uploaded file to ".$settings->get('server', 'temp')."/". htmlentities($_FILES['ulfile']['name']);
//system('chmod -R 744 '.$_SESSION['server']['temp']['dir'].'*'); //system('chmod -R 744 '.$settings->get('server', 'temp').'*');
unset($_POST['txtCommand']); unset($_POST['txtCommand']);
$file = $_SESSION['server']['temp']['dir'].'/'.$_FILES['ulfile']['name']; $file = $settings->get('server', 'temp').'/'.$_FILES['ulfile']['name'];
$_SESSION['file'] = $file; $_SESSION['file'] = $file;
} }
} }

View File

@@ -82,7 +82,7 @@
} }
//get total extension count for domain //get total extension count for domain
if (isset($_SESSION['limit']['extensions']['numeric'])) { if (!empty($settings->get('limit', 'extensions'))) {
$sql = "select count(*) from v_extensions "; $sql = "select count(*) from v_extensions ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
@@ -288,14 +288,14 @@
echo "<div class='action_bar' id='action_bar'>\n"; echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-extensions']."</b><div class='count'>".number_format($num_rows)."</div></div>\n"; echo " <div class='heading'><b>".$text['header-extensions']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
echo " <div class='actions'>\n"; echo " <div class='actions'>\n";
if (permission_exists('extension_import') && (!isset($_SESSION['limit']['extensions']['numeric']) || $total_extensions < $_SESSION['limit']['extensions']['numeric'])) { if (permission_exists('extension_import') && (empty($settings->get('limit', 'extensions', 0)) || $total_extensions < $settings->get('limit', 'extensions'))) {
echo button::create(['type'=>'button','label'=>$text['button-import'],'icon'=>$settings->get('theme', 'button_icon_import'),'link'=>'extension_imports.php']); echo button::create(['type'=>'button','label'=>$text['button-import'],'icon'=>$settings->get('theme', 'button_icon_import'),'link'=>'extension_imports.php']);
} }
if (permission_exists('extension_export')) { if (permission_exists('extension_export')) {
echo button::create(['type'=>'button','label'=>$text['button-export'],'icon'=>$settings->get('theme', 'button_icon_export'),'link'=>'extension_download.php']); echo button::create(['type'=>'button','label'=>$text['button-export'],'icon'=>$settings->get('theme', 'button_icon_export'),'link'=>'extension_download.php']);
} }
$margin_left = permission_exists('extension_import') || permission_exists('extension_export') ? "margin-left: 15px;" : null; $margin_left = permission_exists('extension_import') || permission_exists('extension_export') ? "margin-left: 15px;" : null;
if (permission_exists('extension_add') && (!isset($_SESSION['limit']['extensions']['numeric']) || $total_extensions < $_SESSION['limit']['extensions']['numeric'])) { if (permission_exists('extension_add') && (empty($settings->get('limit', 'extensions', 0)) || $total_extensions < $settings->get('limit', 'extensions'))) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','style'=>($margin_left ?? ''),'link'=>'extension_edit.php']); echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','style'=>($margin_left ?? ''),'link'=>'extension_edit.php']);
unset($margin_left); unset($margin_left);
} }
@@ -435,8 +435,8 @@
echo " <td>".escape($_SESSION['domains'][$row['domain_uuid']]['domain_name'])."</td>\n"; echo " <td>".escape($_SESSION['domains'][$row['domain_uuid']]['domain_name'])."</td>\n";
} }
if (permission_exists('extension_registered')) { if (permission_exists('extension_registered')) {
$icon_registered_color = $_SESSION['extension']['icon_registered_color']['text'] ?? '#12d600'; $icon_registered_color = $settings->get('extension', 'icon_registered_color') ?? '#12d600';
$icon_unregistered_color = $_SESSION['extension']['icon_unregistered_color']['text'] ?? '#e21b1b'; $icon_unregistered_color = $settings->get('extension', 'icon_unregistered_color') ?? '#e21b1b';
$extension_number = $row['extension'].'@'.$_SESSION['domains'][$row['domain_uuid']]['domain_name']; $extension_number = $row['extension'].'@'.$_SESSION['domains'][$row['domain_uuid']]['domain_name'];
$extension_number_alias = $row['number_alias']; $extension_number_alias = $row['number_alias'];

View File

@@ -34,10 +34,20 @@
const app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3'; const app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3';
/** /**
* 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; 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; public $domain_name;
/**
* declare public variables
*/
public $extension_uuid; public $extension_uuid;
public $extension; public $extension;
public $voicemail_id; public $voicemail_id;
@@ -80,9 +90,26 @@
public $delete_voicemail; public $delete_voicemail;
/** /**
* declare private variables * Set in the constructor. Must be a database object and cannot be null.
* @var database Database Object
*/ */
private $database; 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;
/**
* declare private variables
*/
private $permission_prefix; private $permission_prefix;
private $list_page; private $list_page;
private $table; private $table;
@@ -93,7 +120,15 @@
/** /**
* called when the object is created * 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 //assign private variables
$this->permission_prefix = 'extension_'; $this->permission_prefix = 'extension_';
@@ -102,12 +137,6 @@
$this->uuid_prefix = 'extension_'; $this->uuid_prefix = 'extension_';
$this->toggle_field = 'enabled'; $this->toggle_field = 'enabled';
$this->toggle_values = ['true','false']; $this->toggle_values = ['true','false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
} }
public function exists($domain_uuid, $extension) { public function exists($domain_uuid, $extension) {
@@ -188,7 +217,7 @@
} }
public function xml() { public function xml() {
if (isset($_SESSION['switch']['extensions']['dir'])) { if (!empty($this->settings->get('switch', 'extensions'))) {
//declare global variables //declare global variables
global $config, $domain_uuid; global $config, $domain_uuid;
@@ -197,7 +226,7 @@
$user_context = $domain_name; $user_context = $domain_name;
//delete all old extensions to prepare for new ones //delete all old extensions to prepare for new ones
$dialplan_list = glob($_SESSION['switch']['extensions']['dir']."/".$user_context."/v_*.xml"); $dialplan_list = glob($this->settings->get('switch', 'extensions')."/".$user_context."/v_*.xml");
foreach($dialplan_list as $name => $value) { foreach($dialplan_list as $name => $value) {
unlink($value); unlink($value);
} }
@@ -243,8 +272,8 @@
$extension = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $extension); $extension = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $extension);
$dial_string = $row['dial_string']; $dial_string = $row['dial_string'];
if (empty($dial_string)) { if (empty($dial_string)) {
if (!empty($_SESSION['domain']['dial_string']['text'])) { if (!empty($this->settings->get('domain', 'dial_string'))) {
$dial_string = $_SESSION['domain']['dial_string']['text']; $dial_string = $this->settings->get('domain', 'dial_string');
} }
else { else {
$dial_string = "{sip_invite_domain=\${domain_name},leg_timeout=".$call_timeout.",presence_id=\${dialed_user}@\${dialed_domain}}\${sofia_contact(\${dialed_user}@\${dialed_domain})}"; $dial_string = "{sip_invite_domain=\${domain_name},leg_timeout=".$call_timeout.",presence_id=\${dialed_user}@\${dialed_domain}}\${sofia_contact(\${dialed_user}@\${dialed_domain})}";
@@ -318,8 +347,8 @@
$xml .= " <param name=\"dial-string\" value=\"" . $dial_string . "\"/>\n"; $xml .= " <param name=\"dial-string\" value=\"" . $dial_string . "\"/>\n";
$xml .= " </params>\n"; $xml .= " </params>\n";
$xml .= " <variables>\n"; $xml .= " <variables>\n";
$xml .= " <variable name=\"domain_name\" value=\"" . $_SESSION['domain_name'] . "\"/>\n"; $xml .= " <variable name=\"domain_name\" value=\"" . $this->domain_name . "\"/>\n";
$xml .= " <variable name=\"domain_uuid\" value=\"" . $_SESSION['domain_uuid'] . "\"/>\n"; $xml .= " <variable name=\"domain_uuid\" value=\"" . $this->domain_uuid . "\"/>\n";
$xml .= " <variable name=\"extension_uuid\" value=\"" . $extension_uuid . "\"/>\n"; $xml .= " <variable name=\"extension_uuid\" value=\"" . $extension_uuid . "\"/>\n";
if (!empty($row['call_group'])) { if (!empty($row['call_group'])) {
$xml .= " <variable name=\"call_group\" value=\"" . $row['call_group'] . "\"/>\n"; $xml .= " <variable name=\"call_group\" value=\"" . $row['call_group'] . "\"/>\n";
@@ -428,11 +457,11 @@
$xml .= " </variables>\n"; $xml .= " </variables>\n";
$xml .= " </user>\n"; $xml .= " </user>\n";
if (!is_readable($_SESSION['switch']['extensions']['dir']."/".$row['user_context'])) { if (!is_readable($this->settings->get('switch', 'extensions')."/".$row['user_context'])) {
mkdir($_SESSION['switch']['extensions']['dir']."/".$row['user_context'], 0770, false); mkdir($this->settings->get('switch', 'extensions')."/".$row['user_context'], 0770, false);
} }
if (!empty($extension)) { if (!empty($extension)) {
$fout = fopen($_SESSION['switch']['extensions']['dir']."/".$row['user_context']."/v_".$extension.".xml","w"); $fout = fopen($this->settings->get('switch', 'extensions')."/".$row['user_context']."/v_".$extension.".xml","w");
} }
$xml .= "</include>\n"; $xml .= "</include>\n";
fwrite($fout, $xml); fwrite($fout, $xml);
@@ -444,7 +473,7 @@
unset($rows, $row); unset($rows, $row);
//prepare extension //prepare extension
$extension_dir = realpath($_SESSION['switch']['extensions']['dir']); $extension_dir = realpath($this->settings->get('switch', 'extensions'));
$user_context = str_replace(" ", "_", $user_context); $user_context = str_replace(" ", "_", $user_context);
$user_context = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $user_context); $user_context = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $user_context);
@@ -568,7 +597,7 @@
$sql = "select extension, number_alias, user_context, follow_me_uuid from v_extensions "; $sql = "select extension, number_alias, user_context, follow_me_uuid from v_extensions ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and extension_uuid = :extension_uuid "; $sql .= "and extension_uuid = :extension_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $this->domain_uuid;
$parameters['extension_uuid'] = $record['uuid']; $parameters['extension_uuid'] = $record['uuid'];
$row = $this->database->select($sql, $parameters, 'row'); $row = $this->database->select($sql, $parameters, 'row');
if (is_array($row) && @sizeof($row) != 0) { if (is_array($row) && @sizeof($row) != 0) {
@@ -589,10 +618,10 @@
//include ring group destinations, if exists //include ring group destinations, if exists
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/ring_groups/app_config.php")) { if (file_exists($_SERVER["PROJECT_ROOT"]."/app/ring_groups/app_config.php")) {
$array['ring_group_destinations'][$x]['destination_number'] = $extensions[$x]['extension']; $array['ring_group_destinations'][$x]['destination_number'] = $extensions[$x]['extension'];
$array['ring_group_destinations'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['ring_group_destinations'][$x]['domain_uuid'] = $this->domain_uuid;
if (is_numeric($extensions[$x]['number_alias'])) { if (is_numeric($extensions[$x]['number_alias'])) {
$array['ring_group_destinations'][$y]['destination_number'] = $extensions[$x]['number_alias']; $array['ring_group_destinations'][$y]['destination_number'] = $extensions[$x]['number_alias'];
$array['ring_group_destinations'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['ring_group_destinations'][$y]['domain_uuid'] = $this->domain_uuid;
} }
$y++; $y++;
} }
@@ -600,7 +629,7 @@
//include extension settings, if exists //include extension settings, if exists
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/extension_settings/app_config.php")) { if (file_exists($_SERVER["PROJECT_ROOT"]."/app/extension_settings/app_config.php")) {
$array['extension_settings'][$x]['extension_uuid'] = $record['uuid']; $array['extension_settings'][$x]['extension_uuid'] = $record['uuid'];
$array['extension_settings'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['extension_settings'][$x]['domain_uuid'] = $this->domain_uuid;
} }
//create array of voicemail ids //create array of voicemail ids
@@ -629,7 +658,7 @@
$sql = "select voicemail_uuid as uuid from v_voicemails "; $sql = "select voicemail_uuid as uuid from v_voicemails ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and voicemail_id in ('".implode("','", $voicemail_ids)."') "; $sql .= "and voicemail_id in ('".implode("','", $voicemail_ids)."') ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $this->domain_uuid;
$rows = $this->database->select($sql, $parameters, 'all'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $r => $row) { foreach ($rows as $r => $row) {
@@ -675,7 +704,7 @@
unset($extensions); unset($extensions);
//synchronize configuration //synchronize configuration
if (!empty($_SESSION['switch']['extensions']['dir']) && is_writable($_SESSION['switch']['extensions']['dir'])) { if (!empty($this->settings->get('switch', 'extensions')) && is_writable($this->settings->get('switch', 'extensions'))) {
$this->xml(); $this->xml();
} }
@@ -724,7 +753,7 @@
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, extension, number_alias, user_context from v_".$this->table." "; $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, extension, number_alias, user_context from v_".$this->table." ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -762,15 +791,15 @@
$p->delete('extension_edit', 'temp'); $p->delete('extension_edit', 'temp');
//synchronize configuration //synchronize configuration
if (!empty($_SESSION['switch']['extensions']['dir']) && is_writable($_SESSION['switch']['extensions']['dir'])) { if (!empty($this->settings->get('switch', 'extensions')) && is_writable($this->settings->get('switch', 'extensions'))) {
$this->xml(); $this->xml();
} }
//write the provision files //write the provision files
if (!empty($_SESSION['provision']['path']['text'])) { if (!empty($this->settings->get('provision', 'path'))) {
if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/provision')) { if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/provision')) {
$prov = new provision; $prov = new provision;
$prov->domain_uuid = $_SESSION['domain_uuid']; $prov->domain_uuid = $this->domain_uuid;
$response = $prov->write(); $response = $prov->write();
} }
} }

View File

@@ -33,7 +33,7 @@
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get($_SESSION['domain']['language']['code'], 'app/extensions'); $text = $language->get($settings->get('domain', 'language', 'en-us'), 'app/extensions');
//add or update the database //add or update the database
if (isset($_POST['extensions']) && is_array($_POST['extensions']) && @sizeof($_POST['extensions']) != 0) { if (isset($_POST['extensions']) && is_array($_POST['extensions']) && @sizeof($_POST['extensions']) != 0) {

View File

@@ -117,7 +117,7 @@
$num_rows = $database->select($sql, $parameters ?? null, 'column'); $num_rows = $database->select($sql, $parameters ?? null, 'column');
//prepare paging //prepare paging
$rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; $rows_per_page = $settings->get('domain', 'paging', 50);
$param = "&search=".urlencode($search); $param = "&search=".urlencode($search);
if ($show == "all" && permission_exists('fax_extension_view_all')) { if ($show == "all" && permission_exists('fax_extension_view_all')) {
$param .= "&show=all"; $param .= "&show=all";
@@ -294,7 +294,7 @@
if (permission_exists('fax_log_view')) { if (permission_exists('fax_log_view')) {
echo " <a href='fax_logs.php?id=".urlencode($row['fax_uuid'])."'>".$text['label-log']."</a>&nbsp;&nbsp;"; echo " <a href='fax_logs.php?id=".urlencode($row['fax_uuid'])."'>".$text['label-log']."</a>&nbsp;&nbsp;";
} }
if (file_exists(__DIR__ . '/fax_active.php') && permission_exists('fax_active_view') && isset($_SESSION['fax']['send_mode']['text']) && $_SESSION['fax']['send_mode']['text'] == 'queue') { if (file_exists(__DIR__ . '/fax_active.php') && permission_exists('fax_active_view') && !empty($settings->get('fax', 'send_mode')) && $settings->get('fax', 'send_mode') == 'queue') {
echo " <a href='fax_active.php?id=".urlencode($row['fax_uuid'])."'>".$text['label-active']."</a>&nbsp;&nbsp;"; echo " <a href='fax_active.php?id=".urlencode($row['fax_uuid'])."'>".$text['label-active']."</a>&nbsp;&nbsp;";
} }
if (permission_exists('fax_queue_view')) { if (permission_exists('fax_queue_view')) {

View File

@@ -424,7 +424,7 @@
echo " <br>"; echo " <br>";
if ($action == "update") { if ($action == "update") {
echo " <input type='hidden' name='fax_uuid' value='".escape($fax_uuid)."'>\n"; echo " <input type='hidden' name='fax_uuid' value='".escape($fax_uuid)."'>\n";
echo " <input type='hidden' name='dialplan_uuid' value='".escape($dialplan_uuid)."'>\n"; echo " <input type='hidden' name='dialplan_uuid' value='".escape($dialplan_uuid ?? '')."'>\n";
} }
echo " <input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n"; echo " <input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo " </td>\n"; echo " </td>\n";

View File

@@ -47,7 +47,7 @@
} }
//set the fax directory //set the fax directory
$fax_dir = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name']; $fax_dir = $settings->get('switch', 'storage').'/fax/'.$_SESSION['domain_name'];
//get the fax extension //get the fax extension
if (!empty($fax_extension) && is_numeric($fax_extension)) { if (!empty($fax_extension) && is_numeric($fax_extension)) {
@@ -57,8 +57,8 @@
$dir_fax_temp = $fax_dir.'/'.$fax_extension.'/temp'; $dir_fax_temp = $fax_dir.'/'.$fax_extension.'/temp';
//make sure the directories exist //make sure the directories exist
if (!is_dir($_SESSION['switch']['storage']['dir'])) { if (!is_dir($settings->get('switch', 'storage'))) {
mkdir($_SESSION['switch']['storage']['dir'], 0770, true); mkdir($settings->get('switch', 'storage'), 0770, true);
} }
if (!is_dir($fax_dir.'/'.$fax_extension)) { if (!is_dir($fax_dir.'/'.$fax_extension)) {
mkdir($fax_dir.'/'.$fax_extension, 0770, true); mkdir($fax_dir.'/'.$fax_extension, 0770, true);
@@ -549,7 +549,7 @@
echo " ".$text['label-extension']."\n"; echo " ".$text['label-extension']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_extension' maxlength='15' value=\"".escape($fax_extension ?? '')."\" required='required' placeholder=\"".($_SESSION['fax']['extension_range']['text'] ?? '')."\">\n"; echo " <input class='formfld' type='text' name='fax_extension' maxlength='15' value=\"".escape($fax_extension ?? '')."\" required='required' placeholder=\"".($settings->get('fax', 'extension_range') ?? '')."\">\n";
echo "<br />\n"; echo "<br />\n";
echo "".$text['description-extension']."\n"; echo "".$text['description-extension']."\n";
echo "</td>\n"; echo "</td>\n";

View File

@@ -123,8 +123,8 @@
} }
//set the fax directory //set the fax directory
if (!empty($_SESSION['switch']['storage']['dir'])) { if (!empty($settings->get('switch', 'storage'))) {
$fax_dir = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name']; $fax_dir = $settings->get('switch', 'storage').'/fax/'.$_SESSION['domain_name'];
} }
//download the fax //download the fax
@@ -204,8 +204,8 @@
$dir_fax_temp = $fax_dir.'/'.$fax_extension.'/temp'; $dir_fax_temp = $fax_dir.'/'.$fax_extension.'/temp';
//make sure the directories exist //make sure the directories exist
if (!empty($_SESSION['switch']['storage']['dir']) && !is_dir($_SESSION['switch']['storage']['dir'])) { if (!empty($settings->get('switch', 'storage')) && !is_dir($settings->get('switch', 'storage'))) {
mkdir($_SESSION['switch']['storage']['dir'], 0770, false); mkdir($settings->get('switch', 'storage'), 0770, false);
} }
if (!is_dir($fax_dir.'/'.$fax_extension)) { if (!is_dir($fax_dir.'/'.$fax_extension)) {
mkdir($fax_dir.'/'.$fax_extension, 0770, false); mkdir($fax_dir.'/'.$fax_extension, 0770, false);
@@ -250,11 +250,11 @@
$parameters['time_zone'] = $time_zone; $parameters['time_zone'] = $time_zone;
//set the time format options: 12h, 24h //set the time format options: 12h, 24h
if (isset($_SESSION['domain']['time_format']['text'])) { if (!empty($settings->get('domain', 'time_format'))) {
if ($_SESSION['domain']['time_format']['text'] == '12h') { if ($settings->get('domain', 'time_format') == '12h') {
$time_format = 'HH12:MI:SS am'; $time_format = 'HH12:MI:SS am';
} }
elseif ($_SESSION['domain']['time_format']['text'] == '24h') { elseif ($settings->get('domain', 'time_format') == '24h') {
$time_format = 'HH24:MI:SS'; $time_format = 'HH24:MI:SS';
} }
} }

View File

@@ -152,7 +152,7 @@
if (imap_delete($connection, $email_id, FT_UID)) { if (imap_delete($connection, $email_id, FT_UID)) {
if (imap_expunge($connection)) { if (imap_expunge($connection)) {
//clean up local inbox copy //clean up local inbox copy
$fax_dir = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name']; $fax_dir = $settings->get('switch', 'storage').'/fax/'.$_SESSION['domain_name'];
@unlink($fax_dir.'/'.$fax_extension.'/inbox/'.$attachment['name']); @unlink($fax_dir.'/'.$fax_extension.'/inbox/'.$attachment['name']);
//redirect user //redirect user
message::add($text['message-delete']); message::add($text['message-delete']);

View File

@@ -193,7 +193,7 @@
echo " <input type='hidden' name='fax_logs[$x][uuid]' value='".escape($row['fax_log_uuid'])."' />\n"; echo " <input type='hidden' name='fax_logs[$x][uuid]' value='".escape($row['fax_log_uuid'])."' />\n";
echo " </td>\n"; echo " </td>\n";
} }
echo " <td><a href='".$list_row_url."'>".(!empty($_SESSION['domain']['time_format']['text']) && $_SESSION['domain']['time_format']['text'] == '12h' ? date("j M Y g:i:sa", $row['fax_epoch']) : date("j M Y H:i:s", $row['fax_epoch']))."</a>&nbsp;</td>\n"; echo " <td><a href='".$list_row_url."'>".(!empty($settings->get('domain', 'time_format')) && $settings->get('domain', 'time_format') == '12h' ? date("j M Y g:i:sa", $row['fax_epoch']) : date("j M Y H:i:s", $row['fax_epoch']))."</a>&nbsp;</td>\n";
echo " <td>".$row['fax_success']."&nbsp;</td>\n"; echo " <td>".$row['fax_success']."&nbsp;</td>\n";
echo " <td>".$row['fax_result_code']."&nbsp;</td>\n"; echo " <td>".$row['fax_result_code']."&nbsp;</td>\n";
echo " <td>".$row['fax_result_text']."&nbsp;</td>\n"; echo " <td>".$row['fax_result_text']."&nbsp;</td>\n";

View File

@@ -33,10 +33,15 @@
const app_name = 'fax'; const app_name = 'fax';
const app_uuid = '24108154-4ac3-1db6-1551-4731703a4440'; const app_uuid = '24108154-4ac3-1db6-1551-4731703a4440';
/**
* 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;
/** /**
* define the variables * define the variables
*/ */
public $domain_uuid;
public $fax_uuid; public $fax_uuid;
public $dialplan_uuid; public $dialplan_uuid;
public $fax_name; public $fax_name;
@@ -49,10 +54,33 @@
public $order; public $order;
public $download; public $download;
/**
* 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 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 * declare private variables
*/ */
private $database;
private $permission_prefix; private $permission_prefix;
private $list_page; private $list_page;
private $table; private $table;
@@ -64,13 +92,15 @@
/** /**
* Called when the object is created * Called when the object is created
*/ */
public function __construct() { public function __construct(array $setting_array = []) {
//set domain and user UUIDs
//connect to the database $this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? '';
if (empty($this->database)) { $this->domain_name = $setting_array['domain_name'] ?? $_SESSION['domain_name'] ?? '';
$this->database = database::new(); $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]);
} }
/** /**
@@ -131,15 +161,15 @@
$fax_name = ($this->fax_name != '') ? $this->fax_name : format_phone($this->destination_number); $fax_name = ($this->fax_name != '') ? $this->fax_name : format_phone($this->destination_number);
//set the last fax //set the last fax
if (!empty($_SESSION['fax']['last_fax']['text'])) { if (!empty($this->settings->get('fax', 'last_fax'))) {
$last_fax = "last_fax=".xml::sanitize($_SESSION['fax']['last_fax']['text']); $last_fax = "last_fax=".xml::sanitize($this->settings->get('fax', 'last_fax'));
} }
else { else {
$last_fax = "last_fax=\${caller_id_number}-\${strftime(%Y-%m-%d-%H-%M-%S)}"; $last_fax = "last_fax=\${caller_id_number}-\${strftime(%Y-%m-%d-%H-%M-%S)}";
} }
//set the rx_fax //set the rx_fax
$rxfax_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name'].'/'.xml::sanitize($this->fax_extension).'/inbox/'.xml::sanitize($this->forward_prefix).'${last_fax}.tif'; $rxfax_data = $this->settings->get('switch', 'storage').'/fax/'.$this->domain_name.'/'.xml::sanitize($this->fax_extension).'/inbox/'.xml::sanitize($this->forward_prefix).'${last_fax}.tif';
//build the xml dialplan //build the xml dialplan
$dialplan_xml = "<extension name=\"".xml::sanitize($fax_name)."\" continue=\"false\" uuid=\"".xml::sanitize($this->dialplan_uuid)."\">\n"; $dialplan_xml = "<extension name=\"".xml::sanitize($fax_name)."\" continue=\"false\" uuid=\"".xml::sanitize($this->dialplan_uuid)."\">\n";
@@ -168,7 +198,7 @@
$dialplan["dialplan_uuid"] = $this->dialplan_uuid; $dialplan["dialplan_uuid"] = $this->dialplan_uuid;
$dialplan["dialplan_name"] = ($this->fax_name != '') ? $this->fax_name : format_phone($this->destination_number); $dialplan["dialplan_name"] = ($this->fax_name != '') ? $this->fax_name : format_phone($this->destination_number);
$dialplan["dialplan_number"] = $this->fax_extension; $dialplan["dialplan_number"] = $this->fax_extension;
$dialplan["dialplan_context"] = $_SESSION['domain_name']; $dialplan["dialplan_context"] = $this->domain_name;
$dialplan["dialplan_continue"] = false; $dialplan["dialplan_continue"] = false;
$dialplan["dialplan_xml"] = $dialplan_xml; $dialplan["dialplan_xml"] = $dialplan_xml;
$dialplan["dialplan_order"] = "40"; $dialplan["dialplan_order"] = "40";
@@ -200,7 +230,7 @@
//clear the cache //clear the cache
$cache = new cache; $cache = new cache;
$cache->delete("dialplan:".$_SESSION['domain_name']); $cache->delete("dialplan:".$this->domain_name);
//return the dialplan_uuid //return the dialplan_uuid
return $dialplan_response ?? null; return $dialplan_response ?? null;
@@ -247,7 +277,7 @@
$sql = "select ".$this->uuid_prefix."uuid as uuid, dialplan_uuid from v_".$this->table." "; $sql = "select ".$this->uuid_prefix."uuid as uuid, dialplan_uuid from v_".$this->table." ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -262,7 +292,7 @@
$sql = "select fax_file_uuid as uuid, fax_mode, fax_file_path, fax_file_type from v_fax_files "; $sql = "select fax_file_uuid as uuid, fax_mode, fax_file_path, fax_file_type from v_fax_files ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -304,17 +334,17 @@
if (!empty($faxes) && is_array($faxes) && @sizeof($faxes) != 0) { if (!empty($faxes) && is_array($faxes) && @sizeof($faxes) != 0) {
foreach ($faxes as $fax_uuid => $fax) { foreach ($faxes as $fax_uuid => $fax) {
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $fax_uuid; $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $fax_uuid;
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid;
$array['fax_users'][$x][$this->uuid_prefix.'uuid'] = $fax_uuid; $array['fax_users'][$x][$this->uuid_prefix.'uuid'] = $fax_uuid;
$array['fax_users'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['fax_users'][$x]['domain_uuid'] = $this->domain_uuid;
$array['fax_files'][$x][$this->uuid_prefix.'uuid'] = $fax_uuid; $array['fax_files'][$x][$this->uuid_prefix.'uuid'] = $fax_uuid;
$array['fax_files'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['fax_files'][$x]['domain_uuid'] = $this->domain_uuid;
$array['fax_logs'][$x][$this->uuid_prefix.'uuid'] = $fax_uuid; $array['fax_logs'][$x][$this->uuid_prefix.'uuid'] = $fax_uuid;
$array['fax_logs'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['fax_logs'][$x]['domain_uuid'] = $this->domain_uuid;
$array['dialplans'][$x]['dialplan_uuid'] = $fax['dialplan_uuid']; $array['dialplans'][$x]['dialplan_uuid'] = $fax['dialplan_uuid'];
$array['dialplans'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['domain_uuid'] = $this->domain_uuid;
$array['dialplan_details'][$x]['dialplan_uuid'] = $fax['dialplan_uuid']; $array['dialplan_details'][$x]['dialplan_uuid'] = $fax['dialplan_uuid'];
$array['dialplan_details'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplan_details'][$x]['domain_uuid'] = $this->domain_uuid;
$x++; $x++;
} }
} }
@@ -348,7 +378,7 @@
//clear the cache //clear the cache
$cache = new cache; $cache = new cache;
$cache->delete("dialplan:".$_SESSION["domain_name"]); $cache->delete("dialplan:".$this->domain_name);
//clear the destinations session array //clear the destinations session array
if (isset($_SESSION['destinations']['array'])) { if (isset($_SESSION['destinations']['array'])) {
@@ -400,7 +430,7 @@
$sql = "select ".$this->uuid_prefix."uuid as uuid, fax_mode, fax_file_path, fax_file_type from v_".$this->table." "; $sql = "select ".$this->uuid_prefix."uuid as uuid, fax_mode, fax_file_path, fax_file_type from v_".$this->table." ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -441,7 +471,7 @@
$x = 0; $x = 0;
foreach ($fax_files as $fax_file_uuid => $fax_file) { foreach ($fax_files as $fax_file_uuid => $fax_file) {
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $fax_file_uuid; $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $fax_file_uuid;
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid;
$x++; $x++;
} }
@@ -489,7 +519,7 @@
foreach ($records as $x => $record) { foreach ($records as $x => $record) {
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) { if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid;
} }
} }
@@ -550,7 +580,7 @@
$sql = "select * from v_".$this->table." "; $sql = "select * from v_".$this->table." ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
$y = 0; $y = 0;
@@ -574,7 +604,7 @@
$sql_2 .= "where e.user_uuid = u.user_uuid "; $sql_2 .= "where e.user_uuid = u.user_uuid ";
$sql_2 .= "and e.domain_uuid = :domain_uuid "; $sql_2 .= "and e.domain_uuid = :domain_uuid ";
$sql_2 .= "and e.fax_uuid = :fax_uuid "; $sql_2 .= "and e.fax_uuid = :fax_uuid ";
$parameters_2['domain_uuid'] = $_SESSION['domain_uuid']; $parameters_2['domain_uuid'] = $this->domain_uuid;
$parameters_2['fax_uuid'] = $row['fax_uuid']; $parameters_2['fax_uuid'] = $row['fax_uuid'];
$rows_2 = $this->database->select($sql_2, $parameters_2, 'all'); $rows_2 = $this->database->select($sql_2, $parameters_2, 'all');
if (is_array($rows_2) && @sizeof($rows_2) != 0) { if (is_array($rows_2) && @sizeof($rows_2) != 0) {
@@ -641,7 +671,7 @@
//clear the cache //clear the cache
$cache = new cache; $cache = new cache;
$cache->delete("dialplan:".$_SESSION["domain_name"]); $cache->delete("dialplan:".$this->domain_name);
//set message //set message
message::add($text['message-copy']); message::add($text['message-copy']);
@@ -689,7 +719,7 @@
//toggle read state //toggle read state
$array['fax_files'][$x]['fax_file_uuid'] = $record['uuid']; $array['fax_files'][$x]['fax_file_uuid'] = $record['uuid'];
$array['fax_files'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['fax_files'][$x]['domain_uuid'] = $this->domain_uuid;
$array['fax_files'][$x]['read_date'] = empty($read_date) ? 'now()' : null; $array['fax_files'][$x]['read_date'] = empty($read_date) ? 'now()' : null;
$fax_files_toggled++; $fax_files_toggled++;
} }

View File

@@ -35,10 +35,21 @@
const app_name = 'fax_queue'; const app_name = 'fax_queue';
const app_uuid = '3656287f-4b22-4cf1-91f6-00386bf488f4'; const app_uuid = '3656287f-4b22-4cf1-91f6-00386bf488f4';
/**
* Set in the constructor. Must be a database object and cannot be null.
* @var database Database Object
*/
private $database;
/**
* 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 * declare private variables
*/ */
private $database;
private $name; private $name;
private $table; private $table;
private $toggle_field; private $toggle_field;
@@ -48,18 +59,19 @@
/** /**
* called when the object is created * 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 the variables //assign the variables
$this->name = 'fax_queue'; $this->name = 'fax_queue';
$this->table = 'fax_queue'; $this->table = 'fax_queue';
$this->toggle_field = ''; $this->toggle_field = '';
$this->toggle_values = ['true','false']; $this->toggle_values = ['true','false'];
$this->location = 'fax_queue.php'; $this->location = 'fax_queue.php';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
} }
/** /**
@@ -88,7 +100,7 @@
//add to the array //add to the array
if ($record['checked'] == 'true' && is_uuid($record['fax_queue_uuid'])) { if ($record['checked'] == 'true' && is_uuid($record['fax_queue_uuid'])) {
$array[$this->table][$x]['fax_queue_uuid'] = $record['fax_queue_uuid']; $array[$this->table][$x]['fax_queue_uuid'] = $record['fax_queue_uuid'];
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid;
} }
//increment the id //increment the id
@@ -191,7 +203,7 @@
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $this->domain_uuid;
$rows = $this->database->select($sql, $parameters, 'all'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -260,7 +272,7 @@
$sql = "select * from v_".$this->table." "; $sql = "select * from v_".$this->table." ";
$sql .= "where fax_queue_uuid in (".implode(', ', $uuids).") "; $sql .= "where fax_queue_uuid in (".implode(', ', $uuids).") ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $this->domain_uuid;
$rows = $this->database->select($sql, $parameters, 'all'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
$x = 0; $x = 0;

View File

@@ -1127,4 +1127,31 @@ $text['label-member_enabled']['zh-cn'] = "已启用";
$text['label-member_enabled']['ja-jp'] = "有効"; $text['label-member_enabled']['ja-jp'] = "有効";
$text['label-member_enabled']['ko-kr'] = "활성화됨"; $text['label-member_enabled']['ko-kr'] = "활성화됨";
$text['description-agents']['en-us'] = "Select the agent, set the call timeout, wrap up time, and enabled.";
$text['description-agents']['en-gb'] = "Select the agent, set the call timeout, wrap up time, and enabled.";
$text['description-agents']['ar-eg'] = "حدد وكيل التحول، و 설정 الدخول، و الزمن المحدد، و التفعيل.";
$text['description-agents']['de-at'] = "Wählen Sie den Agenten, stellen Sie die Anruferwartungszeit, die Abschlusszeit und den Status ein.";
$text['description-agents']['de-ch'] = "Wählen Sie den Agenten, stellen Sie die Anruferwartungszeit, die Abschlusszeit und den Status ein.";
$text['description-agents']['de-de'] = "Wählen Sie den Agenten, stellen Sie die Anruferwartungszeit, die Abschlusszeit und den Status ein.";
$text['description-agents']['el-gr'] = "Επιλέξτε τον αρχικό, θετείτε το χρόνο αναμονής, το χρόνο ολοκλήρωσης και την ενεργοποίηση.";
$text['description-agents']['es-cl'] = "Seleccione el agente, establezca el tiempo de espera, el tiempo de cierre y el estado.";
$text['description-agents']['es-mx'] = "Seleccione el agente, establezca el tiempo de espera, el tiempo de cierre y el estado.";
$text['description-agents']['fr-ca'] = "Sélectionnez l'agent, définissez le délai d'attente, le temps de clôture et l'état.";
$text['description-agents']['fr-fr'] = "Sélectionnez l'agent, définissez le délai d'attente, le temps de clôture et l'état.";
$text['description-agents']['he-il'] = "בחר את המנהל,設置 הwartime, זמן סיום ופעולה.";
$text['description-agents']['it-it'] = "Seleziona l'agente, impostare il tempo di attesa, il tempo di chiusura e lo stato.";
$text['description-agents']['ka-ge'] = "დაირჩეთ აგენტს, დადგენით გამომავლენი დრო, დამთავრების დრო და აქტიურობა.";
$text['description-agents']['nl-nl'] = "Selecteer de agent, stel de wachtduur, afsluitduur en status in.";
$text['description-agents']['pl-pl'] = "Wybierz agenta, ustaw czas oczekiwania, czas zakończenia i status.";
$text['description-agents']['pt-br'] = "Selecione o agente, configure o tempo de espera, o tempo de encerramento e o status.";
$text['description-agents']['pt-pt'] = "Selecione o agente, configure o tempo de espera, o tempo de encerramento e o status.";
$text['description-agents']['ro-ro'] = "Selectați agentul, setați timpul de așteptare, timpul de închidere și starea.";
$text['description-agents']['ru-ru'] = "Выберите агента, установите время ожидания, время завершения и включите.";
$text['description-agents']['sv-se'] = "Välj agenten, ställ in väntetid, avslutningstid och status.";
$text['description-agents']['uk-ua'] = "Оберіть агента, встановіть час очікування, час закінчення та включіть.";
$text['description-agents']['tr-tr'] = "Ağcın seçin, bekletme süresini, sona erme süresini ve durumunu ayarlayın.";
$text['description-agents']['zh-cn'] = "选择代理,设置等待时间,结束时间,并启用。";
$text['description-agents']['ja-jp'] = "アーカイブを選択し、待ち時間、終了時間、有効化を設定します。";
$text['description-agents']['ko-kr'] = "대리자를 선택하고 대기 시간, 종료 시간, 활성화를 설정하세요.";
?> ?>

View File

@@ -577,7 +577,7 @@
echo " ".$text['label-strategy']."\n"; echo " ".$text['label-strategy']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='fifo_strategy' onchange=\"getElementById('destination_delayorder').innerHTML = (this.selectedIndex == 1 || this.selectedIndex == 3) ? '".$text['label-destination_order']."' : '".$text['label-destination_delay']."';\">\n"; echo " <select class='formfld' name='fifo_strategy' onchange=\"\">\n";
echo " <option value='longest_idle_agent' ".(($fifo_strategy == "'option-longest_idle_agent") ? "selected='selected'" : null).">".$text['option-longest_idle_agent']."</option>\n"; echo " <option value='longest_idle_agent' ".(($fifo_strategy == "'option-longest_idle_agent") ? "selected='selected'" : null).">".$text['option-longest_idle_agent']."</option>\n";
echo " <option value='simultaneous' ".(($fifo_strategy == "simultaneous") ? "selected='selected'" : null).">".$text['option-simultaneous']."</option>\n"; echo " <option value='simultaneous' ".(($fifo_strategy == "simultaneous") ? "selected='selected'" : null).">".$text['option-simultaneous']."</option>\n";
echo " </select>\n"; echo " </select>\n";
@@ -659,7 +659,7 @@
} }
echo " </table>\n"; echo " </table>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-member_enabled']."\n"; echo $text['description-agents']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";

View File

@@ -11,12 +11,21 @@
const app_name = 'fifo'; const app_name = 'fifo';
const app_uuid = '16589224-c876-aeb3-f59f-523a1c0801f7'; const app_uuid = '16589224-c876-aeb3-f59f-523a1c0801f7';
/**
* Set in the constructor. Must be a database object and cannot be null.
* @var database Database Object
*/
private $database;
/**
* 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 the variables * declare the variables
*/ */
private $app_name;
private $app_uuid;
private $database;
private $name; private $name;
private $table; private $table;
private $toggle_field; private $toggle_field;
@@ -27,7 +36,13 @@
/** /**
* called when the object is created * 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 the variables //assign the variables
$this->name = 'fifo'; $this->name = 'fifo';
$this->table = 'fifo'; $this->table = 'fifo';
@@ -36,11 +51,6 @@
$this->toggle_values = ['true','false']; $this->toggle_values = ['true','false'];
$this->description_field = 'fifo_description'; $this->description_field = 'fifo_description';
$this->location = 'fifo.php'; $this->location = 'fifo.php';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
} }
/** /**
@@ -87,7 +97,7 @@
$sql = "select ".$this->uuid_prefix."uuid as uuid, dialplan_uuid from v_".$this->table." "; $sql = "select ".$this->uuid_prefix."uuid as uuid, dialplan_uuid from v_".$this->table." ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; $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'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -102,11 +112,11 @@
foreach ($fifos as $fifo_uuid => $fifo) { foreach ($fifos as $fifo_uuid => $fifo) {
//add to the array //add to the array
$array[$this->table][$x][$this->name.'_uuid'] = $fifo_uuid; $array[$this->table][$x][$this->name.'_uuid'] = $fifo_uuid;
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array[$this->table][$x]['domain_uuid'] = $this->domain_uuid;
$array['fifo_members'][$x]['fifo_uuid'] = $fifo_uuid; $array['fifo_members'][$x]['fifo_uuid'] = $fifo_uuid;
$array['fifo_members'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['fifo_members'][$x]['domain_uuid'] = $this->domain_uuid;
$array['dialplans'][$x]['dialplan_uuid'] = $fifo['dialplan_uuid']; $array['dialplans'][$x]['dialplan_uuid'] = $fifo['dialplan_uuid'];
$array['dialplans'][$x]['domain_uuid'] = $_SESSION['domain_uuid']; $array['dialplans'][$x]['domain_uuid'] = $this->domain_uuid;
//increment the id //increment the id
$x++; $x++;
@@ -165,7 +175,7 @@
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $this->domain_uuid;
$rows = $this->database->select($sql, $parameters, 'all'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -234,7 +244,7 @@
$sql = "select * from v_".$this->table." "; $sql = "select * from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $this->domain_uuid;
$rows = $this->database->select($sql, $parameters, 'all'); $rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {

Some files were not shown because too many files have changed in this diff Show More