MediaWiki
REL1_24
|
The User object encapsulates all of the user-specific settings (user_id, name, rights, password, email address, options, last login time). More...
Public Member Functions | |
__construct () | |
Lightweight constructor for an anonymous user. | |
__toString () | |
addAutopromoteOnceGroups ($event) | |
Add the user to the group if he/she meets given criteria. | |
addGroup ($group) | |
Add the user to the given group. | |
addNewUserLogEntry ($action=false, $reason= '') | |
Add a newuser log entry for this user. | |
addNewUserLogEntryAutoCreate () | |
Add an autocreate newuser log entry for this user Used by things like CentralAuth and perhaps other authplugins. | |
addToDatabase () | |
Add this existing user object to the database. | |
addWatch ($title, $checkRights=WatchedItem::CHECK_USER_RIGHTS) | |
Watch an article. | |
blockedBy () | |
If user is blocked, return the name of the user who placed the block. | |
blockedFor () | |
If user is blocked, return the specified reason for the block. | |
canReceiveEmail () | |
Is this user allowed to receive e-mails within limits of current site configuration? | |
canSendEmail () | |
Is this user allowed to send e-mails within limits of current site configuration? | |
changeableGroups () | |
Returns an array of groups that this user can add and remove. | |
checkPassword ($password) | |
Check to see if the given clear-text password is one of the accepted passwords. | |
checkPasswordValidity ($password) | |
Check if this is a valid password for this user. | |
checkTemporaryPassword ($plaintext) | |
Check if the given clear-text password matches the temporary password sent by e-mail for password reset operations. | |
clearAllNotifications () | |
Resets all of the given user's page-change notification timestamps. | |
clearInstanceCache ($reloadFrom=false) | |
Clear various cached data stored in this object. | |
clearNotification (&$title, $oldid=0) | |
Clear the user's notification timestamp for the given title. | |
clearSharedCache () | |
Clear user data from memcached. | |
confirmEmail () | |
Mark the e-mail address confirmed. | |
doLogout () | |
Clear the user's cookies and session, and reset the instance cache. | |
editToken ($salt= '', $request=null) | |
Alias for getEditToken. | |
expirePassword ($ts=0) | |
Expire a user's password. | |
getAutomaticGroups ($recache=false) | |
Get the list of implicit group memberships this user has. | |
getBlock ($bFromSlave=true) | |
Get the block affecting the user, or null if the user is not blocked. | |
getBlockId () | |
If user is blocked, return the ID for the block. | |
getBoolOption ($oname) | |
Get the user's current setting for a given option, as a boolean value. | |
getDatePreference () | |
Get the user's preferred date format. | |
getEditCount () | |
Get the user's edit count. | |
getEditToken ($salt= '', $request=null) | |
Initialize (if necessary) and return a session token value which can be used in edit forms to show that the user's login credentials aren't being hijacked with a foreign form submission. | |
getEffectiveGroups ($recache=false) | |
Get the list of implicit group memberships this user has. | |
getEmail () | |
Get the user's e-mail address. | |
getEmailAuthenticationTimestamp () | |
Get the timestamp of the user's e-mail authentication. | |
getFirstEditTimestamp () | |
Get the timestamp of the first edit. | |
getFormerGroups () | |
Returns the groups the user has belonged to. | |
getGroups () | |
Get the list of explicit group memberships this user has. | |
getId () | |
Get the user's ID. | |
getIntOption ($oname, $defaultOverride=0) | |
Get the user's current setting for a given option, as an integer value. | |
getName () | |
Get the user name, or the IP of an anonymous user. | |
getNewMessageLinks () | |
Return the data needed to construct links for new talk page message alerts. | |
getNewMessageRevisionId () | |
Get the revision ID for the last talk page revision viewed by the talk page owner. | |
getNewtalk () | |
Check if the user has new messages. | |
getOption ($oname, $defaultOverride=null, $ignoreHidden=false) | |
Get the user's current setting for a given option. | |
getOptionKinds (IContextSource $context, $options=null) | |
Return an associative array mapping preferences keys to the kind of a preference they're used for. | |
getOptions () | |
Get all user's options. | |
getPassword () | |
getPasswordExpired () | |
Check if the user's password is expired. | |
getPasswordExpireDate () | |
Get this user's password expiration date. | |
getPasswordValidity ($password) | |
Given unvalidated password input, return error message on failure. | |
getRealName () | |
Get the user's real name. | |
getRegistration () | |
Get the timestamp of account creation. | |
getRequest () | |
Get the WebRequest object to use with this object. | |
getRights () | |
Get the permissions this user has. | |
getSkin () | |
Get the current skin, loading it if required. | |
getStubThreshold () | |
Get the user preferred stub threshold. | |
getTalkPage () | |
Get this user's talk page title. | |
getTemporaryPassword () | |
getTitleKey () | |
Get the user's name escaped by underscores. | |
getToken ($forceCreation=true) | |
Get the user's current token. | |
getTokenFromOption ($oname) | |
Get a token stored in the preferences (like the watchlist one), resetting it if it's empty (and saving changes). | |
getTouched () | |
Get the user touched timestamp. | |
getUserPage () | |
Get this user's personal page title. | |
getWatchedItem ($title, $checkRights=WatchedItem::CHECK_USER_RIGHTS) | |
Get a WatchedItem for this user and $title. | |
idForName () | |
If only this user's username is known, and it exists, return the user ID. | |
incEditCount () | |
Increment the user's edit-count field. | |
inDnsBlacklist ($ip, $bases) | |
Whether the given IP is in a given DNS blacklist. | |
invalidateCache () | |
Immediately touch the user data cache for this account. | |
invalidateEmail () | |
Invalidate the user's e-mail confirmation, and unauthenticate the e-mail address if it was already confirmed. | |
isAllowed ($action= '') | |
Internal mechanics of testing a permission. | |
isAllowedAll () | |
isAllowedAny () | |
Check if user is allowed to access a feature / make an action. | |
isAllowedToCreateAccount () | |
Get whether the user is allowed to create an account. | |
isAnon () | |
Get whether the user is anonymous. | |
isBlocked ($bFromSlave=true) | |
Check if user is blocked. | |
isBlockedFrom ($title, $bFromSlave=false) | |
Check if user is blocked from editing a particular article. | |
isBlockedFromCreateAccount () | |
Get whether the user is explicitly blocked from account creation. | |
isBlockedFromEmailuser () | |
Get whether the user is blocked from using Special:Emailuser. | |
isBlockedGlobally ($ip= '') | |
Check if user is blocked on all wikis. | |
isDnsBlacklisted ($ip, $checkWhitelist=false) | |
Whether the given IP is in a DNS blacklist. | |
isEmailConfirmationPending () | |
Check whether there is an outstanding request for e-mail confirmation. | |
isEmailConfirmed () | |
Is this user's e-mail address valid-looking and confirmed within limits of the current site configuration? | |
isHidden () | |
Check if user account is hidden. | |
isItemLoaded ($item, $all= 'all') | |
Return whether an item has been loaded. | |
isLocked () | |
Check if user account is locked. | |
isLoggedIn () | |
Get whether the user is logged in. | |
isNewbie () | |
Determine whether the user is a newbie. | |
isPasswordReminderThrottled () | |
Has password reminder email been sent within the last $wgPasswordReminderResendTime hours? | |
isPingLimitable () | |
Is this user subject to rate limiting? | |
isValidPassword ($password) | |
Is the input a valid password for this user? | |
isWatched ($title, $checkRights=WatchedItem::CHECK_USER_RIGHTS) | |
Check the watched status of an article. | |
load () | |
Load the user table data for this object from the source given by mFrom. | |
loadDefaults ($name=false) | |
Set cached properties to default. | |
loadFromDatabase ($flags=0) | |
Load user and user_group data from the database. | |
loadFromId () | |
Load user table data, given mId has already been set. | |
loadFromRow ($row, $data=null) | |
Initialize this object from a row from the user table. | |
logout () | |
Log this user out. | |
matchEditToken ($val, $salt= '', $request=null) | |
Check given value against the token value stored in the session. | |
matchEditTokenNoSuffix ($val, $salt= '', $request=null) | |
Check given value against the token value stored in the session, ignoring the suffix. | |
pingLimiter ($action= 'edit', $incrBy=1) | |
Primitive rate limits: enforce maximum actions per time period to put a brake on flooding. | |
removeGroup ($group) | |
Remove the user from the given group. | |
removeWatch ($title, $checkRights=WatchedItem::CHECK_USER_RIGHTS) | |
Stop watching an article. | |
requiresHTTPS () | |
Determine based on the wiki configuration and the user's options, whether this user must be over HTTPS no matter what. | |
resetOptions ($resetKinds=array( 'registered', 'registered-multiselect', 'registered-checkmatrix', 'unused'), IContextSource $context=null) | |
Reset certain (or all) options to the site defaults. | |
resetPasswordExpiration ($load=true) | |
Clear the password expiration for a user. | |
resetTokenFromOption ($oname) | |
Reset a token stored in the preferences (like the watchlist one). | |
saveSettings () | |
Save this user's settings into the database. | |
saveToCache () | |
Save user data to the shared cache. | |
sendConfirmationMail ($type= 'created') | |
Generate a new e-mail confirmation token and send a confirmation/invalidation mail to the user's given address. | |
sendMail ($subject, $body, $from=null, $replyto=null) | |
Send an e-mail to this user's account. | |
setCookies ($request=null, $secure=null, $rememberMe=false) | |
Set the default cookies for this session on the user's client. | |
setEmail ($str) | |
Set the user's e-mail address. | |
setEmailAuthenticationTimestamp ($timestamp) | |
Set the e-mail authentication timestamp. | |
setEmailWithConfirmation ($str) | |
Set the user's e-mail address and a confirmation mail if needed. | |
setId ($v) | |
Set the user and reload all fields according to a given ID. | |
setInternalPassword ($str) | |
Set the password and reset the random token unconditionally. | |
setName ($str) | |
Set the user name. | |
setNewpassword ($str, $throttle=true) | |
Set the password for a password reminder or new account email. | |
setNewtalk ($val, $curRev=null) | |
Update the 'You have new messages!' status. | |
setOption ($oname, $val) | |
Set the given option for a user. | |
setPassword ($str) | |
Set the password and reset the random token. | |
setRealName ($str) | |
Set the user's real name. | |
setToken ($token=false) | |
Set the random token (used for persistent authentication) Called from loadDefaults() among other places. | |
spreadAnyEditBlock () | |
If this user is logged-in and blocked, block any IP address they've successfully logged in from. | |
useNPPatrol () | |
Check whether to enable new pages patrol features for this user. | |
useRCPatrol () | |
Check whether to enable recent changes patrol features for this user. | |
validateCache ($timestamp) | |
Validate the cache for this account. | |
Static Public Member Functions | |
static | changeableByGroup ($group) |
Returns an array of the groups that a particular group can add/remove. | |
static | comparePasswords ($hash, $password, $userId=false) |
Compare a password hash with a plain-text password. | |
static | createNew ($name, $params=array()) |
Add a user to the database, return the user object. | |
static | crypt ($password, $salt=false) |
Make a new-style password hash. | |
static | edits ($uid) |
Count the number of edits of a user. | |
static | generateToken () |
Generate a looking random token for various uses. | |
static | getAllGroups () |
Return the set of defined explicit groups. | |
static | getAllRights () |
Get a list of all available permissions. | |
static | getCanonicalName ($name, $validate= 'valid') |
Given unvalidated user input, return a canonical username, or false if the username is invalid. | |
static | getDefaultOption ($opt) |
Get a given default option value. | |
static | getDefaultOptions () |
Combine the language default options with any site-specific options and add the default language variants. | |
static | getGroupMember ($group, $username= '#') |
Get the localized descriptive name for a member of a group, if it exists. | |
static | getGroupName ($group) |
Get the localized descriptive name for a group, if it exists. | |
static | getGroupPage ($group) |
Get the title of a page describing a particular group. | |
static | getGroupPermissions ($groups) |
Get the permissions associated with a given list of groups. | |
static | getGroupsWithPermission ($role) |
Get all the groups who have a given permission. | |
static | getImplicitGroups () |
Get a list of implicit groups. | |
static | getPasswordFactory () |
Lazily instantiate and return a factory object for making passwords. | |
static | getRightDescription ($right) |
Get the description of a given right. | |
static | groupHasPermission ($group, $role) |
Check, if the given group has the given permission. | |
static | idFromName ($name) |
Get database id given a user name. | |
static | isCreatableName ($name) |
Usernames which fail to pass this function will be blocked from new account registrations, but may be used internally either by batch processes or by user accounts which have already been created. | |
static | isEveryoneAllowed ($right) |
Check if all users have the given permission. | |
static | isIP ($name) |
Does the string match an anonymous IPv4 address? | |
static | isLocallyBlockedProxy ($ip) |
Check if an IP address is in the local proxy list. | |
static | isUsableName ($name) |
Usernames which fail to pass this function will be blocked from user login and new account registrations, but may be used internally by batch processes. | |
static | isValidUserName ($name) |
Is the input a valid username? | |
static | listOptionKinds () |
Return a list of the types of user options currently returned by User::getOptionKinds(). | |
static | makeGroupLinkHTML ($group, $text= '') |
Create a link to the group in HTML, if available; else return the group name. | |
static | makeGroupLinkWiki ($group, $text= '') |
Create a link to the group in Wikitext, if available; else return the group name. | |
static | newFatalPermissionDeniedStatus ($permission) |
Factory function for fatal permission-denied errors. | |
static | passwordChangeInputAttribs () |
Provide an array of HTML5 attributes to put on an input element intended for the user to enter a new password. | |
static | randomPassword () |
Return a random password. | |
static | resetIdByNameCache () |
Reset the cache used in idFromName(). | |
static | selectFields () |
Return the list of user fields that should be selected to create a new user object. | |
static | whoIs ($id) |
Get the username corresponding to a given user ID. | |
static | whoIsReal ($id) |
Get the real name of a user given their user ID. | |
newFrom*() static factory methods | |
static | newFromName ($name, $validate= 'valid') |
Static factory method for creation from username. | |
static | newFromId ($id) |
Static factory method for creation from a given user ID. | |
static | newFromConfirmationCode ($code) |
Factory method to fetch whichever user has a given email confirmation code. | |
static | newFromSession (WebRequest $request=null) |
Create a new user object using data from session or cookies. | |
static | newFromRow ($row, $data=null) |
Create a new user object from a user row. | |
Public Attributes | |
Block | $mBlock |
* | |
$mBlockedby | |
$mFrom | |
String Initialization data source if mLoadedItems!==true. | |
$mHideName | |
$mOptions | |
$mRights | |
const | EDIT_TOKEN_SUFFIX = EDIT_TOKEN_SUFFIX |
Global constant made accessible as class constants so that autoloader magic can be used. | |
const | MAX_WATCHED_ITEMS_CACHE = 100 |
Maximum items in $mWatchedItems. | |
const | TOKEN_LENGTH = 32 |
int Number of characters in user_token field. | |
const | VERSION = 10 |
int Serialized record version. | |
Static Public Attributes | |
static | $idCacheByName = array() |
Protected Member Functions | |
checkNewtalk ($field, $id, $fromMaster=false) | |
Internal uncached check for new messages. | |
clearCookie ($name, $secure=null, $params=array()) | |
Clear a cookie on the user's client. | |
confirmationToken (&$expiration) | |
Generate, store, and return a new e-mail confirmation code. | |
confirmationTokenUrl ($token) | |
Return a URL the user can use to confirm their email address. | |
deleteNewtalk ($field, $id) | |
Clear the new messages flag for the given user. | |
getTokenUrl ($page, $token) | |
Internal function to format the e-mail validation/invalidation URLs. | |
initEditCount ($add=0) | |
Initialize user_editcount from data out of the revision table. | |
invalidationTokenUrl ($token) | |
Return a URL the user can use to invalidate their email address. | |
loadFromUserObject ($user) | |
Load the data for this user object from another user object. | |
loadOptions ($data=null) | |
Load the user options either from cache, the database or an array. | |
saveOptions () | |
Saves the non-default options for this user, as previously set e.g. | |
setCookie ($name, $value, $exp=0, $secure=null, $params=array()) | |
Set a cookie on the user's client. | |
setItemLoaded ($item) | |
Set that an item has been loaded. | |
spreadBlock () | |
If this (non-anonymous) user is blocked, block the IP address they've successfully logged in from. | |
updateNewtalk ($field, $id, $curRev=null) | |
Add or update the new messages flag. | |
Protected Attributes | |
bool | $mAllowUsertalk |
* | |
$mBlockedGlobally | |
$mBlockreason | |
$mDatePreference | |
$mEffectiveGroups | |
$mFormerGroups | |
$mHash | |
$mImplicitGroups | |
$mLocked | |
$mNewtalk | |
Lazy-initialized variables, invalidated with clearInstanceCache. | |
Static Protected Attributes | |
static | $mAllRights = false |
String Cached results of getAllRights() | |
static | $mCacheVars |
Array of Strings List of member variables which are saved to the shared cache (memcached). | |
static | $mCoreRights |
Array of Strings Core rights. | |
Private Member Functions | |
getBlockedStatus ($bFromSlave=true) | |
Get blocking information. | |
loadFromSession () | |
Load user data from the session or login cookie. | |
loadGroups () | |
Load the groups from the database if they aren't already loaded. | |
loadPasswords () | |
Load the user's password hashes from the database. | |
Static Private Member Functions | |
static | newTouchedTimestamp () |
Generate a current or new-future timestamp to be stored in the user_touched field when we update things. | |
Private Attributes | |
Block | $mBlockedFromCreateAccount = false |
* | |
WebRequest | $mRequest |
array | $mWatchedItems = array() |
* | |
Static Private Attributes | |
static | $mPasswordFactory = null |
Cache variables | |
$mId | |
$mName | |
$mRealName | |
$mPassword | |
$mNewpassword | |
$mNewpassTime | |
$mEmail | |
$mTouched | |
$mEmailAuthenticated | |
$mGroups | |
$mToken | |
$mEmailToken | |
$mEmailTokenExpires | |
$mRegistration | |
$mEditCount | |
$mOptionOverrides | |
$mPasswordExpires | |
$mOptionsLoaded | |
Bool Whether the cache variables have been loaded. | |
$mLoadedItems = array() | |
Array with already loaded items or true if all items have been loaded. |
The User object encapsulates all of the user-specific settings (user_id, name, rights, password, email address, options, last login time).
Client classes use the getXXX() functions to access these fields. These functions do all the work of determining whether the user is logged in, whether the requested option can be satisfied from cookies or whether a database query is needed. Most of the settings needed for rendering normal pages are set in the cookie to minimize use of the database.
Lightweight constructor for an anonymous user.
Use the User::newFrom* factory functions for other kinds of users.
User::__toString | ( | ) |
User::addAutopromoteOnceGroups | ( | $ | event | ) |
Add the user to the group if he/she meets given criteria.
Contrary to autopromotion by $wgAutopromote, the group will be possible to remove manually via Special:UserRights. In such case it will not be re-added automatically. The user will also not lose the group if they no longer meet the criteria.
string | $event | Key in $wgAutopromoteOnce (each one has groups/criteria) |
User::addGroup | ( | $ | group | ) |
User::addNewUserLogEntry | ( | $ | action = false , |
$ | reason = '' |
||
) |
Add a newuser log entry for this user.
Before 1.19 the return value was always true.
string | bool | $action | Account creation type.
|
string | $reason | User supplied reason |
Add an autocreate newuser log entry for this user Used by things like CentralAuth and perhaps other authplugins.
Consider calling addNewUserLogEntry() directly instead.
Add this existing user object to the database.
If the user already exists, a fatal status object is returned, and the user object is initialised with the data from the database.
Previously, this function generated a DB error due to a key conflict if the user already existed. Many extension callers use this function in code along the lines of:
$user = User::newFromName( $name ); if ( !$user->isLoggedIn() ) { $user->addToDatabase(); } // do something with $user...
However, this was vulnerable to a race condition (bug 16020). By initialising the user object if the user exists, we aim to support this calling sequence as far as possible.
Note that if the user exists, this function will acquire a write lock, so it is still advisable to make the call conditional on isLoggedIn(), and to commit the transaction after calling.
MWException |
User::addWatch | ( | $ | title, |
$ | checkRights = WatchedItem::CHECK_USER_RIGHTS |
||
) |
Watch an article.
Title | $title | Title of the article to look at |
int | $checkRights | Whether to check 'viewmywatchlist'/'editmywatchlist' rights. Pass WatchedItem::CHECK_USER_RIGHTS or WatchedItem::IGNORE_USER_RIGHTS. |
Definition at line 3220 of file User.php.
Referenced by WatchAction\doWatch().
User::blockedBy | ( | ) |
If user is blocked, return the name of the user who placed the block.
Definition at line 1826 of file User.php.
References getBlockedStatus().
User::blockedFor | ( | ) |
If user is blocked, return the specified reason for the block.
Definition at line 1835 of file User.php.
References getBlockedStatus().
static User::changeableByGroup | ( | $ | group | ) | [static] |
Returns an array of the groups that a particular group can add/remove.
string | $group | The group to check for whether it can add/remove |
User::checkNewtalk | ( | $ | field, |
$ | id, | ||
$ | fromMaster = false |
||
) | [protected] |
Internal uncached check for new messages.
string | $field | 'user_ip' for anonymous users, 'user_id' otherwise |
string | int | $id | User's IP address for anonymous users, User ID otherwise |
bool | $fromMaster | True to fetch from the master, false for a slave |
Definition at line 2076 of file User.php.
Referenced by getNewtalk().
User::checkPassword | ( | $ | password | ) |
User::checkPasswordValidity | ( | $ | password | ) |
User::checkTemporaryPassword | ( | $ | plaintext | ) |
User::clearCookie | ( | $ | name, |
$ | secure = null , |
||
$ | params = array() |
||
) | [protected] |
Clear a cookie on the user's client.
string | $name | Name of the cookie to clear |
bool | $secure | true: Force setting the secure attribute when setting the cookie false: Force NOT setting the secure attribute when setting the cookie null (default): Use the default ($wgCookieSecure) to set the secure attribute |
array | $params | Array of options sent passed to WebResponse::setcookie() |
Definition at line 3361 of file User.php.
Referenced by doLogout().
User::clearInstanceCache | ( | $ | reloadFrom = false | ) |
Clear various cached data stored in this object.
The cache of the user table data (i.e. self::$mCacheVars) is not cleared unless $reloadFrom is given.
bool | string | $reloadFrom | Reload user and user_groups table data from a given source. May be "name", "id", "defaults", "session", or false for no reload. |
Definition at line 1381 of file User.php.
Referenced by doLogout(), and setId().
User::clearNotification | ( | &$ | title, |
$ | oldid = 0 |
||
) |
Clear the user's notification timestamp for the given title.
If e-notif e-mails are on, they will receive notification mails on the next change of the page if it's watched etc.
Clear user data from memcached.
Use after applying fun updates to the database; caller's responsibility to update user_touched if appropriate.
Called implicitly from invalidateCache() and saveSettings().
Definition at line 2190 of file User.php.
Referenced by saveSettings().
static User::comparePasswords | ( | $ | hash, |
$ | password, | ||
$ | userId = false |
||
) | [static] |
Compare a password hash with a plain-text password.
Requires the user ID if there's a chance that the hash is an old-style hash.
string | $hash | Password hash |
string | $password | Plain-text password to compare |
string | bool | $userId | User ID for old-style password salt |
User::confirmationToken | ( | &$ | expiration | ) | [protected] |
Generate, store, and return a new e-mail confirmation code.
A hash (unsalted, since it's used as a key) is stored.
string | &$expiration | Accepts the expiration time |
User::confirmationTokenUrl | ( | $ | token | ) | [protected] |
Mark the e-mail address confirmed.
static User::createNew | ( | $ | name, |
$ | params = array() |
||
) | [static] |
Add a user to the database, return the user object.
string | $name | Username to add |
array | $params | Array of Strings Non-default parameters to save to the database as user_* fields:
|
Definition at line 3547 of file User.php.
Referenced by UserWrapper\__construct(), and TestUser\__construct().
static User::crypt | ( | $ | password, |
$ | salt = false |
||
) | [static] |
Make a new-style password hash.
string | $password | Plain-text password |
bool | string | $salt | Optional salt, may be random or the user ID. If unspecified or false, will generate one automatically |
User::deleteNewtalk | ( | $ | field, |
$ | id | ||
) | [protected] |
User::doLogout | ( | ) |
Clear the user's cookies and session, and reset the instance cache.
Definition at line 3449 of file User.php.
References array(), clearCookie(), clearInstanceCache(), getRequest(), and setCookie().
static User::edits | ( | $ | uid | ) | [static] |
Count the number of edits of a user.
int | $uid | User ID to check |
User::editToken | ( | $ | salt = '' , |
$ | request = null |
||
) |
Alias for getEditToken.
string | array | $salt | Array of Strings Optional function-specific data for hashing |
WebRequest | null | $request | WebRequest object to use or null to use $wgRequest |
User::expirePassword | ( | $ | ts = 0 | ) |
static User::generateToken | ( | ) | [static] |
Generate a looking random token for various uses.
static User::getAllGroups | ( | ) | [static] |
Return the set of defined explicit groups.
The implicit groups (by default *, 'user' and 'autoconfirmed') are not included, as they are defined automatically, not in the database.
Definition at line 4336 of file User.php.
Referenced by UsersPager\__construct(), ApiQuerySiteinfo\appendUserGroups(), ApiQueryAllUsers\execute(), SpecialListGroupRights\formatPermissions(), UsersPager\getAllGroups(), ApiUserrights\getAllowedParams(), ApiQueryContributors\getAllowedParams(), ApiQueryAllUsers\getAllowedParams(), and SpecialListUsers\prefixSearchSubpages().
static User::getAllRights | ( | ) | [static] |
Get a list of all available permissions.
Definition at line 4348 of file User.php.
References $mAllRights, $mCoreRights, array(), global, and wfRunHooks().
Referenced by ApiQueryContributors\getAllowedParams(), and ApiQueryAllUsers\getAllowedParams().
User::getAutomaticGroups | ( | $ | recache = false | ) |
User::getBlock | ( | $ | bFromSlave = true | ) |
User::getBlockedStatus | ( | $ | bFromSlave = true | ) | [private] |
Get blocking information.
bool | $bFromSlave | Whether to check the slave database first. To improve performance, non-critical checks are done against slaves. Check when actually saving should be done against master. |
Definition at line 1454 of file User.php.
Referenced by blockedBy(), blockedFor(), getBlockId(), isBlockedFromCreateAccount(), and isBlockedFromEmailuser().
User::getBlockId | ( | ) |
If user is blocked, return the ID for the block.
Definition at line 1844 of file User.php.
References false, and getBlockedStatus().
User::getBoolOption | ( | $ | oname | ) |
Get the user's current setting for a given option, as a boolean value.
string | $oname | The option to check |
static User::getCanonicalName | ( | $ | name, |
$ | validate = 'valid' |
||
) | [static] |
Given unvalidated user input, return a canonical username, or false if the username is invalid.
string | $name | User input |
string | bool | $validate | Type of validation to use:
|
MWException |
Definition at line 901 of file User.php.
Referenced by RollbackEdits\execute(), UserrightsPage\execute(), ApiQueryUsers\execute(), UserrightsPage\fetchUser(), ApiQueryContributions\prepareUsername(), and ApiQueryBlocks\prepareUsername().
static User::getDefaultOption | ( | $ | opt | ) | [static] |
Get a given default option value.
string | $opt | Name of option to retrieve |
Definition at line 1439 of file User.php.
Referenced by ConvertUserOptions\convertOptionBatch(), CoreParserFunctions\gender(), GenderCache\getDefault(), and Linker\makeImageLink().
static User::getDefaultOptions | ( | ) | [static] |
Combine the language default options with any site-specific options and add the default language variants.
Definition at line 1406 of file User.php.
Referenced by ApiQuerySiteinfo\appendDefaultOptions(), UserOptions\getDefaultOptionsNames(), UserOptions\LISTER(), Preferences\loadPreferenceValues(), and UserOptions\USAGER().
Get the user's edit count.
Definition at line 2971 of file User.php.
References $count, $dbr, array(), getId(), initEditCount(), wfGetDB(), wfProfileIn(), and wfProfileOut().
Referenced by Autopromote\checkCondition().
User::getEditToken | ( | $ | salt = '' , |
$ | request = null |
||
) |
Initialize (if necessary) and return a session token value which can be used in edit forms to show that the user's login credentials aren't being hijacked with a foreign form submission.
string | array | $salt | Array of Strings Optional function-specific data for hashing |
WebRequest | null | $request | WebRequest object to use or null to use $wgRequest |
Definition at line 3873 of file User.php.
Referenced by WatchAction\getWatchToken().
User::getEffectiveGroups | ( | $ | recache = false | ) |
Get the list of implicit group memberships this user has.
This includes all explicit groups, plus 'user' if logged in, '*' for all accounts, and autopromoted groups
bool | $recache | Whether to avoid the cache |
Definition at line 2898 of file User.php.
Referenced by getRights().
User::getEmail | ( | ) |
Get the user's e-mail address.
Definition at line 2410 of file User.php.
References array(), load(), and wfRunHooks().
Referenced by Autopromote\checkCondition(), and MailAddress\newFromUser().
Get the timestamp of the user's e-mail authentication.
Definition at line 2420 of file User.php.
References array(), load(), and wfRunHooks().
Referenced by Autopromote\checkCondition().
Get the timestamp of the first edit.
Definition at line 4189 of file User.php.
Referenced by Autopromote\checkCondition().
Returns the groups the user has belonged to.
The user may still belong to the returned groups. Compare with getGroups().
The function will not return groups the user had belonged to before MW 1.17
Definition at line 2952 of file User.php.
Referenced by Autopromote\getAutopromoteOnceGroups().
static User::getGroupMember | ( | $ | group, |
$ | username = '#' |
||
) | [static] |
Get the localized descriptive name for a member of a group, if it exists.
string | $group | Internal group name |
string | $username | Username for gender (since 1.19) |
Definition at line 4325 of file User.php.
Referenced by UsersPager\buildGroupLink(), UserrightsPage\buildGroupMemberLink(), RightsLogFormatter\getMessageParameters(), UserrightsPage\groupCheckboxes(), and Preferences\profilePreferences().
static User::getGroupName | ( | $ | group | ) | [static] |
Get the localized descriptive name for a group, if it exists.
string | $group | Internal group name |
Definition at line 4313 of file User.php.
Referenced by UserrightsPage\buildGroupLink(), UsersPager\getAllGroups(), and Preferences\profilePreferences().
static User::getGroupPage | ( | $ | group | ) | [static] |
static User::getGroupPermissions | ( | $ | groups | ) | [static] |
Get the permissions associated with a given list of groups.
array | $groups | Array of Strings List of internal group names |
Definition at line 4211 of file User.php.
Referenced by Autopromote\checkCondition(), ApiQueryAllUsers\execute(), getRights(), and wfStreamThumb().
User::getGroups | ( | ) |
Get the list of explicit group memberships this user has.
The implicit * and user groups are not included.
Definition at line 2885 of file User.php.
Referenced by Autopromote\checkCondition(), and Autopromote\getAutopromoteOnceGroups().
static User::getGroupsWithPermission | ( | $ | role | ) | [static] |
Get all the groups who have a given permission.
string | $role | Role to check |
Definition at line 4238 of file User.php.
Referenced by PermissionsError\__construct(), ApiQueryAllUsers\execute(), ApiQueryContributors\execute(), NewFilesPager\getQueryInfo(), MWNamespace\getRestrictionLevels(), RebuildRecentchanges\rebuildRecentChangesTablePass4(), and ApiQueryAllImages\run().
User::getId | ( | ) |
Get the user's ID.
Definition at line 1910 of file User.php.
References isIP(), isItemLoaded(), and load().
Referenced by ApiUnblock\execute(), ApiBlock\execute(), getEditCount(), incEditCount(), TestRecentChangesHelper\makeDeletedEditRecentChange(), TestRecentChangesHelper\makeEditRecentChange(), TestRecentChangesHelper\makeLogRecentChange(), and TestRecentChangesHelper\makeNewBotEditRecentChange().
static User::getImplicitGroups | ( | ) | [static] |
Get a list of implicit groups.
Definition at line 4365 of file User.php.
References array(), global, and wfRunHooks().
Referenced by UsersPager\getGroups().
User::getIntOption | ( | $ | oname, |
$ | defaultOverride = 0 |
||
) |
Get the user's current setting for a given option, as an integer value.
string | $oname | The option to check |
int | $defaultOverride | A default value returned if the option does not exist |
User::getName | ( | ) |
Get the user name, or the IP of an anonymous user.
Definition at line 1934 of file User.php.
References getRequest(), isItemLoaded(), load(), and IP\sanitizeIP().
Referenced by ApiUnblock\execute(), getNewtalk(), getTitleKey(), idForName(), CreditsAction\link(), TestRecentChangesHelper\makeDeletedEditRecentChange(), TestRecentChangesHelper\makeEditRecentChange(), TestRecentChangesHelper\makeLogRecentChange(), TestRecentChangesHelper\makeNewBotEditRecentChange(), MailAddress\newFromUser(), and CreditsAction\userLink().
Return the data needed to construct links for new talk page message alerts.
If there are new messages, this will return an associative array with the following data: wiki: The database name of the wiki link: Root-relative link to the user's talk page rev: The last talk page revision that the user has seen or null. This is useful for building diff links. If there are no new messages, it returns an empty array.
User::getNewtalk | ( | ) |
Check if the user has new messages.
Definition at line 1978 of file User.php.
References $key, $wgMemc, checkNewtalk(), getName(), global, load(), page, and wfMemcKey().
User::getOption | ( | $ | oname, |
$ | defaultOverride = null , |
||
$ | ignoreHidden = false |
||
) |
Get the user's current setting for a given option.
string | $oname | The option to check |
string | $defaultOverride | A default value returned if the option does not exist |
bool | $ignoreHidden | Whether to ignore the effects of $wgHiddenPrefs |
Reimplemented in PPFuzzUser.
Definition at line 2507 of file User.php.
Referenced by getDatePreference(), and RequestContext\getLanguage().
User::getOptionKinds | ( | IContextSource $ | context, |
$ | options = null |
||
) |
Return an associative array mapping preferences keys to the kind of a preference they're used for.
Different kinds are handled differently when setting or reading preferences.
See User::listOptionKinds for the list of valid option types that can be provided.
IContextSource | $context | |
array | $options | Assoc. array with options keys to check as keys. Defaults to $this->mOptions. |
User::getOptions | ( | ) |
Check if the user's password is expired.
TODO: Put this and password length into a PasswordPolicy object
static User::getPasswordFactory | ( | ) | [static] |
Lazily instantiate and return a factory object for making passwords.
Definition at line 4874 of file User.php.
Referenced by saveSettings(), and PasswordTest\testInvalidUnequalInvalid().
User::getPasswordValidity | ( | $ | password | ) |
Get the user's real name.
Definition at line 2480 of file User.php.
References isItemLoaded(), and load().
Referenced by CreditsAction\link(), MailAddress\newFromUser(), and CreditsAction\userLink().
Get the timestamp of account creation.
Definition at line 4175 of file User.php.
Referenced by Autopromote\checkCondition().
User::getRequest | ( | ) |
Get the WebRequest object to use with this object.
Definition at line 3157 of file User.php.
Referenced by Autopromote\checkCondition(), doLogout(), getName(), isBlockedFromCreateAccount(), and loadFromSession().
static User::getRightDescription | ( | $ | right | ) | [static] |
Get the description of a given right.
string | $right | Right to query |
Definition at line 4618 of file User.php.
Referenced by SpecialListGroupRights\formatPermissions(), and SpecialListGroupRights\outputNamespaceProtectionInfo().
User::getRights | ( | ) |
Get the permissions this user has.
Definition at line 2870 of file User.php.
References array(), getEffectiveGroups(), getGroupPermissions(), and wfRunHooks().
User::getSkin | ( | ) |
User::getToken | ( | $ | forceCreation = true | ) |
User::getTokenFromOption | ( | $ | oname | ) |
Get a token stored in the preferences (like the watchlist one), resetting it if it's empty (and saving changes).
string | $oname | The option name to retrieve the token from |
User::getTokenUrl | ( | $ | page, |
$ | token | ||
) | [protected] |
Internal function to format the e-mail validation/invalidation URLs.
This uses a quickie hack to use the hardcoded English names of the Special: pages, for ASCII safety.
string | $page | Special page |
string | $token | Token |
User::getTouched | ( | ) |
Get this user's personal page title.
Definition at line 3754 of file User.php.
Referenced by CreditsAction\link(), and saveSettings().
User::getWatchedItem | ( | $ | title, |
$ | checkRights = WatchedItem::CHECK_USER_RIGHTS |
||
) |
Get a WatchedItem for this user and $title.
Title | $title | |
int | $checkRights | Whether to check 'viewmywatchlist'/'editmywatchlist' rights. Pass WatchedItem::CHECK_USER_RIGHTS or WatchedItem::IGNORE_USER_RIGHTS. |
static User::groupHasPermission | ( | $ | group, |
$ | role | ||
) | [static] |
Check, if the given group has the given permission.
If you're wanting to check whether all users have a permission, use User::isEveryoneAllowed() instead. That properly checks if it's revoked from anyone.
string | $group | Group to check |
string | $role | Role to check |
Definition at line 4261 of file User.php.
Referenced by SpecialNewpages\filterLinks(), and SpecialCreateAccount\isRestricted().
User::idForName | ( | ) |
static User::idFromName | ( | $ | name | ) | [static] |
Get database id given a user name.
string | $name | Username |
Definition at line 544 of file User.php.
Referenced by ApiQueryLogEvents\execute(), UsersPager\getQueryInfo(), and SpecialUnblock\processUnblock().
Increment the user's edit-count field.
Will have no effect for anonymous users.
Definition at line 4552 of file User.php.
References $dbr, array(), getId(), initEditCount(), invalidateCache(), isAnon(), and wfGetDB().
User::inDnsBlacklist | ( | $ | ip, |
$ | bases | ||
) |
User::initEditCount | ( | $ | add = 0 | ) | [protected] |
Initialize user_editcount from data out of the revision table.
int | $add | Edits to add to the count from the revision table |
Definition at line 4589 of file User.php.
Referenced by getEditCount(), and incEditCount().
Immediately touch the user data cache for this account.
Updates user_touched field, and removes account data from memcached for reload on the next hit.
Definition at line 2203 of file User.php.
Referenced by incEditCount().
Invalidate the user's e-mail confirmation, and unauthenticate the e-mail address if it was already confirmed.
Definition at line 4082 of file User.php.
Referenced by setEmail().
User::invalidationTokenUrl | ( | $ | token | ) | [protected] |
User::isAllowed | ( | $ | action = '' | ) |
Internal mechanics of testing a permission.
string | $action |
Definition at line 3115 of file User.php.
Referenced by Title\areCascadeProtectionSourcesLoaded(), WatchAction\doUnwatch(), WatchAction\doWatch(), SpecialBlock\getFormFields(), Linker\getRevDeleteLink(), isAllowedToCreateAccount(), isBlockedFromCreateAccount(), SpecialBlock\postText(), and SpecialCreateAccount\userCanExecute().
Check if user is allowed to access a feature / make an action.
string | $permissions,... | Permissions to test |
Definition at line 3085 of file User.php.
Referenced by useNPPatrol(), and useRCPatrol().
Get whether the user is allowed to create an account.
Definition at line 3745 of file User.php.
References isAllowed(), and isBlockedFromCreateAccount().
User::isAnon | ( | ) |
Get whether the user is anonymous.
Definition at line 3075 of file User.php.
References isLoggedIn().
Referenced by WatchAction\checkCanExecute(), incEditCount(), CreditsAction\link(), and CreditsAction\userLink().
User::isBlocked | ( | $ | bFromSlave = true | ) |
Check if user is blocked.
bool | $bFromSlave | Whether to check the slave database instead of the master. Hacked from false due to horrible probs on site. |
Definition at line 1781 of file User.php.
Referenced by Autopromote\checkCondition().
User::isBlockedFrom | ( | $ | title, |
$ | bFromSlave = false |
||
) |
Get whether the user is explicitly blocked from account creation.
Definition at line 3714 of file User.php.
References getBlockedStatus(), getRequest(), isAllowed(), and Block\newFromTarget().
Referenced by isAllowedToCreateAccount().
Get whether the user is blocked from using Special:Emailuser.
Definition at line 3736 of file User.php.
References getBlockedStatus().
User::isBlockedGlobally | ( | $ | ip = '' | ) |
static User::isCreatableName | ( | $ | name | ) | [static] |
Usernames which fail to pass this function will be blocked from new account registrations, but may be used internally either by batch processes or by user accounts which have already been created.
Additional blacklisting may be added here rather than in isValidUserName() to avoid disrupting existing accounts.
string | $name | String to match |
User::isDnsBlacklisted | ( | $ | ip, |
$ | checkWhitelist = false |
||
) |
Check whether there is an outstanding request for e-mail confirmation.
Definition at line 4160 of file User.php.
References global, isEmailConfirmed(), and wfTimestamp().
Is this user's e-mail address valid-looking and confirmed within limits of the current site configuration?
Definition at line 4136 of file User.php.
Referenced by isEmailConfirmationPending().
static User::isEveryoneAllowed | ( | $ | right | ) | [static] |
Check if all users have the given permission.
string | $right | Right to check |
Definition at line 4274 of file User.php.
Referenced by RawAction\onView().
User::isHidden | ( | ) |
static User::isIP | ( | $ | name | ) | [static] |
Does the string match an anonymous IPv4 address?
This function exists for username validation, in order to reject usernames which are similar in form to IP addresses. Strings such as 300.300.300.300 will return true because it looks like an IP address, despite not being strictly valid.
We match "\d{1,3}\.\d{1,3}\.\d{1,3}\.xxx" as an anonymous IP address because the usemod software would "cloak" anonymous IP addresses like this, if we allowed accounts like this to be created new users could get the old edits of these anonymous users.
string | $name | Name to match |
Definition at line 601 of file User.php.
Referenced by SpecialContributions\contributionsSub(), RollbackEdits\execute(), getId(), Skin\getRelevantUser(), ReassignEdits\initialiseUser(), ApiQueryContributions\prepareUsername(), and ApiQueryBlocks\prepareUsername().
User::isItemLoaded | ( | $ | item, |
$ | all = 'all' |
||
) |
Return whether an item has been loaded.
string | $item | Item to check. Current possibilities:
|
string | $all | 'all' to check if the whole object has been loaded or any other string to check if only the item is available (e.g. for optimisation) |
Definition at line 1038 of file User.php.
Referenced by getId(), getName(), and getRealName().
static User::isLocallyBlockedProxy | ( | $ | ip | ) | [static] |
User::isLocked | ( | ) |
User::isLoggedIn | ( | ) |
Get whether the user is logged in.
Definition at line 3067 of file User.php.
Referenced by WatchAction\doWatchOrUnwatch(), SpecialBlock\getFormFields(), and isAnon().
User::isNewbie | ( | ) |
static User::isUsableName | ( | $ | name | ) | [static] |
Usernames which fail to pass this function will be blocked from user login and new account registrations, but may be used internally by batch processes.
If an account already exists in this form, login will be blocked by a failure to pass this function.
string | $name | Name to match |
Definition at line 671 of file User.php.
Referenced by ApiBlock\execute().
User::isValidPassword | ( | $ | password | ) |
static User::isValidUserName | ( | $ | name | ) | [static] |
Is the input a valid username?
Checks if the input is a valid username, we don't want an empty string, an IP address, anything that contains slashes (would mess up subpages), is longer than the maximum allowed username size or doesn't begin with a capital letter.
string | $name | Name to match |
Definition at line 617 of file User.php.
Referenced by GenderCache\doQuery(), and CheckUsernames\execute().
User::isWatched | ( | $ | title, |
$ | checkRights = WatchedItem::CHECK_USER_RIGHTS |
||
) |
Check the watched status of an article.
Title | $title | Title of the article to look at |
int | $checkRights | Whether to check 'viewmywatchlist'/'editmywatchlist' rights. Pass WatchedItem::CHECK_USER_RIGHTS or WatchedItem::IGNORE_USER_RIGHTS. |
Definition at line 3209 of file User.php.
Referenced by WatchAction\doWatchOrUnwatch().
static User::listOptionKinds | ( | ) | [static] |
Return a list of the types of user options currently returned by User::getOptionKinds().
Currently, the option kinds are:
The API (and possibly others) use this function to determine the possible option types for validation purposes, so make sure to update this when a new option kind is added.
Definition at line 2664 of file User.php.
Referenced by ApiOptions\getAllowedParams().
User::load | ( | ) |
Load the user table data for this object from the source given by mFrom.
Reimplemented in PPFuzzUser.
Definition at line 311 of file User.php.
Referenced by getEmail(), getEmailAuthenticationTimestamp(), getId(), getName(), getNewtalk(), getRealName(), getTouched(), saveSettings(), setEmail(), setEmailAuthenticationTimestamp(), and setRealName().
User::loadDefaults | ( | $ | name = false | ) |
Set cached properties to default.
string | bool | $name |
Definition at line 990 of file User.php.
Referenced by PPFuzzUser\load(), and loadFromId().
User::loadFromDatabase | ( | $ | flags = 0 | ) |
Load user and user_group data from the database.
$this->mId must be set, this is how the user is identified.
int | $flags | Supports User::READ_LOCKING |
Definition at line 1141 of file User.php.
Referenced by loadFromId().
User::loadFromId | ( | ) |
Load user table data, given mId has already been set.
Definition at line 354 of file User.php.
References $key, $name, $wgMemc, as, global, loadDefaults(), loadFromDatabase(), saveToCache(), wfDebug(), and wfMemcKey().
User::loadFromRow | ( | $ | row, |
$ | data = null |
||
) |
Initialize this object from a row from the user table.
stdClass | $row | Row from the user table to load. |
array | $data | Further user data to load into the object |
user_groups Array with groups out of the user_groups table user_properties Array with properties out of the user_properties table
User::loadFromSession | ( | ) | [private] |
Load user data from the session or login cookie.
Definition at line 1058 of file User.php.
References $from, $result, array(), getRequest(), global, loadFromUserObject(), newFromId(), wfDebug(), wfDebugLog(), and wfRunHooks().
User::loadFromUserObject | ( | $ | user | ) | [protected] |
Load the data for this user object from another user object.
User | $user |
Definition at line 1281 of file User.php.
Referenced by loadFromSession().
User::loadGroups | ( | ) | [private] |
User::loadOptions | ( | $ | data = null | ) | [protected] |
User::loadPasswords | ( | ) | [private] |
Load the user's password hashes from the database.
This is usually called in a scenario where the actual User object was loaded from the cache, and then password comparison needs to be performed. Password hashes are not stored in memcached.
Definition at line 1316 of file User.php.
Referenced by getPassword(), getTemporaryPassword(), and saveSettings().
User::logout | ( | ) |
static User::makeGroupLinkHTML | ( | $ | group, |
$ | text = '' |
||
) | [static] |
Create a link to the group in HTML, if available; else return the group name.
string | $group | Internal name of the group |
string | $text | The text of the link |
Definition at line 4400 of file User.php.
Referenced by Preferences\profilePreferences().
static User::makeGroupLinkWiki | ( | $ | group, |
$ | text = '' |
||
) | [static] |
User::matchEditToken | ( | $ | val, |
$ | salt = '' , |
||
$ | request = null |
||
) |
Check given value against the token value stored in the session.
A match should confirm that the form was submitted from the user's own login session, not a form submission from a third-party site.
string | $val | Input value to compare |
string | $salt | Optional function-specific data for hashing |
WebRequest | null | $request | Object to use or null to use $wgRequest |
User::matchEditTokenNoSuffix | ( | $ | val, |
$ | salt = '' , |
||
$ | request = null |
||
) |
Check given value against the token value stored in the session, ignoring the suffix.
string | $val | Input value to compare |
string | $salt | Optional function-specific data for hashing |
WebRequest | null | $request | Object to use or null to use $wgRequest |
static User::newFatalPermissionDeniedStatus | ( | $ | permission | ) | [static] |
Factory function for fatal permission-denied errors.
string | $permission | User right required |
Definition at line 4969 of file User.php.
Referenced by WatchAction\doUnwatch(), and WatchAction\doWatch().
static User::newFromConfirmationCode | ( | $ | code | ) | [static] |
Factory method to fetch whichever user has a given email confirmation code.
This code is generated when an account is created or its e-mail address has changed.
If the code is invalid or has expired, returns NULL.
string | $code | Confirmation code |
Definition at line 471 of file User.php.
Referenced by EmailConfirmation\attemptConfirm(), and EmailInvalidation\attemptInvalidate().
static User::newFromId | ( | $ | id | ) | [static] |
Static factory method for creation from a given user ID.
int | $id | Valid user ID |
Definition at line 453 of file User.php.
Referenced by UserOptions\CHANGER(), MigrateUserGroup\execute(), RemoveUnusedAccounts\execute(), WrapOldPasswords\execute(), ChangePassword\execute(), ApiQueryAllUsers\execute(), NewFilesPager\formatRow(), UsersPager\getGroups(), NewUsersLogFormatter\getMessageParameters(), loadFromSession(), SpecialSearchTest\newUserWithSearchNS(), EnotifNotifyJob\run(), Skin\showEmailUser(), SpecialPageTest\testRequireLoginAnon(), ResetUserTokens\updateUser(), UserOptions\USAGER(), and Linker\userToolLinks().
static User::newFromName | ( | $ | name, |
$ | validate = 'valid' |
||
) | [static] |
Static factory method for creation from username.
This is slightly less efficient than newFromId(), so use newFromId() if you have both an ID and a name handy.
string | $name | Username, validated by Title::newFromText() |
string | bool | $validate | Validate username. Takes the same parameters as User::getCanonicalName(), except that true is accepted as an alias for 'valid', for BC. |
Definition at line 430 of file User.php.
Referenced by UserWrapper\__construct(), RecentChangeTest\__construct(), TestUser\__construct(), DeletedContributionsPage\__construct(), SpecialMyLanguageTest\addDBData(), GenderCacheTest\addDBData(), ApiBlockTest\addDBData(), BlockTest\addDBData(), BackupDumperLoggerTest\addDBData(), BlockTest\addXffBlocks(), EditPageTest\assertEdit(), SpecialChangePassword\attemptReset(), Undelete\execute(), SpecialContributions\execute(), DeleteDefaultMessages\execute(), ApiBlock\execute(), ImportSiteScripts\execute(), Protect\execute(), ChangePassword\execute(), CleanupSpam\execute(), EditCLI\execute(), CapsCleanup\execute(), SpecialLog\execute(), RollbackEdits\execute(), CreateAndPromote\execute(), DeleteBatch\execute(), TableCleanup\execute(), MoveBatch\execute(), DeleteEqualMessages\execute(), UserrightsPage\fetchUser(), CoreParserFunctions\gender(), CreditsAction\getAuthor(), NewUsersLogFormatter\getMessageParameters(), ResourceLoaderUserGroupsModule\getPages(), Skin\getRelevantUser(), OldChangesListTest\getTestUser(), RCCacheEntryFactoryTest\getTestUser(), ReassignEdits\initialiseUser(), EnotifNotifyJob\run(), SpecialLog\show(), RequestContextTest\testImportScopedSession(), ApiBlockTest\testMakeNormalBlock(), SpecialPageTest\testRequireLoginNotAnon(), and GenderCacheTest\testUserObjects().
static User::newFromRow | ( | $ | row, |
$ | data = null |
||
) | [static] |
Create a new user object from a user row.
The row should have the following fields from the user table in it:
stdClass | $row | A row from the user table |
array | $data | Further data to load into the object (see User::loadFromRow for valid keys) |
Definition at line 512 of file User.php.
Referenced by ApiQueryUsers\execute().
static User::newFromSession | ( | WebRequest $ | request = null | ) | [static] |
Create a new user object using data from session or cookies.
If the login credentials are invalid, the result is an anonymous user.
WebRequest | null | $request | Object to use; $wgRequest will be used if omitted. |
static User::newTouchedTimestamp | ( | ) | [static, private] |
Generate a current or new-future timestamp to be stored in the user_touched field when we update things.
Definition at line 2178 of file User.php.
Referenced by saveSettings().
static User::passwordChangeInputAttribs | ( | ) | [static] |
Provide an array of HTML5 attributes to put on an input element intended for the user to enter a new password.
This may include required, title, and/or pattern, depending on $wgMinimalPasswordLength.
Do *not* use this when asking the user to enter his current password! Regardless of configuration, users may have invalid passwords for whatever reason (e.g., they were set before requirements were tightened up). Only use it when asking for a new password, like on account creation or ResetPass.
Obviously, you still need to do server-side checking.
NOTE: A combination of bugs in various browsers means that this function actually just returns array() unconditionally at the moment. May as well keep it around for when the browser bugs get fixed, though.
Definition at line 4906 of file User.php.
Referenced by UsercreateTemplate\execute().
User::pingLimiter | ( | $ | action = 'edit' , |
$ | incrBy = 1 |
||
) |
Primitive rate limits: enforce maximum actions per time period to put a brake on flooding.
The method generates both a generic profiling point and a per action one (suffix being "-$action".
string | $action | Action to enforce; 'edit' if unspecified |
int | $incrBy | Positive amount to increment counter by [defaults to 1] |
static User::randomPassword | ( | ) | [static] |
Return a random password.
Definition at line 969 of file User.php.
Referenced by TestUser\__construct(), and ApiCreateAccountTest\testValid().
User::removeGroup | ( | $ | group | ) |
User::removeWatch | ( | $ | title, |
$ | checkRights = WatchedItem::CHECK_USER_RIGHTS |
||
) |
Stop watching an article.
Title | $title | Title of the article to look at |
int | $checkRights | Whether to check 'viewmywatchlist'/'editmywatchlist' rights. Pass WatchedItem::CHECK_USER_RIGHTS or WatchedItem::IGNORE_USER_RIGHTS. |
Definition at line 3232 of file User.php.
Referenced by WatchAction\doUnwatch().
static User::resetIdByNameCache | ( | ) | [static] |
User::resetOptions | ( | $ | resetKinds = array( 'registered', 'registered-multiselect', 'registered-checkmatrix', 'unused' ) , |
IContextSource $ | context = null |
||
) |
Reset certain (or all) options to the site defaults.
The optional parameter determines which kinds of preferences will be reset. Supported values are everything that can be reported by getOptionKinds() and 'all', which forces a reset of *all* preferences and overrides everything else.
array | string | $resetKinds | Which kinds of preferences to reset. Defaults to array( 'registered', 'registered-multiselect', 'registered-checkmatrix', 'unused' ) for backwards-compatibility. |
IContextSource | null | $context | Context source used when $resetKinds does not contain 'all', passed to getOptionKinds(). Defaults to RequestContext::getMain() when null. |
User::resetPasswordExpiration | ( | $ | load = true | ) |
User::resetTokenFromOption | ( | $ | oname | ) |
Reset a token stored in the preferences (like the watchlist one).
*Does not* save user's preferences (similarly to setOption()).
string | $oname | The option name to reset the token in |
User::saveOptions | ( | ) | [protected] |
Saves the non-default options for this user, as previously set e.g.
via setOption(), in the database's "user_properties" (preferences) table. Usually used via saveSettings().
Definition at line 4809 of file User.php.
Referenced by saveSettings().
Save this user's settings into the database.
Definition at line 3466 of file User.php.
References array(), clearSharedCache(), getPasswordFactory(), getUserPage(), global, load(), loadPasswords(), newTouchedTimestamp(), saveOptions(), wfGetDB(), wfReadOnly(), and wfRunHooks().
Save user data to the shared cache.
Definition at line 393 of file User.php.
Referenced by loadFromId().
static User::selectFields | ( | ) | [static] |
Return the list of user fields that should be selected to create a new user object.
Definition at line 4946 of file User.php.
Referenced by ApiQueryUsers\execute(), and UserArray\newFromIDs().
User::sendConfirmationMail | ( | $ | type = 'created' | ) |
User::sendMail | ( | $ | subject, |
$ | body, | ||
$ | from = null , |
||
$ | replyto = null |
||
) |
User::setCookie | ( | $ | name, |
$ | value, | ||
$ | exp = 0 , |
||
$ | secure = null , |
||
$ | params = array() |
||
) | [protected] |
Set a cookie on the user's client.
Wrapper for WebResponse::setCookie
string | $name | Name of the cookie to set |
string | $value | Value to set |
int | $exp | Expiration time, as a UNIX time value; if 0 or not specified, use the default $wgCookieExpiration |
bool | $secure | true: Force setting the secure attribute when setting the cookie false: Force NOT setting the secure attribute when setting the cookie null (default): Use the default ($wgCookieSecure) to set the secure attribute |
array | $params | Array of options sent passed to WebResponse::setcookie() |
Definition at line 3347 of file User.php.
Referenced by doLogout().
User::setCookies | ( | $ | request = null , |
$ | secure = null , |
||
$ | rememberMe = false |
||
) |
Set the default cookies for this session on the user's client.
WebRequest | null | $request | WebRequest object to use; $wgRequest will be used if null is passed. |
bool | $secure | Whether to force secure/insecure cookies or use default |
bool | $rememberMe | Whether to add a Token cookie for elongated sessions |
User::setEmail | ( | $ | str | ) |
Set the user's e-mail address.
string | $str | New e-mail address |
Definition at line 2430 of file User.php.
References array(), invalidateEmail(), load(), and wfRunHooks().
User::setEmailAuthenticationTimestamp | ( | $ | timestamp | ) |
Set the e-mail authentication timestamp.
string | $timestamp | TS_MW timestamp |
Definition at line 4096 of file User.php.
References $timestamp, array(), load(), and wfRunHooks().
User::setEmailWithConfirmation | ( | $ | str | ) |
Set the user's e-mail address and a confirmation mail if needed.
string | $str | New e-mail address |
Definition at line 2447 of file User.php.
Referenced by Preferences\trySetUserEmail().
User::setId | ( | $ | v | ) |
Set the user and reload all fields according to a given ID.
int | $v | User ID to reload |
Definition at line 1925 of file User.php.
References clearInstanceCache().
User::setInternalPassword | ( | $ | str | ) |
User::setItemLoaded | ( | $ | item | ) | [protected] |
User::setName | ( | $ | str | ) |
Set the user name.
This does not reload fields from the database according to the given name. Rather, it is used to create a temporary "nonexistent user" for later addition to the database. It can also be used to set the IP address for an anonymous user to something other than the current remote IP.
string | $str | New user name to set |
User::setNewpassword | ( | $ | str, |
$ | throttle = true |
||
) |
Set the password for a password reminder or new account email.
string | $str | New password to set or null to set an invalid password hash meaning that the user will not be able to use it |
bool | $throttle | If true, reset the throttle timestamp to the present |
User::setNewtalk | ( | $ | val, |
$ | curRev = null |
||
) |
User::setOption | ( | $ | oname, |
$ | val | ||
) |
Set the given option for a user.
You need to call saveSettings() to actually write to the database.
string | $oname | The option to set |
mixed | $val | New value to set |
User::setPassword | ( | $ | str | ) |
Set the password and reset the random token.
Calls through to authentication plugin if necessary; will have no effect if the auth plugin refuses to pass the change through or if the legal password checks fail.
As a special case, setting the password to null wipes it, so the account cannot be logged in until a new password is set, for instance via e-mail.
string | $str | New password to set |
PasswordError | On failure |
User::setRealName | ( | $ | str | ) |
User::setToken | ( | $ | token = false | ) |
Set the random token (used for persistent authentication) Called from loadDefaults() among other places.
string | bool | $token | If specified, set the token to this value |
User::spreadBlock | ( | ) | [protected] |
User::updateNewtalk | ( | $ | field, |
$ | id, | ||
$ | curRev = null |
||
) | [protected] |
Add or update the new messages flag.
string | $field | 'user_ip' for anonymous users, 'user_id' otherwise |
string | int | $id | User's IP address for anonymous users, User ID otherwise |
Revision | null | $curRev | New, as yet unseen revision of the user talk page. Ignored if null. |
Check whether to enable new pages patrol features for this user.
Definition at line 3144 of file User.php.
References global, and isAllowedAny().
Check whether to enable recent changes patrol features for this user.
Definition at line 3135 of file User.php.
References global, and isAllowedAny().
User::validateCache | ( | $ | timestamp | ) |
static User::whoIs | ( | $ | id | ) | [static] |
Get the username corresponding to a given user ID.
int | $id | User ID |
Definition at line 525 of file User.php.
Referenced by UserrightsPage\fetchUser(), ImageListPager\formatValue(), and Revision\getRawUserText().
static User::whoIsReal | ( | $ | id | ) | [static] |
User::$mAllRights = false [static, protected] |
String Cached results of getAllRights()
Definition at line 174 of file User.php.
Referenced by getAllRights().
User::$mCacheVars [static, protected] |
array( 'mId', 'mName', 'mRealName', 'mEmail', 'mTouched', 'mToken', 'mEmailAuthenticated', 'mEmailToken', 'mEmailTokenExpires', 'mRegistration', 'mEditCount', 'mGroups', 'mOptionOverrides', )
Array of Strings List of member variables which are saved to the shared cache (memcached).
Any operation which changes the corresponding database fields must call a cache-clearing function.
User::$mCoreRights [static, protected] |
array( 'apihighlimits', 'autoconfirmed', 'autopatrol', 'bigdelete', 'block', 'blockemail', 'bot', 'browsearchive', 'createaccount', 'createpage', 'createtalk', 'delete', 'deletedhistory', 'deletedtext', 'deletelogentry', 'deleterevision', 'edit', 'editinterface', 'editprotected', 'editmyoptions', 'editmyprivateinfo', 'editmyusercss', 'editmyuserjs', 'editmywatchlist', 'editsemiprotected', 'editusercssjs', #deprecated 'editusercss', 'edituserjs', 'hideuser', 'import', 'importupload', 'ipblock-exempt', 'markbotedits', 'mergehistory', 'minoredit', 'move', 'movefile', 'move-categorypages', 'move-rootuserpages', 'move-subpages', 'nominornewtalk', 'noratelimit', 'override-export-depth', 'pagelang', 'passwordreset', 'patrol', 'patrolmarks', 'protect', 'proxyunbannable', 'purge', 'read', 'reupload', 'reupload-own', 'reupload-shared', 'rollback', 'sendemail', 'siteadmin', 'suppressionlog', 'suppressredirect', 'suppressrevision', 'unblockself', 'undelete', 'unwatchedpages', 'upload', 'upload_by_url', 'userrights', 'userrights-interwiki', 'viewmyprivateinfo', 'viewmywatchlist', 'viewsuppressed', 'writeapi', )
Array of Strings Core rights.
Each of these should have a corresponding message of the form "right-$right".
Definition at line 97 of file User.php.
Referenced by getAllRights().
User::$mEditCount [protected] |
User::$mEmail |
User::$mEmailAuthenticated |
User::$mEmailToken [protected] |
User::$mEmailTokenExpires [protected] |
User::$mFrom |
String Initialization data source if mLoadedItems!==true.
May be one of:
Use the User::newFrom*() family of functions to set this.
User::$mGroups |
User::$mLoadedItems = array() [protected] |
User::$mName |
User::$mNewpassTime |
User::$mNewpassword |
User::$mNewtalk [protected] |
User::$mOptionOverrides [protected] |
User::$mOptionsLoaded |
User::$mPassword |
User::$mPasswordExpires [protected] |
User::$mRealName |
User::$mRegistration [protected] |
WebRequest User::$mRequest [private] |
User::$mToken [protected] |
User::$mTouched |
const User::MAX_WATCHED_ITEMS_CACHE = 100 |
const User::TOKEN_LENGTH = 32 |
const User::VERSION = 10 |