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