mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-27 08:50:33 +00:00
Rearrange PopupContext code for readability
For example: * Anonymous users are a critical exception. They must always load the module. * Otherwise check if one preview type is active. * Prefer isRegistered() over isAnon(), because isRegistered() is part of the UserIdentity interface. Change-Id: Iea7e3bb7ef01bd72ccbd1fc5e574437f6dc42aa2
This commit is contained in:
parent
e337445751
commit
7c3f369019
|
@ -159,12 +159,8 @@ class PopupsContext {
|
|||
);
|
||||
}
|
||||
|
||||
// if not in Beta then enable for anonymous users
|
||||
if ( $user->isAnon() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $user->getBoolOption( self::REFERENCE_PREVIEWS_PREFERENCE_NAME_AFTER_BETA );
|
||||
return !$user->isRegistered() ||
|
||||
$user->getBoolOption( self::REFERENCE_PREVIEWS_PREFERENCE_NAME_AFTER_BETA );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -192,9 +188,14 @@ class PopupsContext {
|
|||
* @return bool
|
||||
*/
|
||||
public function shouldSendModuleToUser( \User $user ) {
|
||||
return $user->isAnon() ||
|
||||
$user->getBoolOption( self::PREVIEWS_OPTIN_PREFERENCE_NAME ) ||
|
||||
$this->isReferencePreviewsEnabled( $user );
|
||||
if ( !$user->isRegistered() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$shouldLoadPagePreviews = $user->getBoolOption( self::PREVIEWS_OPTIN_PREFERENCE_NAME );
|
||||
$shouldLoadReferencePreviews = $this->isReferencePreviewsEnabled( $user );
|
||||
|
||||
return $shouldLoadPagePreviews || $shouldLoadReferencePreviews;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue