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

@@ -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