aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-02-16 16:49:10 +0100
committerFerdinand Thiessen <opensource@fthiessen.de>2024-05-21 20:36:26 +0200
commit11dbfa636d746eac4a82460d0677dc6ffe98f068 (patch)
treee73edb3efb690e172882f2cdaaefa4840849da32 /apps
parent85b64e15ad0029305b34c606c6d3805c47d10964 (diff)
downloadnextcloud-server-11dbfa636d746eac4a82460d0677dc6ffe98f068.tar.gz
nextcloud-server-11dbfa636d746eac4a82460d0677dc6ffe98f068.zip
fix(settings): Return mean color of background image on set
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps')
-rw-r--r--apps/theming/lib/ImageManager.php6
-rw-r--r--apps/theming/lib/ThemingDefaults.php15
2 files changed, 13 insertions, 8 deletions
diff --git a/apps/theming/lib/ImageManager.php b/apps/theming/lib/ImageManager.php
index e98971daf3a..1c7368a0db1 100644
--- a/apps/theming/lib/ImageManager.php
+++ b/apps/theming/lib/ImageManager.php
@@ -79,7 +79,11 @@ class ImageManager {
case 'favicon':
return $this->urlGenerator->imagePath('core', 'logo/logo.png') . '?v=' . $cacheBusterCounter;
case 'background':
- return $this->urlGenerator->linkTo(Application::APP_ID, 'img/background/' . BackgroundService::DEFAULT_BACKGROUND_IMAGE);
+ // Removing the background defines its mime as 'backgroundColor'
+ $mimeSetting = $this->config->getAppValue('theming', 'backgroundMime', '');
+ if ($mimeSetting !== 'backgroundColor') {
+ return $this->urlGenerator->linkTo(Application::APP_ID, 'img/background/' . BackgroundService::DEFAULT_BACKGROUND_IMAGE);
+ }
}
return '';
}
diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php
index de284ecf092..a36c9cd5a5a 100644
--- a/apps/theming/lib/ThemingDefaults.php
+++ b/apps/theming/lib/ThemingDefaults.php
@@ -202,6 +202,7 @@ class ThemingDefaults extends \OC_Defaults {
/**
* Color that is used for highlighting elements like important buttons
+ * If user theming is enabled then the user defined value is returned
*/
public function getColorPrimary(): string {
$user = $this->userSession->getUser();
@@ -215,9 +216,7 @@ class ThemingDefaults extends \OC_Defaults {
// user-defined primary color
if (!empty($user)) {
- // we need the background color as a fallback for backwards compatibility with Nextcloud 28 and older
- $userBackgroundColor = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'background_color', '');
- $userPrimaryColor = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'primary_color', $userBackgroundColor);
+ $userPrimaryColor = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'primary_color', '');
if (preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $userPrimaryColor)) {
return $userPrimaryColor;
}
@@ -229,6 +228,7 @@ class ThemingDefaults extends \OC_Defaults {
/**
* Color that is used for the page background (e.g. the header)
+ * If user theming is enabled then the user defined value is returned
*/
public function getColorBackground(): string {
$user = $this->userSession->getUser();
@@ -253,7 +253,7 @@ class ThemingDefaults extends \OC_Defaults {
}
/**
- * Return the default primary color
+ * Return the default primary color - only taking admin setting into account
*/
public function getDefaultColorPrimary(): string {
// try admin color
@@ -478,7 +478,7 @@ class ThemingDefaults extends \OC_Defaults {
}
/**
- * Revert settings to the default value
+ * Revert admin settings to the default value
*
* @param string $setting setting which should be reverted
* @return string default value
@@ -499,12 +499,13 @@ class ThemingDefaults extends \OC_Defaults {
$returnValue = $this->getSlogan();
break;
case 'primary_color':
- $returnValue = $this->getDefaultColorPrimary();
+ $returnValue = BackgroundService::DEFAULT_COLOR;
break;
case 'background_color':
+ // If a background image is set we revert to the mean image color
if ($this->imageManager->hasImage('background')) {
$file = $this->imageManager->getImage('background');
- $this->backgroundService->setGlobalBackground($file->read());
+ $returnValue = $this->backgroundService->setGlobalBackground($file->read()) ?? '';
}
break;
case 'logo':