@@ -219,25 +219,30 @@ public function getShortFooter() {
219219 */
220220 public function getColorPrimary () {
221221 $ user = $ this ->userSession ->getUser ();
222- $ defaultColor = $ this ->getDefaultColorPrimary ();
223- $ themingBackground = $ this ->config ->getUserValue ($ user ->getUID (), Application::APP_ID , 'background ' );
224222
225- // if the user is defined and the selected background is not a colour
226- if ($ user !== null
227- && !preg_match ('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i ' , $ themingBackground )) {
223+ // admin-defined primary color
224+ $ defaultColor = $ this ->getDefaultColorPrimary ();
225+
226+ // user-defined primary color
227+ $ themingBackground = '' ;
228+ if (!empty ($ user )) {
228229 $ themingBackground = $ this ->config ->getUserValue ($ user ->getUID (), Application::APP_ID , 'background ' , 'default ' );
229- if ($ themingBackground === 'default ' ) {
230- $ this ->increaseCacheBuster ();
231- return BackgroundService::DEFAULT_COLOR ;
232- } else if (isset (BackgroundService::SHIPPED_BACKGROUNDS [$ themingBackground ]['primary_color ' ])) {
233- $ this ->increaseCacheBuster ();
234- return BackgroundService::SHIPPED_BACKGROUNDS [$ themingBackground ]['primary_color ' ];
230+
231+ // if the user-selected background is a background reference
232+ if (!preg_match ('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i ' , $ themingBackground )) {
233+ if ($ themingBackground === 'default ' ) {
234+ $ this ->increaseCacheBuster ();
235+ return BackgroundService::DEFAULT_COLOR ;
236+ } else if (isset (BackgroundService::SHIPPED_BACKGROUNDS [$ themingBackground ]['primary_color ' ])) {
237+ $ this ->increaseCacheBuster ();
238+ return BackgroundService::SHIPPED_BACKGROUNDS [$ themingBackground ]['primary_color ' ];
239+ }
235240 }
236- }
237241
238- // If the user selected a specific colour
239- if (preg_match ('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i ' , $ themingBackground )) {
240- return $ themingBackground ;
242+ // If the user selected a specific colour
243+ if (preg_match ('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i ' , $ themingBackground )) {
244+ return $ themingBackground ;
245+ }
241246 }
242247
243248 // If the default color is not valid, return the default background one
@@ -255,7 +260,7 @@ public function getColorPrimary() {
255260 * @return string
256261 */
257262 public function getDefaultColorPrimary () {
258- $ color = $ this ->config ->getAppValue (Application::APP_ID , 'color ' , $ this -> color );
263+ $ color = $ this ->config ->getAppValue (Application::APP_ID , 'color ' );
259264 if (!preg_match ('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i ' , $ color )) {
260265 $ color = '#0082c9 ' ;
261266 }
0 commit comments