Migrate Dark/light mode to a user settings instead of global setting, created new include called router.php to dynamically prepend ../../ to asset pathes based off currect directory depth

This commit is contained in:
johnnyq
2025-08-05 13:32:19 -04:00
parent 7e55808a05
commit 08dd6147f2
16 changed files with 48 additions and 26 deletions

View File

@@ -59,6 +59,7 @@ if (isset($row['role_is_admin']) && $row['role_is_admin'] == 1) {
}
$session_user_config_force_mfa = intval($row['user_config_force_mfa']);
$user_config_records_per_page = intval($row['user_config_records_per_page']);
$user_config_theme_dark = intval($row['user_config_theme_dark']);
// Check user type
if ($session_user_type !== 1) {

View File

@@ -5,4 +5,4 @@
* It is used in conjunction with database_updates.php
*/
DEFINE("LATEST_DATABASE_VERSION", "2.2.7");
DEFINE("LATEST_DATABASE_VERSION", "2.2.8");

View File

@@ -19,6 +19,7 @@ $config_smtp_username = $row['config_smtp_username'];
$config_smtp_password = $row['config_smtp_password'];
$config_mail_from_email = $row['config_mail_from_email'];
$config_mail_from_name = $row['config_mail_from_name'];
// Mail - IMAP
$config_imap_host = $row['config_imap_host'];
$config_imap_port = intval($row['config_imap_port']);
@@ -128,7 +129,6 @@ $config_time_format = "H:i";
// Theme
$config_theme = $row['config_theme'];
$config_theme_dark = intval($row['config_theme_dark']);
// Telemetry
$config_telemetry = intval($row['config_telemetry']);

View File

@@ -6,13 +6,6 @@
header("X-Frame-Options: DENY");
// Determine URI prepending logic (URI Routing maybe move to /includes/router.php)
if ($_SERVER['REQUEST_URI'] === '/user/reports') {
$prepend_uri = "../";
} else {
$prepend_uri = '';
}
?>
<!DOCTYPE html>
@@ -23,7 +16,7 @@ if ($_SERVER['REQUEST_URI'] === '/user/reports') {
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="robots" content="noindex">
<title><?php echo $session_company_name; ?></title>
<title><?= $session_company_name; ?></title>
<!-- Favicon -->
<?php if(file_exists($prepend_uri . '../uploads/favicon.ico')): ?>
@@ -51,7 +44,7 @@ if ($_SERVER['REQUEST_URI'] === '/user/reports') {
<body class="
hold-transition sidebar-mini layout-fixed layout-navbar-fixed
accent-<?php echo isset($_GET['client_id']) ? 'blue' : nullable_htmlentities($config_theme); ?>
<?php if ($config_theme_dark) echo 'dark-mode'; ?>
<?php if ($user_config_theme_dark) echo 'dark-mode'; ?>
">
<div class="wrapper text-sm">

11
includes/router.php Normal file
View File

@@ -0,0 +1,11 @@
<?php
// URI Router
// Currently unused, but the idea is to dynamically prepend ../../ to asset paths (like includes, libraries, etc.)
// based on the current directory depth. This allows us to support deeply nested folder structures.
if ($_SERVER['REQUEST_URI'] === '/user/reports') {
$prepend_uri = "../";
} else {
$prepend_uri = '';
}