mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-11-24 08:13:38 +00:00
Merge "Add an option to disable by default for logged-in users"
This commit is contained in:
commit
32812a974f
|
@ -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';
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue