jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/365583 )

Change subject: BSUserPreferences: Added default options
......................................................................


BSUserPreferences: Added default options

Formerly anonymous and new users (that haven't saved their user preferences
yet), did not have had any BlueSpice settings set on the client side.

See ERM6901

NEEDS CHERRY-PICK TO REL1_27

Change-Id: Ie3b43923d57d763a07ae3356f5325f25d7c36601
---
M UserPreferences/UserPreferences.class.php
1 file changed, 20 insertions(+), 0 deletions(-)

Approvals:
  Mglaser: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/UserPreferences/UserPreferences.class.php 
b/UserPreferences/UserPreferences.class.php
index 85ecefa..7140ca7 100644
--- a/UserPreferences/UserPreferences.class.php
+++ b/UserPreferences/UserPreferences.class.php
@@ -45,6 +45,7 @@
                $this->setHook( 'GetPreferences', 'onGetPreferences', true );
                $this->setHook( 'UserSaveOptions' );
                $this->setHook( 'BeforePageDisplay' );
+               $this->setHook( 'UserGetDefaultOptions' );
 
                wfProfileOut( 'BS::' . __METHOD__ );
        }
@@ -209,4 +210,23 @@
                return true;
        }
 
+       /**
+        * Adds default user settings for users that have not saved their
+        * preferences yet. Is only called once at session start!
+        * @param array $defaultOptions
+        * @return boolean
+        */
+       public function onUserGetDefaultOptions( &$defaultOptions ) {
+               $aRegisteredVariables = BsConfig::getRegisteredVars();
+               foreach( $aRegisteredVariables as $oVariable ) {
+                       //Allow overrides from LocalSettings.php
+                       if( isset( $defaultOptions[$oVariable->getKey()] ) ) {
+                               continue;
+                       }
+                       if( $oVariable->getOptions() & BsConfig::LEVEL_USER ) {
+                               $defaultOptions[$oVariable->getKey()] = 
$oVariable->getValue();
+                       }
+               }
+               return true;
+       }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/365583
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie3b43923d57d763a07ae3356f5325f25d7c36601
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: Robert Vogel <[email protected]>
Gerrit-Reviewer: Ljonka <[email protected]>
Gerrit-Reviewer: Mglaser <[email protected]>
Gerrit-Reviewer: Pwirth <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to