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

@@ -28,6 +28,12 @@
//define the switch_recordings class
class switch_recordings {
/**
* declare constant variables
*/
const app_name = 'recordings';
const app_uuid = '83913217-c7a2-9e90-925d-a866eb40b60e';
/**
* declare public variables
*/
@@ -36,8 +42,8 @@
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $database;
private $permission_prefix;
private $list_page;
private $table;
@@ -49,15 +55,19 @@
* called when the object is created
*/
public function __construct() {
//assign public variables
$this->domain_uuid = $_SESSION['domain_uuid'];
//assign private variables
$this->app_name = 'recordings';
$this->app_uuid = '83913217-c7a2-9e90-925d-a866eb40b60e';
$this->permission_prefix = 'recording_';
$this->list_page = 'recordings.php';
$this->table = 'recordings';
$this->uuid_prefix = 'recording_';
$this->permission_prefix = 'recording_';
$this->list_page = 'recordings.php';
$this->table = 'recordings';
$this->uuid_prefix = 'recording_';
//connect to the database
if (empty($this->database)) {
$this->database = database::new();
}
}
@@ -69,8 +79,7 @@
$sql .= "from v_recordings ";
$sql .= "where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $this->domain_uuid;
$database = new database;
$result = $database->select($sql, $parameters, 'all');
$result = $this->database->select($sql, $parameters, 'all');
if (!empty($result)) {
foreach ($result as $row) {
$recordings[$_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name']."/".$row['recording_filename']] = $row['recording_filename'];
@@ -114,8 +123,7 @@
$sql .= "and recording_uuid = :recording_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['recording_uuid'] = $record['uuid'];
$database = new database;
$filenames[] = $database->select($sql, $parameters, 'column');
$filenames[] = $this->database->select($sql, $parameters, 'column');
unset($sql, $parameters);
//build delete array
@@ -128,10 +136,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);
//delete recording files