Skip to content

Commit 1a2805f

Browse files
author
Kristan Kenney
committed
Per-user theme support
1 parent 18da40d commit 1a2805f

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

bin/v-change-user-theme

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ check_hestia_demo_mode
4242
# Action #
4343
#----------------------------------------------------------#
4444

45+
if [ -z $THEME ]; then
46+
add_object_key "user" 'USER' "$user" 'THEME' 'LANGUAGE'
47+
fi
4548
update_user_value "$user" '$THEME' "$theme"
4649

4750
$BIN/v-log-action "$user" "Info" "System" "User theme changed (User: $user, Theme: $theme)."

web/edit/user/index.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,12 @@
237237
if ($_POST['v_user_theme'] != $_SESSION['userTheme']) {
238238
exec (HESTIA_CMD."v-change-user-theme ".escapeshellarg($v_username)." ".escapeshellarg($_POST['v_user_theme']), $output, $return_var);
239239
check_return_code($return_var,$output);
240-
unset($_SESSION['userTheme']);
241240
unset($output);
242241
$v_user_theme = $_POST['v_user_theme'];
243-
$_SESSION['userTheme'] = $v_user_theme;
242+
if ($_SESSION['user'] === $v_username) {
243+
unset($_SESSION['userTheme']);
244+
$_SESSION['userTheme'] = $v_user_theme;
245+
}
244246
}
245247
}
246248

web/inc/main.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ function top_panel($user, $TAB) {
158158
$panel = json_decode(implode('', $output), true);
159159
unset($output);
160160

161+
unset($_SESSION['userTheme']);
162+
$_SESSION['userTheme'] = $panel[$user]['THEME'];
163+
161164
// Set home location URLs
162165
if (($_SESSION['userContext'] === 'admin') && (!isset($_SESSION['look']))) {
163166
// Display users list for administrators unless they are impersonating a user account

web/templates/header.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
<title><?php echo $_SERVER['HTTP_HOST']; ?> - <?=_($TAB)?> - <?=_('Hestia Control Panel');?></title>
77
<!-- Load base system theme-->
88
<link type="text/css" rel="stylesheet" href="/css/themes/default.min.css?<?=JS_LATEST_UPDATE?>" rel="preload" />
9-
<? if ($_SESSION['userTheme']) {
9+
<? if (!empty($_SESSION['userTheme'])) {
1010
$selected_theme = $_SESSION['userTheme'];
1111
} else {
12-
$seleced_theme = $_SESSION['THEME'];
12+
$selected_theme = $_SESSION['THEME'];
1313
}
1414
?>
1515
<!-- Load custom theme -->
16-
<? if (($_SESSION['THEME'] !== 'default') || ($_SESSION['userTheme'] !== 'default')) {?>
16+
<? if ($selectedTheme !== 'default') {?>
1717
<!-- Load HestiaCP-shipped themes (minified, updated/overwritten with updates) - ($HESTIA/web/css/themes/*.min.css) -->
1818
<link type="text/css" rel="stylesheet" href="/css/themes/<?php echo $selected_theme; ?>.min.css?<?php echo rand(); ?>" rel="preload" />
1919
<!-- Load custom theme files ($HESTIA/web/css/themes/custom/*.css) -->
@@ -37,7 +37,7 @@
3737
</head>
3838
<body class="body-<?=strtolower($TAB)?> lang-<?=$_SESSION['language']?>">
3939
<?php if (($_SESSION['DEBUG_MODE']) == "true" ) {?>
40-
<div style="font-size:12px !important; padding:12px;position:sticky;top:0;z-index:3000;background-color:">
40+
<div style="font-size:12px !important; padding:12px;position:sticky;top:0;z-index:3000;background-color:#fff;">
4141
<?php
4242
echo "<h3>Server Variables</h3>";
4343
foreach ($_SERVER as $key=>$val)

0 commit comments

Comments
 (0)