diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index bdb881375..889dc56dc 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -12,6 +12,10 @@ "8000": { "label": "mkdocs", "onAutoForward": "notify" + }, + "8080": { + "label": "phpmyadmin", + "onAutoForward": "notify" } }, "forwardPorts": [ diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 4521ddc80..ba3b1a9aa 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -28,5 +28,13 @@ services: environment: MYSQL_ROOT_PASSWORD: blis123 + phpmyadmin: + image: phpmyadmin + restart: unless-stopped + ports: + - 8080:80 + environment: + PMA_HOST: db + volumes: blis-data: diff --git a/htdocs/config/v2/delete_backup.php b/htdocs/config/v2/delete_backup.php index c92e3afe7..3261d4929 100644 --- a/htdocs/config/v2/delete_backup.php +++ b/htdocs/config/v2/delete_backup.php @@ -41,7 +41,7 @@ $backup->destroy(); -$_SESSION["BACKUP_FLASH"] = "Backup deleted successfully."; +$_SESSION["FLASH"] = "Backup deleted successfully."; header("Location: lab_config_backups.php?id=$lab_config_id"); diff --git a/htdocs/config/v2/delete_lab_config.php b/htdocs/config/v2/delete_lab_config.php new file mode 100644 index 000000000..9ea87ead2 --- /dev/null +++ b/htdocs/config/v2/delete_lab_config.php @@ -0,0 +1,131 @@ +info("Deleting lab [ID $lab_config_id] database: " . $lab["db_name"]); + + try { + // in db_lib.php + delete_lab_config($lab_config_id); + } catch (Exception $e) { + $log->error("Could not delete database: ". $e); + $err = true; + } + + try { + $langdata_dir = realpath("../../../local/langdata_$lab_config_id"); + if ($langdata_dir) { + $log->info("Deleting folder: $langdata_dir"); + PlatformLib::removeDirectory($langdata_dir); + } else { + $log->info("Lab [ID $lab_config_id] does not have a langdata folder, so skipping delete."); + } + } catch (Exception $e) { + $log->error("Could not delete langdata folder: ". $e); + $err = true; + } + + if (!$err) { + $_SESSION["FLASH"] = "Lab deleted successfully."; + } else { + $_SESSION["FLASH"] = "There was a problem deleting the lab. Please see the logs for details."; + } + + header("Location: lab_config_index.php"); + exit; +} + +require_once(__DIR__."/../../includes/header.php"); +LangUtil::setPageId("lab_config_home"); + +?> + + + +
+

Delete Lab

+ +
+

Are you sure you want to delete ?

+ +

This cannot be undone. ALL data about this lab will be deleted forever!

+ +
+
+ Cancel + + + + +
+
+
+
+ + \ No newline at end of file diff --git a/htdocs/config/v2/lab_config_backup_header.php b/htdocs/config/v2/lab_config_backup_header.php index 9286b7ac1..146ebc2dc 100644 --- a/htdocs/config/v2/lab_config_backup_header.php +++ b/htdocs/config/v2/lab_config_backup_header.php @@ -68,17 +68,14 @@ function render_tab($tab_name, $tab_link, $tab_label) { margin: 0.5rem 1rem; } -.backup-flash { - background-color: lightgreen; - margin: 0.5rem; - padding: 1rem; - font-size: large; -} - a.delete-backup { color: red; } +#pending-migrations { + border: 1px solid darkblue; + background-color: lightblue; +}
@@ -93,12 +90,3 @@ function render_tab($tab_name, $tab_link, $tab_label) { | |
- -".$_SESSION['BACKUP_FLASH'].""; - $_SESSION['BACKUP_FLASH'] = ''; - } -?> diff --git a/htdocs/config/v2/lab_config_backup_restore.php b/htdocs/config/v2/lab_config_backup_restore.php index 5f4f93848..3c45fe1ae 100644 --- a/htdocs/config/v2/lab_config_backup_restore.php +++ b/htdocs/config/v2/lab_config_backup_restore.php @@ -138,14 +138,14 @@ if ($restore_successful) { if ($migrations_successful) { - $_SESSION["BACKUP_FLASH"] = "Backup restored successfully."; + $_SESSION["FLASH"] = "Backup restored successfully."; } else { - $_SESSION["BACKUP_FLASH"] = "Backup database was restored, " + $_SESSION["FLASH"] = "Backup database was restored, " . "but could not be migrated to the new BLIS version. " . "Please check the logs for details."; } } else { - $_SESSION["BACKUP_FLASH"] = "Failed to restore backup."; + $_SESSION["FLASH"] = "Failed to restore backup."; } header("Location: lab_config_backups.php?id=$lab_config_id"); diff --git a/htdocs/config/v2/lab_config_backup_upload.php b/htdocs/config/v2/lab_config_backup_upload.php index b459cbf1c..9fed3be5e 100644 --- a/htdocs/config/v2/lab_config_backup_upload.php +++ b/htdocs/config/v2/lab_config_backup_upload.php @@ -89,7 +89,7 @@ $perm_tmp_path = "/tmp/blis/" . basename($tmp_path); if (!move_uploaded_file($tmp_path, $perm_tmp_path)) { - $_SESSION["BACKUP_FLASH"] = "Failed to upload $filename."; + $_SESSION["FLASH"] = "Failed to upload $filename."; header("Location: lab_config_backup_upload.php?id=$lab_config_id"); return; } diff --git a/htdocs/config/v2/lab_config_backups.php b/htdocs/config/v2/lab_config_backups.php index 161580340..bb8c0d4fc 100644 --- a/htdocs/config/v2/lab_config_backups.php +++ b/htdocs/config/v2/lab_config_backups.php @@ -7,6 +7,7 @@ # require_once(__DIR__."/../../users/accesslist.php"); +require_once(__DIR__."/../../includes/migrations.php"); require_once(__DIR__."/../../includes/user_lib.php"); require_once(__DIR__."/lib/backup.php"); @@ -52,6 +53,9 @@ // TODO: switch this to its own table, maybe... $settings_encryption_enabled = KeyMgmt::read_enc_setting() != "0"; +$migrator = new LabDatabaseMigrator($lab['db_name']); +$has_pending_migrations = $migrator->pending_migrations(); + ?> + +
+ There are database migrations pending. Please click here to apply them. +
+ +

Create New Backup

diff --git a/htdocs/config/v2/lab_config_backups_apply_migrations.php b/htdocs/config/v2/lab_config_backups_apply_migrations.php new file mode 100644 index 000000000..de85d035a --- /dev/null +++ b/htdocs/config/v2/lab_config_backups_apply_migrations.php @@ -0,0 +1,55 @@ +labConfigId && is_admin($current_user)) { + $unauthorized = false; + } +} + +if ($unauthorized) { + header('HTTP/1.1 401 Unauthorized', true, 401); + header("Location: /home.php"); + exit; +} + +$migrator = new LabDatabaseMigrator($lab['db_name']); +$migrations_successful = $migrator->apply_migrations(); + +if ($migrations_successful) { + $_SESSION["FLASH"] = "Migrations applied successfully."; +} else { + $_SESSION["FLASH"] = "There were errors while applying migrations."; +} + +header("Location: lab_config_backups.php?id=$lab_config_id"); +exit; diff --git a/htdocs/config/v2/lab_config_index.php b/htdocs/config/v2/lab_config_index.php index 67a23e392..85a9f2963 100644 --- a/htdocs/config/v2/lab_config_index.php +++ b/htdocs/config/v2/lab_config_index.php @@ -45,6 +45,10 @@ border-bottom: 1px solid #555; } +a.delete { + color: red; +} +
@@ -75,6 +79,8 @@ + + @@ -98,17 +104,19 @@ adminUserId); ?> -
- - - -
-
-
- - - -
+ + + + + + + + + + + + + getMessage(); + $_SESSION["FLASH"] = "Failed to upload $uploaded_filename:" . $e->getMessage(); } header("Location: $lab_config_backups_path"); diff --git a/htdocs/debug/debug.php b/htdocs/debug/debug.php index 0b21eae3e..186d95039 100644 --- a/htdocs/debug/debug.php +++ b/htdocs/debug/debug.php @@ -9,33 +9,15 @@ ?>

