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

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