mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43: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,16 @@
|
||||
//define the sip profiles class
|
||||
class sip_profiles {
|
||||
|
||||
/**
|
||||
* declare constant variables
|
||||
*/
|
||||
const app_name = 'sip_profiles';
|
||||
const app_uuid = 'a6a7c4c5-340a-43ce-bcbc-2ed9bab8659d';
|
||||
|
||||
/**
|
||||
* declare private variables
|
||||
*/
|
||||
private $app_name;
|
||||
private $app_uuid;
|
||||
private $database;
|
||||
private $permission_prefix;
|
||||
private $list_page;
|
||||
private $table;
|
||||
@@ -50,14 +55,17 @@
|
||||
public function __construct() {
|
||||
|
||||
//assign private variables
|
||||
$this->app_name = 'sip_profiles';
|
||||
$this->app_uuid = 'a6a7c4c5-340a-43ce-bcbc-2ed9bab8659d';
|
||||
$this->permission_prefix = 'sip_profile_';
|
||||
$this->list_page = 'sip_profiles.php';
|
||||
$this->table = 'sip_profiles';
|
||||
$this->uuid_prefix = 'sip_profile_';
|
||||
$this->toggle_field = 'sip_profile_enabled';
|
||||
$this->toggle_values = ['true','false'];
|
||||
$this->permission_prefix = 'sip_profile_';
|
||||
$this->list_page = 'sip_profiles.php';
|
||||
$this->table = 'sip_profiles';
|
||||
$this->uuid_prefix = 'sip_profile_';
|
||||
$this->toggle_field = 'sip_profile_enabled';
|
||||
$this->toggle_values = ['true','false'];
|
||||
|
||||
//connect to the database
|
||||
if (empty($this->database)) {
|
||||
$this->database = database::new();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -92,8 +100,7 @@
|
||||
//get necessary sip profile details
|
||||
$sql = "select ".$this->uuid_prefix."uuid as uuid, sip_profile_name, sip_profile_hostname from v_".$this->table." ";
|
||||
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
|
||||
$database = new database;
|
||||
$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) {
|
||||
$sip_profiles[$row['uuid']]['name'] = $row['sip_profile_name'];
|
||||
@@ -120,10 +127,7 @@
|
||||
$p->add('sip_profile_setting_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
|
||||
@@ -213,8 +217,7 @@
|
||||
$sql = "select sip_profile_hostname from v_sip_profiles ";
|
||||
$sql .= "where sip_profile_uuid = :sip_profile_uuid ";
|
||||
$parameters['sip_profile_uuid'] = $this->sip_profile_uuid;
|
||||
$database = new database;
|
||||
$sip_profile_hostname = $database->select($sql, $parameters, 'column');
|
||||
$sip_profile_hostname = $this->database->select($sql, $parameters, 'column');
|
||||
unset($sql, $parameters);
|
||||
}
|
||||
|
||||
@@ -222,10 +225,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);
|
||||
|
||||
//save the sip profile xml
|
||||
@@ -291,8 +291,7 @@
|
||||
$sql = "select sip_profile_hostname from v_sip_profiles ";
|
||||
$sql .= "where sip_profile_uuid = :sip_profile_uuid ";
|
||||
$parameters['sip_profile_uuid'] = $this->sip_profile_uuid;
|
||||
$database = new database;
|
||||
$sip_profile_hostname = $database->select($sql, $parameters, 'column');
|
||||
$sip_profile_hostname = $this->database->select($sql, $parameters, 'column');
|
||||
unset($sql, $parameters);
|
||||
}
|
||||
|
||||
@@ -300,10 +299,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);
|
||||
|
||||
//save the sip profile xml
|
||||
@@ -362,8 +358,7 @@
|
||||
if (!empty($uuids) && @sizeof($uuids) != 0) {
|
||||
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, sip_profile_hostname from v_".$this->table." ";
|
||||
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
|
||||
$database = new database;
|
||||
$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) {
|
||||
$sip_profiles[$row['uuid']]['state'] = $row['toggle'];
|
||||
@@ -385,10 +380,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);
|
||||
|
||||
//determine hostnames, get system hostname if necessary
|
||||
|
||||
Reference in New Issue
Block a user