mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-02-22 02:46:30 +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:
@@ -1291,6 +1291,14 @@ class database {
|
||||
$x = 0;
|
||||
foreach ($array as $parent_name => $tables) {
|
||||
if (is_array($tables)) {
|
||||
|
||||
//get the application name and uuid
|
||||
if (class_exists($parent_name) && defined("$parent_name::$app_name")) {
|
||||
$this->app_name = $parent_name::app_name;
|
||||
$this->app_uuid = $parent_name::app_uuid;
|
||||
}
|
||||
|
||||
//process the array
|
||||
foreach ($tables as $id => $row) {
|
||||
|
||||
//prepare the variables
|
||||
@@ -1454,7 +1462,13 @@ class database {
|
||||
|
||||
//delete the current data
|
||||
foreach($new_array as $table_name => $rows) {
|
||||
//echo "table: ".$table_name."\n";
|
||||
//get the application name and uuid
|
||||
if (class_exists($parent_name)) {
|
||||
$this->app_name = $table_name::app_name;
|
||||
$this->app_uuid = $table_name::app_uuid;
|
||||
}
|
||||
|
||||
//build and run the delete SQL statements
|
||||
foreach($rows as $row) {
|
||||
if (permission_exists(self::singular($table_name).'_delete')) {
|
||||
$sql = "delete from ".self::TABLE_PREFIX.$table_name." ";
|
||||
@@ -2228,7 +2242,7 @@ class database {
|
||||
|
||||
/**
|
||||
* <p>Save an array to the database.</p>
|
||||
* <p>Usage Example:<br><code>$database = new database();<br>$database->app_name = "MyApp";<br>$database->app_uuid = "12345678-1234-1234-1234-123456789abc";<br>$row = 0;<br>$array['mytable'][$row]['mycolumn'] = "myvalue";<br>if ($database->save($array)) { <br> echo "Saved Successfully.";<br> } else {<br> echo "Save Failed.";<br>}</code></p>
|
||||
* <p>Usage Example:<br><code><br>$row = 0;<br>$array['mytable'][$row]['mycolumn'] = "myvalue";<br>if ($database->save($array)) { <br> echo "Saved Successfully.";<br> } else {<br> echo "Save Failed.";<br>}</code></p>
|
||||
* @param array $array Three dimensional Array. The first dimension is the table name without the prefix 'v_'. Second dimension in the row value as int. Third dimension is the column name.
|
||||
* @param bool $transaction_save
|
||||
* @return returns and array wih result details
|
||||
@@ -2273,6 +2287,13 @@ class database {
|
||||
//loop through the array
|
||||
if (is_array($array)) foreach ($array as $parent_name => $parent_array) {
|
||||
|
||||
//get the application name and uuid
|
||||
if (class_exists($parent_name) && defined("$parent_name::$app_name")) {
|
||||
$this->app_name = $parent_name::app_name;
|
||||
$this->app_uuid = $parent_name::app_uuid;
|
||||
}
|
||||
|
||||
//process the parent array, use it to create insert and update SQL statements
|
||||
if (is_array($parent_array)) foreach ($parent_array as $row_id => $parent_field_array) {
|
||||
|
||||
//set the variables
|
||||
@@ -3628,7 +3649,6 @@ class database {
|
||||
/*
|
||||
//example usage
|
||||
//find
|
||||
$database = new database;
|
||||
$database->domain_uuid = $_SESSION["domain_uuid"];
|
||||
$database->type = $db_type;
|
||||
$database->table = "v_extensions";
|
||||
@@ -3644,7 +3664,6 @@ class database {
|
||||
$database->find();
|
||||
print_r($database->result);
|
||||
//insert
|
||||
$database = new database;
|
||||
$database->domain_uuid = $_SESSION["domain_uuid"];
|
||||
$database->table = "v_ivr_menus";
|
||||
$fields[0]['name'] = 'domain_uuid';
|
||||
|
||||
Reference in New Issue
Block a user