Allow ULS toolbar to be disabled for anons only

Per Daniel's request on bug 42157

Change-Id: I5df826f0466bf20729c7969cb7b549e41016c194
This commit is contained in:
Tim Starling
2012-11-16 10:43:26 +11:00
parent 6abb1b3d4a
commit 86e6bc9654
2 changed files with 26 additions and 7 deletions

View File

@@ -19,6 +19,20 @@
*/
class UniversalLanguageSelectorHooks {
public static function isToolbarEnabled() {
global $wgULSEnable, $wgULSEnableAnon;
if ( !$wgULSEnable ) {
return false;
}
if ( !$wgULSEnableAnon ) {
$user = RequestContext::getMain()->getUser();
if ( $user->isAnon() ) {
return false;
}
}
return true;
}
/**
* BeforePageDisplay hook handler.
* @param $out OutputPage
@@ -26,8 +40,7 @@ class UniversalLanguageSelectorHooks {
* @return bool
*/
public static function addModules( $out, $skin ) {
global $wgULSEnable;
if ( !$wgULSEnable ) {
if ( !self::isToolbarEnabled() ) {
return true;
}
@@ -59,8 +72,8 @@ class UniversalLanguageSelectorHooks {
* Hooks: SkinTemplateNavigation, SkinTemplateTabs
*/
static function addTrigger( array &$personal_urls, &$title ) {
global $wgULSEnable, $wgLang;
if ( !$wgULSEnable ) {
global $wgLang;
if ( !self::isToolbarEnabled() ) {
return true;
}
@@ -122,9 +135,8 @@ class UniversalLanguageSelectorHooks {
* @return bool
*/
public static function getLanguage( $user, &$code ) {
global $wgULSEnable, $wgRequest, $wgULSLanguageDetection;
if ( !$wgULSEnable ) {
global $wgRequest, $wgULSLanguageDetection;
if ( !self::isToolbarEnabled() ) {
return true;
}

View File

@@ -76,6 +76,13 @@ $wgULSLanguageDetection = true;
*/
$wgULSEnable = true;
/**
* Enable ULS language selection for anonymous users. Equivalent to $wgULSEnable
* except that it only applies to anonymous users. Setting this to false will
* avoid breaking Squid caches (see bug 41451).
*/
$wgULSEnableAnon = true;
$dir = __DIR__;
// Internationalization