Debug Utilities

-".$_SESSION['DEBUG_FLASH']."
"; - $_SESSION['DEBUG_FLASH'] = ''; - } -?> - getMessage(); + $_SESSION["FLASH"] = "Lab backup was unsuccessful: " . $e->getMessage(); } header("Location: $lab_config_backups_path"); diff --git a/htdocs/includes/db_lib.php b/htdocs/includes/db_lib.php index 389eaceb6..e94c9b9dc 100644 --- a/htdocs/includes/db_lib.php +++ b/htdocs/includes/db_lib.php @@ -8375,9 +8375,12 @@ function delete_lab_config($lab_config_id) } # Delete DB instance db_delete($lab_config->dbName); + # Delete DB revamp instance - $revamp_db_name = "blis_revamp_".$lab_config->id; - db_delete($revamp_db_name); + # This appears to be an unused idea. This table never actually gets created. + // $revamp_db_name = "blis_revamp_".$lab_config->id; + // db_delete($revamp_db_name); + # Delete entries from lab_config_access $query_string = "DELETE FROM lab_config_access ". diff --git a/htdocs/includes/features.php b/htdocs/includes/features.php index d5391f6bb..46729444f 100644 --- a/htdocs/includes/features.php +++ b/htdocs/includes/features.php @@ -8,7 +8,9 @@ class Features { public static function lab_config_v2_enabled() { - return Features::ev_enabled("BLIS_LAB_BACKUPS_V2_ENABLED"); + return true; + // Enabled by default now! + // return Features::ev_enabled("BLIS_LAB_BACKUPS_V2_ENABLED"); } private static function ev_enabled($ev) { diff --git a/htdocs/includes/header.php b/htdocs/includes/header.php index 75f9638bb..1176a649c 100644 --- a/htdocs/includes/header.php +++ b/htdocs/includes/header.php @@ -148,4 +148,26 @@ } ?>
+ + + +
+ +
+ +