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