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