mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
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:
@@ -27,11 +27,17 @@
|
||||
//define the vars class
|
||||
class vars {
|
||||
|
||||
/**
|
||||
* declare constant variables
|
||||
*/
|
||||
const app_name = 'vars';
|
||||
const app_uuid = '54e08402-c1b8-0a9d-a30a-f569fc174dd8';
|
||||
|
||||
/**
|
||||
* declare private variables
|
||||
*/
|
||||
private $app_name;
|
||||
private $app_uuid;
|
||||
|
||||
private $database;
|
||||
private $permission_prefix;
|
||||
private $list_page;
|
||||
private $table;
|
||||
@@ -45,15 +51,17 @@
|
||||
public function __construct() {
|
||||
|
||||
//assign private variables
|
||||
$this->app_name = 'vars';
|
||||
$this->app_uuid = '54e08402-c1b8-0a9d-a30a-f569fc174dd8';
|
||||
$this->permission_prefix = 'var_';
|
||||
$this->list_page = 'vars.php';
|
||||
$this->table = 'vars';
|
||||
$this->uuid_prefix = 'var_';
|
||||
$this->toggle_field = 'var_enabled';
|
||||
$this->toggle_values = ['true','false'];
|
||||
$this->permission_prefix = 'var_';
|
||||
$this->list_page = 'vars.php';
|
||||
$this->table = 'vars';
|
||||
$this->uuid_prefix = 'var_';
|
||||
$this->toggle_field = 'var_enabled';
|
||||
$this->toggle_values = ['true','false'];
|
||||
|
||||
//connect to the database
|
||||
if (empty($this->database)) {
|
||||
$this->database = database::new();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,10 +96,7 @@
|
||||
if (!empty($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);
|
||||
|
||||
//unset the user defined variables
|
||||
@@ -138,8 +143,7 @@
|
||||
if (!empty($uuids) && @sizeof($uuids) != 0) {
|
||||
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
|
||||
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
|
||||
$database = new database;
|
||||
$rows = $database->select($sql, null, 'all');
|
||||
$rows = $this->database->select($sql, null, 'all');
|
||||
if (!empty($rows) && @sizeof($rows) != 0) {
|
||||
foreach ($rows as $row) {
|
||||
$states[$row['uuid']] = $row['toggle'];
|
||||
@@ -160,10 +164,8 @@
|
||||
if (!empty($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);
|
||||
|
||||
//unset the user defined variables
|
||||
@@ -213,8 +215,7 @@
|
||||
if (!empty($uuids) && @sizeof($uuids) != 0) {
|
||||
$sql = "select * from v_".$this->table." ";
|
||||
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
|
||||
$database = new database;
|
||||
$rows = $database->select($sql, null, 'all');
|
||||
$rows = $this->database->select($sql, null, 'all');
|
||||
if (!empty($rows) && @sizeof($rows) != 0) {
|
||||
foreach ($rows as $x => $row) {
|
||||
|
||||
@@ -234,10 +235,8 @@
|
||||
if (!empty($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);
|
||||
|
||||
//unset the user defined variables
|
||||
|
||||
Reference in New Issue
Block a user