MediaWiki master
MediaWiki\User\Options\UserOptionsLookup Class Reference

Provides access to user options. More...

Inherited by MediaWiki\User\Options\DefaultOptionsLookup, MediaWiki\User\Options\StaticUserOptionsLookup, and MediaWiki\User\Options\UserOptionsManager.

Public Member Functions

 getBoolOption (UserIdentity $user, string $oname, int $queryFlags=IDBAccessObject::READ_NORMAL)
 Get the user's current setting for a given option, as a boolean value.
 
 getDefaultOption (string $opt, ?UserIdentity $userIdentity=null)
 Get a given default option value.
 
 getDefaultOptions (?UserIdentity $userIdentity=null)
 Combine the language default options with any site-specific and user-specific defaults and add the default language variants.
 
 getIntOption (UserIdentity $user, string $oname, int $defaultOverride=0, int $queryFlags=IDBAccessObject::READ_NORMAL)
 Get the user's current setting for a given option, as an integer value.
 
 getOption (UserIdentity $user, string $oname, $defaultOverride=null, bool $ignoreHidden=false, int $queryFlags=IDBAccessObject::READ_NORMAL)
 Get the user's current setting for a given option.
 
 getOptions (UserIdentity $user, int $flags=0, int $queryFlags=IDBAccessObject::READ_NORMAL)
 Get all user's options.
 
 isOptionGlobal (UserIdentity $user, string $key)
 Determine if a user option came from a source other than the local store or the defaults.
 

Public Attributes

const EXCLUDE_DEFAULTS = 1
 Exclude user options that are set to their default value.
 
const LOCAL_EXCEPTION_SUFFIX = '-local-exception'
 The suffix appended to preference names for the associated preference that tracks whether they have a local override.
 

Detailed Description

Provides access to user options.

Since
1.35

Definition at line 30 of file UserOptionsLookup.php.

Member Function Documentation

◆ getBoolOption()

MediaWiki\User\Options\UserOptionsLookup::getBoolOption ( UserIdentity $user,
string $oname,
int $queryFlags = IDBAccessObject::READ_NORMAL )

Get the user's current setting for a given option, as a boolean value.

Parameters
UserIdentity$userThe user to get the option for
string$onameThe option to check
int$queryFlagsA bit field composed of READ_XXX flags
Returns
bool User's current value for the option
See also
getOption()

Definition at line 119 of file UserOptionsLookup.php.

Referenced by Skin\getCategories(), Skin\getCategoryLinks(), Skin\getDefaultModules(), Skin\isResponsive(), ChangesList\newFromContext(), and MediaWiki\Actions\ActionEntryPoint\performRequest().

◆ getDefaultOption()

MediaWiki\User\Options\UserOptionsLookup::getDefaultOption ( string $opt,
?UserIdentity $userIdentity = null )

Get a given default option value.

Parameters
string$optName of option to retrieve
UserIdentity | null$userIdentityUser to look the defaults up for; set to null to ignore any user-specific defaults (since 1.42)
Returns
mixed|null Default option value

Reimplemented in MediaWiki\User\Options\UserOptionsManager.

Definition at line 62 of file UserOptionsLookup.php.

References MediaWiki\User\Options\UserOptionsLookup\getDefaultOptions().

Referenced by MediaWiki\Language\Language\dateFormat(), MediaWiki\Parser\CoreParserFunctions\gender(), and MediaWiki\Linker\Linker\makeImageLink().

◆ getDefaultOptions()

MediaWiki\User\Options\UserOptionsLookup::getDefaultOptions ( ?UserIdentity $userIdentity = null)
abstract

Combine the language default options with any site-specific and user-specific defaults and add the default language variants.

Parameters
UserIdentity | null$userIdentityUser to look the default up for; set to null to ignore any user-specific defaults (since 1.42)
Returns
array

Reimplemented in MediaWiki\User\Options\DefaultOptionsLookup, MediaWiki\User\Options\StaticUserOptionsLookup, and MediaWiki\User\Options\UserOptionsManager.

Referenced by MediaWiki\User\Options\UserOptionsLookup\getDefaultOption().

◆ getIntOption()

