aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostiantyn Miakshyn <molodchick@gmail.com>2025-01-07 16:48:33 +0100
committerKonstantin Myakshin <molodchick@gmail.com>2025-01-18 21:00:33 +0200
commit77e8a554059cbf0f294c2e684870717294c64227 (patch)
treec5b11d017eff8ea78830d316f5c71108ba8f03a1
parentd42da42b607cc49e7cadbe79fc3b07f6d7fb2a97 (diff)
downloadnextcloud-server-77e8a554059cbf0f294c2e684870717294c64227.tar.gz
nextcloud-server-77e8a554059cbf0f294c2e684870717294c64227.zip
fix: Apply enforce theme config for anonymous users as wellbackport/50076/stable30
Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
-rw-r--r--apps/theming/lib/Service/ThemesService.php5
-rw-r--r--core/templates/layout.public.php4
-rw-r--r--lib/private/TemplateLayout.php8
3 files changed, 15 insertions, 2 deletions
diff --git a/apps/theming/lib/Service/ThemesService.php b/apps/theming/lib/Service/ThemesService.php
index 67b5289b1ba..3b40e72bb5b 100644
--- a/apps/theming/lib/Service/ThemesService.php
+++ b/apps/theming/lib/Service/ThemesService.php
@@ -153,12 +153,15 @@ class ThemesService {
* @return string[]
*/
public function getEnabledThemes(): array {
+ $enforcedTheme = $this->config->getSystemValueString('enforce_theme', '');
$user = $this->userSession->getUser();
if ($user === null) {
+ if ($enforcedTheme !== '') {
+ return [$enforcedTheme];
+ }
return [];
}
- $enforcedTheme = $this->config->getSystemValueString('enforce_theme', '');
$enabledThemes = json_decode($this->config->getUserValue($user->getUID(), Application::APP_ID, 'enabled-themes', '["default"]'));
if ($enforcedTheme !== '') {
return array_merge([$enforcedTheme], $enabledThemes);
diff --git a/core/templates/layout.public.php b/core/templates/layout.public.php
index 10b64fcdef8..a83b1ff9b28 100644
--- a/core/templates/layout.public.php
+++ b/core/templates/layout.public.php
@@ -35,7 +35,9 @@ p($theme->getTitle());
<?php emit_script_loading_tags($_); ?>
<?php print_unescaped($_['headers']); ?>
</head>
-<body id="<?php p($_['bodyid']);?>">
+<body id="<?php p($_['bodyid']);?>" <?php foreach ($_['enabledThemes'] as $themeId) {
+ p("data-theme-$themeId ");
+}?> data-themes="<?php p(join(',', $_['enabledThemes'])) ?>">
<?php include('layout.noscript.warning.php'); ?>
<?php include('layout.initial-state.php'); ?>
<div id="skip-actions">
diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php
index c49d16ddb80..8b97165aed7 100644
--- a/lib/private/TemplateLayout.php
+++ b/lib/private/TemplateLayout.php
@@ -158,6 +158,14 @@ class TemplateLayout extends \OC_Template {
$this->assign('appid', $appId);
$this->assign('bodyid', 'body-public');
+ // Set body data-theme
+ $this->assign('enabledThemes', []);
+ if ($this->appManager->isEnabledForUser('theming') && class_exists('\OCA\Theming\Service\ThemesService')) {
+ /** @var \OCA\Theming\Service\ThemesService $themesService */
+ $themesService = \OC::$server->get(\OCA\Theming\Service\ThemesService::class);
+ $this->assign('enabledThemes', $themesService->getEnabledThemes());
+ }
+
// Set logo link target
$logoUrl = $this->config->getSystemValueString('logo_url', '');
$this->assign('logoUrl', $logoUrl);