MediaWiki  master
ExternalUserNames Class Reference

Class to parse and build external user names. More...

Public Member Functions

 __construct ( $usernamePrefix, $assignKnownUsers)
 
 addPrefix ( $name)
 Add an interwiki prefix to the username regardless of circumstances. More...
 
 applyPrefix ( $name)
 Add an interwiki prefix to the username, if appropriate. More...
 

Static Public Member Functions

static getLocal ( $username)
 Get local part of the user name. More...
 
static getUserLinkTitle ( $userName)
 Get a target Title to link a username. More...
 
static isExternal ( $username)
 Tells whether the username is external or not. More...
 

Detailed Description

Class to parse and build external user names.

Since
1.31

Definition at line 32 of file ExternalUserNames.php.

Constructor & Destructor Documentation

◆ __construct()

ExternalUserNames::__construct (   $usernamePrefix,
  $assignKnownUsers 
)
Parameters
string$usernamePrefixPrefix to apply to unknown (and possibly also known) usernames
bool$assignKnownUsersWhether to apply the prefix to usernames that exist locally

Definition at line 53 of file ExternalUserNames.php.

Member Function Documentation

◆ addPrefix()

ExternalUserNames::addPrefix (   $name)

Add an interwiki prefix to the username regardless of circumstances.

Parameters
string$name
Returns
string Prefixed username, using ">" as separator

Definition at line 145 of file ExternalUserNames.php.

Referenced by applyPrefix().

◆ applyPrefix()

ExternalUserNames::applyPrefix (   $name)

Add an interwiki prefix to the username, if appropriate.

This method does have a side-effect on SUL (single user login) wikis: Calling this calls the ImportHandleUnknownUser hook from the CentralAuth extension, which assigns a local ID to the global user name, if possible. No prefix is applied if this is successful.

See also
https://meta.wikimedia.org/wiki/Help:Unified_login
https://www.mediawiki.org/wiki/Manual:Hooks/ImportHandleUnknownUser
Parameters
string$name
Returns
string Either the unchanged username if it's a known local user (or not a valid username), otherwise the name with the prefix prepended.

Definition at line 110 of file ExternalUserNames.php.

References addPrefix().

◆ getLocal()

static ExternalUserNames::getLocal (   $username)
static

Get local part of the user name.

Parameters
string$usernameUsername to get
Returns
string

Definition at line 165 of file ExternalUserNames.php.

◆ getUserLinkTitle()

static ExternalUserNames::getUserLinkTitle (   $userName)
static

Get a target Title to link a username.

Parameters
string$userNameUsername to link
Returns
null|Title

Definition at line 65 of file ExternalUserNames.php.

References $title, SpecialPage\getTitleFor(), NS_MAIN, and NS_USER.

Referenced by MediaWiki\EditPage\EditPage\getContentObject(), and MediaWiki\Linker\Linker\userLink().

◆ isExternal()

static ExternalUserNames::isExternal (   $username)
static

Tells whether the username is external or not.

Parameters
string$usernameUsername to check
Returns
bool true if it's external, false otherwise.

Definition at line 155 of file ExternalUserNames.php.

Referenced by MediaWiki\Specials\SpecialContributions\execute(), ApiFeedContributions\execute(), ApiQueryUserContribs\execute(), NewFilesPager\formatRow(), MediaWiki\EditPage\EditPage\getContentObject(), User\getId(), MediaWiki\Linker\Linker\userLink(), and MediaWiki\Linker\Linker\userToolLinks().


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