MediaWiki\User\Options\UserOptionsLookup::getIntOption ( UserIdentity $user,
string $oname,
int $defaultOverride = 0,
int $queryFlags = IDBAccessObject::READ_NORMAL )

Get the user's current setting for a given option, as an integer value.

Parameters
UserIdentity$userThe user to get the option for
string$onameThe option to check
int$defaultOverrideA default value returned if the option does not exist
int$queryFlagsA bit field composed of READ_XXX flags
Returns
int User's current value for the option
See also
getOption()

Definition at line 138 of file UserOptionsLookup.php.

◆ getOption()

MediaWiki\User\Options\UserOptionsLookup::getOption ( UserIdentity $user,
string $oname,
$defaultOverride = null,
bool $ignoreHidden = false,
int $queryFlags = IDBAccessObject::READ_NORMAL )
abstract

Get the user's current setting for a given option.

Parameters
UserIdentity$userThe user to get the option for
string$onameThe option to check
mixed | null$defaultOverrideA default value returned if the option does not exist
bool$ignoreHiddenWhether to ignore the effects of $wgHiddenPrefs
int$queryFlagsA bit field composed of READ_XXX flags
Returns
mixed|null User's current value for the option, Note that while option values retrieved from the database are always strings, default values and values set within the current request and not yet saved may be of another type.
See also
getBoolOption()
getIntOption()

Reimplemented in MediaWiki\User\Options\DefaultOptionsLookup, MediaWiki\User\Options\StaticUserOptionsLookup, and MediaWiki\User\Options\UserOptionsManager.

Referenced by EmailNotification\actuallyNotifyOnPageChange(), MediaWiki\EditPage\TextboxBuilder\buildTextboxAttribs(), MediaWiki\User\User\canReceiveEmail(), MediaWiki\User\User\getDatePreference(), Skin\getDefaultModules(), MediaWiki\HTMLForm\Field\HTMLTextAreaField\getInputCodex(), MediaWiki\HTMLForm\Field\HTMLTextAreaField\getInputHTML(), MediaWiki\HTMLForm\Field\HTMLTextAreaField\getInputOOUI(), MediaWiki\Context\RequestContext\getLanguage(), and MediaWiki\User\User\getTokenFromOption().

◆ getOptions()

MediaWiki\User\Options\UserOptionsLookup::getOptions ( UserIdentity $user,
int $flags = 0,
int $queryFlags = IDBAccessObject::READ_NORMAL )
abstract

Get all user's options.

Parameters
UserIdentity$userThe user to get the option for
int$flagsBitwise combination of: UserOptionsManager::EXCLUDE_DEFAULTS Exclude user options that are set to the default value. Options that are set to their conditionally default value are not excluded.
int$queryFlagsA bit field composed of READ_XXX flags
Returns
array

Reimplemented in MediaWiki\User\Options\DefaultOptionsLookup, MediaWiki\User\Options\StaticUserOptionsLookup, and MediaWiki\User\Options\UserOptionsManager.

Referenced by MediaWiki\ResourceLoader\UserOptionsModule\getScript().

◆ isOptionGlobal()

MediaWiki\User\Options\UserOptionsLookup::isOptionGlobal ( UserIdentity $user,
string $key )

Determine if a user option came from a source other than the local store or the defaults.

If this is true, setting the option will be ignored unless GLOBAL_OVERRIDE or GLOBAL_UPDATE is passed to setOption().

Parameters
UserIdentity$user
string$key
Returns
bool

Reimplemented in MediaWiki\User\Options\UserOptionsManager.

Definition at line 161 of file UserOptionsLookup.php.

Member Data Documentation

◆ EXCLUDE_DEFAULTS

const MediaWiki\User\Options\UserOptionsLookup::EXCLUDE_DEFAULTS = 1

Exclude user options that are set to their default value.

Definition at line 35 of file UserOptionsLookup.php.

◆ LOCAL_EXCEPTION_SUFFIX

const MediaWiki\User\Options\UserOptionsLookup::LOCAL_EXCEPTION_SUFFIX = '-local-exception'

The suffix appended to preference names for the associated preference that tracks whether they have a local override.

Since
1.43

Definition at line 42 of file UserOptionsLookup.php.


The documentation for this class was generated from the following file: