Robert Vogel has uploaded a new change for review. ( 
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(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceExtensions 
refs/changes/83/365583/1

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: newchange
Gerrit-Change-Id: Ie3b43923d57d763a07ae3356f5325f25d7c36601
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: Robert Vogel <[email protected]>

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

Reply via email to