summaryrefslogtreecommitdiffstats
path: root/apps/theming/lib/ThemingDefaults.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/theming/lib/ThemingDefaults.php')
-rw-r--r--apps/theming/lib/ThemingDefaults.php33
1 files changed, 19 insertions, 14 deletions
diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php
index cc23053a9c3..b1fb90e00e0 100644
--- a/apps/theming/lib/ThemingDefaults.php
+++ b/apps/theming/lib/ThemingDefaults.php
@@ -219,23 +219,28 @@ class ThemingDefaults extends \OC_Defaults {
*/
public function getColorPrimary() {
$user = $this->userSession->getUser();
- $defaultColor = $this->getDefaultColorPrimary();
- $themingBackground = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'background');
- // if the user is defined and the selected background is not a colour
- if ($user !== null
- && !preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $themingBackground)) {
+ // admin-defined primary color
+ $defaultColor = $this->getDefaultColorPrimary();
+
+ // user-defined primary color
+ $themingBackground = '';
+ if (!empty($user)) {
$themingBackground = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'background', 'default');
- if ($themingBackground === 'default') {
- return BackgroundService::DEFAULT_COLOR;
- } else if (isset(BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color'])) {
- return BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color'];
+
+ // if the user-selected background is a background reference
+ if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $themingBackground)) {
+ if ($themingBackground === 'default') {
+ return BackgroundService::DEFAULT_COLOR;
+ } else if (isset(BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color'])) {
+ return BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color'];
+ }
}
- }
- // If the user selected a specific colour
- if (preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $themingBackground)) {
- return $themingBackground;
+ // If the user selected a specific colour
+ if (preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $themingBackground)) {
+ return $themingBackground;
+ }
}
// If the default color is not valid, return the default background one
@@ -253,7 +258,7 @@ class ThemingDefaults extends \OC_Defaults {
* @return string
*/
public function getDefaultColorPrimary() {
- $color = $this->config->getAppValue(Application::APP_ID, 'color', $this->color);
+ $color = $this->config->getAppValue(Application::APP_ID, 'color');
if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $color)) {
$color = '#0082c9';
}