Database class integration. Modify database class singular() method to support table names ending in 'ses', such as v_databases.

This commit is contained in:
Nate
2019-07-09 20:06:17 -06:00
parent 2cb44c3b7d
commit fca4691ac6
11 changed files with 287 additions and 340 deletions

View File

@@ -50,8 +50,8 @@
$document['title'] = $text['title-apps'];
//get variables used to control the order
$order_by = check_str($_GET["order_by"]);
$order = check_str($_GET["order"]);
$order_by = $_GET["order_by"];
$order = $_GET["order"];
//get the list of installed apps from the core and mod directories
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");

View File

@@ -39,14 +39,10 @@ else {
$text = $language->get();
//get the id
if (count($_GET) > 0) {
$id = check_str($_GET["id"]);
}
if (is_uuid($_GET["id"]) {
if (strlen($id) > 0) {
if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
$app_uuid = $_GET["id"];
//get the list of installed apps from the core and mod directories
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
$x=0;
@@ -60,36 +56,45 @@ if (strlen($id) > 0) {
$name = $row['name'];
if ($row["uuid"] == $app_uuid && $row['category'] != "Core") {
//delete the app from the menu
foreach ($row['menu'] as &$menu) {
foreach ($row['menu'] as $index => &$menu) {
//delete menu groups and permissions from the database
$sql = "delete from v_menu_item_groups ";
$sql .= "where menu_item_uuid = '".$menu['uuid']."' ";
$db->query($sql);
$sql = "delete from v_menu_items ";
$sql .= "where menu_item_uuid = '".$menu['uuid']."' ";
$db->query($sql);
$array['menu_item_groups'][$index]['menu_item_uuid'] = $menu['uuid'];
$array['menu_items'][$index['menu_item_uuid'] = $menu['uuid'];
//delete the app from the file system
if (strlen($menu['path']) > 0) {
system('rm -rf '.dirname($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.$menu['path']));
}
}
if (is_array($array) && sizeof($array) != 0) {
$database = new database;
$database->app_name = 'apps';
$database->app_uuid = 'd8704214-75a0-e52f-1336-f0780e29fef8';
$database->delete($array);
unset($array);
}
//delete the group permissions for the app
foreach ($row['permissions'] as &$permission) {
$sql = "delete from v_group_permissions ";
$sql .= "where permission_name = '".$permission['name']."' ";
$db->query($sql);
foreach ($row['permissions'] as $index => &$permission) {
$array['group_permissions'][$index]['permission_name'] = $permission['name'];
}
if (is_array($array) && sizeof($array) != 0) {
$database = new database;
$database->app_name = 'apps';
$database->app_uuid = 'd8704214-75a0-e52f-1336-f0780e29fef8';
$database->delete($array);
unset($array);
}
}
}
}
//set message
message::add($text['message-delete']);
}
}
//redirect the browser
message::add($text['message-delete']);
header("Location: apps.php");
return;

View File

@@ -39,9 +39,9 @@ else {
$text = $language->get();
//action add or update
if (isset($_REQUEST["id"])) {
if (is_uuid($_REQUEST["id"])) {
$action = "update";
$app_uuid = check_str($_REQUEST["id"]);
$app_uuid = $_REQUEST["id"];
}
else {
$action = "add";
@@ -49,14 +49,14 @@ else {
//get http post variables and set them to php variables
if (count($_POST)>0) {
$app_enabled = check_str($_POST["app_enabled"]);
$app_enabled = $_POST["app_enabled"];
}
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$msg = '';
if ($action == "update") {
$app_uuid = check_str($_POST["app_uuid"]);
$app_uuid = $_POST["app_uuid"];
}
//check for all required data
@@ -77,35 +77,27 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
//add or update the database
if ($_POST["persistformvar"] != "true") {
if ($action == "add") {
$sql = "insert into v_apps ";
$sql .= "(";
$sql .= "app_uuid ";
$sql .= ")";
$sql .= "values ";
$sql .= "(";
$sql .= "'".uuid()."' ";
$sql .= ")";
//$db->exec(check_sql($sql));
unset($sql);
$array['apps'][0]['app_uuid'] = uuid();
message::add($text['message-add']);
header("Location: apps.php");
return;
} //if ($action == "add")
}
if ($action == "update") {
$sql = "update v_apps set ";
$sql .= "app_uuid = '$app_uuid' ";
$sql .= "where app_uuid = '$app_uuid'";
//$db->exec(check_sql($sql));
unset($sql);
$array['apps'][0]['app_uuid'] = $app_uuid;
message::add($text['message-update']);
header("Location: apps.php");
return;
} //if ($action == "update")
} //if ($_POST["persistformvar"] != "true")
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
}
if (is_array($array) && sizeof($array) != 0) {
$database = new database;
$database->app_name = 'apps';
$database->app_uuid = 'd8704214-75a0-e52f-1336-f0780e29fef8';
$database->save($array);
unset($array);
}
header("Location: apps.php");
exit;
}
}
//show the header
require_once "resources/header.php";