aboutsummaryrefslogtreecommitdiffstats
path: root/apps/theming/lib
diff options
context:
space:
mode:
authorskjnldsv <skjnldsv@protonmail.com>2024-06-14 11:32:16 +0200
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2024-06-17 07:21:32 +0000
commitc3b2e681a03cd257121336d1b613d9e46663836f (patch)
treebf506d9e51b0f8fec2b2b43e527411786222691f /apps/theming/lib
parent5ba6f3e4b7f2c46a74c2737076d12cb8d42479a2 (diff)
downloadnextcloud-server-c3b2e681a03cd257121336d1b613d9e46663836f.tar.gz
nextcloud-server-c3b2e681a03cd257121336d1b613d9e46663836f.zip
fix(theming): also apply enforced theme for guests
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/theming/lib')
-rw-r--r--apps/theming/lib/Service/ThemesService.php30
1 files changed, 22 insertions, 8 deletions
diff --git a/apps/theming/lib/Service/ThemesService.php b/apps/theming/lib/Service/ThemesService.php
index 0d252e96431..0fb6cee6824 100644
--- a/apps/theming/lib/Service/ThemesService.php
+++ b/apps/theming/lib/Service/ThemesService.php
@@ -33,24 +33,22 @@ use OCA\Theming\Themes\LightTheme;
use OCP\IConfig;
use OCP\IUser;
use OCP\IUserSession;
+use Psr\Log\LoggerInterface;
class ThemesService {
- private IUserSession $userSession;
- private IConfig $config;
-
/** @var ITheme[] */
private array $themesProviders;
- public function __construct(IUserSession $userSession,
- IConfig $config,
- DefaultTheme $defaultTheme,
+ public function __construct(
+ private IUserSession $userSession,
+ private IConfig $config,
+ private LoggerInterface $logger,
+ private DefaultTheme $defaultTheme,
LightTheme $lightTheme,
DarkTheme $darkTheme,
HighContrastTheme $highContrastTheme,
DarkHighContrastTheme $darkHighContrastTheme,
DyslexiaFont $dyslexiaFont) {
- $this->userSession = $userSession;
- $this->config = $config;
// Register themes
$this->themesProviders = [
@@ -69,6 +67,22 @@ class ThemesService {
* @return ITheme[]
*/
public function getThemes(): array {
+ // Enforced theme if configured
+ $enforcedTheme = $this->config->getSystemValueString('enforce_theme', '');
+ if ($enforcedTheme !== '') {
+ if (!isset($this->themesProviders[$enforcedTheme])) {
+ $this->logger->error('Enforced theme not found', ['theme' => $enforcedTheme]);
+ return $this->themesProviders;
+ }
+
+ $defaultTheme = $this->themesProviders[$this->defaultTheme->getId()];
+ $theme = $this->themesProviders[$enforcedTheme];
+ return [
+ $defaultTheme->getId() => $defaultTheme,
+ $theme->getId() => $theme,
+ ];
+ }
+
return $this->themesProviders;
}