Merge "Add an option to disable by default for logged-in users"

This commit is contained in:
jenkins-bot 2014-08-20 21:26:21 +00:00 committed by Gerrit Code Review
commit 32812a974f
2 changed files with 23 additions and 15 deletions

View file

@ -63,12 +63,20 @@ if ( !isset( $wgMediaViewerUseThumbnailGuessing ) ) {
$wgMediaViewerUseThumbnailGuessing = false;
}
if ( !isset( $wgEnableMediaViewerForLoggedInUsersOnly ) ) {
if ( !isset( $wgMediaViewerEnableByDefault ) ) {
/**
* @var bool: If set, and $wgMediaViewerIsInBeta is unset, Media Viewer will be turned on for
* all logged-in users. False if unset.
* If trueish, and $wgMediaViewerIsInBeta is unset, Media Viewer will be turned on by default.
* @var bool
*/
$wgEnableMediaViewerForLoggedInUsersOnly = false;
$wgMediaViewerEnableByDefault = true;
}
if ( !isset( $wgMediaViewerEnableByDefaultForAnonymous ) ) {
/**
* If set, overrides $wgMediaViewerEnableByDefault for anonymous users.
* @var bool
*/
$wgMediaViewerEnableByDefaultForAnonymous = $wgMediaViewerEnableByDefault;
}
$wgMessagesDirs['MultimediaViewer'] = __DIR__ . '/i18n';
@ -948,7 +956,12 @@ foreach ( array(
$wgAutoloadClasses['MultimediaViewerHooks'] = __DIR__ . '/MultimediaViewerHooks.php';
$wgDefaultUserOptions['multimediaviewer-enable'] = true;
$wgExtensionFunctions[] = function () {
global $wgMediaViewerEnableByDefault, $wgDefaultUserOptions;
if ( $wgMediaViewerEnableByDefault ) {
$wgDefaultUserOptions['multimediaviewer-enable'] = true;
}
};
$wgHooks['GetPreferences'][] = 'MultimediaViewerHooks::getPreferences';
$wgHooks['GetBetaFeaturePreferences'][] = 'MultimediaViewerHooks::getBetaPreferences';

View file

@ -37,22 +37,17 @@ class MultimediaViewerHooks {
* @return bool
*/
protected static function shouldHandleClicks( $user ) {
global $wgMediaViewerIsInBeta, $wgEnableMediaViewerForLoggedInUsersOnly;
global $wgMediaViewerIsInBeta, $wgMediaViewerEnableByDefaultForAnonymous;
if ( $wgMediaViewerIsInBeta && class_exists( 'BetaFeatures' ) ) {
return BetaFeatures::isFeatureEnabled( $user, 'multimedia-viewer' );
}
if ( $user->getOption( 'multimediaviewer-enable' ) ) {
if ( $wgEnableMediaViewerForLoggedInUsersOnly ) {
return $user->isLoggedIn();
} else {
// Default to enabling for everyone.
return true;
}
if ( !$user->isLoggedIn() && isset( $wgMediaViewerEnableByDefaultForAnonymous ) ) {
return (bool)$wgMediaViewerEnableByDefaultForAnonymous;
} else {
return (bool)$user->getOption( 'multimediaviewer-enable' );
}
return false;
}
/**