MediaWiki  REL1_31
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...
 

Private Attributes

 $assignKnownUsers = false
 
 $triedCreations = []
 
 $usernamePrefix = 'imported'
 

Detailed Description

Class to parse and build external user names.

Since
1.31

Definition at line 29 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 38 of file ExternalUserNames.php.

References $assignKnownUsers, and $usernamePrefix.

Member Function Documentation

◆ addPrefix()

ExternalUserNames::addPrefix (   $name)

Add an interwiki prefix to the username regardless of circumstances.

Parameters
string$nameName being imported
Returns
string Name

Definition at line 105 of file ExternalUserNames.php.

References $name.

Referenced by applyPrefix().

◆ applyPrefix()

ExternalUserNames::applyPrefix (   $name)

Add an interwiki prefix to the username, if appropriate.

Parameters
string$nameName being imported
Returns
string Name, possibly with the prefix prepended.

Definition at line 75 of file ExternalUserNames.php.

References $name, addPrefix(), User\idFromName(), User\isUsableName(), and Hooks\run().

◆ getLocal()

static ExternalUserNames::getLocal (   $username)
static

Get local part of the user name.

Parameters
string$usernameUsername to get
Returns
string

Definition at line 125 of file ExternalUserNames.php.

References $username.

Referenced by ExternalUserNamesTest\testGetLocal().

◆ 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 50 of file ExternalUserNames.php.

References $title, MWNamespace\getCanonicalName(), SpecialPage\getTitleFor(), Title\makeTitle(), NS_MAIN, and NS_USER.

Referenced by ExternalUserNamesTest\testGetUserLinkTitle(), and 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 115 of file ExternalUserNames.php.

References $username.

Referenced by SpecialContributions\execute(), ApiQueryContributions\execute(), ExternalUserNamesTest\testIsExternal(), Linker\userLink(), Linker\userToolLinks(), and ApiBase\validateUser().

Member Data Documentation

◆ $assignKnownUsers

ExternalUserNames::$assignKnownUsers = false
private

Definition at line 31 of file ExternalUserNames.php.

Referenced by __construct().

◆ $triedCreations

ExternalUserNames::$triedCreations = []
private

Definition at line 32 of file ExternalUserNames.php.

◆ $usernamePrefix

ExternalUserNames::$usernamePrefix = 'imported'
private

Definition at line 30 of file ExternalUserNames.php.

Referenced by __construct().


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