MarkTraceur has submitted this change and it was merged. Change subject: Add an option to disable by default for logged-in users ......................................................................
Add an option to disable by default for logged-in users Soft-depends on I90f6ab5b44fbcde0b89f56e795f69472c4940854 Bug: 69363 Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/822 Change-Id: Ief0df5b4f4285d99208f007b0510a396f6c272e0 --- M MultimediaViewer.php M MultimediaViewerHooks.php 2 files changed, 23 insertions(+), 15 deletions(-) Approvals: MarkTraceur: Verified; Looks good to me, approved diff --git a/MultimediaViewer.php b/MultimediaViewer.php index 7d23bea..bd02dc1 100644 --- a/MultimediaViewer.php +++ b/MultimediaViewer.php @@ -69,12 +69,20 @@ $wgMediaViewerUseThumbnailGuessing = true; } -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'; @@ -954,7 +962,12 @@ $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'; diff --git a/MultimediaViewerHooks.php b/MultimediaViewerHooks.php index 27d7b49..6ac204a 100644 --- a/MultimediaViewerHooks.php +++ b/MultimediaViewerHooks.php @@ -37,22 +37,17 @@ * @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; } /** -- To view, visit https://gerrit.wikimedia.org/r/155443 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ief0df5b4f4285d99208f007b0510a396f6c272e0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MultimediaViewer Gerrit-Branch: wmf/1.24wmf17 Gerrit-Owner: MarkTraceur <mtrac...@member.fsf.org> Gerrit-Reviewer: Gergő Tisza <gti...@wikimedia.org> Gerrit-Reviewer: MarkTraceur <mtrac...@member.fsf.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits