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:
@@ -17,7 +17,7 @@
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2024
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2025
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
@@ -30,7 +30,7 @@
|
||||
class plugin_email {
|
||||
|
||||
/**
|
||||
* Define variables and their scope
|
||||
* Declare public variables
|
||||
*/
|
||||
public $domain_name;
|
||||
public $domain_uuid;
|
||||
@@ -41,6 +41,16 @@ class plugin_email {
|
||||
public $contact_uuid;
|
||||
public $debug;
|
||||
|
||||
/**
|
||||
* Called when the object is created
|
||||
*/
|
||||
public function __construct() {
|
||||
//connect to the database
|
||||
if (empty($this->database)) {
|
||||
$this->database = database::new();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* time based one time password with email
|
||||
* @return array [authorized] => true or false
|
||||
@@ -126,8 +136,7 @@ class plugin_email {
|
||||
}
|
||||
$sql .= "and (user_type = 'default' or user_type is null) ";
|
||||
$parameters['username'] = $_REQUEST['username'];
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
$row = $this->database->select($sql, $parameters, 'row');
|
||||
unset($parameters);
|
||||
|
||||
//set class variables
|
||||
@@ -198,7 +207,7 @@ class plugin_email {
|
||||
//$sql .= "where user_uuid = :user_uuid;";
|
||||
//$parameters['auth_code'] = $auth_code_hash;
|
||||
//$parameters['user_uuid'] = $this->user_uuid;
|
||||
//$database->execute($sql, $parameters);
|
||||
//$this->database->execute($sql, $parameters);
|
||||
//unset($sql);
|
||||
|
||||
//email settings
|
||||
@@ -228,8 +237,7 @@ class plugin_email {
|
||||
$parameters['template_category'] = 'authentication';
|
||||
$parameters['template_subcategory'] = 'email';
|
||||
$parameters['template_type'] = 'html';
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
$row = $this->database->select($sql, $parameters, 'row');
|
||||
$email_subject = $row['template_subject'];
|
||||
$email_body = $row['template_body'];
|
||||
unset($sql, $parameters, $row);
|
||||
@@ -273,11 +281,8 @@ class plugin_email {
|
||||
$array['email_queue'][0]["email_uuid"] = $email_uuid;
|
||||
$array['email_queue'][0]["email_action_before"] = null;
|
||||
$array['email_queue'][0]["email_action_after"] = null;
|
||||
$database = new database;
|
||||
$database->app_name = 'email queue';
|
||||
$database->app_uuid = '5befdf60-a242-445f-91b3-2e9ee3e0ddf7';
|
||||
$database->save($array);
|
||||
$err = $database->message;
|
||||
$this->database->save($array);
|
||||
$err = $this->database->message;
|
||||
unset($array);
|
||||
|
||||
//remove the temporary permission
|
||||
@@ -378,8 +383,7 @@ class plugin_email {
|
||||
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
|
||||
}
|
||||
$parameters['username'] = $_SESSION["username"];
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
$row = $this->database->select($sql, $parameters, 'row');
|
||||
$this->user_uuid = $row['user_uuid'];
|
||||
$this->user_email = $row['user_email'];
|
||||
$this->contact_uuid = $row['contact_uuid'];
|
||||
@@ -433,8 +437,7 @@ class plugin_email {
|
||||
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
|
||||
}
|
||||
$parameters['user_uuid'] = $_SESSION["user_uuid"];
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
$row = $this->database->select($sql, $parameters, 'row');
|
||||
unset($parameters);
|
||||
|
||||
//set a few session variables
|
||||
@@ -479,8 +482,7 @@ class plugin_email {
|
||||
$parameters['domain_uuid'] = $this->domain_uuid;
|
||||
$parameters['user_uuid'] = $this->user_uuid;
|
||||
$parameters['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
|
||||
$database = new database;
|
||||
$user_log_count = $database->select($sql, $parameters, 'all');
|
||||
$user_log_count = $this->database->select($sql, $parameters, 'all');
|
||||
//view_array($user_log_count);
|
||||
unset($sql, $parameters);
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
class plugin_ldap {
|
||||
|
||||
/**
|
||||
* Define variables and their scope
|
||||
* Declare public variables
|
||||
*/
|
||||
public $debug;
|
||||
public $domain_name;
|
||||
@@ -17,6 +17,16 @@ class plugin_ldap {
|
||||
public $user_uuid;
|
||||
public $contact_uuid;
|
||||
|
||||
/**
|
||||
* Called when the object is created
|
||||
*/
|
||||
public function __construct() {
|
||||
//connect to the database
|
||||
if (empty($this->database)) {
|
||||
$this->database = database::new();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ldap checks a local or remote ldap database to authenticate the user
|
||||
* @return array [authorized] => true or false
|
||||
@@ -132,8 +142,7 @@ class plugin_ldap {
|
||||
}
|
||||
$sql .= "and (user_type = 'default' or user_type is null) ";
|
||||
$parameters['username'] = $this->username;
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
$row = $this->database->select($sql, $parameters, 'row');
|
||||
if (is_array($row) && @sizeof($row) != 0) {
|
||||
if ($settings['users']['unique'] == "global" && $row["domain_uuid"] != $this->domain_uuid) {
|
||||
//get the domain uuid
|
||||
@@ -183,10 +192,7 @@ class plugin_ldap {
|
||||
$p->add('user_group_add', 'temp');
|
||||
|
||||
//execute insert
|
||||
$database = new database;
|
||||
$database->app_name = 'authentication';
|
||||
$database->app_uuid = 'a8a12918-69a4-4ece-a1ae-3932be0e41f1';
|
||||
$database->save($array);
|
||||
$this->database->save($array);
|
||||
unset($array);
|
||||
|
||||
//revoke temporary permissions
|
||||
|
||||
@@ -43,6 +43,16 @@ class plugin_totp {
|
||||
public $contact_uuid;
|
||||
private $user_totp_secret;
|
||||
|
||||
/**
|
||||
* Called when the object is created
|
||||
*/
|
||||
public function __construct() {
|
||||
//connect to the database
|
||||
if (empty($this->database)) {
|
||||
$this->database = database::new();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* time based one time password aka totp
|
||||
* @return array [authorized] => true or false
|
||||
@@ -144,8 +154,7 @@ class plugin_totp {
|
||||
}
|
||||
$sql .= "and (user_type = 'default' or user_type is null) ";
|
||||
$parameters['username'] = $this->username;
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
$row = $this->database->select($sql, $parameters, 'row');
|
||||
if (empty($row) || !is_array($row) || @sizeof($row) == 0) {
|
||||
//clear submitted usernames
|
||||
unset($this->username, $_SESSION['username'], $_REQUEST['username'], $_POST['username']);
|
||||
@@ -228,10 +237,7 @@ class plugin_totp {
|
||||
$p->add("user_edit", "temp");
|
||||
|
||||
//save the data
|
||||
$database = new database;
|
||||
$database->app_name = 'users';
|
||||
$database->app_uuid = '112124b3-95c2-5352-7e9d-d14c0b88f207';
|
||||
$database->save($array);
|
||||
$this->database->save($array);
|
||||
|
||||
//remove the temporary permission
|
||||
$p->delete("user_edit", "temp");
|
||||
@@ -305,8 +311,7 @@ class plugin_totp {
|
||||
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
|
||||
}
|
||||
$parameters['username'] = $_SESSION["username"];
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
$row = $this->database->select($sql, $parameters, 'row');
|
||||
$this->user_uuid = $row['user_uuid'];
|
||||
$this->user_email = $row['user_email'];
|
||||
$this->contact_uuid = $row['contact_uuid'];
|
||||
@@ -359,8 +364,7 @@ class plugin_totp {
|
||||
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
|
||||
}
|
||||
$parameters['user_uuid'] = $_SESSION["user_uuid"];
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
$row = $this->database->select($sql, $parameters, 'row');
|
||||
unset($parameters);
|
||||
}
|
||||
else {
|
||||
@@ -399,8 +403,7 @@ class plugin_totp {
|
||||
$parameters['domain_uuid'] = $this->domain_uuid;
|
||||
$parameters['user_uuid'] = $this->user_uuid;
|
||||
$parameters['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
|
||||
$database = new database;
|
||||
$user_log_count = $database->select($sql, $parameters, 'all');
|
||||
$user_log_count = $this->database->select($sql, $parameters, 'all');
|
||||
//view_array($user_log_count);
|
||||
unset($sql, $parameters);
|
||||
*/
|
||||
|
||||
@@ -27,13 +27,17 @@
|
||||
//define the contacts class
|
||||
class contacts {
|
||||
|
||||
const APP_NAME = "contacts";
|
||||
const APP_UUID = "04481e0e-a478-c559-adad-52bd4174574c";
|
||||
/**
|
||||
* declare constant variables
|
||||
*/
|
||||
const app_name = 'contacts';
|
||||
const app_uuid = '04481e0e-a478-c559-adad-52bd4174574c';
|
||||
|
||||
/**
|
||||
* declare private variables
|
||||
*/
|
||||
private $app_name;
|
||||
private $app_uuid;
|
||||
|
||||
private $database;
|
||||
private $permission_prefix;
|
||||
private $list_page;
|
||||
private $tables;
|
||||
@@ -50,23 +54,26 @@
|
||||
public function __construct() {
|
||||
|
||||
//assign private variables
|
||||
$this->app_name = self::APP_NAME;
|
||||
$this->app_uuid = self::APP_UUID;
|
||||
$this->permission_prefix = 'contact_';
|
||||
$this->list_page = 'contacts.php';
|
||||
$this->tables[] = 'contact_addresses';
|
||||
$this->tables[] = 'contact_attachments';
|
||||
$this->tables[] = 'contact_emails';
|
||||
$this->tables[] = 'contact_groups';
|
||||
$this->tables[] = 'contact_notes';
|
||||
$this->tables[] = 'contact_phones';
|
||||
$this->tables[] = 'contact_relations';
|
||||
$this->tables[] = 'contact_settings';
|
||||
$this->tables[] = 'contact_times';
|
||||
$this->tables[] = 'contact_urls';
|
||||
$this->tables[] = 'contact_users';
|
||||
$this->tables[] = 'contacts';
|
||||
$this->uuid_prefix = 'contact_';
|
||||
$this->permission_prefix = 'contact_';
|
||||
$this->list_page = 'contacts.php';
|
||||
$this->tables[] = 'contact_addresses';
|
||||
$this->tables[] = 'contact_attachments';
|
||||
$this->tables[] = 'contact_emails';
|
||||
$this->tables[] = 'contact_groups';
|
||||
$this->tables[] = 'contact_notes';
|
||||
$this->tables[] = 'contact_phones';
|
||||
$this->tables[] = 'contact_relations';
|
||||
$this->tables[] = 'contact_settings';
|
||||
$this->tables[] = 'contact_times';
|
||||
$this->tables[] = 'contact_urls';
|
||||
$this->tables[] = 'contact_users';
|
||||
$this->tables[] = 'contacts';
|
||||
$this->uuid_prefix = 'contact_';
|
||||
|
||||
//connect to the database
|
||||
if (empty($this->database)) {
|
||||
$this->database = database::new();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -108,20 +115,15 @@
|
||||
|
||||
//grant temp permissions
|
||||
$p = permissions::new();
|
||||
$database = new database;
|
||||
foreach ($this->tables as $table) {
|
||||
$p->add(database::singular($table).'_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 temp permissions
|
||||
$database = new database;
|
||||
foreach ($this->tables as $table) {
|
||||
$p->delete(database::singular($table).'_delete', 'temp');
|
||||
}
|
||||
@@ -153,7 +155,6 @@
|
||||
//check permissions and build the delete array
|
||||
$x = 0;
|
||||
foreach ($records as $property_name => $properties) {
|
||||
$database = new database;
|
||||
if (permission_exists(database::singular($property_name).'_delete')) {
|
||||
if (is_array($properties) && @sizeof($properties) != 0) {
|
||||
foreach ($properties as $property) {
|
||||
@@ -171,11 +172,8 @@
|
||||
//delete the checked rows
|
||||
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);
|
||||
unset($array);
|
||||
$this->database->delete($array);
|
||||
unset($array);
|
||||
}
|
||||
unset($records);
|
||||
}
|
||||
@@ -217,10 +215,7 @@
|
||||
//delete the checked rows
|
||||
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);
|
||||
}
|
||||
unset($records);
|
||||
@@ -264,11 +259,8 @@
|
||||
//delete the checked rows
|
||||
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);
|
||||
unset($array);
|
||||
$this->database->delete($array);
|
||||
unset($array);
|
||||
}
|
||||
unset($records);
|
||||
}
|
||||
|
||||
@@ -29,11 +29,16 @@
|
||||
*/
|
||||
class dashboard {
|
||||
|
||||
/**
|
||||
* declare constant variables
|
||||
*/
|
||||
const app_name = 'dashboard';
|
||||
const app_uuid = '55533bef-4f04-434a-92af-999c1e9927f7';
|
||||
|
||||
/**
|
||||
* declare the variables
|
||||
*/
|
||||
private $app_name;
|
||||
private $app_uuid;
|
||||
private $database;
|
||||
private $name;
|
||||
private $table;
|
||||
private $tables;
|
||||
@@ -48,16 +53,19 @@
|
||||
*/
|
||||
public function __construct() {
|
||||
//assign the variables
|
||||
$this->app_name = 'dashboard';
|
||||
$this->app_uuid = '55533bef-4f04-434a-92af-999c1e9927f7';
|
||||
$this->tables[] = 'dashboards';
|
||||
$this->tables[] = 'dashboard_widgets';
|
||||
$this->tables[] = 'dashboard_widget_groups';
|
||||
$this->toggle_field = 'dashboard_enabled';
|
||||
$this->toggle_values = ['true','false'];
|
||||
$this->description_field = 'dashboard_description';
|
||||
$this->location = 'dashboard.php';
|
||||
$this->uuid_prefix = 'dashboard_';
|
||||
$this->tables[] = 'dashboards';
|
||||
$this->tables[] = 'dashboard_widgets';
|
||||
$this->tables[] = 'dashboard_widget_groups';
|
||||
$this->toggle_field = 'dashboard_enabled';
|
||||
$this->toggle_values = ['true','false'];
|
||||
$this->description_field = 'dashboard_description';
|
||||
$this->location = 'dashboard.php';
|
||||
$this->uuid_prefix = 'dashboard_';
|
||||
|
||||
//connect to the database
|
||||
if (empty($this->database)) {
|
||||
$this->database = database::new();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,20 +109,15 @@
|
||||
|
||||
//grant temp permissions
|
||||
$p = permissions::new();
|
||||
$database = new database;
|
||||
foreach ($this->tables as $table) {
|
||||
$p->add(database::singular($table).'_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 temp permissions
|
||||
$database = new database;
|
||||
foreach ($this->tables as $table) {
|
||||
$p->delete(database::singular($table).'_delete', 'temp');
|
||||
}
|
||||
@@ -160,8 +163,7 @@
|
||||
if (is_array($uuids) && @sizeof($uuids) != 0) {
|
||||
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
|
||||
$sql .= "where ".$this->name."_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) {
|
||||
$states[$row['uuid']] = $row['toggle'];
|
||||
@@ -184,10 +186,8 @@
|
||||
//save the changes
|
||||
if (is_array($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);
|
||||
|
||||
//set message
|
||||
@@ -234,8 +234,7 @@
|
||||
if (is_array($uuids) && @sizeof($uuids) != 0) {
|
||||
$sql = "select * from v_".$this->table." ";
|
||||
$sql .= "where dashboard_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) {
|
||||
$x = 0;
|
||||
foreach ($rows as $row) {
|
||||
@@ -256,10 +255,8 @@
|
||||
//save the changes and set the message
|
||||
if (is_array($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);
|
||||
|
||||
//set message
|
||||
@@ -307,10 +304,7 @@
|
||||
//delete the checked rows
|
||||
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);
|
||||
|
||||
//set message
|
||||
@@ -352,8 +346,7 @@
|
||||
if (is_array($uuids) && @sizeof($uuids) != 0) {
|
||||
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
|
||||
$sql .= "where ".$this->name."_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) {
|
||||
$states[$row['uuid']] = $row['toggle'];
|
||||
@@ -376,10 +369,8 @@
|
||||
//save the changes
|
||||
if (is_array($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);
|
||||
|
||||
//set message
|
||||
@@ -417,8 +408,7 @@
|
||||
$sql = "select group_name, group_uuid from v_groups ";
|
||||
$sql .= "where group_uuid = :group_uuid ";
|
||||
$parameters['group_uuid'] = $group_uuid;
|
||||
$database = new database;
|
||||
$group = $database->select($sql, $parameters, 'row');
|
||||
$group = $this->database->select($sql, $parameters, 'row');
|
||||
}
|
||||
|
||||
//build the delete array
|
||||
@@ -443,8 +433,7 @@
|
||||
if (!empty($array) && @sizeof($array) != 0) {
|
||||
$sql = "select dashboard_uuid, ".$this->name."_uuid, ";
|
||||
$sql .= "group_uuid from v_".$this->name."_groups ";
|
||||
$database = new database;
|
||||
$dashboard_widget_groups = $database->select($sql, null, 'all');
|
||||
$dashboard_widget_groups = $this->database->select($sql, null, 'all');
|
||||
$array[$this->name.'_groups'] = array_filter($array[$this->name.'_groups'], function($ar) use ($dashboard_widget_groups) {
|
||||
foreach ($dashboard_widget_groups as $existing_array_item) {
|
||||
if ($ar['dashboard_uuid'] == $existing_array_item['dashboard_uuid'] && $ar[$this->name.'_uuid'] == $existing_array_item[$this->name.'_uuid'] && $ar['group_uuid'] == $existing_array_item['group_uuid']) {
|
||||
@@ -459,10 +448,8 @@
|
||||
//add the checked rows from group
|
||||
if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
|
||||
//execute save
|
||||
$database = new database;
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->save($array);
|
||||
|
||||
$this->database->save($array);
|
||||
unset($array);
|
||||
//set message
|
||||
message::add($text['message-add']);
|
||||
@@ -498,8 +485,7 @@
|
||||
$sql = "select group_name, group_uuid from v_groups ";
|
||||
$sql .= "where group_uuid = :group_uuid ";
|
||||
$parameters['group_uuid'] = $group_uuid;
|
||||
$database = new database;
|
||||
$group = $database->select($sql, $parameters, 'row');
|
||||
$group = $this->database->select($sql, $parameters, 'row');
|
||||
}
|
||||
|
||||
//build the delete array
|
||||
@@ -523,8 +509,7 @@
|
||||
if (!empty($uuids) && @sizeof($uuids) != 0) {
|
||||
$sql = "select dashboard_uuid, ".$this->name."_uuid from v_".$this->table." ";
|
||||
$sql .= "where ".$this->name."_parent_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) {
|
||||
//assign dashboard widget groups
|
||||
@@ -546,10 +531,7 @@
|
||||
$p->add('dashboard_widget_group_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
|
||||
|
||||
@@ -27,11 +27,17 @@
|
||||
//define the databases class
|
||||
class databases {
|
||||
|
||||
/**
|
||||
* declare constant variables
|
||||
*/
|
||||
const app_name = 'databases';
|
||||
const app_uuid = '8d229b6d-1383-fcec-74c6-4ce1682479e2';
|
||||
|
||||
/**
|
||||
* declare private variables
|
||||
*/
|
||||
private $app_name;
|
||||
private $app_uuid;
|
||||
|
||||
private $database;
|
||||
private $permission_prefix;
|
||||
private $list_page;
|
||||
private $table;
|
||||
@@ -43,12 +49,15 @@
|
||||
public function __construct() {
|
||||
|
||||
//assign private variables
|
||||
$this->app_name = 'databases';
|
||||
$this->app_uuid = '8d229b6d-1383-fcec-74c6-4ce1682479e2';
|
||||
$this->permission_prefix = 'database_';
|
||||
$this->list_page = 'databases.php';
|
||||
$this->table = 'databases';
|
||||
$this->uuid_prefix = 'database_';
|
||||
$this->permission_prefix = 'database_';
|
||||
$this->list_page = 'databases.php';
|
||||
$this->table = 'databases';
|
||||
$this->uuid_prefix = 'database_';
|
||||
|
||||
//connect to the database
|
||||
if (empty($this->database)) {
|
||||
$this->database = database::new();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -84,10 +93,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);
|
||||
|
||||
//set message
|
||||
@@ -130,8 +136,7 @@
|
||||
if (is_array($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, $parameters ?? null, 'all');
|
||||
$rows = $this->database->select($sql, $parameters ?? null, 'all');
|
||||
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||
foreach ($rows as $x => $row) {
|
||||
|
||||
@@ -151,10 +156,8 @@
|
||||
if (is_array($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);
|
||||
|
||||
//set message
|
||||
|
||||
@@ -30,10 +30,15 @@
|
||||
class default_settings {
|
||||
|
||||
/**
|
||||
* declare the variables
|
||||
* declare constant variables
|
||||
*/
|
||||
const app_name = 'default_settings';
|
||||
const app_uuid = '2c2453c0-1bea-4475-9f44-4d969650de09';
|
||||
|
||||
/**
|
||||
* declare private variables
|
||||
*/
|
||||
private $app_name;
|
||||
private $app_uuid;
|
||||
private $database;
|
||||
private $name;
|
||||
private $table;
|
||||
private $toggle_field;
|
||||
@@ -46,13 +51,16 @@
|
||||
*/
|
||||
public function __construct() {
|
||||
//assign the variables
|
||||
$this->app_name = 'default_settings';
|
||||
$this->app_uuid = '2c2453c0-1bea-4475-9f44-4d969650de09';
|
||||
$this->name = 'default_setting';
|
||||
$this->table = 'default_settings';
|
||||
$this->toggle_field = 'default_setting_enabled';
|
||||
$this->toggle_values = ['true','false'];
|
||||
$this->location = 'default_settings.php';
|
||||
$this->name = 'default_setting';
|
||||
$this->table = 'default_settings';
|
||||
$this->toggle_field = 'default_setting_enabled';
|
||||
$this->toggle_values = ['true','false'];
|
||||
$this->location = 'default_settings.php';
|
||||
|
||||
//connect to the database
|
||||
if (empty($this->database)) {
|
||||
$this->database = database::new();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,10 +98,7 @@
|
||||
//delete the checked rows
|
||||
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);
|
||||
|
||||
//set message
|
||||
@@ -133,8 +138,7 @@
|
||||
if (is_array($uuids) && @sizeof($uuids) != 0) {
|
||||
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
|
||||
$sql .= "where ".$this->name."_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) {
|
||||
$states[$row['uuid']] = $row['toggle'];
|
||||
@@ -157,10 +161,8 @@
|
||||
//save the changes
|
||||
if (is_array($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);
|
||||
|
||||
//set message
|
||||
@@ -208,8 +210,7 @@
|
||||
$sql = "select * from v_default_settings ";
|
||||
$sql .= "where default_setting_uuid = :default_setting_uuid ";
|
||||
$parameters['default_setting_uuid'] = $uuid;
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
$row = $this->database->select($sql, $parameters, 'row');
|
||||
if (is_array($row) && sizeof($row) != 0) {
|
||||
$default_setting_category = $row["default_setting_category"];
|
||||
$default_setting_subcategory = $row["default_setting_subcategory"];
|
||||
@@ -241,9 +242,8 @@
|
||||
$parameters['domain_setting_category'] = $default_setting_category;
|
||||
$parameters['domain_setting_subcategory'] = $default_setting_subcategory;
|
||||
$parameters['domain_setting_name'] = $default_setting_name;
|
||||
$database = new database;
|
||||
$target_domain_setting_uuid = $database->select($sql, $parameters, 'column');
|
||||
$message = $database->message;
|
||||
$target_domain_setting_uuid = $this->database->select($sql, $parameters, 'column');
|
||||
$message = $this->database->message;
|
||||
|
||||
$action = is_uuid($target_domain_setting_uuid) ? 'update' : 'add';
|
||||
unset($sql, $parameters);
|
||||
@@ -272,11 +272,8 @@
|
||||
|
||||
//execute
|
||||
if (is_uuid($array['domain_settings'][$x]['domain_setting_uuid'])) {
|
||||
$database = new database;
|
||||
$database->app_name = $this->table;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->save($array);
|
||||
$message = $database->message;
|
||||
$this->database->save($array);
|
||||
$message = $this->database->message;
|
||||
unset($array);
|
||||
|
||||
$settings_copied++;
|
||||
@@ -298,11 +295,8 @@
|
||||
unset($array['default_settings'][$x]['update_user']);
|
||||
|
||||
//execute
|
||||
$database = new database;
|
||||
$database->app_name = $this->table;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->save($array);
|
||||
$message = $database->message;
|
||||
$this->database->save($array);
|
||||
$message = $this->database->message;
|
||||
unset($array);
|
||||
|
||||
$settings_copied++;
|
||||
|
||||
@@ -27,11 +27,17 @@
|
||||
//define the domain settings class
|
||||
class domain_settings {
|
||||
|
||||
/**
|
||||
* declare constant variables
|
||||
*/
|
||||
const app_name = 'domain_settings';
|
||||
const app_uuid = 'b31e723a-bf70-670c-a49b-470d2a232f71';
|
||||
|
||||
/**
|
||||
* declare private variables
|
||||
*/
|
||||
private $app_name;
|
||||
private $app_uuid;
|
||||
|
||||
private $database;
|
||||
private $permission_prefix;
|
||||
private $list_page;
|
||||
private $table;
|
||||
@@ -51,15 +57,17 @@
|
||||
public function __construct() {
|
||||
|
||||
//assign private variables
|
||||
$this->app_name = 'domain_settings';
|
||||
$this->app_uuid = 'b31e723a-bf70-670c-a49b-470d2a232f71';
|
||||
$this->permission_prefix = 'domain_setting_';
|
||||
$this->list_page = PROJECT_PATH."/core/domains/domain_edit.php?id=".urlencode($this->domain_uuid ?? '');
|
||||
$this->table = 'domain_settings';
|
||||
$this->uuid_prefix = 'domain_setting_';
|
||||
$this->toggle_field = 'domain_setting_enabled';
|
||||
$this->toggle_values = ['true','false'];
|
||||
$this->permission_prefix = 'domain_setting_';
|
||||
$this->list_page = PROJECT_PATH."/core/domains/domain_edit.php?id=".urlencode($this->domain_uuid ?? '');
|
||||
$this->table = 'domain_settings';
|
||||
$this->uuid_prefix = 'domain_setting_';
|
||||
$this->toggle_field = 'domain_setting_enabled';
|
||||
$this->toggle_values = ['true','false'];
|
||||
|
||||
//connect to the database
|
||||
if (empty($this->database)) {
|
||||
$this->database = database::new();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,10 +103,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);
|
||||
|
||||
//set message
|
||||
@@ -141,8 +146,7 @@
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
|
||||
$parameters['domain_uuid'] = $this->domain_uuid;
|
||||
$database = new database;
|
||||
$rows = $database->select($sql, $parameters, 'all');
|
||||
$rows = $this->database->select($sql, $parameters, 'all');
|
||||
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||
foreach ($rows as $row) {
|
||||
$states[$row['uuid']] = $row['toggle'];
|
||||
@@ -165,10 +169,8 @@
|
||||
if (is_array($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);
|
||||
|
||||
//set message
|
||||
@@ -220,8 +222,7 @@
|
||||
$sql = "select * from v_domain_settings ";
|
||||
$sql .= "where domain_setting_uuid = :domain_setting_uuid ";
|
||||
$parameters['domain_setting_uuid'] = $uuid;
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
$row = $this->database->select($sql, $parameters, 'row');
|
||||
if (is_array($row) && sizeof($row) != 0) {
|
||||
$domain_setting_category = $row["domain_setting_category"];
|
||||
$domain_setting_subcategory = $row["domain_setting_subcategory"];
|
||||
@@ -250,8 +251,7 @@
|
||||
$parameters['domain_setting_category'] = $domain_setting_category;
|
||||
$parameters['domain_setting_subcategory'] = $domain_setting_subcategory;
|
||||
$parameters['domain_setting_name'] = $domain_setting_name;
|
||||
$database = new database;
|
||||
$target_domain_setting_uuid = $database->select($sql, $parameters, 'column');
|
||||
$target_domain_setting_uuid = $this->database->select($sql, $parameters, 'column');
|
||||
|
||||
$action = is_uuid($target_domain_setting_uuid) ? 'update' : 'add';
|
||||
unset($sql, $parameters);
|
||||
@@ -285,10 +285,9 @@
|
||||
|
||||
//execute
|
||||
if (is_uuid($array['domain_settings'][0]['domain_setting_uuid'])) {
|
||||
$database = new database;
|
||||
$database->app_name = 'domain_settings';
|
||||
$database->app_uuid = 'b31e723a-bf70-670c-a49b-470d2a232f71';
|
||||
$database->save($array);
|
||||
$this->database->app_name = 'domain_settings';
|
||||
$this->database->app_uuid = 'b31e723a-bf70-670c-a49b-470d2a232f71';
|
||||
$this->database->save($array);
|
||||
unset($array);
|
||||
|
||||
$settings_copied++;
|
||||
@@ -305,8 +304,7 @@
|
||||
$sql = "select * from v_domain_settings ";
|
||||
$sql .= "where domain_setting_uuid = :domain_setting_uuid ";
|
||||
$parameters['domain_setting_uuid'] = $uuid;
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
$row = $this->database->select($sql, $parameters, 'row');
|
||||
if (is_array($row) && sizeof($row) != 0) {
|
||||
$domain_setting_category = $row["domain_setting_category"];
|
||||
$domain_setting_subcategory = $row["domain_setting_subcategory"];
|
||||
@@ -332,8 +330,7 @@
|
||||
$parameters['default_setting_category'] = $domain_setting_category;
|
||||
$parameters['default_setting_subcategory'] = $domain_setting_subcategory;
|
||||
$parameters['default_setting_name'] = $domain_setting_name;
|
||||
$database = new database;
|
||||
$target_default_setting_uuid = $database->select($sql, $parameters, 'column');
|
||||
$target_default_setting_uuid = $this->database->select($sql, $parameters, 'column');
|
||||
|
||||
$action = is_uuid($target_default_setting_uuid) ? 'update' : 'add';
|
||||
unset($sql, $parameters);
|
||||
@@ -361,10 +358,9 @@
|
||||
|
||||
//execute
|
||||
if (is_uuid($array['default_settings'][0]['default_setting_uuid'])) {
|
||||
$database = new database;
|
||||
$database->app_name = 'domain_settings';
|
||||
$database->app_uuid = 'b31e723a-bf70-670c-a49b-470d2a232f71';
|
||||
$database->save($array);
|
||||
$this->database->app_name = 'domain_settings';
|
||||
$this->database->app_uuid = 'b31e723a-bf70-670c-a49b-470d2a232f71';
|
||||
$this->database->save($array);
|
||||
unset($array);
|
||||
|
||||
$settings_copied++;
|
||||
|
||||
@@ -27,11 +27,17 @@
|
||||
//define the email templates class
|
||||
class email_templates {
|
||||
|
||||
/**
|
||||
* declare constant variables
|
||||
*/
|
||||
const app_name = 'email_templates';
|
||||
const app_uuid = '8173e738-2523-46d5-8943-13883befd2fd';
|
||||
|
||||
/**
|
||||
* declare private variables
|
||||
*/
|
||||
private $app_name;
|
||||
private $app_uuid;
|
||||
|
||||
private $database;
|
||||
private $permission_prefix;
|
||||
private $list_page;
|
||||
private $table;
|
||||
@@ -45,14 +51,17 @@
|
||||
public function __construct() {
|
||||
|
||||
//assign private variables
|
||||
$this->app_name = 'email_templates';
|
||||
$this->app_uuid = '8173e738-2523-46d5-8943-13883befd2fd';
|
||||
$this->permission_prefix = 'email_template_';
|
||||
$this->list_page = 'email_templates.php';
|
||||
$this->table = 'email_templates';
|
||||
$this->uuid_prefix = 'email_template_';
|
||||
$this->toggle_field = 'template_enabled';
|
||||
$this->toggle_values = ['true','false'];
|
||||
$this->permission_prefix = 'email_template_';
|
||||
$this->list_page = 'email_templates.php';
|
||||
$this->table = 'email_templates';
|
||||
$this->uuid_prefix = 'email_template_';
|
||||
$this->toggle_field = 'template_enabled';
|
||||
$this->toggle_values = ['true','false'];
|
||||
|
||||
//connect to the database
|
||||
if (empty($this->database)) {
|
||||
$this->database = database::new();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -88,10 +97,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);
|
||||
|
||||
//set message
|
||||
@@ -134,8 +140,7 @@
|
||||
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$database = new database;
|
||||
$rows = $database->select($sql, $parameters, 'all');
|
||||
$rows = $this->database->select($sql, $parameters, 'all');
|
||||
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||
foreach ($rows as $row) {
|
||||
$states[$row['uuid']] = $row['toggle'];
|
||||
@@ -156,10 +161,8 @@
|
||||
if (is_array($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);
|
||||
|
||||
//set message
|
||||
@@ -205,8 +208,7 @@
|
||||
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$database = new database;
|
||||
$rows = $database->select($sql, $parameters, 'all');
|
||||
$rows = $this->database->select($sql, $parameters, 'all');
|
||||
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||
foreach ($rows as $x => $row) {
|
||||
|
||||
@@ -226,10 +228,8 @@
|
||||
if (is_array($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);
|
||||
|
||||
//set message
|
||||
|
||||
@@ -27,6 +27,29 @@
|
||||
//define the permission class
|
||||
class permission {
|
||||
|
||||
/**
|
||||
* declare constant variables
|
||||
*/
|
||||
const app_name = 'groups';
|
||||
const app_uuid = '2caf27b0-540a-43d5-bb9b-c9871a1e4f84';
|
||||
|
||||
/**
|
||||
* declare private variables
|
||||
*/
|
||||
|
||||
private $database;
|
||||
|
||||
/**
|
||||
* called when the object is created
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
//assign the database
|
||||
if (empty($this->database)) {
|
||||
$this->database = database::new();
|
||||
}
|
||||
}
|
||||
|
||||
//delete the permissions
|
||||
function delete() {
|
||||
|
||||
@@ -67,8 +90,7 @@
|
||||
$sql .= " and group_name in (".$group_names.") ";
|
||||
$sql .= ")";
|
||||
$sql .= "and (permission_protected <> 'true' or permission_protected is null)";
|
||||
$database = new database;
|
||||
$result = $database->select($sql);
|
||||
$result = $this->database->select($sql);
|
||||
|
||||
//get the group_permissons
|
||||
/*
|
||||
@@ -79,8 +101,7 @@
|
||||
$sql .= " where group_protected <> true ";
|
||||
$sql .= " and group_name in (".$group_names.") ";
|
||||
$sql .= ");";
|
||||
$database = new database;
|
||||
$group_permissions = $database->select($sql, null, 'all');
|
||||
$group_permissions = $this->database->select($sql, null, 'all');
|
||||
*/
|
||||
|
||||
//delete unprotected group permissions
|
||||
@@ -98,10 +119,7 @@
|
||||
$p = permissions::new();
|
||||
$p->add('group_permission_delete', 'temp');
|
||||
//execute delete
|
||||
$database = new database;
|
||||
$database->app_name = 'groups';
|
||||
$database->app_uuid = '2caf27b0-540a-43d5-bb9b-c9871a1e4f84';
|
||||
$database->delete($array);
|
||||
$this->database->delete($array);
|
||||
unset($array);
|
||||
//revoke temporary permissions
|
||||
$p->delete('group_permission_delete', 'temp');
|
||||
@@ -116,16 +134,14 @@
|
||||
//if the are no groups add the default groups
|
||||
$sql = "select * from v_groups ";
|
||||
$sql .= "where domain_uuid is null ";
|
||||
$database = new database;
|
||||
$groups = $database->select($sql, null, 'all');
|
||||
$groups = $this->database->select($sql, null, 'all');
|
||||
|
||||
//delete the group permissions
|
||||
$this->delete();
|
||||
|
||||
//get the remaining group permissions
|
||||
$sql = "select permission_name, group_name from v_group_permissions ";
|
||||
$database = new database;
|
||||
$database_group_permissions = $database->select($sql, null, 'all');
|
||||
$this->database_group_permissions = $this->database->select($sql, null, 'all');
|
||||
|
||||
//get the $apps array from the installed apps from the core and mod directories
|
||||
$config_list = glob($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/*/*/app_config.php");
|
||||
@@ -158,7 +174,7 @@
|
||||
if (!$group_protected) {
|
||||
// check if the item is not currently in the database
|
||||
$exists = false;
|
||||
foreach ($database_group_permissions as $i => $group_permission) {
|
||||
foreach ($this->database_group_permissions as $i => $group_permission) {
|
||||
if ($group_permission['permission_name'] == $permission['name']) {
|
||||
if ($group_permission['group_name'] == $group_name) {
|
||||
$exists = true;
|
||||
@@ -189,10 +205,7 @@
|
||||
$p->add('group_permission_add', 'temp');
|
||||
|
||||
//execute insert
|
||||
$database = new database;
|
||||
$database->app_name = 'groups';
|
||||
$database->app_uuid = '2caf27b0-540a-43d5-bb9b-c9871a1e4f84';
|
||||
$database->save($array);
|
||||
$this->database->save($array);
|
||||
unset($array);
|
||||
|
||||
//revoke temporary permissions
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
class install {
|
||||
|
||||
/**
|
||||
* declare the variables
|
||||
*/
|
||||
private $app_name;
|
||||
private $app_uuid;
|
||||
* declare constant variables
|
||||
*/
|
||||
const app_name = 'install';
|
||||
const app_uuid = '75507e6e-891e-11e5-af63-feff819cdc9f';
|
||||
|
||||
/**
|
||||
* declare public variables
|
||||
*/
|
||||
public $message;
|
||||
public $database_host;
|
||||
public $database_port;
|
||||
@@ -18,9 +22,7 @@
|
||||
* called when the object is created
|
||||
*/
|
||||
public function __construct() {
|
||||
//assign the variables
|
||||
$this->app_name = 'install';
|
||||
$this->app_uuid = '75507e6e-891e-11e5-af63-feff819cdc9f';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,10 +30,15 @@
|
||||
class user_logs {
|
||||
|
||||
/**
|
||||
* declare the variables
|
||||
*/
|
||||
private $app_name;
|
||||
private $app_uuid;
|
||||
* declare constant variables
|
||||
*/
|
||||
const app_name = 'user_logs';
|
||||
const app_uuid = '582a13cf-7d75-4ea3-b2d9-60914352d76e';
|
||||
|
||||
/**
|
||||
* declare private variables
|
||||
*/
|
||||
private $database;
|
||||
private $name;
|
||||
private $table;
|
||||
private $toggle_field;
|
||||
@@ -45,13 +50,16 @@
|
||||
*/
|
||||
public function __construct() {
|
||||
//assign the variables
|
||||
$this->app_name = 'user_logs';
|
||||
$this->app_uuid = '582a13cf-7d75-4ea3-b2d9-60914352d76e';
|
||||
$this->name = 'user_log';
|
||||
$this->table = 'user_logs';
|
||||
$this->toggle_field = '';
|
||||
$this->toggle_values = ['true','false'];
|
||||
$this->location = 'user_logs.php';
|
||||
$this->name = 'user_log';
|
||||
$this->table = 'user_logs';
|
||||
$this->toggle_field = '';
|
||||
$this->toggle_values = ['true','false'];
|
||||
$this->location = 'user_logs.php';
|
||||
|
||||
//connect to the database
|
||||
if (empty($this->database)) {
|
||||
$this->database = database::new();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,6 +67,9 @@
|
||||
*/
|
||||
public static function add($result, $details = '') {
|
||||
|
||||
//create the database object
|
||||
$database = database::new();
|
||||
|
||||
//prepare the array
|
||||
$array = [];
|
||||
$array['user_logs'][0]["timestamp"] = 'now()';
|
||||
@@ -84,11 +95,6 @@
|
||||
$p->add("user_log_add", 'temp');
|
||||
|
||||
//save to the data
|
||||
$database = new database;
|
||||
$database->app_name = 'authentication';
|
||||
$database->app_uuid = 'a8a12918-69a4-4ece-a1ae-3932be0e41f1';
|
||||
if (strlen($user_log_uuid ?? '')>0)
|
||||
$database->uuid($user_log_uuid);
|
||||
$database->save($array, false);
|
||||
$message = $database->message;
|
||||
|
||||
@@ -132,10 +138,7 @@
|
||||
//delete the checked rows
|
||||
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);
|
||||
|
||||
//set message
|
||||
|
||||
@@ -27,11 +27,17 @@
|
||||
//define the user settings class
|
||||
class user_settings {
|
||||
|
||||
/**
|
||||
* declare constant variables
|
||||
*/
|
||||
const app_name = 'user_settings';
|
||||
const app_uuid = '3a3337f7-78d1-23e3-0cfd-f14499b8ed97';
|
||||
|
||||
/**
|
||||
* declare private variables
|
||||
*/
|
||||
private $app_name;
|
||||
private $app_uuid;
|
||||
|
||||
private $database;
|
||||
private $permission_prefix;
|
||||
private $list_page;
|
||||
private $table;
|
||||
@@ -50,15 +56,17 @@
|
||||
public function __construct() {
|
||||
|
||||
//assign private variables
|
||||
$this->app_name = 'user_settings';
|
||||
$this->app_uuid = '3a3337f7-78d1-23e3-0cfd-f14499b8ed97';
|
||||
$this->permission_prefix = 'user_setting_';
|
||||
$this->list_page = PROJECT_PATH."/core/user/user_edit.php?id=".urlencode($this->user_uuid ?? '');
|
||||
$this->table = 'user_settings';
|
||||
$this->uuid_prefix = 'user_setting_';
|
||||
$this->toggle_field = 'user_setting_enabled';
|
||||
$this->toggle_values = ['true','false'];
|
||||
$this->permission_prefix = 'user_setting_';
|
||||
$this->list_page = PROJECT_PATH."/core/user/user_edit.php?id=".urlencode($this->user_uuid ?? '');
|
||||
$this->table = 'user_settings';
|
||||
$this->uuid_prefix = 'user_setting_';
|
||||
$this->toggle_field = 'user_setting_enabled';
|
||||
$this->toggle_values = ['true','false'];
|
||||
|
||||
//connect to the database
|
||||
if (empty($this->database)) {
|
||||
$this->database = database::new();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,10 +102,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);
|
||||
|
||||
//set message
|
||||
@@ -140,8 +145,7 @@
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$database = new database;
|
||||
$rows = $database->select($sql, $parameters, 'all');
|
||||
$rows = $this->database->select($sql, $parameters, 'all');
|
||||
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||
foreach ($rows as $row) {
|
||||
$states[$row['uuid']] = $row['toggle'];
|
||||
@@ -164,10 +168,8 @@
|
||||
if (is_array($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);
|
||||
|
||||
//set message
|
||||
|
||||
@@ -29,11 +29,18 @@
|
||||
*/
|
||||
class users {
|
||||
|
||||
/**
|
||||
* declare constant variables
|
||||
*/
|
||||
const app_name = 'users';
|
||||
const app_uuid = '112124b3-95c2-5352-7e9d-d14c0b88f207';
|
||||
|
||||
/**
|
||||
* declare the variables
|
||||
*/
|
||||
private $app_name;
|
||||
private $app_uuid;
|
||||
private $database;
|
||||
private $name;
|
||||
private $table;
|
||||
private $toggle_field;
|
||||
@@ -45,13 +52,16 @@
|
||||
*/
|
||||
public function __construct() {
|
||||
//assign the variables
|
||||
$this->app_name = 'users';
|
||||
$this->app_uuid = '112124b3-95c2-5352-7e9d-d14c0b88f207';
|
||||
$this->name = 'user';
|
||||
$this->table = 'users';
|
||||
$this->toggle_field = 'user_enabled';
|
||||
$this->toggle_values = ['true','false'];
|
||||
$this->location = 'users.php';
|
||||
$this->name = 'user';
|
||||
$this->table = 'users';
|
||||
$this->toggle_field = 'user_enabled';
|
||||
$this->toggle_values = ['true','false'];
|
||||
$this->location = 'users.php';
|
||||
|
||||
//connect to the database
|
||||
if (empty($this->database)) {
|
||||
$this->database = database::new();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,8 +97,7 @@
|
||||
$sql = "select domain_uuid from v_users ";
|
||||
$sql .= "where user_uuid = :user_uuid ";
|
||||
$parameters['user_uuid'] = $user_uuid;
|
||||
$database = new database;
|
||||
$domain_uuid = $database->select($sql, $parameters, 'column');
|
||||
$domain_uuid = $this->database->select($sql, $parameters, 'column');
|
||||
unset($sql, $parameters);
|
||||
}
|
||||
else {
|
||||
@@ -130,10 +139,7 @@
|
||||
$p->add('user_group_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);
|
||||
|
||||
$p->delete('user_setting_delete', 'temp');
|
||||
@@ -176,8 +182,7 @@
|
||||
if (is_array($uuids) && @sizeof($uuids) != 0) {
|
||||
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
|
||||
$sql .= "where ".$this->name."_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) {
|
||||
$states[$row['uuid']] = $row['toggle'];
|
||||
@@ -200,10 +205,8 @@
|
||||
//save the changes
|
||||
if (is_array($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);
|
||||
|
||||
//set message
|
||||
@@ -246,8 +249,7 @@
|
||||
if (!empty($uuids) && is_array($uuids) && @sizeof($uuids) != 0) {
|
||||
$sql = "select * from v_".$this->table." ";
|
||||
$sql .= "where ".$this->name."_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) {
|
||||
$x = 0;
|
||||
foreach ($rows as $row) {
|
||||
@@ -268,10 +270,8 @@
|
||||
//save the changes and set the message
|
||||
if (!empty($array) && is_array($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);
|
||||
|
||||
//set message
|
||||
@@ -288,20 +288,20 @@
|
||||
* @return void
|
||||
*/
|
||||
public static function database_maintenance(settings $settings): void {
|
||||
$database = $settings->database();
|
||||
$domains = maintenance_service::get_domains($database);
|
||||
$this->database = $settings->database();
|
||||
$domains = maintenance_service::get_domains($this->database);
|
||||
foreach ($domains as $domain_uuid => $domain_name) {
|
||||
$domain_settings = new settings(['database' => $database, 'domain_uuid' => $domain_uuid]);
|
||||
$domain_settings = new settings(['database' => $this->database, 'domain_uuid' => $domain_uuid]);
|
||||
$retention_days = $domain_settings->get('users', 'database_retention_days', '');
|
||||
if (!empty($retention_days) && is_numeric($retention_days)) {
|
||||
$sql = "delete from v_user_logs where timestamp < NOW() - INTERVAL '$retention_days days'";
|
||||
$sql.= " and domain_uuid = '$domain_uuid'";
|
||||
$database->execute($sql);
|
||||
$code = $database->message['code'] ?? 0;
|
||||
$this->database->execute($sql);
|
||||
$code = $this->database->message['code'] ?? 0;
|
||||
if ($code == 200) {
|
||||
maintenance_service::log_write(self::class, "Successfully removed entries older than $retention_days", $domain_uuid);
|
||||
} else {
|
||||
$message = $database->message['message'] ?? "An unknown error has occurred";
|
||||
$message = $this->database->message['message'] ?? "An unknown error has occurred";
|
||||
maintenance_service::log_write(self::class, "Unable to remove old database records. Error message: $message ($code)", $domain_uuid, maintenance_service::LOG_ERROR);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user