Define app_name and app_uuid as constants (#7534)

* Set a constant on each class for app_name and app_uuid
* Update the database class to use the app_uuid and app_name
* Update the classes to use the database::new()
* Remove the instances of 'new database'
This commit is contained in:
FusionPBX
2025-09-30 21:37:09 -06:00
committed by GitHub
parent 6485b18822
commit 2fe8b65988
69 changed files with 2571 additions and 2809 deletions

View File

@@ -5,11 +5,16 @@
*/
class access_controls {
/**
* declare constant variables
*/
const app_name = 'access_controls';
const app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -21,9 +26,12 @@
public function __construct() {
//assign private variables
$this->app_name = 'access_controls';
$this->app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
$this->list_page = 'access_controls.php';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
@@ -69,10 +77,7 @@
$p->add('access_control_node_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions
@@ -128,10 +133,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//clear the cache
@@ -189,8 +191,7 @@
//primary table
$sql = "select * from v_" . $this->table . " ";
$sql .= "where " . $this->uuid_prefix . "uuid in (" . implode(', ', $uuids) . ") ";
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$y = 0;
foreach ($rows as $x => $row) {
@@ -206,8 +207,7 @@
//nodes sub table
$sql_2 = "select * from v_access_control_nodes where access_control_uuid = :access_control_uuid";
$parameters_2['access_control_uuid'] = $row['access_control_uuid'];
$database = new database;
$rows_2 = $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) {
foreach ($rows_2 as $row_2) {
@@ -236,10 +236,7 @@
$p->add('access_control_node_add', 'temp');
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions

View File

@@ -30,17 +30,34 @@
class basic_operator_panel {
/**
* Define the variables
* declare constant variables
*/
const app_name = 'basic_operator_panel';
const app_uuid = 'dd3d173a-5d51-4231-ab22-b18c5b712bb2';
/**
* declare public variables
*/
public $domain_uuid;
/**
* declare private variables
*/
private $database;
/**
* Called when the object is created
*/
public function __construct() {
//assign public variables
if (!isset($this->domain_uuid)) {
$this->domain_uuid = $_SESSION['domain_uuid'];
}
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
@@ -71,8 +88,7 @@
$sql .= "order by ";
$sql .= "e.extension asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$extensions = $database->select($sql, $parameters);
$extensions = $this->database->select($sql, $parameters);
//store extension status by user uuid
if (isset($extensions)) {

View File

@@ -27,11 +27,16 @@
//define the bridges class
class bridges {
/**
* declare constant variables
*/
const app_name = 'bridges';
const app_uuid = 'a6a7c4c5-340a-43ce-bcbc-2ed9bab8659d';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -45,14 +50,18 @@
public function __construct() {
//assign private variables
$this->app_name = 'bridges';
$this->app_uuid = 'a6a7c4c5-340a-43ce-bcbc-2ed9bab8659d';
$this->permission_prefix = 'bridge_';
$this->list_page = 'bridges.php';
$this->table = 'bridges';
$this->uuid_prefix = 'bridge_';
$this->toggle_field = 'bridge_enabled';
$this->toggle_values = ['true','false'];
$this->permission_prefix = 'bridge_';
$this->list_page = 'bridges.php';
$this->table = 'bridges';
$this->uuid_prefix = 'bridge_';
$this->toggle_field = 'bridge_enabled';
$this->toggle_values = ['true','false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
@@ -89,10 +98,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//clear the destinations session array
@@ -140,8 +146,7 @@
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -162,10 +167,8 @@
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//clear the destinations session array
@@ -216,8 +219,7 @@
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $x => $row) {
@@ -237,10 +239,8 @@
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message

View File

@@ -5,18 +5,22 @@
*/
class call_block {
/**
* declare constant variables
*/
const app_name = 'call_block';
const app_uuid = '9ed63276-e085-4897-839c-4f2e36d92d6c';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
private $uuid_prefix;
private $toggle_field;
private $toggle_values;
private $database;
/**
* declare public variables
@@ -31,18 +35,18 @@
*/
public function __construct() {
//initialize the database
$this->database = new database;
//assign private variables
$this->app_name = 'call_block';
$this->app_uuid = '9ed63276-e085-4897-839c-4f2e36d92d6c';
$this->permission_prefix = 'call_block_';
$this->list_page = 'call_block.php';
$this->table = 'call_block';
$this->uuid_prefix = 'call_block_';
$this->toggle_field = 'call_block_enabled';
$this->toggle_values = ['true','false'];
$this->permission_prefix = 'call_block_';
$this->list_page = 'call_block.php';
$this->table = 'call_block';
$this->uuid_prefix = 'call_block_';
$this->toggle_field = 'call_block_enabled';
$this->toggle_values = ['true','false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
@@ -108,8 +112,6 @@
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->delete($array);
unset($array);
@@ -181,8 +183,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->save($array);
unset($array);
@@ -255,8 +256,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->save($array);
unset($array);
@@ -419,7 +419,7 @@
//ensure call block is enabled in the dialplan (build update array)
$sql = "select dialplan_uuid from v_dialplans ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and app_uuid = '".$this->app_uuid."' ";
$sql .= "and app_uuid = '".self::app_uuid."' ";
$sql .= "and dialplan_enabled <> true ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$rows = $this->database->select($sql, $parameters);
@@ -436,8 +436,7 @@
$p->add('dialplan_edit', 'temp');
//save the array
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->save($array);
$response = $this->database->message;
unset($array);

View File

@@ -30,11 +30,17 @@
*/
class call_broadcast {
/**
* declare constant variables
*/
const app_name = 'call_broadcast';
const app_uuid = 'efc11f6b-ed73-9955-4d4d-3a1bed75a056';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -46,12 +52,15 @@
public function __construct() {
//assign private variables
$this->app_name = 'call_broadcast';
$this->app_uuid = 'efc11f6b-ed73-9955-4d4d-3a1bed75a056';
$this->permission_prefix = 'call_broadcast_';
$this->list_page = 'call_broadcast.php';
$this->table = 'call_broadcasts';
$this->uuid_prefix = 'call_broadcast_';
$this->permission_prefix = 'call_broadcast_';
$this->list_page = 'call_broadcast.php';
$this->table = 'call_broadcasts';
$this->uuid_prefix = 'call_broadcast_';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
@@ -88,10 +97,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//set message
@@ -136,8 +142,7 @@
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $x => $row) {
@@ -157,10 +162,8 @@
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message

View File

@@ -29,8 +29,15 @@
*/
//define the call center class
class call_center {
/**
* define the variables
* declare constant variables
*/
const app_name = 'call_center';
const app_uuid = '95788e50-9500-079e-2807-fd530b0ea370';
/**
* define public variables
*/
public $domain_uuid;
public $call_center_queue_uuid;
@@ -43,8 +50,7 @@
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -54,9 +60,10 @@
* Called when the object is created
*/
public function __construct() {
//assign private variables
$this->app_name = 'call_center';
$this->app_uuid = '95788e50-9500-079e-2807-fd530b0ea370';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
@@ -80,10 +87,7 @@
$p->add('dialplan_detail_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = 'call_centers';
$database->app_uuid = '95788e50-9500-079e-2807-fd530b0ea370';
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions
@@ -220,11 +224,8 @@
$p->add("dialplan_detail_edit", 'temp');
//save the dialplan
$database = new database;
$database->app_name = 'call_centers';
$database->app_uuid = '95788e50-9500-079e-2807-fd530b0ea370';
$database->save($array);
$dialplan_response = $database->message;
$this->database->save($array);
$dialplan_response = $this->database->message;
$this->dialplan_uuid = $dialplan_response['uuid'];
unset($array);
@@ -243,10 +244,7 @@
$p->add('call_center_queue_edit', 'temp');
//execute update
$database = new database;
$database->app_name = 'call_centers';
$database->app_uuid = '95788e50-9500-079e-2807-fd530b0ea370';
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions
@@ -302,8 +300,7 @@
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in ('".implode("','", $uuids)."') ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$call_center_queues[$row['uuid']]['dialplan_uuid'] = $row['dialplan_uuid'];
@@ -352,10 +349,7 @@
$p->add('dialplan_detail_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions
@@ -447,10 +441,7 @@
$p->add('call_center_tier_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions
@@ -510,8 +501,7 @@
//primary table
$sql = "select * from v_".$this->table." ";
$sql .= "where ".$this->uuid_prefix."uuid in ('".implode("','", $uuids)."') ";
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$y = 0;
foreach ($rows as $x => $row) {
@@ -529,8 +519,7 @@
//call center tiers sub table
$sql_2 = "select * from v_call_center_tiers where call_center_queue_uuid = :call_center_queue_uuid";
$parameters_2['call_center_queue_uuid'] = $row['call_center_queue_uuid'];
$database = new database;
$rows_2 = $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) {
foreach ($rows_2 as $row_2) {
@@ -549,8 +538,7 @@
//call center queue dialplan record
$sql_3 = "select * from v_dialplans where dialplan_uuid = :dialplan_uuid";
$parameters_3['dialplan_uuid'] = $row['dialplan_uuid'];
$database = new database;
$dialplan = $database->select($sql_3, $parameters_3, 'row');
$dialplan = $this->database->select($sql_3, $parameters_3, 'row');
if (is_array($dialplan) && @sizeof($dialplan) != 0) {
//copy data
@@ -580,10 +568,7 @@
$p->add('dialplan_add', 'temp');
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions

View File

@@ -32,11 +32,17 @@
*/
public $toggle_field;
/**
* declare constant variables
*/
const app_name = 'call_flows';
const app_uuid = 'b1b70f85-6b42-429b-8c5a-60c8b02b7d14';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -49,13 +55,16 @@
public function __construct() {
//assign private variables
$this->app_name = 'call_flows';
$this->app_uuid = 'b1b70f85-6b42-429b-8c5a-60c8b02b7d14';
$this->permission_prefix = 'call_flow_';
$this->list_page = 'call_flows.php';
$this->table = 'call_flows';
$this->uuid_prefix = 'call_flow_';
$this->toggle_values = ['true','false'];
$this->permission_prefix = 'call_flow_';
$this->list_page = 'call_flows.php';
$this->table = 'call_flows';
$this->uuid_prefix = 'call_flow_';
$this->toggle_values = ['true','false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
@@ -93,8 +102,7 @@
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$call_flows[$row['uuid']]['dialplan_uuid'] = $row['dialplan_uuid'];
@@ -125,10 +133,7 @@
$p->add('dialplan_detail_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions
@@ -193,8 +198,7 @@
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (!empty($rows)) {
foreach ($rows as $row) {
$call_flows[$row['uuid']]['state'] = $row['toggle'];
@@ -226,10 +230,8 @@
$p->add('dialplan_edit', 'temp');
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions
@@ -326,8 +328,7 @@
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $x => $row) {
$new_call_flow_uuid = uuid();
@@ -344,8 +345,7 @@
//call flow dialplan record
$sql_2 = "select * from v_dialplans where dialplan_uuid = :dialplan_uuid";
$parameters_2['dialplan_uuid'] = $row['dialplan_uuid'];
$database = new database;
$dialplan = $database->select($sql_2, $parameters_2, 'row');
$dialplan = $this->database->select($sql_2, $parameters_2, 'row');
if (is_array($dialplan) && @sizeof($dialplan) != 0) {
//copy data
@@ -377,10 +377,8 @@
$p->add('dialplan_add', 'temp');
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions

View File

@@ -31,6 +31,12 @@
//define the call_forward class
class call_forward {
/**
* declare constant variables
*/
const app_name = 'call_forward';
const app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d';
/**
* declare public variables
*/
@@ -47,8 +53,8 @@
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $extension;
private $number_alias;
private $toll_allow;
@@ -57,18 +63,17 @@
* called when the object is created
*/
public function __construct() {
//assign private variables
$this->app_name = 'call_forward';
$this->app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d';
$this->toggle_field = 'forward_all_enabled';
$this->toggle_values = ['true', 'false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
public function set() {
//create the database connection
$database = new database;
//determine whether to update the dial string
$sql = "select * from v_extensions ";
@@ -76,7 +81,7 @@
$sql .= "and extension_uuid = :extension_uuid ";
$parameters['domain_uuid'] = $this->domain_uuid;
$parameters['extension_uuid'] = $this->extension_uuid;
$row = $database->select($sql, $parameters, 'row');
$row = $this->database->select($sql, $parameters, 'row');
if (is_array($row) && @sizeof($row) != 0) {
$this->extension = $row["extension"];
$this->number_alias = $row["number_alias"];
@@ -101,9 +106,7 @@
$p->add('extension_add', 'temp');
//execute update
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions
@@ -137,9 +140,6 @@
//check we have permission for this action
if (permission_exists('call_forward')) {
//create the database connection
$database = new database;
//add multi-lingual support
$language = new text;
$text = $language->get();
@@ -167,7 +167,7 @@
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and extension_uuid in (" . implode(', ', $uuids) . ") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$extensions[$row['uuid']]['extension'] = $row['extension'];
@@ -225,9 +225,7 @@
$p->add('extension_edit', 'temp');
//save the array
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions

View File

@@ -26,6 +26,16 @@
//define the dnd class
class do_not_disturb {
/**
* declare constant variables
*/
const app_name = 'call_forward';
const app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d';
/**
* declare public variables
*/
public $debug;
public $domain_uuid;
public $domain_name;
@@ -33,6 +43,24 @@
public $extension;
public $enabled;
/**
* declare private variables
*/
private $database;
/**
* called when the object is created
*/
public function __construct() {
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
//update the user_status
public function user_status() {
//update the status
@@ -54,8 +82,7 @@
$parameters['user_status'] = "Do Not Disturb";
$parameters['domain_uuid'] = $this->domain_uuid;
$parameters['username'] = $_SESSION['username'];
$database = new database;
$database->execute($sql);
$this->database->execute($sql);
}
}
@@ -73,8 +100,7 @@
$parameters['extension'] = $this->extension;
}
$parameters['domain_uuid'] = $this->domain_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
$row = $this->database->select($sql, $parameters, 'row');
if (is_array($row) && @sizeof($row) != 0) {
if (is_uuid($this->extension_uuid)) {
$this->extension_uuid = $row["extension_uuid"];
@@ -99,10 +125,7 @@
$p->add('extension_edit', 'temp');
//execute update
$database = new database;
$database->app_name = 'calls';
$database->app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d';
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions
@@ -120,8 +143,7 @@
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $permission;
private $list_page;
private $table;
@@ -135,8 +157,6 @@
public function toggle($records) {
//assign private variables
$this->app_name = 'calls';
$this->app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d';
$this->permission = 'do_not_disturb';
$this->list_page = 'calls.php';
$this->table = 'extensions';
@@ -178,8 +198,7 @@
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$extensions[$row['uuid']]['extension'] = $row['extension'];
@@ -230,10 +249,8 @@
$p->add('extension_edit', 'temp');
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions

View File

@@ -30,8 +30,17 @@
//define the follow me class
class follow_me {
/**
* declare constant variables
*/
const app_name = 'call_forward';
const app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d';
/**
* declare public variables
*/
public $domain_uuid;
private $domain_name;
public $db_type;
public $follow_me_uuid;
public $cid_name_prefix;
@@ -41,9 +50,6 @@
public $follow_me_ignore_busy;
public $outbound_caller_id_name;
public $outbound_caller_id_number;
private $extension;
private $number_alias;
private $toll_allow;
public $destination_data_1;
public $destination_type_1;
@@ -78,6 +84,26 @@
public $destination_timeout = 0;
public $destination_order = 1;
/**
* declare private variables
*/
private $database;
private $toll_allow;
private $domain_name;
private $extension;
private $number_alias;
/**
* called when the object is created
*/
public function __construct() {
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
public function add() {
//build follow me insert array
@@ -94,10 +120,7 @@
$p = permissions::new();
$p->add('follow_me_add', 'temp');
//execute insert
$database = new database;
$database->app_name = 'calls';
$database->app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d';
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions
$p->delete('follow_me_add', 'temp');
@@ -118,10 +141,7 @@
$p = permissions::new();
$p->add('follow_me_add', 'temp');
//execute update
$database = new database;
$database->app_name = 'calls';
$database->app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d';
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions
$p->delete('follow_me_add', 'temp');
@@ -138,10 +158,7 @@
$p = permissions::new();
$p->add('follow_me_destination_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = 'calls';
$database->app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d';
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions
$p->delete('follow_me_destination_delete', 'temp');
@@ -213,10 +230,7 @@
$p = permissions::new();
$p->add('follow_me_destination_add', 'temp');
//execute insert
$database = new database;
$database->app_name = 'calls';
$database->app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d';
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions
$p->delete('follow_me_destination_add', 'temp');
@@ -229,8 +243,7 @@
$parameters['follow_me_uuid'] = $this->follow_me_uuid;
$sql = "select extension_uuid from v_extensions ";
$sql .= "where follow_me_uuid = :follow_me_uuid ";
$database = new database;
$result = $database->select($sql, $parameters);
$result = $this->database->select($sql, $parameters);
$extension_uuid = $result[0]['extension_uuid'];
//grant temporary permissions
@@ -249,10 +262,7 @@
$array['extensions'][0]["follow_me_enabled"] = $this->follow_me_enabled;
//save the destination
$database = new database;
$database->app_name = 'follow_me';
$database->app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d';
$database->save($array);
$this->database->save($array);
//remove the temporary permission
$p->delete("follow_me_edit", 'temp');
@@ -260,12 +270,10 @@
} //function
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $permission;
private $list_page;
private $table;
@@ -279,8 +287,6 @@
public function toggle($records) {
//assign private variables
$this->app_name = 'calls';
$this->app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d';
$this->permission = 'follow_me';
$this->list_page = 'calls.php';
$this->table = 'extensions';
@@ -322,8 +328,7 @@
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$extensions[$row['uuid']]['extension'] = $row['extension'];
@@ -355,8 +360,7 @@
) {
$sql = "select count(*) from v_follow_me_destinations where follow_me_uuid = :follow_me_uuid";
$parameters['follow_me_uuid'] = $extension['follow_me_uuid'];
$database = new database;
$num_rows = $database->select($sql, $parameters, 'column');
$num_rows = $this->database->select($sql, $parameters, 'column');
$destinations_exist = $num_rows ? true : false;
unset($sql, $parameters, $num_rows);
}
@@ -394,10 +398,8 @@
$p->add('follow_me_edit', 'temp');
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions

View File

@@ -29,15 +29,19 @@
*/
class call_recordings {
/**
* declare constant variables
*/
const app_name = 'follow_me';
const app_uuid = 'b1b70f85-6b42-429b-8c5a-60c8b02b7d14';
/**
* declare the variables
*/
private $app_name;
private $app_uuid;
private $name;
private $table;
private $settings;
private $database;
private $name;
private $table;
private $description_field;
private $location;
public $recording_uuid;
@@ -48,18 +52,16 @@
*/
public function __construct() {
//assign the variables
$this->app_name = 'call_recordings';
$this->app_uuid = '56165644-598d-4ed8-be01-d960bcb8ffed';
$this->name = 'call_recording';
$this->table = 'call_recordings';
$this->description_field = 'call_recording_description';
$this->location = 'call_recordings.php';
$this->name = 'call_recording';
$this->table = 'call_recordings';
$this->description_field = 'call_recording_description';
$this->location = 'call_recordings.php';
//allow global
$this->database = database::new();
$this->database = database::new();
//initialize the settings object
$this->settings = new settings(["domain_uuid" => $_SESSION['domain_uuid'], "user_uuid" => $_SESSION['user_uuid']]);
$this->settings = new settings(["domain_uuid" => $_SESSION['domain_uuid'], "user_uuid" => $_SESSION['user_uuid']]);
}
/**

View File

@@ -28,6 +28,12 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
//define the conference centers class
class conference_centers {
/**
* declare constant variables
*/
const app_name = 'conference_centers';
const app_uuid = '8d083f5a-f726-42a8-9ffa-8d28f848f10e';
/**
* declare public variables
*/
@@ -40,30 +46,29 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
public $search;
public $count;
public $created_by;
public $toggle_field;
/**
* declare private variables
*/
private $fields;
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
private $uuid_prefix;
private $toggle_values;
private $fields;
/**
* Called when the object is created
*/
public function __construct() {
//assign private variables
$this->app_name = 'conference_centers';
$this->app_uuid = '8d083f5a-f726-42a8-9ffa-8d28f848f10e';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
@@ -96,8 +101,7 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
$parameters['created_by'] = $this->created_by;
}
$parameters['domain_uuid'] = $this->domain_uuid;
$database = new database;
return $database->select($sql, $parameters, 'column');
return $this->database->select($sql, $parameters, 'column');
}
/**
@@ -170,8 +174,7 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
$parameters['domain_uuid'] = $this->domain_uuid;
$parameters['rows_per_page'] = $this->rows_per_page;
$parameters['offset'] = $this->offset;
$database = new database;
$conference_rooms = $database->select($sql, $parameters, 'all');
$conference_rooms = $this->database->select($sql, $parameters, 'all');
if (!empty($conference_rooms)) {
$x = 0;
@@ -226,8 +229,7 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
//$sql .= "and domain_uuid = :domain_uuid ";
$parameters['conference_session_uuid'] = $conference_session_uuid;
//$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
$conference_sessions = $database->select($sql, $parameters, 'all');
$conference_sessions = $this->database->select($sql, $parameters, 'all');
if (is_array($conference_sessions)) {
foreach ($conference_sessions as $row) {
$recording = $row['recording'];
@@ -330,8 +332,7 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
$sql .= "and conference_center_uuid = :conference_center_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['conference_center_uuid'] = $record['uuid'];
$database = new database;
$dialplan_uuid = $database->select($sql, $parameters, 'column');
$dialplan_uuid = $this->database->select($sql, $parameters, 'column');
unset($sql, $parameters);
//create array
@@ -353,10 +354,7 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
$p->add('dialplan_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions
@@ -429,10 +427,7 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
$p->add('conference_room_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions
@@ -493,10 +488,7 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
$p->add('conference_user_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions
@@ -552,8 +544,7 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (!empty($rows)) {
foreach ($rows as $row) {
$conference_centers[$row['uuid']]['state'] = $row['toggle'];
@@ -581,10 +572,8 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
$p->add("dialplan_edit", "temp");
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions
@@ -658,8 +647,7 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (!empty($rows)) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -701,10 +689,8 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
if (!empty($array)) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
@@ -759,8 +745,7 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (!empty($rows)) {
foreach ($rows as $x => $row) {
@@ -780,10 +765,8 @@ Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
if (!empty($array)) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message

View File

@@ -29,11 +29,17 @@
*/
class conference_controls {
/**
* declare constant variables
*/
const app_name = 'conference_controls';
const app_uuid = 'e1ad84a2-79e1-450c-a5b1-7507a043e048';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $name;
private $table;
private $toggle_field;
@@ -50,9 +56,10 @@
* called when the object is created
*/
public function __construct() {
//assign the variables
$this->app_name = 'conference_controls';
$this->app_uuid = 'e1ad84a2-79e1-450c-a5b1-7507a043e048';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
@@ -102,10 +109,7 @@
$p->add('conference_control_detail_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions
@@ -160,10 +164,7 @@
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//set message
@@ -211,8 +212,7 @@
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters ?? null, 'all');
$rows = $this->database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -235,10 +235,8 @@
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
@@ -283,8 +281,7 @@
if (!empty($uuids) && is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters ?? null, 'all');
$rows = $this->database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -309,10 +306,8 @@
//save the changes
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
@@ -364,8 +359,7 @@
//primary table
$sql = "select * from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters ?? null, 'all');
$rows = $this->database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$y = 0;
foreach ($rows as $x => $row) {
@@ -381,8 +375,7 @@
//details sub table
$sql_2 = "select * from v_conference_control_details where conference_control_uuid = :conference_control_uuid";
$parameters_2['conference_control_uuid'] = $row['conference_control_uuid'];
$database = new database;
$rows_2 = $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) {
foreach ($rows_2 as $row_2) {
@@ -406,10 +399,8 @@
//save the changes and set the message
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message

View File

@@ -29,11 +29,16 @@
*/
class conference_profiles {
/**
* declare constant variables
*/
const app_name = 'conference_profiles';
const app_uuid = 'c33e2c2a-847f-44c1-8c0d-310df5d65ba9';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $name;
private $table;
private $toggle_field;
@@ -50,9 +55,10 @@
* called when the object is created
*/
public function __construct() {
//assign the variables
$this->app_name = 'conference_profiles';
$this->app_uuid = 'c33e2c2a-847f-44c1-8c0d-310df5d65ba9';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
@@ -102,9 +108,7 @@
$p->add('conference_profile_param_delete', 'temp');
//execute delete
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->$database->delete($array);
unset($array);
//revoke temporary permissions
@@ -156,9 +160,7 @@
//delete the checked rows
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//execute delete
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->$database->delete($array);
unset($array);
//set message
@@ -206,7 +208,7 @@
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$rows = $database->select($sql, $parameters ?? null, 'all');
$rows = $this->$database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -229,9 +231,7 @@
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->$database->save($array);
unset($array);
//set message
@@ -276,7 +276,7 @@
if (!empty($uuids) && is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$rows = $database->select($sql, $parameters ?? null, 'all');
$rows = $this->$database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -301,9 +301,7 @@
//save the changes
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//save the array
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->$database->save($array);
unset($array);
//set message
@@ -355,7 +353,7 @@
//primary table
$sql = "select * from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$rows = $database->select($sql, $parameters ?? null, 'all');
$rows = $this->$database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$y = 0;
foreach ($rows as $x => $row) {
@@ -371,7 +369,7 @@
//params sub table
$sql_2 = "select * from v_conference_profile_params where conference_profile_uuid = :conference_profile_uuid";
$parameters_2['conference_profile_uuid'] = $row['conference_profile_uuid'];
$rows_2 = $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) {
foreach ($rows_2 as $row_2) {
@@ -401,9 +399,7 @@
$p->add('conference_profile_param_add', 'temp');
//save the array
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->$database->save($array);
unset($array);
//revoke temporary permissions

View File

@@ -27,11 +27,17 @@
//define the conferences class
class conferences {
/**
* declare constant variables
*/
const app_name = 'conferences';
const app_uuid = 'b81412e8-7253-91f4-e48e-42fc2c9a38d9';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -43,18 +49,20 @@
* called when the object is created
*/
public function __construct() {
//assign private variables
$this->app_name = 'conferences';
$this->app_uuid = 'b81412e8-7253-91f4-e48e-42fc2c9a38d9';
$this->permission_prefix = 'conference_';
$this->list_page = 'conferences.php';
$this->table = 'conferences';
$this->uuid_prefix = 'conference_';
$this->toggle_field = 'conference_enabled';
$this->toggle_values = ['true','false'];
$this->permission_prefix = 'conference_';
$this->list_page = 'conferences.php';
$this->table = 'conferences';
$this->uuid_prefix = 'conference_';
$this->toggle_field = 'conference_enabled';
$this->toggle_values = ['true','false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
* delete records
*/
@@ -86,8 +94,7 @@
$sql .= "and conference_uuid = :conference_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['conference_uuid'] = $record['uuid'];
$database = new database;
$dialplan_uuid = $database->select($sql, $parameters, 'column');
$dialplan_uuid = $this->database->select($sql, $parameters, 'column');
unset($sql, $parameters);
//build array
@@ -113,10 +120,7 @@
$p->add('dialplan_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions
@@ -177,8 +181,7 @@
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$conferences[$row['uuid']]['state'] = $row['toggle'];
@@ -206,10 +209,8 @@
$p->add('dialplan_edit', 'temp');
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions
@@ -270,8 +271,7 @@
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$y = 0;
foreach ($rows as $x => $row) {
@@ -292,8 +292,7 @@
$sql_2 .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters_2['conference_uuid'] = $row['conference_uuid'];
$parameters_2['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$conference_users = $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) {
foreach ($conference_users as $conference_user) {
@@ -314,8 +313,7 @@
//conference dialplan record
$sql_3 = "select * from v_dialplans where dialplan_uuid = :dialplan_uuid";
$parameters_3['dialplan_uuid'] = $row['dialplan_uuid'];
$database = new database;
$dialplan = $database->select($sql_3, $parameters_3, 'row');
$dialplan = $this->database->select($sql_3, $parameters_3, 'row');
if (is_array($dialplan) && @sizeof($dialplan) != 0) {
//copy data
@@ -345,10 +343,8 @@
$p->add('dialplan_add', 'temp');
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions

View File

@@ -29,6 +29,12 @@
*/
class destinations {
/**
* declare constant variables
*/
const app_name = 'destinations';
const app_uuid = '5ec89622-b19c-3559-64f0-afde802ab139';
/**
* declare public variables
*/
@@ -57,30 +63,28 @@
public function __construct($setting_array = []) {
//open a database connection
if (empty($setting_array['database'])) {
$this->database = database::new();
} else {
$this->database = $setting_array['database'];
}
if (empty($setting_array['database'])) {
$this->database = database::new();
} 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'];
}
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
$this->app_name = 'destinations';
$this->app_uuid = '5ec89622-b19c-3559-64f0-afde802ab139';
$this->permission_prefix = 'destination_';
$this->list_page = 'destinations.php';
$this->table = 'destinations';
$this->uuid_prefix = 'destination_';
$this->permission_prefix = 'destination_';
$this->list_page = 'destinations.php';
$this->table = 'destinations';
$this->uuid_prefix = 'destination_';
}
/**
@@ -1080,8 +1084,6 @@
$p->add('dialplan_detail_delete', 'temp');
//execute delete
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->delete($array);
unset($array);

View File

@@ -26,7 +26,16 @@
//define the device class
class device {
public $db;
/**
* declare constant variables
*/
const app_name = 'devices';
const app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e';
/**
* declare public variables
*/
public $domain_uuid;
public $template_dir;
public $device_uuid;
@@ -36,8 +45,6 @@
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $permission_prefix;
private $list_page;
private $table;
@@ -68,9 +75,6 @@
$this->database = $setting_array['database'];
}
//assign private variables
$this->app_name = 'devices';
$this->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e';
}
@@ -528,8 +532,6 @@
$p->add('device_key_delete', 'temp');
//execute delete
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->delete($array);
unset($array);
@@ -590,8 +592,6 @@
//delete the checked rows
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//execute delete
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->delete($array);
unset($array);
}
@@ -636,8 +636,6 @@
//delete the checked rows
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//execute delete
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->delete($array);
unset($array);
}
@@ -682,8 +680,6 @@
//delete the checked rows
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//execute delete
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->delete($array);
unset($array);
}
@@ -737,8 +733,6 @@
$p->add('device_vendor_function_group_delete', 'temp');
//execute delete
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->delete($array);
unset($array);
@@ -798,8 +792,6 @@
$p->add('device_vendor_function_group_delete', 'temp');
//execute delete
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->delete($array);
unset($array);
@@ -860,8 +852,6 @@
$p->add('device_profile_setting_delete', 'temp');
//execute delete
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->delete($array);
unset($array);
@@ -912,8 +902,6 @@
//execute delete
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->delete($array);
unset($array);
}
@@ -957,8 +945,6 @@
//execute delete
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->delete($array);
unset($array);
}
@@ -1030,8 +1016,7 @@
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//save the array
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->save($array);
unset($array);
@@ -1108,8 +1093,7 @@
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//save the array
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->save($array);
unset($array);
@@ -1179,8 +1163,7 @@
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//save the array
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->save($array);
unset($array);
@@ -1252,8 +1235,7 @@
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//save the array
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->save($array);
unset($array);
@@ -1385,8 +1367,7 @@
$p->add('device_profile_setting_add', 'temp');
//save the array
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->save($array);
unset($array);

View File

@@ -27,7 +27,15 @@
//define the dialplan class
class dialplan {
//variables
/**
* declare constant variables
*/
const app_name = 'dialplans';
const app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
/**
* declare public variables
*/
public $domain_uuid;
public $dialplan_uuid;
public $dialplan_detail_uuid;
@@ -38,7 +46,6 @@
public $bridges;
public $variables;
//dialplans
public $dialplan_details;
public $dialplan_name;
public $dialplan_number;
@@ -50,7 +57,6 @@
public $dialplan_enabled;
public $dialplan_description;
//dialplan_details
public $dialplan_detail_tag;
public $dialplan_detail_order;
public $dialplan_detail_type;
@@ -59,21 +65,18 @@
public $dialplan_detail_inline;
public $dialplan_detail_group;
//xml
public $uuid;
public $context;
public $source;
public $destination;
public $is_empty;
public $array;
public $list_page;
/**
* declare public/private properties
*/
private $app_name;
public $app_uuid;
* declare private variables
*/
private $permission_prefix;
public $list_page;
private $table;
private $uuid_prefix;
private $toggle_field;
@@ -91,8 +94,6 @@
$this->dialplan_global = false;
//assign property defaults
$this->app_name = 'dialplans';
$this->app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db'; //dialplans
$this->permission_prefix = 'dialplan_';
$this->list_page = 'dialplans.php';
$this->table = 'dialplans';
@@ -108,75 +109,6 @@
}
}
public function dialplan_add() {
//build insert array
$array['dialplans'][0]['dialplan_uuid'] = $this->dialplan_uuid;
$array['dialplans'][0]['domain_uuid'] = !$this->dialplan_global ? $this->domain_uuid : null;
$array['dialplans'][0]['app_uuid'] = $this->app_uuid;
$array['dialplans'][0]['dialplan_name'] = $this->dialplan_name;
$array['dialplans'][0]['dialplan_number'] = $this->dialplan_number;
$array['dialplans'][0]['dialplan_destination'] = $this->dialplan_destination;
$array['dialplans'][0]['dialplan_continue'] = $this->dialplan_continue;
$array['dialplans'][0]['dialplan_order'] = $this->dialplan_order;
$array['dialplans'][0]['dialplan_context'] = $this->dialplan_context;
$array['dialplans'][0]['dialplan_enabled'] = $this->dialplan_enabled;
$array['dialplans'][0]['dialplan_description'] = $this->dialplan_description;
//grant temporary permissions
$p = permissions::new();
$p->add('dialplan_add', 'temp');
//execute insert
$this->database->app_name = 'dialplans';
$this->database->app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
$this->database->save($array);
unset($array);
//clear the destinations session array
if (isset($_SESSION['destinations']['array'])) {
unset($_SESSION['destinations']['array']);
}
//revoke temporary permissions
$p->delete('dialplan_add', 'temp');
}
public function dialplan_update() {
//build update array
$array['dialplans'][0]['dialplan_uuid'] = $this->dialplan_uuid;
$array['dialplans'][0]['dialplan_name'] = $this->dialplan_name;
if (!empty($this->dialplan_continue)) {
$array['dialplans'][0]['dialplan_continue'] = $this->dialplan_continue;
}
$array['dialplans'][0]['dialplan_order'] = $this->dialplan_order;
$array['dialplans'][0]['dialplan_context'] = $this->dialplan_context;
$array['dialplans'][0]['dialplan_enabled'] = $this->dialplan_enabled;
$array['dialplans'][0]['dialplan_description'] = $this->dialplan_description;
//grant temporary permissions
$p = permissions::new();
$p->add('dialplan_edit', 'temp');
//execute update
$this->database->app_name = 'dialplans';
$this->database->app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
$this->database->save($array);
unset($array);
//revoke temporary permissions
$p->delete('dialplan_edit', 'temp');
}
private function app_uuid_exists() {
$sql = "select count(*) from v_dialplans ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and app_uuid = :app_uuid ";
$parameters['domain_uuid'] = $this->domain_uuid;
$parameters['app_uuid'] = $this->app_uuid;
return $this->database->select($sql, $parameters ?? null, 'column') != 0 ? true : false;
unset($sql, $parameters);
}
public function dialplan_exists() {
$sql = "select count(*) from v_dialplans ";
@@ -459,8 +391,6 @@
//save the data
if (!empty($array)) {
$this->database->app_name = 'dialplans';
$this->database->app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
$this->database->save($array);
unset($array);
}
@@ -1068,8 +998,6 @@
$p->add('dialplan_edit', 'temp');
//execute update
$this->database->app_name = 'dialplans';
$this->database->app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
$this->database->save($array);
unset($array);
@@ -1127,27 +1055,6 @@
*/
public function delete($records) {
//determine app and permission prefix
if ($this->app_uuid == 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4') {
$this->app_name = 'dialplan_inbound';
$this->permission_prefix = 'inbound_route_';
}
else if ($this->app_uuid == '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3') {
$this->app_name = 'dialplan_outbound';
$this->permission_prefix = 'outbound_route_';
}
else if ($this->app_uuid == '16589224-c876-aeb3-f59f-523a1c0801f7') {
$this->app_name = 'fifo';
$this->permission_prefix = 'fifo_';
}
else if ($this->app_uuid == '4b821450-926b-175a-af93-a03c441818b1') {
$this->app_name = 'time_conditions';
$this->permission_prefix = 'time_condition_';
}
else {
//use default in constructor
}
if (permission_exists($this->permission_prefix.'delete')) {
//add multi-lingual support
@@ -1192,8 +1099,6 @@
$p->add('dialplan_detail_delete', 'temp');
//execute delete
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->delete($array);
//revoke temporary permissions
@@ -1226,30 +1131,10 @@
public function delete_details($records) {
//set private variables
$this->table = 'dialplan_details';
$this->uuid_prefix = 'dialplan_detail_';
//determine app and permission prefix
if ($this->app_uuid == 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4') {
$this->app_name = 'dialplan_inbound';
$this->permission_prefix = 'inbound_route_';
}
else if ($this->app_uuid == '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3') {
$this->app_name = 'dialplan_outbound';
$this->permission_prefix = 'outbound_route_';
}
else if ($this->app_uuid == '16589224-c876-aeb3-f59f-523a1c0801f7') {
$this->app_name = 'fifo';
$this->permission_prefix = 'fifo_';
}
else if ($this->app_uuid == '4b821450-926b-175a-af93-a03c441818b1') {
$this->app_name = 'time_conditions';
$this->permission_prefix = 'time_condition_';
}
else {
$this->permission_prefix = 'dialplan_detail_';
}
$this->table = 'dialplan_details';
$this->uuid_prefix = 'dialplan_detail_';
//check the delete permission
if (permission_exists($this->permission_prefix.'delete')) {
//add multi-lingual support
@@ -1293,8 +1178,6 @@
$p->add('dialplan_detail_delete', 'temp');
//execute delete
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->delete($array);
//revoke temporary permissions
@@ -1321,27 +1204,6 @@
*/
public function toggle($records) {
//determine app and permission prefix
if ($this->app_uuid == 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4') {
$this->app_name = 'dialplan_inbound';
$this->permission_prefix = 'inbound_route_';
}
else if ($this->app_uuid == '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3') {
$this->app_name = 'dialplan_outbound';
$this->permission_prefix = 'outbound_route_';
}
else if ($this->app_uuid == '16589224-c876-aeb3-f59f-523a1c0801f7') {
$this->app_name = 'fifo';
$this->permission_prefix = 'fifo_';
}
else if ($this->app_uuid == '4b821450-926b-175a-af93-a03c441818b1') {
$this->app_name = 'time_conditions';
$this->permission_prefix = 'time_condition_';
}
else {
//use default in constructor
}
if (permission_exists($this->permission_prefix.'edit')) {
//add multi-lingual support
@@ -1398,8 +1260,6 @@
$p->add('dialplan_edit', 'temp');
//save the array
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->save($array);
unset($array);
@@ -1435,26 +1295,6 @@
public function copy($records) {
//determine app and permission prefix
if ($this->app_uuid == 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4') {
$this->app_name = 'dialplan_inbound';
$this->permission_prefix = 'inbound_route_';
}
else if ($this->app_uuid == '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3') {
$this->app_name = 'dialplan_outbound';
$this->permission_prefix = 'outbound_route_';
}
else if ($this->app_uuid == '16589224-c876-aeb3-f59f-523a1c0801f7') {
$this->app_name = 'fifo';
$this->permission_prefix = 'fifo_';
}
else if ($this->app_uuid == '4b821450-926b-175a-af93-a03c441818b1') {
$this->app_name = 'time_conditions';
$this->permission_prefix = 'time_condition_';
}
else {
//use default in constructor
}
if (permission_exists($this->permission_prefix.'add')) {
//add multi-lingual support
@@ -1549,10 +1389,7 @@
$p->add('dialplan_detail_add', 'temp');
//save the array
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->save($array);
//view_array($this->database->message);
unset($array);
//revoke temporary permissions

View File

@@ -5,11 +5,16 @@
*/
class email_queue {
/**
* declare constant variables
*/
const app_name = 'email_queue';
const app_uuid = '5befdf60-a242-445f-91b3-2e9ee3e0ddf7';
/**
* declare the variables
*/
private $app_name;
private $app_uuid;
private $database;
private $name;
private $table;
private $toggle_field;
@@ -21,13 +26,16 @@
*/
public function __construct() {
//assign the variables
$this->app_name = 'email_queue';
$this->app_uuid = '5befdf60-a242-445f-91b3-2e9ee3e0ddf7';
$this->name = 'email_queue';
$this->table = 'email_queue';
$this->toggle_field = '';
$this->toggle_values = ['true','false'];
$this->location = 'email_queue.php';
$this->name = 'email_queue';
$this->table = 'email_queue';
$this->toggle_field = '';
$this->toggle_values = ['true','false'];
$this->location = 'email_queue.php';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
@@ -67,10 +75,7 @@
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//set message
@@ -118,10 +123,8 @@
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
@@ -163,8 +166,7 @@
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -187,10 +189,8 @@
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
@@ -235,8 +235,7 @@
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$x = 0;
foreach ($rows as $row) {
@@ -256,10 +255,8 @@
//save the changes and set the message
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message

View File

@@ -29,11 +29,16 @@
*/
class event_guard {
/**
* declare constant variables
*/
const app_name = 'event_guard';
const app_uuid = 'c5b86612-1514-40cb-8e2c-3f01a8f6f637';
/**
* declare the variables
*/
private $app_name;
private $app_uuid;
private $database;
private $name;
private $table;
private $toggle_field;
@@ -45,13 +50,16 @@
*/
public function __construct() {
//assign the variables
$this->app_name = 'event_guard';
$this->app_uuid = 'c5b86612-1514-40cb-8e2c-3f01a8f6f637';
$this->name = 'event_guard_log';
$this->table = 'event_guard_logs';
$this->toggle_field = '';
$this->toggle_values = ['block','pending'];
$this->location = 'event_guard_logs.php';
$this->name = 'event_guard_log';
$this->table = 'event_guard_logs';
$this->toggle_field = '';
$this->toggle_values = ['block','pending'];
$this->location = 'event_guard_logs.php';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
@@ -89,10 +97,7 @@
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//set message
@@ -139,10 +144,7 @@
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//initialize the settings object
@@ -192,8 +194,7 @@
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -216,10 +217,8 @@
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
@@ -262,8 +261,7 @@
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select * from v_".$this->table." ";
$sql .= "where event_guard_log_uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$x = 0;
foreach ($rows as $row) {
@@ -283,10 +281,8 @@
//save the changes and set the message
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message

View File

@@ -29,11 +29,16 @@
*/
class extension_settings {
/**
* declare constant variables
*/
const app_name = 'extension_settings';
const app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
/**
* declare the variables
*/
private $app_name;
private $app_uuid;
private $database;
private $name;
private $table;
private $toggle_field;
@@ -46,14 +51,17 @@
*/
public function __construct() {
//assign the variables
$this->app_name = 'extension_settings';
$this->app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
$this->name = 'extension_setting';
$this->table = 'extension_settings';
$this->toggle_field = 'extension_setting_enabled';
$this->toggle_values = ['true','false'];
$this->description_field = 'extension_setting_description';
$this->location = 'extension_settings.php';
$this->name = 'extension_setting';
$this->table = 'extension_settings';
$this->toggle_field = 'extension_setting_enabled';
$this->toggle_values = ['true','false'];
$this->description_field = 'extension_setting_description';
$this->location = 'extension_settings.php';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
@@ -92,18 +100,14 @@
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//clear the cache
$sql = "select extension, number_alias, user_context from v_extensions ";
$sql .= "where extension_uuid = :extension_uuid ";
$parameters['extension_uuid'] = $this->extension_uuid;
$database = new database;
$extension = $database->select($sql, $parameters, 'row');
$extension = $this->database->select($sql, $parameters, 'row');
$cache = new cache;
$cache->delete("directory:".$extension["extension"]."@".$extension["user_context"]);
$cache->delete("directory:".$extension["number_alias"]."@".$extension["user_context"]);
@@ -147,8 +151,7 @@
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$extension_uuid = $rows[0]['extension_uuid'];
foreach ($rows as $row) {
@@ -172,18 +175,15 @@
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//clear the cache
$sql = "select extension, number_alias, user_context from v_extensions ";
$sql .= "where extension_uuid = :extension_uuid ";
$parameters['extension_uuid'] = $extension_uuid;
$database = new database;
$extension = $database->select($sql, $parameters, 'row');
$extension = $this->database->select($sql, $parameters, 'row');
$cache = new cache;
$cache->delete("directory:".$extension["extension"]."@".$extension["user_context"]);
$cache->delete("directory:".$extension["number_alias"]."@".$extension["user_context"]);
@@ -230,8 +230,7 @@
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $x => $row) {
// var_dump($row); exit;
@@ -252,10 +251,8 @@
//save the changes and set the message
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message

View File

@@ -27,6 +27,12 @@
//define the directory class
class extension {
/**
* declare constant variables
*/
const app_name = 'extensions';
const app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3';
/**
* declare public variables
*/
@@ -72,13 +78,11 @@
public $enabled;
public $description;
public $delete_voicemail;
private $database;
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -91,20 +95,18 @@
*/
public function __construct() {
//connect to the database
if (!isset($database)) {
$this->database = new database;
}
//assign private variables
$this->app_name = 'extensions';
$this->app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3';
$this->permission_prefix = 'extension_';
$this->list_page = 'extensions.php';
$this->table = 'extensions';
$this->uuid_prefix = 'extension_';
$this->toggle_field = 'enabled';
$this->toggle_values = ['true','false'];
$this->permission_prefix = 'extension_';
$this->list_page = 'extensions.php';
$this->table = 'extensions';
$this->uuid_prefix = 'extension_';
$this->toggle_field = 'enabled';
$this->toggle_values = ['true','false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
@@ -652,8 +654,6 @@
$p->add('extension_setting_delete', 'temp');
//execute delete
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->delete($array);
unset($array);
@@ -754,8 +754,7 @@
$p->add('extension_edit', 'temp');
//save the array
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->save($array);
unset($array);

View File

@@ -27,6 +27,12 @@
//define the fax class
class fax {
/**
* declare constant variables
*/
const app_name = 'fax';
const app_uuid = '24108154-4ac3-1db6-1551-4731703a4440';
/**
* define the variables
*/
@@ -46,8 +52,7 @@
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -61,9 +66,10 @@
*/
public function __construct() {
//assign private variables
$this->app_name = 'fax';
$this->app_uuid = '24108154-4ac3-1db6-1551-4731703a4440';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
@@ -112,10 +118,9 @@
$p->add('dialplan_detail_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = 'fax';
$database->app_uuid = '24108154-4ac3-1db6-1551-4731703a4440';
$database->delete($array);
$this->database->app_name = 'fax';
$this->database->app_uuid = '24108154-4ac3-1db6-1551-4731703a4440';
$this->database->delete($array);
unset($array);
//revoke temporary permissions
@@ -182,11 +187,10 @@
$p->add("dialplan_detail_edit", 'temp');
//save the dialplan
$database = new database;
$database->app_name = 'fax';
$database->app_uuid = '24108154-4ac3-1db6-1551-4731703a4440';
$database->save($array);
//$message = $database->message;
$this->database->app_name = 'fax';
$this->database->app_uuid = '24108154-4ac3-1db6-1551-4731703a4440';
$this->database->save($array);
//$message = $this->database->message;
//remove the temporary permission
$p->delete("dialplan_add", 'temp');
@@ -244,8 +248,7 @@
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$faxes[$row['uuid']]['dialplan_uuid'] = $row['dialplan_uuid'];
@@ -260,8 +263,7 @@
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
if ($row['fax_mode'] == 'rx') { $fax_files[$row['uuid']]['folder'] = 'inbox'; }
@@ -330,10 +332,7 @@
$p->add('dialplan_detail_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions
@@ -402,8 +401,7 @@
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
if ($row['fax_mode'] == 'rx') { $fax_files[$row['uuid']]['folder'] = 'inbox'; }
@@ -451,10 +449,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//set message
@@ -502,10 +497,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//set message
@@ -559,8 +551,7 @@
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$y = 0;
foreach ($rows as $x => $row) {
@@ -585,8 +576,7 @@
$sql_2 .= "and e.fax_uuid = :fax_uuid ";
$parameters_2['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters_2['fax_uuid'] = $row['fax_uuid'];
$database = new database;
$rows_2 = $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) {
foreach ($rows_2 as $row_2) {
@@ -607,8 +597,7 @@
//fax dialplan record
$sql_3 = "select * from v_dialplans where dialplan_uuid = :dialplan_uuid";
$parameters_3['dialplan_uuid'] = $row['dialplan_uuid'];
$database = new database;
$dialplan = $database->select($sql_3, $parameters_3, 'row');
$dialplan = $this->database->select($sql_3, $parameters_3, 'row');
if (is_array($dialplan) && @sizeof($dialplan) != 0) {
//copy data
@@ -639,10 +628,8 @@
$p->add('dialplan_add', 'temp');
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions
@@ -697,8 +684,7 @@
//get current read state
$sql = "select read_date from v_fax_files where fax_file_uuid = :fax_file_uuid";
$parameters['fax_file_uuid'] = $record['uuid'];
$database = new database;
$read_date = $database->select($sql, $parameters, 'column');
$read_date = $this->database->select($sql, $parameters, 'column');
unset($sql, $parameters);
//toggle read state
@@ -714,10 +700,8 @@
if (!empty($array) && is_array($array)) {
//execute save
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array, false);
$this->database->save($array, false);
unset($array);
//return toggled count

View File

@@ -30,10 +30,15 @@
class fax_queue {
/**
* declare the variables
* declare constant variables
*/
const app_name = 'fax_queue';
const app_uuid = '3656287f-4b22-4cf1-91f6-00386bf488f4';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $name;
private $table;
private $toggle_field;
@@ -45,13 +50,16 @@
*/
public function __construct() {
//assign the variables
$this->app_name = 'fax_queue';
$this->app_uuid = '3656287f-4b22-4cf1-91f6-00386bf488f4';
$this->name = 'fax_queue';
$this->table = 'fax_queue';
$this->toggle_field = '';
$this->toggle_values = ['true','false'];
$this->location = 'fax_queue.php';
$this->name = 'fax_queue';
$this->table = 'fax_queue';
$this->toggle_field = '';
$this->toggle_values = ['true','false'];
$this->location = 'fax_queue.php';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
@@ -90,10 +98,7 @@
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//set message
@@ -143,10 +148,8 @@
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
@@ -189,8 +192,7 @@
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -213,10 +215,8 @@
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
@@ -261,8 +261,7 @@
$sql .= "where fax_queue_uuid in (".implode(', ', $uuids).") ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$x = 0;
foreach ($rows as $row) {
@@ -282,10 +281,8 @@
//save the changes and set the message
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
@@ -302,21 +299,21 @@
* @return void
*/
public static function database_maintenance(settings $settings): void {
$database = $settings->database();
$domains = maintenance_service::get_domains($database);
$this->database = $settings->database();
$domains = maintenance_service::get_domains($this->database);
foreach ($domains as $domain_uuid => $domain_name) {
$domain_settings = new settings(['database'=>$database, 'domain_uuid'=>$domain_uuid]);
$domain_settings = new settings(['database'=>$this->database, 'domain_uuid'=>$domain_uuid]);
$retention_days = $domain_settings->get('fax_queue', 'database_retention_days', '');
//delete from v_fax_queue where fax_status = 'sent' and fax_date < NOW() - INTERVAL '$days_keep_fax_queue days'
if (!empty($retention_days) && is_numeric($retention_days)) {
$sql = "delete from v_fax_queue where fax_status = 'sent' and fax_date < NOW() - INTERVAL '$retention_days days'";
$sql .= " and domain_uuid = '$domain_uuid'";
$database->execute($sql);
$code = $database->message['code'] ?? 0;
$this->database->execute($sql);
$code = $this->database->message['code'] ?? 0;
if ($code == 200) {
maintenance_service::log_write(self::class, "Successfully removed entries older than $retention_days", $domain_uuid);
} else {
$message = $database->message['message'] ?? "An unknown error has occurred";
$message = $this->database->message['message'] ?? "An unknown error has occurred";
maintenance_service::log_write(self::class, "Unable to remove old database records. Error message: $message ($code)", $domain_uuid, maintenance_service::LOG_ERROR);
}
}

View File

@@ -5,11 +5,18 @@
*/
class fifo {
/**
* declare constant variables
*/
const app_name = 'fifo';
const app_uuid = '16589224-c876-aeb3-f59f-523a1c0801f7';
/**
* declare the variables
*/
private $app_name;
private $app_uuid;
private $database;
private $name;
private $table;
private $toggle_field;
@@ -22,15 +29,18 @@
*/
public function __construct() {
//assign the variables
$this->app_name = 'fifo';
$this->app_uuid = '16589224-c876-aeb3-f59f-523a1c0801f7';
$this->name = 'fifo';
$this->table = 'fifo';
$this->uuid_prefix = 'fifo_';
$this->toggle_field = 'fifo_enabled';
$this->toggle_values = ['true','false'];
$this->description_field = 'fifo_description';
$this->location = 'fifo.php';
$this->name = 'fifo';
$this->table = 'fifo';
$this->uuid_prefix = 'fifo_';
$this->toggle_field = 'fifo_enabled';
$this->toggle_values = ['true','false'];
$this->description_field = 'fifo_description';
$this->location = 'fifo.php';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
@@ -78,8 +88,7 @@
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$fifos[$row['uuid']]['dialplan_uuid'] = $row['dialplan_uuid'];
@@ -111,10 +120,7 @@
$p->add('dialplan_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions
@@ -160,8 +166,7 @@
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -184,10 +189,8 @@
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
@@ -232,8 +235,7 @@
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$x = 0;
@@ -260,10 +262,8 @@
$p->add('fifo_member_add', 'temp');
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions

View File

@@ -27,11 +27,16 @@
//define the gateways class
class gateways {
/**
* declare constant variables
*/
const app_name = 'gateways';
const app_uuid = '297ab33e-2c2f-8196-552c-f3567d2caaf8';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -45,14 +50,17 @@
public function __construct() {
//assign private variables
$this->app_name = 'gateways';
$this->app_uuid = '297ab33e-2c2f-8196-552c-f3567d2caaf8';
$this->permission_prefix = 'gateway_';
$this->list_page = 'gateways.php';
$this->table = 'gateways';
$this->uuid_prefix = 'gateway_';
$this->toggle_field = 'enabled';
$this->toggle_values = ['true','false'];
$this->permission_prefix = 'gateway_';
$this->list_page = 'gateways.php';
$this->table = 'gateways';
$this->uuid_prefix = 'gateway_';
$this->toggle_field = 'enabled';
$this->toggle_values = ['true','false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
@@ -95,8 +103,7 @@
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
$database = new database;
$rows = $database->select($sql, $parameters ?? null, 'all');
$rows = $this->database->select($sql, $parameters ?? null, 'all');
if (!empty($rows) && is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$gateways[$row['uuid']]['name'] = $row['gateway'];
@@ -183,8 +190,7 @@
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
$database = new database;
$rows = $database->select($sql, $parameters ?? null, 'all');
$rows = $this->database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$gateways[$row['uuid']]['name'] = $row['gateway'];
@@ -261,8 +267,7 @@
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
$database = new database;
$rows = $database->select($sql, $parameters ?? null, 'all');
$rows = $this->database->select($sql, $parameters ?? null, 'all');
if (!empty($rows) && is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$gateways[$row['uuid']]['name'] = $row['gateway'];
@@ -307,10 +312,7 @@
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//synchronize the xml config
@@ -388,8 +390,7 @@
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
$database = new database;
$rows = $database->select($sql, $parameters ?? null, 'all');
$rows = $this->database->select($sql, $parameters ?? null, 'all');
if (!empty($rows) && is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$gateways[$row['uuid']]['state'] = $row['state'];
@@ -412,10 +413,8 @@
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//update gateway session variables or remove xml files (if necessary)
@@ -514,8 +513,7 @@
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
$database = new database;
$rows = $database->select($sql, $parameters ?? null, 'all');
$rows = $this->database->select($sql, $parameters ?? null, 'all');
if (!empty($rows) && is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $x => $row) {
$primary_uuid = uuid();
@@ -549,10 +547,8 @@
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//add new gateways to session variables

View File

@@ -27,6 +27,12 @@
//define the ivr_menu class
class ivr_menu {
/**
* declare constant variables
*/
const app_name = 'ivr_menus';
const app_uuid = 'a5788e9b-58bc-bd1b-df59-fff5d51253ab';
/**
* declare public variables
*/
@@ -36,8 +42,8 @@
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -51,10 +57,13 @@
public function __construct() {
//assign private variables
$this->app_name = 'ivr_menus';
$this->app_uuid = 'a5788e9b-58bc-bd1b-df59-fff5d51253ab';
$this->list_page = 'ivr_menus.php';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
public function find() {
@@ -68,8 +77,7 @@
$sql .= $this->order_by;
}
$parameters['domain_uuid'] = $this->domain_uuid;
$database = new database;
return $database->select($sql, $parameters, 'all');
return $this->database->select($sql, $parameters, 'all');
}
/**
@@ -114,8 +122,7 @@
$sql .= "where (domain_uuid = :domain_uuid) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$ivr_menus[$row['uuid']]['dialplan_uuid'] = $row['dialplan_uuid'];
@@ -143,10 +150,7 @@
$p->add('dialplan_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions
@@ -218,8 +222,7 @@
$sql .= "and ivr_menu_uuid = :ivr_menu_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['ivr_menu_uuid'] = $this->ivr_menu_uuid;
$database = new database;
$ivr_menu_context = $database->select($sql, $parameters, 'column');
$ivr_menu_context = $this->database->select($sql, $parameters, 'column');
unset($sql, $parameters);
}
@@ -227,10 +230,7 @@
if (!empty($array)) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//clear the cache
@@ -286,8 +286,7 @@
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$ivr_menus[$row['uuid']]['state'] = $row['toggle'];
@@ -315,10 +314,7 @@
$p->add('dialplan_edit', 'temp');
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions
@@ -388,8 +384,7 @@
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (!empty($rows)) {
$y = $z = 0;
foreach ($rows as $x => $row) {
@@ -407,8 +402,7 @@
//ivr menu options sub table
$sql_2 = "select * from v_ivr_menu_options where ivr_menu_uuid = :ivr_menu_uuid";
$parameters_2['ivr_menu_uuid'] = $row['ivr_menu_uuid'];
$database = new database;
$rows_2 = $database->select($sql_2, $parameters_2, 'all');
$rows_2 = $this->database->select($sql_2, $parameters_2, 'all');
if (!empty($rows_2)) {
foreach ($rows_2 as $row_2) {
@@ -429,8 +423,7 @@
//ivr menu dialplan record
$sql_3 = "select * from v_dialplans where dialplan_uuid = :dialplan_uuid";
$parameters_3['dialplan_uuid'] = $row['dialplan_uuid'];
$database = new database;
$dialplan = $database->select($sql_3, $parameters_3, 'row');
$dialplan = $this->database->select($sql_3, $parameters_3, 'row');
if (!empty($dialplan)) {
//copy data
@@ -463,10 +456,7 @@
$p->add('dialplan_add', 'temp');
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions

File diff suppressed because it is too large Load Diff

View File

@@ -29,12 +29,19 @@
//define the switch_music_on_hold class
class switch_music_on_hold {
/**
* declare constant variables
*/
const app_name = 'music_on_hold';
const app_uuid = '1dafe0f8-c08a-289b-0312-15baf4f20f81';
/**
* declare private variables
*/
private $xml;
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -46,13 +53,16 @@
public function __construct() {
//assign private variables
$this->app_name = 'music_on_hold';
$this->app_uuid = '1dafe0f8-c08a-289b-0312-15baf4f20f81';
$this->permission_prefix = 'music_on_hold_';
$this->list_page = 'music_on_hold.php';
$this->table = 'music_on_hold';
$this->uuid_prefix = 'music_on_hold_';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
public function select($name, $selected, $options) {
@@ -101,8 +111,7 @@
$sql .= "and stream_enabled = 'true' ";
$sql .= "order by stream_name asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$streams = $database->select($sql, $parameters, 'all');
$streams = $this->database->select($sql, $parameters, 'all');
if (is_array($streams) && @sizeof($streams) != 0) {
$select .= " <optgroup label='".$text['label-streams']."'>";
foreach($streams as $row){
@@ -138,8 +147,7 @@
$sql .= "where (m.domain_uuid = :domain_uuid or m.domain_uuid is null) ";
$sql .= "order by m.domain_uuid desc, music_on_hold_name asc, music_on_hold_rate asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
return $database->select($sql, $parameters, 'all');
return $this->database->select($sql, $parameters, 'all');
unset($sql, $parameters);
}
@@ -232,15 +240,13 @@
public function import() {
//get the domains
$sql = "select * from v_domains ";
$database = new database;
$domains = $database->select($sql, null, 'all');
$domains = $this->database->select($sql, null, 'all');
unset($sql);
//get the music_on_hold array
$sql = "select * from v_music_on_hold ";
$sql .= "order by domain_uuid desc, music_on_hold_name asc, music_on_hold_rate asc";
$database = new database;
$music_on_hold = $database->select($sql, null, 'all');
$music_on_hold = $this->database->select($sql, null, 'all');
unset($sql);
//build an array of the sound files
@@ -302,11 +308,10 @@
$p = permissions::new();
$p->add('music_on_hold_add', 'temp');
$database = new database;
$database->app_name = 'music_on_hold';
$database->app_uuid = '1dafe0f8-c08a-289b-0312-15baf4f20f81';
$database->save($array);
//echo $database->message;
$this->database->app_name = 'music_on_hold';
$this->database->app_uuid = '1dafe0f8-c08a-289b-0312-15baf4f20f81';
$this->database->save($array);
//echo $this->database->message;
unset($array);
$p->delete('music_on_hold_add', 'temp');
@@ -358,8 +363,7 @@
$sql .= "where (domain_uuid = :domain_uuid ".(!permission_exists('music_on_hold_domain') ? "": "or domain_uuid is null ").") ";
$sql .= "and music_on_hold_uuid in ('".implode("','", array_keys($moh))."') ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$streams[$row['music_on_hold_uuid']] = $row;
@@ -414,10 +418,7 @@
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//set flag

View File

@@ -27,11 +27,22 @@
//define the number translations class
class number_translations {
/**
* declare constant variables
*/
const app_name = 'number_translations';
const app_uuid = '6ad54de6-4909-11e7-a919-92ebcb67fe33';
/**
* declare public variables
*/
public $number_translation_uuid;
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -40,25 +51,23 @@
private $toggle_values;
public $xml;
/**
* declare public variables
*/
public $number_translation_uuid;
/**
* called when the object is created
*/
public function __construct() {
//assign private variables
$this->app_name = 'number_translations';
$this->app_uuid = '6ad54de6-4909-11e7-a919-92ebcb67fe33';
$this->permission_prefix = 'number_translation_';
$this->list_page = 'number_translations.php';
$this->table = 'number_translations';
$this->uuid_prefix = 'number_translation_';
$this->toggle_field = 'number_translation_enabled';
$this->toggle_values = ['true','false'];
$this->permission_prefix = 'number_translation_';
$this->list_page = 'number_translations.php';
$this->table = 'number_translations';
$this->uuid_prefix = 'number_translation_';
$this->toggle_field = 'number_translation_enabled';
$this->toggle_values = ['true','false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
@@ -69,8 +78,7 @@
$sql = "select count(*) from v_number_translations ";
$sql .= "where number_translation_name = :number_translation_name ";
$parameters['number_translation_name'] = $name;
$database = new database;
return $database->select($sql, $parameters, 'column') != 0 ? true : false;
return $this->database->select($sql, $parameters, 'column') != 0 ? true : false;
unset($sql, $parameters);
}
@@ -122,14 +130,13 @@
$p->add('number_translation_add', 'temp');
$p->add('number_translation_detail_add', 'temp');
//execute insert
$database = new database;
$database->app_name = 'number_translations';
$database->app_uuid = '6ad54de6-4909-11e7-a919-92ebcb67fe33';
$database->save($array);
$this->database->app_name = 'number_translations';
$this->database->app_uuid = '6ad54de6-4909-11e7-a919-92ebcb67fe33';
$this->database->save($array);
unset($array);
if (!empty($this->display_type) && $this->display_type == "text") {
if ($database->message['code'] != '200') {
echo "number_translation:".$number_translation['@attributes']['name'].": failed: ".$database->message['message']."\n";
if ($this->database->message['code'] != '200') {
echo "number_translation:".$number_translation['@attributes']['name'].": failed: ".$this->database->message['message']."\n";
}
else {
echo "number_translation:".$number_translation['@attributes']['name'].": added with ".(($order/5)-1)." entries\n";
@@ -179,10 +186,7 @@
$p->add('number_translation_detail_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions
@@ -232,10 +236,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
}
@@ -274,8 +275,7 @@
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -296,10 +296,8 @@
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
@@ -345,8 +343,7 @@
//primary table
$sql = "select * from v_".$this->table." ";
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$y = 0;
foreach ($rows as $x => $row) {
@@ -362,8 +359,7 @@
//nodes sub table
$sql_2 = "select * from v_number_translation_details where number_translation_uuid = :number_translation_uuid";
$parameters_2['number_translation_uuid'] = $row['number_translation_uuid'];
$database = new database;
$rows_2 = $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) {
foreach ($rows_2 as $row_2) {
@@ -393,10 +389,8 @@
$p->add('number_translation_detail_add', 'temp');
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions

View File

@@ -27,11 +27,22 @@
//define the phrases class
class phrases {
/**
* declare constant variables
*/
const app_name = 'phrases';
const app_uuid = '5c6f597c-9b78-11e4-89d3-123b93f75cba';
/**
* declare public variables
*/
public $phrase_uuid;
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -39,25 +50,23 @@
private $toggle_field;
private $toggle_values;
/**
* declare public variables
*/
public $phrase_uuid;
/**
* called when the object is created
*/
public function __construct() {
//assign private variables
$this->app_name = 'phrases';
$this->app_uuid = '5c6f597c-9b78-11e4-89d3-123b93f75cba';
$this->permission_prefix = 'phrase_';
$this->list_page = 'phrases.php';
$this->table = 'phrases';
$this->uuid_prefix = 'phrase_';
$this->toggle_field = 'phrase_enabled';
$this->toggle_values = ['true','false'];
$this->permission_prefix = 'phrase_';
$this->list_page = 'phrases.php';
$this->table = 'phrases';
$this->uuid_prefix = 'phrase_';
$this->toggle_field = 'phrase_enabled';
$this->toggle_values = ['true','false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
@@ -95,8 +104,7 @@
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$phrase_languages[$row['uuid']] = $row['lang'];
@@ -125,10 +133,7 @@
$p->add('phrase_detail_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions
@@ -194,8 +199,7 @@
$sql .= "and phrase_uuid = :phrase_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['phrase_uuid'] = $this->phrase_uuid;
$database = new database;
$phrase_language = $database->select($sql, $parameters, 'column');
$phrase_language = $this->database->select($sql, $parameters, 'column');
unset($sql, $parameters, $rows, $row);
}
@@ -207,10 +211,7 @@
$p->add('phrase_detail_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions
@@ -260,8 +261,7 @@
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -283,10 +283,8 @@
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//clear the cache
@@ -348,8 +346,7 @@
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$y = 0;
foreach ($rows as $x => $row) {
@@ -365,8 +362,7 @@
//details sub table
$sql_2 = "select * from v_phrase_details where phrase_uuid = :phrase_uuid";
$parameters_2['phrase_uuid'] = $row['phrase_uuid'];
$database = new database;
$rows_2 = $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) {
foreach ($rows_2 as $row_2) {
@@ -401,10 +397,8 @@
$p->add('phrase_detail_add', 'temp');
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions

View File

@@ -27,11 +27,16 @@
//define the pin numbers class
class pin_numbers {
/**
* declare constant variables
*/
const app_name = 'pin_numbers';
const app_uuid = '4b88ccfb-cb98-40e1-a5e5-33389e14a388';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -45,14 +50,17 @@
public function __construct() {
//assign private variables
$this->app_name = 'pin_numbers';
$this->app_uuid = '4b88ccfb-cb98-40e1-a5e5-33389e14a388';
$this->permission_prefix = 'pin_number_';
$this->list_page = 'pin_numbers.php';
$this->table = 'pin_numbers';
$this->uuid_prefix = 'pin_number_';
$this->toggle_field = 'enabled';
$this->toggle_values = ['true','false'];
$this->permission_prefix = 'pin_number_';
$this->list_page = 'pin_numbers.php';
$this->table = 'pin_numbers';
$this->uuid_prefix = 'pin_number_';
$this->toggle_field = 'enabled';
$this->toggle_values = ['true','false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
@@ -89,10 +97,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//set message
@@ -135,8 +140,7 @@
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -157,10 +161,8 @@
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
@@ -206,8 +208,7 @@
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $x => $row) {
@@ -227,10 +228,8 @@
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message

View File

@@ -28,105 +28,124 @@
//define the provision class
class provision {
/**
* declare constant variables
*/
const app_name = 'provision';
const app_uuid = 'abf28ead-92ef-3de6-ebbb-023fbc2b6dd3';
/**
* declare public variables
*/
public $domain_uuid;
public $domain_name;
public $template_dir;
public $device_address;
public $device_template;
/**
* declare private variables
*/
private $settings;
private $database;
/**
* called when the object is created
*/
public function __construct($params = []) {
//preset the the values
$settings = null;
$domain_uuid = null;
$settings = null;
$domain_uuid = null;
//use the parameters to set the values if they exist
if (isset($params['database'])) {
$this->database = $params['database'];
}
if (isset($params['settings'])) {
$settings = $params['settings'];
}
if (isset($params['domain_uuid'])) {
$domain_uuid = $params['domain_uuid'];
}
if (isset($params['database'])) {
$this->database = $params['database'];
}
if (isset($params['settings'])) {
$settings = $params['settings'];
}
if (isset($params['domain_uuid'])) {
$domain_uuid = $params['domain_uuid'];
}
//check if we can use the settings object to get the database object
if (!empty($settings) && empty($this->database)) {
$this->database = $settings->database();
}
if (!empty($settings) && empty($this->database)) {
$this->database = $settings->database();
}
//fill in missing
if (empty($this->database)) {
$this->database = database::new();
}
if (empty($settings)) {
$settings = new settings(['database' => $this->database, 'domain_uuid' => $domain_uuid]);
}
if (empty($this->database)) {
$this->database = database::new();
}
if (empty($settings)) {
$settings = new settings(['database' => $this->database, 'domain_uuid' => $domain_uuid]);
}
//assign to the object
$this->settings = $settings;
$this->domain_uuid = $domain_uuid;
$this->settings = $settings;
$this->domain_uuid = $domain_uuid;
//get the project root
$project_root = dirname(__DIR__, 4);
$project_root = dirname(__DIR__, 4);
//set the default template directory
if (PHP_OS == "Linux") {
//set the default template dir
if (empty($this->template_dir)) {
if (file_exists('/usr/share/fusionpbx/templates/provision')) {
$this->template_dir = '/usr/share/fusionpbx/templates/provision';
}
elseif (file_exists('/etc/fusionpbx/resources/templates/provision')) {
$this->template_dir = '/etc/fusionpbx/resources/templates/provision';
}
else {
$this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision';
}
if (PHP_OS == "Linux") {
//set the default template dir
if (empty($this->template_dir)) {
if (file_exists('/usr/share/fusionpbx/templates/provision')) {
$this->template_dir = '/usr/share/fusionpbx/templates/provision';
}
}
elseif (PHP_OS == "FreeBSD") {
//if the FreeBSD port is installed use the following paths by default.
if (empty($this->template_dir)) {
if (file_exists('/usr/local/share/fusionpbx/templates/provision')) {
$this->template_dir = '/usr/local/share/fusionpbx/templates/provision';
}
elseif (file_exists('/usr/local/etc/fusionpbx/resources/templates/provision')) {
$this->template_dir = '/usr/local/etc/fusionpbx/resources/templates/provision';
}
else {
$this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision';
}
elseif (file_exists('/etc/fusionpbx/resources/templates/provision')) {
$this->template_dir = '/etc/fusionpbx/resources/templates/provision';
}
}
else if (PHP_OS == "NetBSD") {
//set the default template_dir
if (empty($this->template_dir)) {
else {
$this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision';
}
}
else if (PHP_OS == "OpenBSD") {
//set the default template_dir
if (empty($this->template_dir)) {
}
}
elseif (PHP_OS == "FreeBSD") {
//if the FreeBSD port is installed use the following paths by default.
if (empty($this->template_dir)) {
if (file_exists('/usr/local/share/fusionpbx/templates/provision')) {
$this->template_dir = '/usr/local/share/fusionpbx/templates/provision';
}
elseif (file_exists('/usr/local/etc/fusionpbx/resources/templates/provision')) {
$this->template_dir = '/usr/local/etc/fusionpbx/resources/templates/provision';
}
else {
$this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision';
}
}
else {
//set the default template_dir
if (empty($this->template_dir)) {
$this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision';
}
}
}
}
else if (PHP_OS == "NetBSD") {
//set the default template_dir
if (empty($this->template_dir)) {
$this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision';
}
}
else if (PHP_OS == "OpenBSD") {
//set the default template_dir
if (empty($this->template_dir)) {
$this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision';
}
}
else {
//set the default template_dir
if (empty($this->template_dir)) {
$this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision';
}
}
//normalize the device address
if (isset($this->device_address)) {
$this->device_address = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $this->device_address));
}
if (isset($this->device_address)) {
$this->device_address = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $this->device_address));
}
}
/**
* get the domain uuid
*/
public function get_domain_uuid() {
return $this->domain_uuid;
}

View File

@@ -28,6 +28,12 @@
//define the switch_recordings class
class switch_recordings {
/**
* declare constant variables
*/
const app_name = 'recordings';
const app_uuid = '83913217-c7a2-9e90-925d-a866eb40b60e';
/**
* declare public variables
*/
@@ -36,8 +42,8 @@
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -49,15 +55,19 @@
* called when the object is created
*/
public function __construct() {
//assign public variables
$this->domain_uuid = $_SESSION['domain_uuid'];
//assign private variables
$this->app_name = 'recordings';
$this->app_uuid = '83913217-c7a2-9e90-925d-a866eb40b60e';
$this->permission_prefix = 'recording_';
$this->list_page = 'recordings.php';
$this->table = 'recordings';
$this->uuid_prefix = 'recording_';
$this->permission_prefix = 'recording_';
$this->list_page = 'recordings.php';
$this->table = 'recordings';
$this->uuid_prefix = 'recording_';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
@@ -69,8 +79,7 @@
$sql .= "from v_recordings ";
$sql .= "where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $this->domain_uuid;
$database = new database;
$result = $database->select($sql, $parameters, 'all');
$result = $this->database->select($sql, $parameters, 'all');
if (!empty($result)) {
foreach ($result as $row) {
$recordings[$_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name']."/".$row['recording_filename']] = $row['recording_filename'];
@@ -114,8 +123,7 @@
$sql .= "and recording_uuid = :recording_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['recording_uuid'] = $record['uuid'];
$database = new database;
$filenames[] = $database->select($sql, $parameters, 'column');
$filenames[] = $this->database->select($sql, $parameters, 'column');
unset($sql, $parameters);
//build delete array
@@ -128,10 +136,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//delete recording files

View File

@@ -26,11 +26,15 @@
class registrations {
/**
* declare constant variables
*/
const app_name = 'registrations';
const app_uuid = '5d9e7cd7-629e-3553-4cf5-f26e39fefa39';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $permission_prefix;
private $list_page;
public $show;
@@ -81,8 +85,6 @@
}
//assign private variables
$this->app_name = 'registrations';
$this->app_uuid = '5d9e7cd7-629e-3553-4cf5-f26e39fefa39';
$this->permission_prefix = 'registration_';
$this->list_page = 'registrations.php';
$this->show = 'local';

View File

@@ -27,11 +27,16 @@
//define the ring groups class
class ring_groups {
/**
* declare constant variables
*/
const app_name = 'ring_groups';
const app_uuid = '1d61fb65-1eec-bc73-a6ee-a6203b4fe6f2';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -50,14 +55,17 @@
public function __construct() {
//assign private variables
$this->app_name = 'ring_groups';
$this->app_uuid = '1d61fb65-1eec-bc73-a6ee-a6203b4fe6f2';
$this->permission_prefix = 'ring_group_';
$this->list_page = 'ring_groups.php';
$this->table = 'ring_groups';
$this->uuid_prefix = 'ring_group_';
$this->toggle_field = 'ring_group_enabled';
$this->toggle_values = ['true','false'];
$this->permission_prefix = 'ring_group_';
$this->list_page = 'ring_groups.php';
$this->table = 'ring_groups';
$this->uuid_prefix = 'ring_group_';
$this->toggle_field = 'ring_group_enabled';
$this->toggle_values = ['true','false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
@@ -95,8 +103,7 @@
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$ring_groups[$row['uuid']]['dialplan_uuid'] = $row['dialplan_uuid'];
@@ -131,10 +138,7 @@
$p->add('dialplan_detail_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions
@@ -206,8 +210,7 @@
$sql .= "and ring_group_uuid = :ring_group_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['ring_group_uuid'] = $this->ring_group_uuid;
$database = new database;
$ring_group_context = $database->select($sql, $parameters, 'column');
$ring_group_context = $this->database->select($sql, $parameters, 'column');
unset($sql, $parameters);
}
@@ -225,10 +228,7 @@
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//apply settings reminder
@@ -278,8 +278,7 @@
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$ring_groups[$row['uuid']]['state'] = $row['toggle'];
@@ -308,10 +307,8 @@
$p->add('dialplan_edit', 'temp');
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions
@@ -379,8 +376,7 @@
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$y = $z = 0;
foreach ($rows as $x => $row) {
@@ -398,8 +394,7 @@
//users sub table
$sql_2 = "select * from v_ring_group_users where ring_group_uuid = :ring_group_uuid";
$parameters_2['ring_group_uuid'] = $row['ring_group_uuid'];
$database = new database;
$rows_2 = $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) {
foreach ($rows_2 as $row_2) {
@@ -420,8 +415,7 @@
//destinations sub table
$sql_3 = "select * from v_ring_group_destinations where ring_group_uuid = :ring_group_uuid";
$parameters_3['ring_group_uuid'] = $row['ring_group_uuid'];
$database = new database;
$rows_3 = $database->select($sql_3, $parameters_3, 'all');
$rows_3 = $this->database->select($sql_3, $parameters_3, 'all');
if (is_array($rows_3) && @sizeof($rows_3) != 0) {
foreach ($rows_3 as $row_3) {
@@ -442,8 +436,7 @@
//ring group dialplan record
$sql_4 = "select * from v_dialplans where dialplan_uuid = :dialplan_uuid";
$parameters_4['dialplan_uuid'] = $row['dialplan_uuid'];
$database = new database;
$dialplan = $database->select($sql_4, $parameters_4, 'row');
$dialplan = $this->database->select($sql_4, $parameters_4, 'row');
if (is_array($dialplan) && @sizeof($dialplan) != 0) {
//copy data
@@ -477,10 +470,8 @@
$p->add("dialplan_add", "temp");
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions

View File

@@ -27,11 +27,16 @@
//define the sip profiles class
class sip_profiles {
/**
* declare constant variables
*/
const app_name = 'sip_profiles';
const app_uuid = 'a6a7c4c5-340a-43ce-bcbc-2ed9bab8659d';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -50,14 +55,17 @@
public function __construct() {
//assign private variables
$this->app_name = 'sip_profiles';
$this->app_uuid = 'a6a7c4c5-340a-43ce-bcbc-2ed9bab8659d';
$this->permission_prefix = 'sip_profile_';
$this->list_page = 'sip_profiles.php';
$this->table = 'sip_profiles';
$this->uuid_prefix = 'sip_profile_';
$this->toggle_field = 'sip_profile_enabled';
$this->toggle_values = ['true','false'];
$this->permission_prefix = 'sip_profile_';
$this->list_page = 'sip_profiles.php';
$this->table = 'sip_profiles';
$this->uuid_prefix = 'sip_profile_';
$this->toggle_field = 'sip_profile_enabled';
$this->toggle_values = ['true','false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
@@ -92,8 +100,7 @@
//get necessary sip profile details
$sql = "select ".$this->uuid_prefix."uuid as uuid, sip_profile_name, sip_profile_hostname from v_".$this->table." ";
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters ?? null, 'all');
$rows = $this->database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$sip_profiles[$row['uuid']]['name'] = $row['sip_profile_name'];
@@ -120,10 +127,7 @@
$p->add('sip_profile_setting_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions
@@ -213,8 +217,7 @@
$sql = "select sip_profile_hostname from v_sip_profiles ";
$sql .= "where sip_profile_uuid = :sip_profile_uuid ";
$parameters['sip_profile_uuid'] = $this->sip_profile_uuid;
$database = new database;
$sip_profile_hostname = $database->select($sql, $parameters, 'column');
$sip_profile_hostname = $this->database->select($sql, $parameters, 'column');
unset($sql, $parameters);
}
@@ -222,10 +225,7 @@
if (!empty($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//save the sip profile xml
@@ -291,8 +291,7 @@
$sql = "select sip_profile_hostname from v_sip_profiles ";
$sql .= "where sip_profile_uuid = :sip_profile_uuid ";
$parameters['sip_profile_uuid'] = $this->sip_profile_uuid;
$database = new database;
$sip_profile_hostname = $database->select($sql, $parameters, 'column');
$sip_profile_hostname = $this->database->select($sql, $parameters, 'column');
unset($sql, $parameters);
}
@@ -300,10 +299,7 @@
if (!empty($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//save the sip profile xml
@@ -362,8 +358,7 @@
if (!empty($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, sip_profile_hostname from v_".$this->table." ";
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters ?? null, 'all');
$rows = $this->database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$sip_profiles[$row['uuid']]['state'] = $row['toggle'];
@@ -385,10 +380,8 @@
if (!empty($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//determine hostnames, get system hostname if necessary

View File

@@ -29,11 +29,16 @@
*/
class sofia_global_settings {
/**
* declare constant variables
*/
const app_name = 'sofia_global_settings';
const app_uuid = '240c25a3-a2cf-44ea-a300-0626eca5b945';
/**
* declare the variables
*/
private $app_name;
private $app_uuid;
private $database;
private $name;
private $table;
private $toggle_field;
@@ -46,14 +51,17 @@
*/
public function __construct() {
//assign the variables
$this->app_name = 'sofia_global_settings';
$this->app_uuid = '240c25a3-a2cf-44ea-a300-0626eca5b945';
$this->name = 'sofia_global_setting';
$this->table = 'sofia_global_settings';
$this->toggle_field = 'global_setting_enabled';
$this->toggle_values = ['true','false'];
$this->description_field = 'global_setting_description';
$this->location = 'sofia_global_settings.php';
$this->name = 'sofia_global_setting';
$this->table = 'sofia_global_settings';
$this->toggle_field = 'global_setting_enabled';
$this->toggle_values = ['true','false'];
$this->description_field = 'global_setting_description';
$this->location = 'sofia_global_settings.php';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
@@ -91,10 +99,7 @@
//delete the checked rows
if (!empty($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//set message
@@ -134,8 +139,7 @@
if (!empty($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, null, 'all');
$rows = $this->database->select($sql, null, 'all');
if (!empty($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -158,10 +162,8 @@
//save the changes
if (!empty($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
@@ -204,8 +206,7 @@
if (!empty($uuids) && @sizeof($uuids) != 0) {
$sql = "select * from v_".$this->table." ";
$sql .= "where sofia_global_setting_uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, null, 'all');
$rows = $this->database->select($sql, null, 'all');
if (!empty($rows) && @sizeof($rows) != 0) {
$x = 0;
foreach ($rows as $row) {
@@ -227,10 +228,8 @@
//save the changes and set the message
if (!empty($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message

View File

@@ -27,11 +27,17 @@
//define the streams class
class streams {
/**
* declare constant variables
*/
const app_name = 'streams';
const app_uuid = 'ffde6287-aa18-41fc-9a38-076d292e0a38';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -45,14 +51,17 @@
public function __construct() {
//assign private variables
$this->app_name = 'streams';
$this->app_uuid = 'ffde6287-aa18-41fc-9a38-076d292e0a38';
$this->permission_prefix = 'stream_';
$this->list_page = 'streams.php';
$this->table = 'streams';
$this->uuid_prefix = 'stream_';
$this->toggle_field = 'stream_enabled';
$this->toggle_values = ['true','false'];
$this->permission_prefix = 'stream_';
$this->list_page = 'streams.php';
$this->table = 'streams';
$this->uuid_prefix = 'stream_';
$this->toggle_field = 'stream_enabled';
$this->toggle_values = ['true','false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
@@ -88,10 +97,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//set message
@@ -134,8 +140,7 @@
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -156,10 +161,8 @@
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
@@ -205,8 +208,7 @@
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $x => $row) {
@@ -226,10 +228,8 @@
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message

View File

@@ -27,87 +27,103 @@
class ringbacks {
//define variables
/**
* declare constant variables
*/
const app_name = 'ringbacks';
const app_uuid = 'b63db353-e1c6-4401-8f10-101a6ee73b74';
/**
* declare public variables
*/
public $domain_uuid;
public $ringtones_list;
/**
* declare private variables
*/
private $tones_list;
private $music_list;
private $recordings_list;
private $default_ringback_label;
private $streams;
//class constructor
/**
* called when the object is created
*/
public function __construct() {
//set the domain_uuid
$this->domain_uuid = $_SESSION['domain_uuid'];
$this->domain_uuid = $_SESSION['domain_uuid'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
//add multi-lingual support
$language = new text;
$text = $language->get();
$language = new text;
$text = $language->get();
//get the ringtones
$sql = "select * from v_vars ";
$sql .= "where var_category = 'Ringtones' ";
$sql .= "order by var_name asc ";
$database = new database;
$ringtones = $database->select($sql, null, 'all');
if (!empty($ringtones)) {
foreach ($ringtones as $ringtone) {
$ringtone = $ringtone['var_name'];
if (isset($text['label-'.$ringtone])) {
$label = $text['label-'.$ringtone];
}
else {
$label = $ringtone;
}
$ringtones_list[$ringtone] = $label;
$sql = "select * from v_vars ";
$sql .= "where var_category = 'Ringtones' ";
$sql .= "order by var_name asc ";
$ringtones = $this->database->select($sql, null, 'all');
if (!empty($ringtones)) {
foreach ($ringtones as $ringtone) {
$ringtone = $ringtone['var_name'];
if (isset($text['label-'.$ringtone])) {
$label = $text['label-'.$ringtone];
}
else {
$label = $ringtone;
}
$ringtones_list[$ringtone] = $label;
}
$this->ringtones_list = $ringtones_list ?? '';
unset($sql, $ringtones, $ringtone, $ringtones_list);
}
$this->ringtones_list = $ringtones_list ?? '';
unset($sql, $ringtones, $ringtone, $ringtones_list);
//get the default_ringback label
/*
$sql = "select * from v_vars where var_name = 'ringback' ";
$database = new database;
$row = $database->select($sql, null, 'row');
unset($sql);
$default_ringback = (string) $row['var_value'];
$default_ringback = preg_replace('/\A\$\${/',"",$default_ringback);
$default_ringback = preg_replace('/}\z/',"",$default_ringback);
#$label = $text['label-'.$default_ringback];
#if($label == "") {
$label = $default_ringback;
#}
$this->default_ringback_label = $label;
unset($results, $default_ringback, $label);
*/
/*
$sql = "select * from v_vars where var_name = 'ringback' ";
$row = $this->database->select($sql, null, 'row');
unset($sql);
$default_ringback = (string) $row['var_value'];
$default_ringback = preg_replace('/\A\$\${/',"",$default_ringback);
$default_ringback = preg_replace('/}\z/',"",$default_ringback);
#$label = $text['label-'.$default_ringback];
#if($label == "") {
$label = $default_ringback;
#}
$this->default_ringback_label = $label;
unset($results, $default_ringback, $label);
*/
//get the tones
$tones = new tones;
$this->tones_list = $tones->tones_list();
$tones = new tones;
$this->tones_list = $tones->tones_list();
//get music on hold and recordings
if (is_dir($_SERVER["PROJECT_ROOT"].'/app/music_on_hold')) {
$music = new switch_music_on_hold;
$this->music_list = $music->get();
}
if (is_dir($_SERVER["PROJECT_ROOT"].'/app/recordings')) {
$recordings = new switch_recordings;
$this->recordings_list = $recordings->list_recordings();
}
if (is_dir($_SERVER["PROJECT_ROOT"].'/app/music_on_hold')) {
$music = new switch_music_on_hold;
$this->music_list = $music->get();
}
if (is_dir($_SERVER["PROJECT_ROOT"].'/app/recordings')) {
$recordings = new switch_recordings;
$this->recordings_list = $recordings->list_recordings();
}
if (is_dir($_SERVER["PROJECT_ROOT"].'/app/streams')) {
$sql = "select * from v_streams ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and stream_enabled = 'true' ";
$sql .= "order by stream_name asc ";
$parameters['domain_uuid'] = $this->domain_uuid;
$database = new database;
$streams = $database->select($sql, $parameters, 'all');
$this->streams = $streams;
unset($sql, $parameters, $streams, $row);
}
if (is_dir($_SERVER["PROJECT_ROOT"].'/app/streams')) {
$sql = "select * from v_streams ";
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and stream_enabled = 'true' ";
$sql .= "order by stream_name asc ";
$parameters['domain_uuid'] = $this->domain_uuid;
$streams = $this->database->select($sql, $parameters, 'all');
$this->streams = $streams;
unset($sql, $parameters, $streams, $row);
}
}
public function valid($value) {

View File

@@ -27,11 +27,18 @@
//define the time conditions class
class time_conditions {
/**
* declare constant variables
*/
const app_name = 'time_conditions';
const app_uuid = '4b821450-926b-175a-af93-a03c441818b1';
/**
* declare public/private properties
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -45,14 +52,17 @@
$this->dialplan_global = false;
//assign property defaults
$this->app_name = 'time_conditions';
$this->app_uuid = '4b821450-926b-175a-af93-a03c441818b1';
$this->permission_prefix = 'time_condition_';
$this->list_page = 'time_conditions.php';
$this->table = 'dialplans';
$this->uuid_prefix = 'dialplan_';
$this->toggle_field = 'dialplan_enabled';
$this->toggle_values = ['true','false'];
$this->permission_prefix = 'time_condition_';
$this->list_page = 'time_conditions.php';
$this->table = 'dialplans';
$this->uuid_prefix = 'dialplan_';
$this->toggle_field = 'dialplan_enabled';
$this->toggle_values = ['true','false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
@@ -88,8 +98,7 @@
$sql = "select dialplan_context from v_dialplans ";
$sql .= "where dialplan_uuid = :dialplan_uuid ";
$parameters['dialplan_uuid'] = $record['uuid'];
$database = new database;
$dialplan_contexts[] = $database->select($sql, $parameters, 'column');
$dialplan_contexts[] = $this->database->select($sql, $parameters, 'column');
unset($sql, $parameters);
}
@@ -104,10 +113,7 @@
$p->add('dialplan_detail_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
//revoke temporary permissions
$p->delete('dialplan_delete', 'temp');
@@ -169,8 +175,7 @@
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -196,10 +201,8 @@
$p->add('dialplan_edit', 'temp');
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions
@@ -262,8 +265,7 @@
//primary table
$sql = "select * from v_".$this->table." ";
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters ?? null, 'all');
$rows = $this->database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$y = 0;
foreach ($rows as $x => $row) {
@@ -279,8 +281,7 @@
//details sub table
$sql_2 = "select * from v_dialplan_details where dialplan_uuid = :dialplan_uuid";
$parameters_2['dialplan_uuid'] = $row['dialplan_uuid'];
$database = new database;
$rows_2 = $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) {
foreach ($rows_2 as $row_2) {
@@ -314,10 +315,7 @@
$p->add('dialplan_detail_add', 'temp');
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions

View File

@@ -27,11 +27,17 @@
//define the vars class
class vars {
/**
* declare constant variables
*/
const app_name = 'vars';
const app_uuid = '54e08402-c1b8-0a9d-a30a-f569fc174dd8';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -45,15 +51,17 @@
public function __construct() {
//assign private variables
$this->app_name = 'vars';
$this->app_uuid = '54e08402-c1b8-0a9d-a30a-f569fc174dd8';
$this->permission_prefix = 'var_';
$this->list_page = 'vars.php';
$this->table = 'vars';
$this->uuid_prefix = 'var_';
$this->toggle_field = 'var_enabled';
$this->toggle_values = ['true','false'];
$this->permission_prefix = 'var_';
$this->list_page = 'vars.php';
$this->table = 'vars';
$this->uuid_prefix = 'var_';
$this->toggle_field = 'var_enabled';
$this->toggle_values = ['true','false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
@@ -88,10 +96,7 @@
if (!empty($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//unset the user defined variables
@@ -138,8 +143,7 @@
if (!empty($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, null, 'all');
$rows = $this->database->select($sql, null, 'all');
if (!empty($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -160,10 +164,8 @@
if (!empty($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//unset the user defined variables
@@ -213,8 +215,7 @@
if (!empty($uuids) && @sizeof($uuids) != 0) {
$sql = "select * from v_".$this->table." ";
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, null, 'all');
$rows = $this->database->select($sql, null, 'all');
if (!empty($rows) && @sizeof($rows) != 0) {
foreach ($rows as $x => $row) {
@@ -234,10 +235,8 @@
if (!empty($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//unset the user defined variables

View File

@@ -27,11 +27,17 @@
//define the voicemail greetings class
class voicemail_greetings {
/**
* declare constant variables
*/
const app_name = 'voicemail_greetings';
const app_uuid = 'e4b4fbee-9e4d-8e46-3810-91ba663db0c2';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -48,17 +54,20 @@
public function __construct() {
//assign private variables
$this->app_name = 'voicemail_greetings';
$this->app_uuid = 'e4b4fbee-9e4d-8e46-3810-91ba663db0c2';
$this->permission_prefix = 'voicemail_greeting_';
if (is_numeric($this->voicemail_id)) {
$this->list_page = 'voicemail_greetings.php?id='.urlencode($this->voicemail_id).'&back='.urlencode(PROJECT_PATH.'/app/voicemail/voicemails.php');
}
else {
$this->list_page = PROJECT_PATH.'/app/voicemails/voicemails.php';
}
$this->table = 'voicemail_greetings';
$this->uuid_prefix = 'voicemail_greeting_';
$this->permission_prefix = 'voicemail_greeting_';
if (is_numeric($this->voicemail_id)) {
$this->list_page = 'voicemail_greetings.php?id='.urlencode($this->voicemail_id).'&back='.urlencode(PROJECT_PATH.'/app/voicemail/voicemails.php');
}
else {
$this->list_page = PROJECT_PATH.'/app/voicemails/voicemails.php';
}
$this->table = 'voicemail_greetings';
$this->uuid_prefix = 'voicemail_greeting_';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
@@ -100,8 +109,7 @@
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->uuid_prefix."uuid as uuid, greeting_filename, greeting_id from v_".$this->table." ";
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters ?? null, 'all');
$rows = $this->database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$greeting_filenames[$row['uuid']] = $row['greeting_filename'];
@@ -138,10 +146,7 @@
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['voicemail_id'] = $voicemail_id;
$parameters['greeting_id'] = $greeting_id;
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->execute($sql, $parameters);
$this->database->execute($sql, $parameters);
unset($sql, $parameters);
}
}
@@ -150,10 +155,7 @@
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//set message
message::add($text['message-delete']);

View File

@@ -27,6 +27,12 @@
//define the voicemail class
class voicemail {
/**
* declare constant variables
*/
const app_name = 'voicemail';
const app_uuid = 'b523c2d2-64cd-46f1-9520-ca4b4098e044';
/**
* declare public variables
*/
@@ -44,8 +50,6 @@
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $permission_prefix;
private $list_page;
private $table;
@@ -68,43 +72,41 @@
public function __construct(array $params = []) {
//set the domain_uuid if not provided
if (!empty($params['domain_uuid']) && is_uuid($params['domain_uuid'])) {
$this->domain_uuid = $params['domain_uuid'];
} else {
$this->domain_uuid = $_SESSION['domain_uuid'] ?? '';
}
if (!empty($params['domain_uuid']) && is_uuid($params['domain_uuid'])) {
$this->domain_uuid = $params['domain_uuid'];
} else {
$this->domain_uuid = $_SESSION['domain_uuid'] ?? '';
}
//set the user_uuid if not provided
if (!empty($params['user_uuid']) && is_uuid($params['user_uuid'])) {
$this->user_uuid = $params['user_uuid'];
} else {
$this->user_uuid = $_SESSION['user_uuid'] ?? '';
}
if (!empty($params['user_uuid']) && is_uuid($params['user_uuid'])) {
$this->user_uuid = $params['user_uuid'];
} else {
$this->user_uuid = $_SESSION['user_uuid'] ?? '';
}
//database connection
if (empty($params['database'])) {
$this->database = database::new();
} else {
$this->database = $params['database'];
}
if (empty($params['database'])) {
$this->database = database::new();
} else {
$this->database = $params['database'];
}
//assign the settings object
if (empty($params['settings'])) {
$this->settings = new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]);
}
else {
$this->settings = $params['settings'];
}
if (empty($params['settings'])) {
$this->settings = new settings(['database' => $this->database, 'domain_uuid' => $this->domain_uuid, 'user_uuid' => $this->user_uuid]);
}
else {
$this->settings = $params['settings'];
}
//assign private variables
$this->app_name = 'voicemail';
$this->app_uuid = 'b523c2d2-64cd-46f1-9520-ca4b4098e044';
$this->permission_prefix = 'voicemail_';
$this->list_page = 'voicemails.php';
$this->table = 'voicemails';
$this->uuid_prefix = 'voicemail_';
$this->toggle_field = 'voicemail_enabled';
$this->toggle_values = ['true','false'];
$this->permission_prefix = 'voicemail_';
$this->list_page = 'voicemails.php';
$this->table = 'voicemails';
$this->uuid_prefix = 'voicemail_';
$this->toggle_field = 'voicemail_enabled';
$this->toggle_values = ['true','false'];
}
@@ -430,8 +432,6 @@
$p->add('voicemail_greeting_delete', 'temp');
//execute delete
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->delete($array);
unset($array);
@@ -492,8 +492,6 @@
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->delete($array);
unset($array);
}
@@ -542,8 +540,6 @@
$p->add('voicemail_destination_delete', 'temp');
//execute delete
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->delete($array);
unset($array);
@@ -618,8 +614,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->save($array);
unset($array);
@@ -713,8 +708,6 @@
$p->add('voicemail_message_delete', 'temp');
//execute delete
$this->database->app_name = $this->app_name;
$this->database->app_name = $this->app_uuid;
$this->database->delete($array);
unset($array);
@@ -751,8 +744,6 @@
$p->add('voicemail_message_edit', 'temp');
//execute update
$this->database->app_name = $this->app_name;
$this->database->app_name = $this->app_uuid;
$this->database->save($array);
unset($array);
@@ -995,8 +986,6 @@
$p->add('email_queue_attachment_add', 'temp');
//execute update
$this->database->app_name = $this->app_name;
$this->database->app_name = $this->app_uuid;
$this->database->save($array);
unset($array);
@@ -1099,8 +1088,6 @@
$p->add('voicemail_message_edit', 'temp');
//execute update
$this->database->app_name = $this->app_name;
$this->database->app_name = $this->app_uuid;
$this->database->save($array);
unset($array);
@@ -1139,8 +1126,6 @@
$p->add('voicemail_message_edit', 'temp');
//execute update
$this->database->app_name = $this->app_name;
$this->database->app_name = $this->app_uuid;
$this->database->save($array);
unset($array);
@@ -1470,14 +1455,11 @@
//$table = self::TABLE;
$table = 'voicemail_messages';
//get a database connection
$database = $settings->database();
//get a list of domains
$domains = maintenance::get_domains($database);
$domains = maintenance::get_domains($this->database);
foreach ($domains as $domain_uuid => $domain_name) {
//get domain settings
$domain_settings = new settings(['database' => $database, 'domain_uuid' => $domain_uuid]);
$domain_settings = new settings(['database' => $this->database, 'domain_uuid' => $domain_uuid]);
//ensure we have a retention day
$retention_days = $domain_settings->get('voicemail', maintenance::DATABASE_SUBCATEGORY, '');
@@ -1485,12 +1467,12 @@
//clear out old records
$sql = "delete from v_{$table} WHERE to_timestamp(created_epoch) < NOW() - INTERVAL '{$retention_days} days'"
. " and domain_uuid = '{$domain_uuid}'";
$database->execute($sql);
$code = $database->message['code'] ?? 0;
if ($database->message['code'] == 200) {
$this->database->execute($sql);
$code = $this->database->message['code'] ?? 0;
if ($this->database->message['code'] == 200) {
maintenance_service::log_write(self::class, "Successfully removed entries older than $retention_days", $domain_uuid);
} else {
$message = $database->message['message'] ?? "An unknown error has occurred";
$message = $this->database->message['message'] ?? "An unknown error has occurred";
maintenance_service::log_write(self::class, "Unable to remove old database records. Error message: $message ($code)", $domain_uuid, maintenance_service::LOG_ERROR);
}
}

View File

@@ -29,6 +29,40 @@
*/
class xml_cdr {
/**
* declare constant variables
*/
const app_name = 'xml_cdr';
const app_uuid = '4a085c51-7635-ff03-f67b-86e834422848';
/**
* declare public variables
*/
public $array;
public $fields;
public $setting;
public $domain_uuid;
public $call_details;
public $call_direction;
public $status;
public $billsec;
public $recording_uuid;
public $binary;
/**
* user summary
*/
public $quick_select;
public $start_stamp_begin;
public $start_stamp_end;
public $include_internal;
public $extensions;
/**
* Used by read_files, xml_array, and save methods
*/
public $file;
/**
* Internal array structure that is populated from the database
* @var array Array of settings loaded from Default Settings
@@ -47,46 +81,20 @@
*/
private $destinations;
/**
* define variables
*/
public $array;
public $fields;
public $setting;
public $domain_uuid;
public $call_details;
public $call_direction;
public $status;
public $billsec;
private $username;
private $password;
private $json;
public $recording_uuid;
public $binary;
/**
* user summary
*/
public $quick_select;
public $start_stamp_begin;
public $start_stamp_end;
public $include_internal;
public $extensions;
/**
* delete method
*/
private $app_name;
private $app_uuid;
private $permission_prefix;
private $list_page;
private $table;
private $uuid_prefix;
/**
* Used by read_files, xml_array, and save methods
* additional private variables
*/
public $file;
private $username;
private $password;
private $json;
/**
* Called when the object is created
@@ -113,8 +121,6 @@
}
//assign private variables (for delete method)
$this->app_name = 'xml_cdr';
$this->app_uuid = '4a085c51-7635-ff03-f67b-86e834422848';
$this->permission_prefix = 'xml_cdr_';
$this->list_page = 'xml_cdr.php';
$this->table = 'xml_cdr';
@@ -2223,8 +2229,6 @@
$p->add('call_recording_delete', 'temp');
//execute delete
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->delete($array);
unset($array);
@@ -2287,35 +2291,32 @@
//set table name for query
$table = 'xml_cdr';
//get a database connection
$database = $settings->database();
//get a list of domains
$domains = maintenance::get_domains($database);
$domains = maintenance::get_domains($this->database);
foreach ($domains as $domain_uuid => $domain_name) {
//get domain settings
$domain_settings = new settings(['database' => $database, 'domain_uuid' => $domain_uuid]);
$domain_settings = new settings(['database' => $this->database, 'domain_uuid' => $domain_uuid]);
//get the retention days for xml cdr table using 'cdr' and 'database_retention_days'
$xml_cdr_retention_days = $domain_settings->get('cdr', 'database_retention_days', '');
//get the retention days for xml cdr flow table
if ($database->table_exists('xml_cdr_flow')) {
if ($this->database->table_exists('xml_cdr_flow')) {
$xml_cdr_flow_retention_days = $domain_settings->get('cdr', 'flow_database_retention_days', $xml_cdr_retention_days);
} else {
$xml_cdr_flow_retention_days = null;
}
//get the retention days for xml cdr json table
if ($database->table_exists('xml_cdr_json')) {
if ($this->database->table_exists('xml_cdr_json')) {
$xml_cdr_json_retention_days = $domain_settings->get('cdr', 'json_database_retention_days', $xml_cdr_retention_days);
} else {
$xml_cdr_json_retention_days = null;
}
//get the retention days for xml cdr logs table
if ($database->table_exists('xml_cdr_logs')) {
if ($this->database->table_exists('xml_cdr_logs')) {
$xml_cdr_logs_retention_days = $domain_settings->get('cdr', 'logs_database_retention_days', $xml_cdr_retention_days);
} else {
$xml_cdr_logs_retention_days = null;
@@ -2327,13 +2328,13 @@
//clear out old xml_cdr records
$sql = "delete from v_{$table} WHERE insert_date < NOW() - INTERVAL '{$xml_cdr_retention_days} days'"
. " and domain_uuid = '{$domain_uuid}'";
$database->execute($sql);
$code = $database->message['code'] ?? 0;
$this->database->execute($sql);
$code = $this->database->message['code'] ?? 0;
//record result
if ($code == 200) {
maintenance_service::log_write(self::class, "Successfully removed entries older than $xml_cdr_retention_days", $domain_uuid);
} else {
$message = $database->message['message'] ?? "An unknown error has occurred";
$message = $this->database->message['message'] ?? "An unknown error has occurred";
maintenance_service::log_write(self::class, "XML CDR " . "Unable to remove old database records. Error message: $message ($code)", $domain_uuid, maintenance_service::LOG_ERROR);
}
@@ -2341,13 +2342,13 @@
if (!empty($xml_cdr_flow_retention_days)) {
$sql = "delete from v_xml_cdr_flow WHERE insert_date < NOW() - INTERVAL '{$xml_cdr_flow_retention_days} days'"
. " and domain_uuid = '{$domain_uuid}";
$database->execute($sql);
$code = $database->message['code'] ?? 0;
$this->database->execute($sql);
$code = $this->database->message['code'] ?? 0;
//record result
if ($database->message['code'] == 200) {
if ($this->database->message['code'] == 200) {
maintenance_service::log_write(self::class, "Successfully removed XML CDR FLOW entries from $domain_name", $domain_uuid);
} else {
$message = $database->message['message'] ?? "An unknown error has occurred";
$message = $this->database->message['message'] ?? "An unknown error has occurred";
maintenance_service::log_write(self::class, "XML CDR FLOW " . "Unable to remove old database records. Error message: $message ($code)", $domain_uuid, maintenance_service::LOG_ERROR);
}
}
@@ -2356,13 +2357,13 @@
if (!empty($xml_cdr_json_retention_days)) {
$sql = "DELETE FROM v_xml_cdr_json WHERE insert_date < NOW() - INTERVAL '{$xml_cdr_json_retention_days} days'"
. " and domain_uuid = '{$domain_uuid}";
$database->execute($sql);
$code = $database->message['code'] ?? 0;
$this->database->execute($sql);
$code = $this->database->message['code'] ?? 0;
//record result
if ($database->message['code'] == 200) {
if ($this->database->message['code'] == 200) {
maintenance_service::log_write(self::class, "Successfully removed XML CDR JSON entries from $domain_name", $domain_uuid);
} else {
$message = $database->message['message'] ?? "An unknown error has occurred";
$message = $this->database->message['message'] ?? "An unknown error has occurred";
maintenance_service::log_write(self::class, "XML CDR JSON " . "Unable to remove old database records. Error message: $message ($code)", $domain_uuid, maintenance_service::LOG_ERROR);
}
}
@@ -2371,13 +2372,13 @@
if (!empty($xml_cdr_logs_retention_days)) {
$sql = "DELETE FROM v_xml_cdr_logs WHERE insert_date < NOW() - INTERVAL '{$xml_cdr_logs_retention_days} days'"
. " and domain_uuid = '{$domain_uuid}'";
$database->execute($sql);
$code = $database->message['code'] ?? 0;
$this->database->execute($sql);
$code = $this->database->message['code'] ?? 0;
//record result
if ($database->message['code'] === 200) {
if ($this->database->message['code'] === 200) {
maintenance_service::log_write(self::class, "Successfully removed XML CDR LOG entries from $domain_name", $domain_uuid);
} else {
$message = $database->message['message'] ?? "An unknown error has occurred";
$message = $this->database->message['message'] ?? "An unknown error has occurred";
maintenance_service::log_write(self::class, "XML CDR LOG " . "Unable to remove old database records. Error message: $message ($code)", $domain_uuid, maintenance_service::LOG_ERROR);
}
}

View File

@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2024
Portions created by the Initial Developer are Copyright (C) 2008-2025
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -30,7 +30,7 @@
class plugin_email {
/**
* Define variables and their scope
* Declare public variables
*/
public $domain_name;
public $domain_uuid;
@@ -41,6 +41,16 @@ class plugin_email {
public $contact_uuid;
public $debug;
/**
* Called when the object is created
*/
public function __construct() {
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
* time based one time password with email
* @return array [authorized] => true or false
@@ -126,8 +136,7 @@ class plugin_email {
}
$sql .= "and (user_type = 'default' or user_type is null) ";
$parameters['username'] = $_REQUEST['username'];
$database = new database;
$row = $database->select($sql, $parameters, 'row');
$row = $this->database->select($sql, $parameters, 'row');
unset($parameters);
//set class variables
@@ -198,7 +207,7 @@ class plugin_email {
//$sql .= "where user_uuid = :user_uuid;";
//$parameters['auth_code'] = $auth_code_hash;
//$parameters['user_uuid'] = $this->user_uuid;
//$database->execute($sql, $parameters);
//$this->database->execute($sql, $parameters);
//unset($sql);
//email settings
@@ -228,8 +237,7 @@ class plugin_email {
$parameters['template_category'] = 'authentication';
$parameters['template_subcategory'] = 'email';
$parameters['template_type'] = 'html';
$database = new database;
$row = $database->select($sql, $parameters, 'row');
$row = $this->database->select($sql, $parameters, 'row');
$email_subject = $row['template_subject'];
$email_body = $row['template_body'];
unset($sql, $parameters, $row);
@@ -273,11 +281,8 @@ class plugin_email {
$array['email_queue'][0]["email_uuid"] = $email_uuid;
$array['email_queue'][0]["email_action_before"] = null;
$array['email_queue'][0]["email_action_after"] = null;
$database = new database;
$database->app_name = 'email queue';
$database->app_uuid = '5befdf60-a242-445f-91b3-2e9ee3e0ddf7';
$database->save($array);
$err = $database->message;
$this->database->save($array);
$err = $this->database->message;
unset($array);
//remove the temporary permission
@@ -378,8 +383,7 @@ class plugin_email {
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
}
$parameters['username'] = $_SESSION["username"];
$database = new database;
$row = $database->select($sql, $parameters, 'row');
$row = $this->database->select($sql, $parameters, 'row');
$this->user_uuid = $row['user_uuid'];
$this->user_email = $row['user_email'];
$this->contact_uuid = $row['contact_uuid'];
@@ -433,8 +437,7 @@ class plugin_email {
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
}
$parameters['user_uuid'] = $_SESSION["user_uuid"];
$database = new database;
$row = $database->select($sql, $parameters, 'row');
$row = $this->database->select($sql, $parameters, 'row');
unset($parameters);
//set a few session variables
@@ -479,8 +482,7 @@ class plugin_email {
$parameters['domain_uuid'] = $this->domain_uuid;
$parameters['user_uuid'] = $this->user_uuid;
$parameters['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
$database = new database;
$user_log_count = $database->select($sql, $parameters, 'all');
$user_log_count = $this->database->select($sql, $parameters, 'all');
//view_array($user_log_count);
unset($sql, $parameters);
*/

View File

@@ -8,7 +8,7 @@
class plugin_ldap {
/**
* Define variables and their scope
* Declare public variables
*/
public $debug;
public $domain_name;
@@ -17,6 +17,16 @@ class plugin_ldap {
public $user_uuid;
public $contact_uuid;
/**
* Called when the object is created
*/
public function __construct() {
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
* ldap checks a local or remote ldap database to authenticate the user
* @return array [authorized] => true or false
@@ -132,8 +142,7 @@ class plugin_ldap {
}
$sql .= "and (user_type = 'default' or user_type is null) ";
$parameters['username'] = $this->username;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
$row = $this->database->select($sql, $parameters, 'row');
if (is_array($row) && @sizeof($row) != 0) {
if ($settings['users']['unique'] == "global" && $row["domain_uuid"] != $this->domain_uuid) {
//get the domain uuid
@@ -183,10 +192,7 @@ class plugin_ldap {
$p->add('user_group_add', 'temp');
//execute insert
$database = new database;
$database->app_name = 'authentication';
$database->app_uuid = 'a8a12918-69a4-4ece-a1ae-3932be0e41f1';
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions

View File

@@ -43,6 +43,16 @@ class plugin_totp {
public $contact_uuid;
private $user_totp_secret;
/**
* Called when the object is created
*/
public function __construct() {
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
* time based one time password aka totp
* @return array [authorized] => true or false
@@ -144,8 +154,7 @@ class plugin_totp {
}
$sql .= "and (user_type = 'default' or user_type is null) ";
$parameters['username'] = $this->username;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
$row = $this->database->select($sql, $parameters, 'row');
if (empty($row) || !is_array($row) || @sizeof($row) == 0) {
//clear submitted usernames
unset($this->username, $_SESSION['username'], $_REQUEST['username'], $_POST['username']);
@@ -228,10 +237,7 @@ class plugin_totp {
$p->add("user_edit", "temp");
//save the data
$database = new database;
$database->app_name = 'users';
$database->app_uuid = '112124b3-95c2-5352-7e9d-d14c0b88f207';
$database->save($array);
$this->database->save($array);
//remove the temporary permission
$p->delete("user_edit", "temp");
@@ -305,8 +311,7 @@ class plugin_totp {
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
}
$parameters['username'] = $_SESSION["username"];
$database = new database;
$row = $database->select($sql, $parameters, 'row');
$row = $this->database->select($sql, $parameters, 'row');
$this->user_uuid = $row['user_uuid'];
$this->user_email = $row['user_email'];
$this->contact_uuid = $row['contact_uuid'];
@@ -359,8 +364,7 @@ class plugin_totp {
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
}
$parameters['user_uuid'] = $_SESSION["user_uuid"];
$database = new database;
$row = $database->select($sql, $parameters, 'row');
$row = $this->database->select($sql, $parameters, 'row');
unset($parameters);
}
else {
@@ -399,8 +403,7 @@ class plugin_totp {
$parameters['domain_uuid'] = $this->domain_uuid;
$parameters['user_uuid'] = $this->user_uuid;
$parameters['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
$database = new database;
$user_log_count = $database->select($sql, $parameters, 'all');
$user_log_count = $this->database->select($sql, $parameters, 'all');
//view_array($user_log_count);
unset($sql, $parameters);
*/

View File

@@ -27,13 +27,17 @@
//define the contacts class
class contacts {
const APP_NAME = "contacts";
const APP_UUID = "04481e0e-a478-c559-adad-52bd4174574c";
/**
* declare constant variables
*/
const app_name = 'contacts';
const app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $tables;
@@ -50,23 +54,26 @@
public function __construct() {
//assign private variables
$this->app_name = self::APP_NAME;
$this->app_uuid = self::APP_UUID;
$this->permission_prefix = 'contact_';
$this->list_page = 'contacts.php';
$this->tables[] = 'contact_addresses';
$this->tables[] = 'contact_attachments';
$this->tables[] = 'contact_emails';
$this->tables[] = 'contact_groups';
$this->tables[] = 'contact_notes';
$this->tables[] = 'contact_phones';
$this->tables[] = 'contact_relations';
$this->tables[] = 'contact_settings';
$this->tables[] = 'contact_times';
$this->tables[] = 'contact_urls';
$this->tables[] = 'contact_users';
$this->tables[] = 'contacts';
$this->uuid_prefix = 'contact_';
$this->permission_prefix = 'contact_';
$this->list_page = 'contacts.php';
$this->tables[] = 'contact_addresses';
$this->tables[] = 'contact_attachments';
$this->tables[] = 'contact_emails';
$this->tables[] = 'contact_groups';
$this->tables[] = 'contact_notes';
$this->tables[] = 'contact_phones';
$this->tables[] = 'contact_relations';
$this->tables[] = 'contact_settings';
$this->tables[] = 'contact_times';
$this->tables[] = 'contact_urls';
$this->tables[] = 'contact_users';
$this->tables[] = 'contacts';
$this->uuid_prefix = 'contact_';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
@@ -108,20 +115,15 @@
//grant temp permissions
$p = permissions::new();
$database = new database;
foreach ($this->tables as $table) {
$p->add(database::singular($table).'_delete', 'temp');
}
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temp permissions
$database = new database;
foreach ($this->tables as $table) {
$p->delete(database::singular($table).'_delete', 'temp');
}
@@ -153,7 +155,6 @@
//check permissions and build the delete array
$x = 0;
foreach ($records as $property_name => $properties) {
$database = new database;
if (permission_exists(database::singular($property_name).'_delete')) {
if (is_array($properties) && @sizeof($properties) != 0) {
foreach ($properties as $property) {
@@ -171,11 +172,8 @@
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
unset($array);
$this->database->delete($array);
unset($array);
}
unset($records);
}
@@ -217,10 +215,7 @@
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
}
unset($records);
@@ -264,11 +259,8 @@
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
unset($array);
$this->database->delete($array);
unset($array);
}
unset($records);
}

View File

@@ -29,11 +29,16 @@
*/
class dashboard {
/**
* declare constant variables
*/
const app_name = 'dashboard';
const app_uuid = '55533bef-4f04-434a-92af-999c1e9927f7';
/**
* declare the variables
*/
private $app_name;
private $app_uuid;
private $database;
private $name;
private $table;
private $tables;
@@ -48,16 +53,19 @@
*/
public function __construct() {
//assign the variables
$this->app_name = 'dashboard';
$this->app_uuid = '55533bef-4f04-434a-92af-999c1e9927f7';
$this->tables[] = 'dashboards';
$this->tables[] = 'dashboard_widgets';
$this->tables[] = 'dashboard_widget_groups';
$this->toggle_field = 'dashboard_enabled';
$this->toggle_values = ['true','false'];
$this->description_field = 'dashboard_description';
$this->location = 'dashboard.php';
$this->uuid_prefix = 'dashboard_';
$this->tables[] = 'dashboards';
$this->tables[] = 'dashboard_widgets';
$this->tables[] = 'dashboard_widget_groups';
$this->toggle_field = 'dashboard_enabled';
$this->toggle_values = ['true','false'];
$this->description_field = 'dashboard_description';
$this->location = 'dashboard.php';
$this->uuid_prefix = 'dashboard_';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
@@ -101,20 +109,15 @@
//grant temp permissions
$p = permissions::new();
$database = new database;
foreach ($this->tables as $table) {
$p->add(database::singular($table).'_delete', 'temp');
}
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temp permissions
$database = new database;
foreach ($this->tables as $table) {
$p->delete(database::singular($table).'_delete', 'temp');
}
@@ -160,8 +163,7 @@
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters ?? null, 'all');
$rows = $this->database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -184,10 +186,8 @@
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
@@ -234,8 +234,7 @@
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select * from v_".$this->table." ";
$sql .= "where dashboard_uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters ?? null, 'all');
$rows = $this->database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$x = 0;
foreach ($rows as $row) {
@@ -256,10 +255,8 @@
//save the changes and set the message
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
@@ -307,10 +304,7 @@
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//set message
@@ -352,8 +346,7 @@
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters ?? null, 'all');
$rows = $this->database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -376,10 +369,8 @@
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
@@ -417,8 +408,7 @@
$sql = "select group_name, group_uuid from v_groups ";
$sql .= "where group_uuid = :group_uuid ";
$parameters['group_uuid'] = $group_uuid;
$database = new database;
$group = $database->select($sql, $parameters, 'row');
$group = $this->database->select($sql, $parameters, 'row');
}
//build the delete array
@@ -443,8 +433,7 @@
if (!empty($array) && @sizeof($array) != 0) {
$sql = "select dashboard_uuid, ".$this->name."_uuid, ";
$sql .= "group_uuid from v_".$this->name."_groups ";
$database = new database;
$dashboard_widget_groups = $database->select($sql, null, 'all');
$dashboard_widget_groups = $this->database->select($sql, null, 'all');
$array[$this->name.'_groups'] = array_filter($array[$this->name.'_groups'], function($ar) use ($dashboard_widget_groups) {
foreach ($dashboard_widget_groups as $existing_array_item) {
if ($ar['dashboard_uuid'] == $existing_array_item['dashboard_uuid'] && $ar[$this->name.'_uuid'] == $existing_array_item[$this->name.'_uuid'] && $ar['group_uuid'] == $existing_array_item['group_uuid']) {
@@ -459,10 +448,8 @@
//add the checked rows from group
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//execute save
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
message::add($text['message-add']);
@@ -498,8 +485,7 @@
$sql = "select group_name, group_uuid from v_groups ";
$sql .= "where group_uuid = :group_uuid ";
$parameters['group_uuid'] = $group_uuid;
$database = new database;
$group = $database->select($sql, $parameters, 'row');
$group = $this->database->select($sql, $parameters, 'row');
}
//build the delete array
@@ -523,8 +509,7 @@
if (!empty($uuids) && @sizeof($uuids) != 0) {
$sql = "select dashboard_uuid, ".$this->name."_uuid from v_".$this->table." ";
$sql .= "where ".$this->name."_parent_uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, null, 'all');
$rows = $this->database->select($sql, null, 'all');
if (!empty($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
//assign dashboard widget groups
@@ -546,10 +531,7 @@
$p->add('dashboard_widget_group_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions

View File

@@ -27,11 +27,17 @@
//define the databases class
class databases {
/**
* declare constant variables
*/
const app_name = 'databases';
const app_uuid = '8d229b6d-1383-fcec-74c6-4ce1682479e2';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -43,12 +49,15 @@
public function __construct() {
//assign private variables
$this->app_name = 'databases';
$this->app_uuid = '8d229b6d-1383-fcec-74c6-4ce1682479e2';
$this->permission_prefix = 'database_';
$this->list_page = 'databases.php';
$this->table = 'databases';
$this->uuid_prefix = 'database_';
$this->permission_prefix = 'database_';
$this->list_page = 'databases.php';
$this->table = 'databases';
$this->uuid_prefix = 'database_';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
@@ -84,10 +93,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//set message
@@ -130,8 +136,7 @@
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select * from v_".$this->table." ";
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters ?? null, 'all');
$rows = $this->database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $x => $row) {
@@ -151,10 +156,8 @@
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message

View File

@@ -30,10 +30,15 @@
class default_settings {
/**
* declare the variables
* declare constant variables
*/
const app_name = 'default_settings';
const app_uuid = '2c2453c0-1bea-4475-9f44-4d969650de09';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $name;
private $table;
private $toggle_field;
@@ -46,13 +51,16 @@
*/
public function __construct() {
//assign the variables
$this->app_name = 'default_settings';
$this->app_uuid = '2c2453c0-1bea-4475-9f44-4d969650de09';
$this->name = 'default_setting';
$this->table = 'default_settings';
$this->toggle_field = 'default_setting_enabled';
$this->toggle_values = ['true','false'];
$this->location = 'default_settings.php';
$this->name = 'default_setting';
$this->table = 'default_settings';
$this->toggle_field = 'default_setting_enabled';
$this->toggle_values = ['true','false'];
$this->location = 'default_settings.php';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
@@ -90,10 +98,7 @@
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//set message
@@ -133,8 +138,7 @@
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters ?? null, 'all');
$rows = $this->database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -157,10 +161,8 @@
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
@@ -208,8 +210,7 @@
$sql = "select * from v_default_settings ";
$sql .= "where default_setting_uuid = :default_setting_uuid ";
$parameters['default_setting_uuid'] = $uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
$row = $this->database->select($sql, $parameters, 'row');
if (is_array($row) && sizeof($row) != 0) {
$default_setting_category = $row["default_setting_category"];
$default_setting_subcategory = $row["default_setting_subcategory"];
@@ -241,9 +242,8 @@
$parameters['domain_setting_category'] = $default_setting_category;
$parameters['domain_setting_subcategory'] = $default_setting_subcategory;
$parameters['domain_setting_name'] = $default_setting_name;
$database = new database;
$target_domain_setting_uuid = $database->select($sql, $parameters, 'column');
$message = $database->message;
$target_domain_setting_uuid = $this->database->select($sql, $parameters, 'column');
$message = $this->database->message;
$action = is_uuid($target_domain_setting_uuid) ? 'update' : 'add';
unset($sql, $parameters);
@@ -272,11 +272,8 @@
//execute
if (is_uuid($array['domain_settings'][$x]['domain_setting_uuid'])) {
$database = new database;
$database->app_name = $this->table;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$message = $database->message;
$this->database->save($array);
$message = $this->database->message;
unset($array);
$settings_copied++;
@@ -298,11 +295,8 @@
unset($array['default_settings'][$x]['update_user']);
//execute
$database = new database;
$database->app_name = $this->table;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$message = $database->message;
$this->database->save($array);
$message = $this->database->message;
unset($array);
$settings_copied++;

View File

@@ -27,11 +27,17 @@
//define the domain settings class
class domain_settings {
/**
* declare constant variables
*/
const app_name = 'domain_settings';
const app_uuid = 'b31e723a-bf70-670c-a49b-470d2a232f71';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -51,15 +57,17 @@
public function __construct() {
//assign private variables
$this->app_name = 'domain_settings';
$this->app_uuid = 'b31e723a-bf70-670c-a49b-470d2a232f71';
$this->permission_prefix = 'domain_setting_';
$this->list_page = PROJECT_PATH."/core/domains/domain_edit.php?id=".urlencode($this->domain_uuid ?? '');
$this->table = 'domain_settings';
$this->uuid_prefix = 'domain_setting_';
$this->toggle_field = 'domain_setting_enabled';
$this->toggle_values = ['true','false'];
$this->permission_prefix = 'domain_setting_';
$this->list_page = PROJECT_PATH."/core/domains/domain_edit.php?id=".urlencode($this->domain_uuid ?? '');
$this->table = 'domain_settings';
$this->uuid_prefix = 'domain_setting_';
$this->toggle_field = 'domain_setting_enabled';
$this->toggle_values = ['true','false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
@@ -95,10 +103,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//set message
@@ -141,8 +146,7 @@
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $this->domain_uuid;
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -165,10 +169,8 @@
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
@@ -220,8 +222,7 @@
$sql = "select * from v_domain_settings ";
$sql .= "where domain_setting_uuid = :domain_setting_uuid ";
$parameters['domain_setting_uuid'] = $uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
$row = $this->database->select($sql, $parameters, 'row');
if (is_array($row) && sizeof($row) != 0) {
$domain_setting_category = $row["domain_setting_category"];
$domain_setting_subcategory = $row["domain_setting_subcategory"];
@@ -250,8 +251,7 @@
$parameters['domain_setting_category'] = $domain_setting_category;
$parameters['domain_setting_subcategory'] = $domain_setting_subcategory;
$parameters['domain_setting_name'] = $domain_setting_name;
$database = new database;
$target_domain_setting_uuid = $database->select($sql, $parameters, 'column');
$target_domain_setting_uuid = $this->database->select($sql, $parameters, 'column');
$action = is_uuid($target_domain_setting_uuid) ? 'update' : 'add';
unset($sql, $parameters);
@@ -285,10 +285,9 @@
//execute
if (is_uuid($array['domain_settings'][0]['domain_setting_uuid'])) {
$database = new database;
$database->app_name = 'domain_settings';
$database->app_uuid = 'b31e723a-bf70-670c-a49b-470d2a232f71';
$database->save($array);
$this->database->app_name = 'domain_settings';
$this->database->app_uuid = 'b31e723a-bf70-670c-a49b-470d2a232f71';
$this->database->save($array);
unset($array);
$settings_copied++;
@@ -305,8 +304,7 @@
$sql = "select * from v_domain_settings ";
$sql .= "where domain_setting_uuid = :domain_setting_uuid ";
$parameters['domain_setting_uuid'] = $uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
$row = $this->database->select($sql, $parameters, 'row');
if (is_array($row) && sizeof($row) != 0) {
$domain_setting_category = $row["domain_setting_category"];
$domain_setting_subcategory = $row["domain_setting_subcategory"];
@@ -332,8 +330,7 @@
$parameters['default_setting_category'] = $domain_setting_category;
$parameters['default_setting_subcategory'] = $domain_setting_subcategory;
$parameters['default_setting_name'] = $domain_setting_name;
$database = new database;
$target_default_setting_uuid = $database->select($sql, $parameters, 'column');
$target_default_setting_uuid = $this->database->select($sql, $parameters, 'column');
$action = is_uuid($target_default_setting_uuid) ? 'update' : 'add';
unset($sql, $parameters);
@@ -361,10 +358,9 @@
//execute
if (is_uuid($array['default_settings'][0]['default_setting_uuid'])) {
$database = new database;
$database->app_name = 'domain_settings';
$database->app_uuid = 'b31e723a-bf70-670c-a49b-470d2a232f71';
$database->save($array);
$this->database->app_name = 'domain_settings';
$this->database->app_uuid = 'b31e723a-bf70-670c-a49b-470d2a232f71';
$this->database->save($array);
unset($array);
$settings_copied++;

View File

@@ -27,11 +27,17 @@
//define the email templates class
class email_templates {
/**
* declare constant variables
*/
const app_name = 'email_templates';
const app_uuid = '8173e738-2523-46d5-8943-13883befd2fd';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -45,14 +51,17 @@
public function __construct() {
//assign private variables
$this->app_name = 'email_templates';
$this->app_uuid = '8173e738-2523-46d5-8943-13883befd2fd';
$this->permission_prefix = 'email_template_';
$this->list_page = 'email_templates.php';
$this->table = 'email_templates';
$this->uuid_prefix = 'email_template_';
$this->toggle_field = 'template_enabled';
$this->toggle_values = ['true','false'];
$this->permission_prefix = 'email_template_';
$this->list_page = 'email_templates.php';
$this->table = 'email_templates';
$this->uuid_prefix = 'email_template_';
$this->toggle_field = 'template_enabled';
$this->toggle_values = ['true','false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
@@ -88,10 +97,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//set message
@@ -134,8 +140,7 @@
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -156,10 +161,8 @@
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
@@ -205,8 +208,7 @@
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $x => $row) {
@@ -226,10 +228,8 @@
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message

View File

@@ -27,6 +27,29 @@
//define the permission class
class permission {
/**
* declare constant variables
*/
const app_name = 'groups';
const app_uuid = '2caf27b0-540a-43d5-bb9b-c9871a1e4f84';
/**
* declare private variables
*/
private $database;
/**
* called when the object is created
*/
public function __construct() {
//assign the database
if (empty($this->database)) {
$this->database = database::new();
}
}
//delete the permissions
function delete() {
@@ -67,8 +90,7 @@
$sql .= " and group_name in (".$group_names.") ";
$sql .= ")";
$sql .= "and (permission_protected <> 'true' or permission_protected is null)";
$database = new database;
$result = $database->select($sql);
$result = $this->database->select($sql);
//get the group_permissons
/*
@@ -79,8 +101,7 @@
$sql .= " where group_protected <> true ";
$sql .= " and group_name in (".$group_names.") ";
$sql .= ");";
$database = new database;
$group_permissions = $database->select($sql, null, 'all');
$group_permissions = $this->database->select($sql, null, 'all');
*/
//delete unprotected group permissions
@@ -98,10 +119,7 @@
$p = permissions::new();
$p->add('group_permission_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = 'groups';
$database->app_uuid = '2caf27b0-540a-43d5-bb9b-c9871a1e4f84';
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions
$p->delete('group_permission_delete', 'temp');
@@ -116,16 +134,14 @@
//if the are no groups add the default groups
$sql = "select * from v_groups ";
$sql .= "where domain_uuid is null ";
$database = new database;
$groups = $database->select($sql, null, 'all');
$groups = $this->database->select($sql, null, 'all');
//delete the group permissions
$this->delete();
//get the remaining group permissions
$sql = "select permission_name, group_name from v_group_permissions ";
$database = new database;
$database_group_permissions = $database->select($sql, null, 'all');
$this->database_group_permissions = $this->database->select($sql, null, 'all');
//get the $apps array from the installed apps from the core and mod directories
$config_list = glob($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/*/*/app_config.php");
@@ -158,7 +174,7 @@
if (!$group_protected) {
// check if the item is not currently in the database
$exists = false;
foreach ($database_group_permissions as $i => $group_permission) {
foreach ($this->database_group_permissions as $i => $group_permission) {
if ($group_permission['permission_name'] == $permission['name']) {
if ($group_permission['group_name'] == $group_name) {
$exists = true;
@@ -189,10 +205,7 @@
$p->add('group_permission_add', 'temp');
//execute insert
$database = new database;
$database->app_name = 'groups';
$database->app_uuid = '2caf27b0-540a-43d5-bb9b-c9871a1e4f84';
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions

View File

@@ -3,10 +3,14 @@
class install {
/**
* declare the variables
*/
private $app_name;
private $app_uuid;
* declare constant variables
*/
const app_name = 'install';
const app_uuid = '75507e6e-891e-11e5-af63-feff819cdc9f';
/**
* declare public variables
*/
public $message;
public $database_host;
public $database_port;
@@ -18,9 +22,7 @@
* called when the object is created
*/
public function __construct() {
//assign the variables
$this->app_name = 'install';
$this->app_uuid = '75507e6e-891e-11e5-af63-feff819cdc9f';
}
/**

View File

@@ -30,10 +30,15 @@
class user_logs {
/**
* declare the variables
*/
private $app_name;
private $app_uuid;
* declare constant variables
*/
const app_name = 'user_logs';
const app_uuid = '582a13cf-7d75-4ea3-b2d9-60914352d76e';
/**
* declare private variables
*/
private $database;
private $name;
private $table;
private $toggle_field;
@@ -45,13 +50,16 @@
*/
public function __construct() {
//assign the variables
$this->app_name = 'user_logs';
$this->app_uuid = '582a13cf-7d75-4ea3-b2d9-60914352d76e';
$this->name = 'user_log';
$this->table = 'user_logs';
$this->toggle_field = '';
$this->toggle_values = ['true','false'];
$this->location = 'user_logs.php';
$this->name = 'user_log';
$this->table = 'user_logs';
$this->toggle_field = '';
$this->toggle_values = ['true','false'];
$this->location = 'user_logs.php';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
@@ -59,6 +67,9 @@
*/
public static function add($result, $details = '') {
//create the database object
$database = database::new();
//prepare the array
$array = [];
$array['user_logs'][0]["timestamp"] = 'now()';
@@ -84,11 +95,6 @@
$p->add("user_log_add", 'temp');
//save to the data
$database = new database;
$database->app_name = 'authentication';
$database->app_uuid = 'a8a12918-69a4-4ece-a1ae-3932be0e41f1';
if (strlen($user_log_uuid ?? '')>0)
$database->uuid($user_log_uuid);
$database->save($array, false);
$message = $database->message;
@@ -132,10 +138,7 @@
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//set message

View File

@@ -27,11 +27,17 @@
//define the user settings class
class user_settings {
/**
* declare constant variables
*/
const app_name = 'user_settings';
const app_uuid = '3a3337f7-78d1-23e3-0cfd-f14499b8ed97';
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -50,15 +56,17 @@
public function __construct() {
//assign private variables
$this->app_name = 'user_settings';
$this->app_uuid = '3a3337f7-78d1-23e3-0cfd-f14499b8ed97';
$this->permission_prefix = 'user_setting_';
$this->list_page = PROJECT_PATH."/core/user/user_edit.php?id=".urlencode($this->user_uuid ?? '');
$this->table = 'user_settings';
$this->uuid_prefix = 'user_setting_';
$this->toggle_field = 'user_setting_enabled';
$this->toggle_values = ['true','false'];
$this->permission_prefix = 'user_setting_';
$this->list_page = PROJECT_PATH."/core/user/user_edit.php?id=".urlencode($this->user_uuid ?? '');
$this->table = 'user_settings';
$this->uuid_prefix = 'user_setting_';
$this->toggle_field = 'user_setting_enabled';
$this->toggle_values = ['true','false'];
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
@@ -94,10 +102,7 @@
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//set message
@@ -140,8 +145,7 @@
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -164,10 +168,8 @@
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message

View File

@@ -29,11 +29,18 @@
*/
class users {
/**
* declare constant variables
*/
const app_name = 'users';
const app_uuid = '112124b3-95c2-5352-7e9d-d14c0b88f207';
/**
* declare the variables
*/
private $app_name;
private $app_uuid;
private $database;
private $name;
private $table;
private $toggle_field;
@@ -45,13 +52,16 @@
*/
public function __construct() {
//assign the variables
$this->app_name = 'users';
$this->app_uuid = '112124b3-95c2-5352-7e9d-d14c0b88f207';
$this->name = 'user';
$this->table = 'users';
$this->toggle_field = 'user_enabled';
$this->toggle_values = ['true','false'];
$this->location = 'users.php';
$this->name = 'user';
$this->table = 'users';
$this->toggle_field = 'user_enabled';
$this->toggle_values = ['true','false'];
$this->location = 'users.php';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
@@ -87,8 +97,7 @@
$sql = "select domain_uuid from v_users ";
$sql .= "where user_uuid = :user_uuid ";
$parameters['user_uuid'] = $user_uuid;
$database = new database;
$domain_uuid = $database->select($sql, $parameters, 'column');
$domain_uuid = $this->database->select($sql, $parameters, 'column');
unset($sql, $parameters);
}
else {
@@ -130,10 +139,7 @@
$p->add('user_group_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
$p->delete('user_setting_delete', 'temp');
@@ -176,8 +182,7 @@
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters ?? null, 'all');
$rows = $this->database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
@@ -200,10 +205,8 @@
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
@@ -246,8 +249,7 @@
if (!empty($uuids) && is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select * from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters ?? null, 'all');
$rows = $this->database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$x = 0;
foreach ($rows as $row) {
@@ -268,10 +270,8 @@
//save the changes and set the message
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
@@ -288,20 +288,20 @@
* @return void
*/
public static function database_maintenance(settings $settings): void {
$database = $settings->database();
$domains = maintenance_service::get_domains($database);
$this->database = $settings->database();
$domains = maintenance_service::get_domains($this->database);
foreach ($domains as $domain_uuid => $domain_name) {
$domain_settings = new settings(['database' => $database, 'domain_uuid' => $domain_uuid]);
$domain_settings = new settings(['database' => $this->database, 'domain_uuid' => $domain_uuid]);
$retention_days = $domain_settings->get('users', 'database_retention_days', '');
if (!empty($retention_days) && is_numeric($retention_days)) {
$sql = "delete from v_user_logs where timestamp < NOW() - INTERVAL '$retention_days days'";
$sql.= " and domain_uuid = '$domain_uuid'";
$database->execute($sql);
$code = $database->message['code'] ?? 0;
$this->database->execute($sql);
$code = $this->database->message['code'] ?? 0;
if ($code == 200) {
maintenance_service::log_write(self::class, "Successfully removed entries older than $retention_days", $domain_uuid);
} else {
$message = $database->message['message'] ?? "An unknown error has occurred";
$message = $this->database->message['message'] ?? "An unknown error has occurred";
maintenance_service::log_write(self::class, "Unable to remove old database records. Error message: $message ($code)", $domain_uuid, maintenance_service::LOG_ERROR);
}
} else {

View File

@@ -1291,6 +1291,14 @@ class database {
$x = 0;
foreach ($array as $parent_name => $tables) {
if (is_array($tables)) {
//get the application name and uuid
if (class_exists($parent_name) && defined("$parent_name::$app_name")) {
$this->app_name = $parent_name::app_name;
$this->app_uuid = $parent_name::app_uuid;
}
//process the array
foreach ($tables as $id => $row) {
//prepare the variables
@@ -1454,7 +1462,13 @@ class database {
//delete the current data
foreach($new_array as $table_name => $rows) {
//echo "table: ".$table_name."\n";
//get the application name and uuid
if (class_exists($parent_name)) {
$this->app_name = $table_name::app_name;
$this->app_uuid = $table_name::app_uuid;
}
//build and run the delete SQL statements
foreach($rows as $row) {
if (permission_exists(self::singular($table_name).'_delete')) {
$sql = "delete from ".self::TABLE_PREFIX.$table_name." ";
@@ -2228,7 +2242,7 @@ class database {
/**
* <p>Save an array to the database.</p>
* <p>Usage Example:<br><code>$database = new database();<br>$database->app_name = "MyApp";<br>$database->app_uuid = "12345678-1234-1234-1234-123456789abc";<br>$row = 0;<br>$array['mytable'][$row]['mycolumn'] = "myvalue";<br>if ($database->save($array)) { <br>&nbsp;&nbsp;echo "Saved Successfully.";<br> } else {<br>&nbsp;&nbsp;echo "Save Failed.";<br>}</code></p>
* <p>Usage Example:<br><code><br>$row = 0;<br>$array['mytable'][$row]['mycolumn'] = "myvalue";<br>if ($database->save($array)) { <br>&nbsp;&nbsp;echo "Saved Successfully.";<br> } else {<br>&nbsp;&nbsp;echo "Save Failed.";<br>}</code></p>
* @param array $array Three dimensional Array. The first dimension is the table name without the prefix 'v_'. Second dimension in the row value as int. Third dimension is the column name.
* @param bool $transaction_save
* @return returns and array wih result details
@@ -2273,6 +2287,13 @@ class database {
//loop through the array
if (is_array($array)) foreach ($array as $parent_name => $parent_array) {
//get the application name and uuid
if (class_exists($parent_name) && defined("$parent_name::$app_name")) {
$this->app_name = $parent_name::app_name;
$this->app_uuid = $parent_name::app_uuid;
}
//process the parent array, use it to create insert and update SQL statements
if (is_array($parent_array)) foreach ($parent_array as $row_id => $parent_field_array) {
//set the variables
@@ -3628,7 +3649,6 @@ class database {
/*
//example usage
//find
$database = new database;
$database->domain_uuid = $_SESSION["domain_uuid"];
$database->type = $db_type;
$database->table = "v_extensions";
@@ -3644,7 +3664,6 @@ class database {
$database->find();
print_r($database->result);
//insert
$database = new database;
$database->domain_uuid = $_SESSION["domain_uuid"];
$database->table = "v_ivr_menus";
$fields[0]['name'] = 'domain_uuid';

View File

@@ -26,6 +26,10 @@
//define the directory class
class switch_directory {
/**
* declare public variables
*/
public $domain_uuid;
public $domain_name;
public $db_type;
@@ -60,41 +64,55 @@
public $enabled;
public $description;
/**
* Called when the object is created
*/
public function __construct() {
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
// get domain_uuid
public function get_domain_uuid() {
return $this->domain_uuid;
}
public function get_domain_uuid() {
return $this->domain_uuid;
}
// set domain_uuid
public function set_domain_uuid($domain_uuid){
$this->domain_uuid = $domain_uuid;
}
public function set_domain_uuid($domain_uuid){
$this->domain_uuid = $domain_uuid;
}
// get domain_name
public function get_domain_name() {
return $this->domain_name;
}
public function get_domain_name() {
return $this->domain_name;
}
// set domain_name
public function set_domain_name($domain_name){
$this->domain_name = $domain_name;
}
public function set_domain_name($domain_name){
$this->domain_name = $domain_name;
}
// get db_type
public function get_db_type() {
return $this->db_type;
}
public function get_db_type() {
return $this->db_type;
}
// set db_type
public function set_db_type($db_type){
$this->db_type = $db_type;
}
public function set_db_type($db_type){
$this->db_type = $db_type;
}
// get extension
public function get_extension() {
return $this->extension;
}
public function get_extension() {
return $this->extension;
}
// set extension
public function set_extension($extension){
$this->extension = $extension;
}
public function set_extension($extension){
$this->extension = $extension;
}
public function add() {
$domain_uuid = $this->domain_uuid;
@@ -183,10 +201,7 @@
$p->add('extension_add', 'temp');
//execute insert
$database = new database;
$database->app_name = 'switch_directory';
$database->app_uuid = 'efc9cdbf-8616-435d-9d21-ae8d4e6b5225';
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions
@@ -286,10 +301,7 @@
$p->add('extension_edit', 'temp');
//execute insert
$database = new database;
$database->app_name = 'switch_directory';
$database->app_uuid = 'efc9cdbf-8616-435d-9d21-ae8d4e6b5225';
$database->save($array);
$this->database->save($array);
unset($array);
//revoke temporary permissions
@@ -307,10 +319,7 @@
$p = permissions::new();
$p->add('extension_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = 'switch_directory';
$database->app_uuid = 'efc9cdbf-8616-435d-9d21-ae8d4e6b5225';
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions
$p->delete('extension_delete', 'temp');
@@ -488,8 +497,7 @@
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "order by call_group asc ";
$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
$rows = $this->database->select($sql, $parameters, 'all');
$i = 0;
$extension_xml_condensed = false;
if ($extension_xml_condensed) {

View File

@@ -31,11 +31,15 @@
*/
class domains {
/**
* declare constant variables
*/
const app_name = 'domains';
const app_uuid = '8b91605b-f6d2-42e6-a56d-5d1ded01bb44';
/**
* declare the variables
*/
private $app_name;
private $app_uuid;
private $name;
private $table;
private $toggle_field;
@@ -53,8 +57,6 @@
*/
public function __construct($setting_array = []) {
//assign the variables
$this->app_name = 'domains';
$this->app_uuid = '8b91605b-f6d2-42e6-a56d-5d1ded01bb44';
$this->name = 'domain';
$this->table = 'domains';
$this->toggle_field = 'domain_enabled';
@@ -271,8 +273,6 @@
//delete the checked rows
if (is_array($domain_array) && @sizeof($domain_array) != 0) {
//execute delete
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->delete($domain_array);
//set message
@@ -338,8 +338,7 @@
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->save($array);
unset($array);
@@ -404,8 +403,7 @@
//save the changes and set the message
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->save($array);
unset($array);

View File

@@ -31,12 +31,14 @@
class email {
/**
* declare the variables
*/
private $app_name;
private $app_uuid;
private $name;
* declare constant variables
*/
const app_name = 'email';
const app_uuid = '7a4fef67-5bf8-436a-ae25-7e3c03afcf96';
/**
* declare public variables
*/
public $domain_uuid;
public $method;
public $recipients;
@@ -50,6 +52,11 @@
public $read_confirmation;
public $error;
public $response;
/**
* declare private variables
*/
private $name;
private $settings;
/**
@@ -57,9 +64,7 @@
*/
public function __construct($params = []) {
//assign the variables
$this->app_name = 'email';
$this->name = 'email';
$this->app_uuid = '7a4fef67-5bf8-436a-ae25-7e3c03afcf96';
$this->priority = 0;
$this->debug_level = 3;
$this->read_confirmation = false;

View File

@@ -31,14 +31,22 @@
class groups {
/**
* declare the variables
* declare constant variables
*/
const app_name = 'groups';
const app_uuid = '2caf27b0-540a-43d5-bb9b-c9871a1e4f84';
/**
* declare public variables
*/
public $group_uuid;
public $group_level;
/**
* declare private variables
*/
private $database;
private $app_name;
private $app_uuid;
public $group_uuid;
private $groups;
public $group_level;
private $name;
private $table;
private $toggle_field;
@@ -51,16 +59,13 @@
* called when the object is created
*/
public function __construct(database $database = null, $domain_uuid = null, $user_uuid = null) {
//assign the variables
$this->app_name = 'groups';
$this->app_uuid = '2caf27b0-540a-43d5-bb9b-c9871a1e4f84';
//handle the database object
if (isset($database)) {
$this->database = $database;
}
else {
$this->database = new database;
$this->database = database::new();
}
//set the domain_uuid

View File

@@ -30,18 +30,26 @@
class menu {
/**
* declare the variables
* declare constant variables
*/
const app_name = 'menus';
const app_uuid = 'f4b3b3d2-6287-489c-2a00-64529e46f2d7';
/**
* declare private variables
*/
public $menu_uuid;
public $menu_language;
public $text;
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $name;
private $table;
private $toggle_field;
private $toggle_values;
private $location;
public $menu_uuid;
public $menu_language;
public $text;
/**
* Set in the constructor. Must be a database object and cannot be null.
@@ -72,8 +80,6 @@
*/
public function __construct($setting_array = []) {
//assign the variables
$this->app_name = 'menus';
$this->app_uuid = 'f4b3b3d2-6287-489c-2a00-64529e46f2d7';
$this->location = 'menus.php';
$this->domain_uuid = $setting_array['domain_uuid'] ?? $_SESSION['domain_uuid'] ?? '';
@@ -147,8 +153,6 @@
$p->add('menu_language_delete', 'temp');
//execute delete
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->delete($array);
unset($array);
@@ -227,8 +231,6 @@
$p->add('menu_item_group_delete', 'temp');
//execute delete
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->delete($array);
unset($array);
@@ -301,8 +303,7 @@
//save the changes
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//save the array
$this->database->app_name = $this->app_name;
$this->database->app_uuid = $this->app_uuid;
$this->database->save($array);
unset($array);
@@ -389,8 +390,7 @@
$sql = "select group_name, group_uuid from v_groups ";
$sql .= "where group_uuid = :group_uuid ";
$parameters['group_uuid'] = $group_uuid;
$database = new database;
$group = $database->select($sql, $parameters, 'row');
$group = $this->database->select($sql, $parameters, 'row');
}
//build the delete array
@@ -416,8 +416,7 @@
if (!empty($array) && @sizeof($array) != 0) {
$sql = "select menu_uuid, menu_item_uuid, ";
$sql .= "group_uuid from v_menu_item_groups ";
$database = new database;
$menu_item_groups = $database->select($sql, null, 'all');
$menu_item_groups = $this->database->select($sql, null, 'all');
$array['menu_item_groups'] = array_filter($array['menu_item_groups'], function($ar) use ($menu_item_groups) {
foreach ($menu_item_groups as $existingArrayItem) {
if ($ar['menu_uuid'] == $existingArrayItem['menu_uuid'] && $ar['menu_item_uuid'] == $existingArrayItem['menu_item_uuid'] && $ar['group_uuid'] == $existingArrayItem['group_uuid']) {
@@ -432,10 +431,7 @@
//add the checked rows fro group
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//execute save
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
$this->database->save($array);
unset($array);
//set message
message::add($text['message-add']);
@@ -471,8 +467,7 @@
$sql = "select group_name, group_uuid from v_groups ";
$sql .= "where group_uuid = :group_uuid ";
$parameters['group_uuid'] = $group_uuid;
$database = new database;
$group = $database->select($sql, $parameters, 'row');
$group = $this->database->select($sql, $parameters, 'row');
}
//build the delete array
@@ -497,8 +492,7 @@
if (!empty($uuids) && @sizeof($uuids) != 0) {
$sql = "select menu_uuid, menu_item_uuid as uuid from v_".$this->table." ";
$sql .= "where menu_item_parent_uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, null, 'all');
$rows = $this->database->select($sql, null, 'all');
if (!empty($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
//assign menu item groups
@@ -522,10 +516,7 @@
$p->add('menu_item_group_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
$this->database->delete($array);
unset($array);
//revoke temporary permissions

View File

@@ -15,10 +15,13 @@ class sounds {
public $full_path;
/**
* Class constructor
*/
* Called when the object is created
*/
public function __construct() {
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
@@ -45,8 +48,7 @@ class sounds {
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "order by recording_name asc ";
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
$database = new database;
$recordings = $database->select($sql, $parameters, 'all');
$recordings = $this->database->select($sql, $parameters, 'all');
if (is_array($recordings) && @sizeof($recordings) != 0) {
foreach ($recordings as $x => $row) {
$recording_name = $row["recording_name"];
@@ -63,8 +65,7 @@ class sounds {
$sql = "select * from v_phrases ";
$sql .= "where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
$database = new database;
$phrases = $database->select($sql, $parameters, 'all');
$phrases = $this->database->select($sql, $parameters, 'all');
if (is_array($phrases) && @sizeof($phrases) != 0) {
foreach ($phrases as $row) {
$array['phrases'][$x]['name'] = "phrase:".$row["phrase_name"];

View File

@@ -12,10 +12,13 @@
public $event_socket_password;
/**
* Called when the object is created
* called when the object is created
*/
public function __construct() {
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
/**
@@ -209,8 +212,7 @@
//get an array of the default settings
$sql = "select * from v_default_settings ";
$sql .= "where default_setting_category = 'switch' ";
$database = new database;
$default_settings = $database->select($sql, null, 'all');
$default_settings = $this->database->select($sql, null, 'all');
unset($sql);
//find the missing default settings
@@ -251,10 +253,7 @@
$p->add('default_setting_add', 'temp');
//execute insert
$database = new database;
$database->app_name = 'switch_settings';
$database->app_uuid = '84e91084-a227-43cd-ae99-a0f8ed61eb8b';
$database->save($array);
$this->database->save($array);
//revoke temporary permissions
$p->delete('default_setting_add', 'temp');

View File

@@ -27,41 +27,49 @@
class tones {
//define variables
private $tones;
/**
* declare private variables
*/
private $music_list;
private $recordings_list;
private $default_tone_label;
//class constructor
/**
* called when the object is created
*/
public function __construct() {
//add multi-lingual support
$language = new text;
$text = $language->get();
$language = new text;
$text = $language->get();
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
//get the tones
$sql = "select * from v_vars ";
$sql .= "where var_category = 'Tones' ";
$sql .= "order by var_name asc ";
$database = new database;
$tones = $database->select($sql, null, 'all');
if (!empty($tones)) {
foreach ($tones as $tone) {
$tone = $tone['var_name'];
if (isset($text['label-'.$tone])) {
$label = $text['label-'.$tone];
}
else {
$label = $tone;
}
$tone_list[$tone] = $label;
}
}
$this->tones = $tone_list ?? '';
unset($sql, $tones, $tone, $tone_list);
}
public function tones_list() {
return $this->tones;
//get the tones
$sql = "select * from v_vars ";
$sql .= "where var_category = 'Tones' ";
$sql .= "order by var_name asc ";
$tones = $this->database->select($sql, null, 'all');
if (!empty($tones)) {
foreach ($tones as $tone) {
$tone = $tone['var_name'];
if (isset($text['label-'.$tone])) {
$label = $text['label-'.$tone];
}
else {
$label = $tone;
}
$tone_list[$tone] = $label;
}
}
unset($sql, $tones, $tone);
//return the tones
return $tone_list ?? '';
}
}

View File

@@ -506,31 +506,6 @@ function get_recording_filename($id) {
unset($sql, $parameters, $row);
}
function dialplan_add($domain_uuid, $dialplan_uuid, $dialplan_name, $dialplan_order, $dialplan_context, $dialplan_enabled, $dialplan_description, $app_uuid) {
//build insert array
$array['dialplans'][0]['dialplan_uuid'] = $dialplan_uuid;
$array['dialplans'][0]['domain_uuid'] = $domain_uuid;
if (is_uuid($app_uuid)) {
$array['dialplans'][0]['app_uuid'] = $app_uuid;
}
$array['dialplans'][0]['dialplan_name'] = $dialplan_name;
$array['dialplans'][0]['dialplan_order'] = $dialplan_order;
$array['dialplans'][0]['dialplan_context'] = $dialplan_context;
$array['dialplans'][0]['dialplan_enabled'] = $dialplan_enabled;
$array['dialplans'][0]['dialplan_description'] = $dialplan_description;
//grant temporary permissions
$p = permissions::new();
$p->add('dialplan_add', 'temp');
//execute insert
$database = new database;
$database->app_name = 'switch-function-dialplan_add';
$database->app_uuid = '2fa2243c-47a1-41a0-b144-eb2b609219e0';
$database->save($array);
unset($array);
//revoke temporary permissions
$p->delete('dialplan_add', 'temp');
}
if (!function_exists('phone_letter_to_number')) {
function phone_letter_to_number($tmp) {
$tmp = strtolower($tmp);