mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Move database methods to static and document database class (#6474)
* Add new static method to created newly connected database object * Document database class and clean up and document some of the methods. This removes the methods that should not be in each instance and places them in the single instance class as to occupy less resources and be able to create database objects more efficiently. * More docs & removed the ability to set any value within the object. Co-authored-by: Tim Fry <tim@voipstratus.com>
This commit is contained in:
@@ -119,7 +119,7 @@ if (!class_exists('contacts')) {
|
||||
$p = new permissions;
|
||||
$database = new database;
|
||||
foreach ($this->tables as $table) {
|
||||
$p->add($database->singular($table).'_delete', 'temp');
|
||||
$p->add(database::singular($table).'_delete', 'temp');
|
||||
}
|
||||
|
||||
//execute delete
|
||||
@@ -132,7 +132,7 @@ if (!class_exists('contacts')) {
|
||||
//revoke temp permissions
|
||||
$database = new database;
|
||||
foreach ($this->tables as $table) {
|
||||
$p->delete($database->singular($table).'_delete', 'temp');
|
||||
$p->delete(database::singular($table).'_delete', 'temp');
|
||||
}
|
||||
|
||||
//set message
|
||||
@@ -163,11 +163,11 @@ if (!class_exists('contacts')) {
|
||||
$x = 0;
|
||||
foreach ($records as $property_name => $properties) {
|
||||
$database = new database;
|
||||
if (permission_exists($database->singular($property_name).'_delete')) {
|
||||
if (permission_exists(database::singular($property_name).'_delete')) {
|
||||
if (is_array($properties) && @sizeof($properties) != 0) {
|
||||
foreach ($properties as $property) {
|
||||
if ($property['checked'] == 'true' && is_uuid($property['uuid'])) {
|
||||
$array[$property_name][$x][$database->singular($property_name).'_uuid'] = $property['uuid'];
|
||||
$array[$property_name][$x][database::singular($property_name).'_uuid'] = $property['uuid'];
|
||||
$array[$property_name][$x]['contact_uuid'] = $this->contact_uuid;
|
||||
$array[$property_name][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$x++;
|
||||
|
||||
@@ -273,7 +273,8 @@
|
||||
$database = new database;
|
||||
$database->app_name = 'dialplans';
|
||||
$database->app_uuid = $app_uuid;
|
||||
$database->uuid($dialplan_uuid);
|
||||
if ( strlen($dialplan_uuid)>0 )
|
||||
$database->uuid($dialplan_uuid);
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ if (!class_exists('user_logs')) {
|
||||
* add user_logs
|
||||
*/
|
||||
public static function add($result) {
|
||||
$array = [];
|
||||
//prepare the array
|
||||
$array['user_logs'][0]["timestamp"] = 'now()';
|
||||
$array['user_logs'][0]["domain_uuid"] = $result['domain_uuid'];
|
||||
@@ -97,7 +98,8 @@ if (!class_exists('user_logs')) {
|
||||
$database = new database;
|
||||
$database->app_name = 'authentication';
|
||||
$database->app_uuid = 'a8a12918-69a4-4ece-a1ae-3932be0e41f1';
|
||||
$database->uuid($user_log_uuid);
|
||||
if (strlen($user_log_uuid)>0)
|
||||
$database->uuid($user_log_uuid);
|
||||
$database->save($array, false);
|
||||
$message = $database->message;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user