User Class Reference

The User object encapsulates all of the user-specific settings (user_id, name, rights, password, email address, options, last login time). More...

Inherited by PPFuzzUser.

List of all members.

Public Member Functions

 User ()
 Lightweight constructor for an anonymous user.
 load ()
 Load the user table data for this object from the source given by mFrom.
 loadFromId ()
 Load user table data, given mId has already been set.
 saveToCache ()
 Save user data to the shared cache.
 isValidPassword ($password)
 Is the input a valid password for this user?
 loadDefaults ($name=false)
 Set cached properties to default.
 SetupSession ()
 loadFromDatabase ()
 Load user and user_group data from the database.
 loadFromRow ($row)
 Initialize this object from a row from the user table.
 loadGroups ()
 Load the groups from the database if they aren't already loaded.
 clearInstanceCache ($reloadFrom=false)
 Clear various cached data stored in this object.
 getBlockedStatus ($bFromSlave=true)
 Get blocking information.
 inSorbsBlacklist ($ip)
 Whether the given IP is in the SORBS blacklist.
 inDnsBlacklist ($ip, $base)
 Whether the given IP is in a given DNS blacklist.
 isPingLimitable ()
 Is this user subject to rate limiting?
 pingLimiter ($action='edit')
 Primitive rate limits: enforce maximum actions per time period to put a brake on flooding.
 isBlocked ($bFromSlave=true)
 Check if user is blocked.
 isBlockedFrom ($title, $bFromSlave=false)
 Check if user is blocked from editing a particular 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.
 getBlockId ()
 If user is blocked, return the ID for the block.
 isBlockedGlobally ($ip= '')
 Check if user is blocked on all wikis.
 isLocked ()
 Check if user account is locked.
 isHidden ()
 Check if user account is hidden.
 getId ()
 Get the user's ID.
 setId ($v)
 Set the user and reload all fields according to a given ID.
 getName ()
 Get the user name, or the IP of an anonymous user.
 setName ($str)
 Set the user name.
 getTitleKey ()
 Get the user's name escaped by underscores.
 getNewtalk ()
 Check if the user has new messages.
 getNewMessageLinks ()
 Return the talk page(s) this user has new messages on.
 checkNewtalk ($field, $id, $fromMaster=false)
 Internal uncached check for new messages.
 updateNewtalk ($field, $id)
 Add or update the new messages flag.
 deleteNewtalk ($field, $id)
 Clear the new messages flag for the given user.
 setNewtalk ($val)
 Update the 'You have new messages!' status.
 invalidateCache ()
 Immediately touch the user data cache for this account.
 validateCache ($timestamp)
 Validate the cache for this account.
 getTouched ()
 Get the user touched timestamp.
 setPassword ($str)
 Set the password and reset the random token.
 setInternalPassword ($str)
 Set the password and reset the random token unconditionally.
 getToken ()
 Get the user's current token.
 setToken ($token=false)
 Set the random token (used for persistent authentication) Called from loadDefaults() among other places.
 setCookiePassword ($str)
 Set the cookie password.
 setNewpassword ($str, $throttle=true)
 Set the password for a password reminder or new account email.
 isPasswordReminderThrottled ()
 Has password reminder email been sent within the last $wgPasswordReminderResendTime hours?
 getEmail ()
 Get the user's e-mail address.
 getEmailAuthenticationTimestamp ()
 Get the timestamp of the user's e-mail authentication.
 setEmail ($str)
 Set the user's e-mail address.
 getRealName ()
 Get the user's real name.
 setRealName ($str)
 Set the user's real name.
 getOption ($oname, $defaultOverride= '')
 Get the user's current setting for a given option.
 getBoolOption ($oname)
 Get the user's current setting for a given option, as a boolean value.
 getIntOption ($oname, $defaultOverride=0)
 Get the user's current setting for a given option, as a boolean value.
 setOption ($oname, $val)
 Set the given option for a user.
 restoreOptions ()
 Reset all options to the site defaults.
 getDatePreference ()
 Get the user's preferred date format.
 getRights ()
 Get the permissions this user has.
 getGroups ()
 Get the list of explicit group memberships this user has.
 getEffectiveGroups ($recache=false)
 Get the list of implicit group memberships this user has.
 getEditCount ()
 Get the user's edit count.
 addGroup ($group)
 Add the user to the given group.
 removeGroup ($group)
 Remove the user from the given group.
 isLoggedIn ()
 Get whether the user is logged in.
 isAnon ()
 Get whether the user is anonymous.
 isBot ()
 Get whether the user is a bot.
 isAllowed ($action= '')
 Check if user is allowed to access a feature / make an action.
 useRCPatrol ()
 Check whether to enable recent changes patrol features for this user.
 useNPPatrol ()
 Check whether to enable new pages patrol features for this user.
getSkin ()
 Get the current skin, loading it if required.
 isWatched ($title)
 Check the watched status of an article.
 addWatch ($title)
 Watch an article.
 removeWatch ($title)
 Stop watching an article.
 clearNotification (&$title)
 Clear the user's notification timestamp for the given title.
 clearAllNotifications ($currentUser)
 Resets all of the given user's page-change notification timestamps.
 encodeOptions ()
 Encode this user's options as a string.
 decodeOptions ($str)
 Set this user's options from an encoded string.
 setCookies ()
 Set the default cookies for this session on the user's client.
 logout ()
 Log this user out.
 doLogout ()
 Clear the user's cookies and session, and reset the instance cache.
 saveSettings ()
 Save this user's settings into the database.
 idForName ()
 If only this user's username is known, and it exists, return the user ID.
 addToDatabase ()
 Add this existing user object to the database.
 spreadBlock ()
 If this (non-anonymous) user is blocked, block any IP address they've successfully logged in from.
 getPageRenderingHash ()
 Generate a string which will be different for any combination of user options which would produce different parser output.
 isBlockedFromCreateAccount ()
 Get whether the user is explicitly blocked from account creation.
 isBlockedFromEmailuser ()
 Get whether the user is blocked from using Special:Emailuser.
 isAllowedToCreateAccount ()
 Get whether the user is allowed to create an account.
 setLoaded ($loaded)
 getUserPage ()
 Get this user's personal page title.
 getTalkPage ()
 Get this user's talk page title.
 isNewbie ()
 Determine whether the user is a newbie.
 isActiveEditor ()
 Is the user active? We check to see if they've made at least X number of edits in the last Y days.
 checkPassword ($password)
 Check to see if the given clear-text password is one of the accepted passwords.
 checkTemporaryPassword ($plaintext)
 Check if the given clear-text password matches the temporary password sent by e-mail for password reset operations.
 editToken ($salt= '')
 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.
 generateToken ($salt= '')
 Generate a looking random token for various uses.
 matchEditToken ($val, $salt= '')
 Check given value against the token value stored in the session.
 matchEditTokenNoSuffix ($val, $salt= '')
 Check given value against the token value stored in the session, ignoring the suffix.
 sendConfirmationMail ()
 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.
 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.
 invalidationTokenUrl ($token)
 Return a URL the user can use to invalidate their email address.
 confirmEmail ()
 Mark the e-mail address confirmed.
 invalidateEmail ()
 Invalidate the user's e-mail confirmation, and unauthenticate the e-mail address if it was already confirmed.
 setEmailAuthenticationTimestamp ($timestamp)
 Set the e-mail authentication timestamp.
 canSendEmail ()
 Is this user allowed to send e-mails within limits of current site configuration?
 canReceiveEmail ()
 Is this user allowed to receive e-mails within limits of current site configuration?
 isEmailConfirmed ()
 Is this user's e-mail address valid-looking and confirmed within limits of the current site configuration?
 isEmailConfirmationPending ()
 Check whether there is an outstanding request for e-mail confirmation.
 getRegistration ()
 Get the timestamp of account creation.
 getFirstEditTimestamp ()
 Get the timestamp of the first edit.
 incEditCount ()
 Increment the user's edit-count field.
 addNewUserLogEntry ($byEmail=false)
 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.

Static Public Member Functions

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.
static idFromName ($name)
 Get database id given a user name.
static isIP ($name)
 Does the string match an anonymous IPv4 address?
static isValidUserName ($name)
 Is the input a valid username?
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 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 isValidEmailAddr ($addr)
 Does a string look like an e-mail address?
static getCanonicalName ($name, $validate= 'valid')
 Given unvalidated user input, return a canonical username, or false if the username is invalid.
static edits ($uid)
 Count the number of edits of a user.
static randomPassword ()
 Return a random password.
static getDefaultOptions ()
 Combine the language default options with any site-specific options and add the default language variants.
static getDefaultOption ($opt)
 Get a given default option value.
static getToggles ()
 Get a list of user toggle names.
static createNew ($name, $params=array())
 Add a user to the database, return the user object.
 getMaxID ()
 Get the maximum valid user ID.
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 getGroupName ($group)
 Get the localized descriptive name for a group, if it exists.
static getGroupMember ($group)
 Get the localized descriptive name for a member of a group, if it exists.
static getAllGroups ()
 Return the set of defined explicit groups.
static getAllRights ()
 Get a list of all available permissions.
static getImplicitGroups ()
 Get a list of implicit groups.
static getGroupPage ($group)
 Get the title of a page describing a particular group.
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 getRightDescription ($right)
 Get the description of a given right.
static oldCrypt ($password, $userId)
 Make an old-style password hash.
static crypt ($password, $salt=false)
 Make a new-style password hash.
static comparePasswords ($hash, $password, $userId=false)
 Compare a password hash with a plain-text password.
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 ()
 Create a new user object using data from session or cookies.
static newFromRow ($row)
 Create a new user object from a user row.

Public Attributes

 $mDataLoaded
  Boolean : Whether the cache variables have been loaded.
 $mAuthLoaded
 $mFrom
  String : Initialization data source if mDataLoaded==false.
Cache variables
 $mId
 $mName
 $mRealName
 $mPassword
 $mNewpassword
 $mNewpassTime
 $mEmail
 $mOptions
 $mTouched
 $mToken
 $mEmailAuthenticated
 $mEmailToken
 $mEmailTokenExpires
 $mRegistration
 $mGroups
Lazy-initialized variables, invalidated with clearInstanceCache
 $mNewtalk
 $mDatePreference
 $mBlockedby
 $mHash
 $mSkin
 $mRights
 $mBlockreason
 $mBlock
 $mEffectiveGroups
 $mBlockedGlobally
 $mLocked
 $mHideName

Static Public Attributes

static $mToggles
  { String :} : A list of default user toggles, i.e., boolean user preferences that are displayed by Special:Preferences as checkboxes.
static $mCacheVars
  { String :} : List of member variables which are saved to the shared cache (memcached).
static $mCoreRights
  { String :} : Core rights.
static $mAllRights = false
  String : Cached results of getAllRights()

Protected Member Functions

 setCookie ($name, $value, $exp=0)
 Set a cookie on the user's client.
 clearCookie ($name)
 Clear a cookie on the user's client.
 getTokenUrl ($page, $token)
 Internal function to format the e-mail validation/invalidation URLs.

Private Member Functions

 loadFromSession ()
 Load user data from the session or login cookie.
 clearSharedCache ()
 Clear user data from memcached.

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.


Detailed Description

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.

Definition at line 43 of file User.php.


Member Function Documentation

User::addGroup ( group  ) 

Add the user to the given group.

This takes immediate effect.

Parameters:
$group  String : Name of the group to add

Definition at line 2041 of file User.php.

References $dbw, getEffectiveGroups(), getGroupPermissions(), getId(), invalidateCache(), loadGroups(), and wfGetDB().

User::addNewUserLogEntry ( byEmail = false  ) 

Add a newuser log entry for this user.

Parameters:
$byEmail Boolean: account made by email?

Definition at line 3372 of file User.php.

References $action, $wgContLang, $wgNewUserLog, $wgUser, getId(), getName(), getUserPage(), and wfMsgForContent().

User::addNewUserLogEntryAutoCreate (  ) 

Add an autocreate newuser log entry for this user Used by things like CentralAuth and perhaps other authplugins.

Definition at line 3394 of file User.php.

References $wgNewUserLog, getId(), and getUserPage().

User::addToDatabase (  ) 

Add this existing user object to the database.

Definition at line 2509 of file User.php.

References $dbw, clearInstanceCache(), encodeOptions(), load(), and wfGetDB().

User::addWatch ( title  ) 

Watch an article.

Parameters:
$title {Title} Title of the article to look at

Definition at line 2185 of file User.php.

References $title, WatchedItem::fromUserTitle(), and invalidateCache().

User::blockedBy (  ) 

If user is blocked, return the name of the user who placed the block.

Returns:
String : name of blocker

Definition at line 1319 of file User.php.

References getBlockedStatus().

User::blockedFor (  ) 

If user is blocked, return the specified reason for the block.

Returns:
String : Blocking reason

Definition at line 1328 of file User.php.

References getBlockedStatus().

User::canReceiveEmail (  ) 

Is this user allowed to receive e-mails within limits of current site configuration?

Returns:
Boolean : True if allowed

Definition at line 2991 of file User.php.

References getOption(), and isEmailConfirmed().

User::canSendEmail (  ) 

Is this user allowed to send e-mails within limits of current site configuration?

Returns:
Boolean : True if allowed

Definition at line 2976 of file User.php.

References $wgEnableEmail, $wgEnableUserEmail, isEmailConfirmed(), and wfRunHooks().

User::checkNewtalk ( field,
id,
fromMaster = false 
)

Internal uncached check for new messages.

See also:
getNewtalk()
Parameters:
$field  String : 'user_ip' for anonymous users, 'user_id' otherwise
$id  String : or Integer : : User's IP address for anonymous users, User ID otherwise
$fromMaster  Boolean : true to fetch from the master, false for a slave
Returns:
Boolean : True if the user has new messages
Access:
private

Definition at line 1528 of file User.php.

References $db, $ok, and wfGetDB().

Referenced by getNewtalk().

User::checkPassword ( password  ) 

Check to see if the given clear-text password is one of the accepted passwords.

Parameters:
$password  String : user password.
Returns:
Boolean : True if the given password is correct, otherwise False.

Definition at line 2709 of file User.php.

References $password, $wgAuth, isValidPassword(), and load().

User::checkTemporaryPassword ( plaintext  ) 

Check if the given clear-text password matches the temporary password sent by e-mail for password reset operations.

Returns:
Boolean : True if matches, false otherwise

Definition at line 2749 of file User.php.

References $wgNewPasswordExpiry, getId(), load(), and wfTimestamp().

User::clearAllNotifications ( currentUser  ) 

Resets all of the given user's page-change notification timestamps.

If e-notif e-mails are on, they will receive notification mails on the next change of any watched page.

Parameters:
$currentUser  Integer : User ID

Definition at line 2268 of file User.php.

References $dbw, $wgShowUpdatedMarker, $wgUseEnotif, setNewtalk(), and wfGetDB().

User::clearCookie ( name  )  [protected]

Clear a cookie on the user's client.

Parameters:
$name  String : Name of the cookie to clear

Definition at line 2339 of file User.php.

References $name, and setCookie().

Referenced by doLogout(), and setCookies().

User::clearInstanceCache ( reloadFrom = false  ) 

Clear various cached data stored in this object.

Parameters:
$reloadFrom  String : 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 964 of file User.php.

Referenced by addToDatabase(), doLogout(), setId(), and User().

User::clearNotification ( &$  title  ) 

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.

Parameters:
$title {Title} Title of the article to look at

Definition at line 2207 of file User.php.

References $dbw, $title, $wgShowUpdatedMarker, $wgUseEnotif, $wgUser, getId(), getName(), isAnon(), setNewtalk(), wfGetDB(), wfReadOnly(), and wfRunHooks().

User::clearSharedCache (  )  [private]

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 1637 of file User.php.

References $wgMemc, load(), and wfMemcKey().

Referenced by invalidateCache(), and 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.

Parameters:
$hash  String : Password hash
$password  String : Plain-text password to compare
$userId  String : User ID for old-style password salt
Returns:
Boolean :

Definition at line 3346 of file User.php.

References $password, $result, $type, oldCrypt(), and wfRunHooks().

User::confirmationToken ( &$  expiration  ) 

Generate, store, and return a new e-mail confirmation code.

A hash (unsalted, since it's used as a key) is stored.

Note:
Call saveSettings() after calling this function to commit this change to the database.
Parameters:
[out] &$expiration  Mixed : Accepts the expiration time
Returns:
String : New token
Access:
private

Definition at line 2883 of file User.php.

References generateToken(), load(), and wfTimestamp().

Referenced by sendConfirmationMail().

User::confirmationTokenUrl ( token  ) 

Return a URL the user can use to confirm their email address.

Parameters:
$token  String : Accepts the email confirmation token
Returns:
String : New token URL
Access:
private

Definition at line 2901 of file User.php.

References getTokenUrl().

Referenced by sendConfirmationMail().

User::confirmEmail (  ) 

Mark the e-mail address confirmed.

Note:
Call saveSettings() after calling this function to commit the change.

Definition at line 2942 of file User.php.

References setEmailAuthenticationTimestamp(), and wfTimestampNow().

static User::createNew ( name,
params = array() 
) [static]

Add a user to the database, return the user object.

Parameters:
$name  String : Username to add
$params  { String :} : Non-default parameters to save to the database:
  • password The user's password. Password logins will be disabled if this is omitted.
  • newpassword A temporary password mailed to the user
  • email The user's email address
  • email_authenticated The email authentication timestamp
  • real_name The user's real name
  • options An associative array of non-default options
  • token Random authentication token. Do not set.
  • registration Registration timestamp. Do not set.
Returns:
User : A new User object, or null if the username already exists

Definition at line 2471 of file User.php.

References $dbw, $fields, $name, $user, newFromId(), and wfGetDB().

static User::crypt ( password,
salt = false 
) [static]

Make a new-style password hash.

Parameters:
$password  String : Plain-text password
$salt  String : Optional salt, may be random or the user ID. If unspecified or false, will generate one automatically
Returns:
String : Password hash

Definition at line 3319 of file User.php.

References $password, $wgPasswordSalt, wfGenerateToken(), and wfRunHooks().

Referenced by setInternalPassword(), and setNewpassword().

User::decodeOptions ( str  ) 

Set this user's options from an encoded string.

Parameters:
$str  String : Encoded options to import
Access:
private

Definition at line 2311 of file User.php.

References $s.

Referenced by loadFromRow().

User::deleteNewtalk ( field,
id 
)

Clear the new messages flag for the given user.

Parameters:
$field  String : 'user_ip' for anonymous users, 'user_id' otherwise
$id  String : or Integer : : User's IP address for anonymous users, User ID otherwise
Returns:
Boolean : True if successful, false otherwise
Access:
private

Definition at line 1568 of file User.php.

References $dbw, wfDebug(), and wfGetDB().

Referenced by setNewtalk().

User::doLogout (  ) 

Clear the user's cookies and session, and reset the instance cache.

Access:
private
See also:
logout()

Definition at line 2393 of file User.php.

References clearCookie(), clearInstanceCache(), setCookie(), and wfTimestampNow().

Referenced by logout().

static User::edits ( uid  )  [static]

Count the number of edits of a user.

Todo:
It should not be static and some day should be merged as proper member function / deprecated -- domas
Parameters:
$uid User ID to check
Returns:
The user's edit count

Definition at line 705 of file User.php.

References $count, $dbr, $dbw, wfGetDB(), wfProfileIn(), and wfProfileOut().

Referenced by getEditCount(), and Linker::userToolLinks().

User::editToken ( salt = ''  ) 

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.

Parameters:
$salt  String : or { String :} : Optional function-specific data for hashing
Returns:
String : The new edit token

Definition at line 2769 of file User.php.

References generateToken(), and isAnon().

Referenced by matchEditToken(), and matchEditTokenNoSuffix().

User::encodeOptions (  ) 

Encode this user's options as a string.

Returns:
String : Encoded options
Access:
private

Definition at line 2293 of file User.php.

References $s, getDefaultOptions(), and load().

Referenced by addToDatabase(), and saveSettings().

User::generateToken ( salt = ''  ) 

Generate a looking random token for various uses.

Parameters:
$salt  String : Optional salt value
Returns:
String : The new random token

Definition at line 2792 of file User.php.

Referenced by confirmationToken(), and editToken().

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.

Returns:
{ String :} : Array of internal group names

Definition at line 3138 of file User.php.

References $wgGroupPermissions.

Referenced by UsersPager::__construct(), UserrightsPage::changeableGroups(), ApiQueryAllUsers::execute(), UsersPager::getAllGroups(), and ApiQueryAllUsers::getAllowedParams().

static User::getAllRights (  )  [static]

Get a list of all available permissions.

Returns:
{ String :} : Array of permission names

Definition at line 3150 of file User.php.

References $wgAvailableRights, and wfRunHooks().

User::getBlockedStatus ( bFromSlave = true  ) 

Get blocking information.

Access:
private
Parameters:
$bFromSlave  Boolean : 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 1046 of file User.php.

References $wgEnableSorbs, $wgProxyWhitelist, inSorbsBlacklist(), isAllowed(), isLoggedIn(), load(), spreadBlock(), wfDebug(), wfGetIP(), wfIsLocallyBlockedProxy(), wfMsg(), wfProfileIn(), wfProfileOut(), and wfRunHooks().

Referenced by blockedBy(), blockedFor(), getBlockId(), isBlocked(), isBlockedFromCreateAccount(), isBlockedFromEmailuser(), and isHidden().

User::getBlockId (  ) 

If user is blocked, return the ID for the block.

Returns:
Integer : Block ID

Definition at line 1337 of file User.php.

References getBlockedStatus().

User::getBoolOption ( oname  ) 

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

Parameters:
$oname  String : The option to check
Returns:
Boolean : User's current value for the option
See also:
getOption()

Definition at line 1893 of file User.php.

References getOption().

static User::getCanonicalName ( name,
validate = 'valid' 
) [static]

Given unvalidated user input, return a canonical username, or false if the username is invalid.

Parameters:
$name  String : User input
$validate  String : or Boolean : : Type of validation to use:
  • false No validation
  • 'valid' Valid for batch processes
  • 'usable' Valid for batch processes and login
  • 'creatable' Valid for batch processes, login and account creation

Definition at line 650 of file User.php.

References $name, $t, $wgAuth, $wgContLang, isCreatableName(), isUsableName(), isValidUserName(), Title::makeTitle(), and Title::newFromText().

Referenced by ApiRollback::execute(), ApiQueryUsers::execute(), newFromName(), ApiQueryContributions::prepareUsername(), ApiQueryBlocks::prepareUsername(), and wfSpecialRestrictUser().

User::getDatePreference (  ) 

Get the user's preferred date format.

Returns:
String : User's preferred date format

Definition at line 1955 of file User.php.

References $wgLang, and getOption().

Referenced by getPageRenderingHash().

static User::getDefaultOption ( opt  )  [static]

Get a given default option value.

Parameters:
$opt  String : Name of option to retrieve
Returns:
String : Default option value

Definition at line 1012 of file User.php.

References getDefaultOptions().

Referenced by SkinMonoBookCBT::body_ondblclick(), CoreParserFunctions::gender(), Linker::makeImageLink2(), ImagePage::openShowImage(), and PreferencesForm::validateGender().

static User::getDefaultOptions (  )  [static]

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

Returns:
{ String :} : Array of options

Definition at line 985 of file User.php.

References $wgContLang, $wgDefaultUserOptions, and $wgNamespacesToBeSearchedDefault.

Referenced by Language::dateFormat(), encodeOptions(), ApiQueryUserInfo::getCurrentUserInfo(), getDefaultOption(), userOptions::getDefaultOptionsNames(), Language::getDefaultUserOptions(), getOption(), userOptions::LISTER(), restoreOptions(), setOption(), and userOptions::USAGER().

User::getEditCount (  ) 

Get the user's edit count.

Returns:
Integer : User'e edit count

Definition at line 2023 of file User.php.

References edits(), and getId().

Referenced by Autopromote::checkCondition(), and loadFromDatabase().

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

Parameters:
$recache  Boolean : Whether to avoid the cache
Returns:
{ String :} : Array of internal group names

Definition at line 2000 of file User.php.

References Autopromote::getAutopromoteGroups(), getGroups(), getId(), and wfRunHooks().

Referenced by addGroup(), getRights(), isPingLimitable(), and removeGroup().

User::getEmail (  ) 

Get the user's e-mail address.

Returns:
String : User's email address

Definition at line 1816 of file User.php.

References load(), and wfRunHooks().

Referenced by Autopromote::checkCondition().

User::getEmailAuthenticationTimestamp (  ) 

Get the timestamp of the user's e-mail authentication.

Returns:
String : TS_MW timestamp

Definition at line 1826 of file User.php.

References load(), and wfRunHooks().

Referenced by Autopromote::checkCondition(), and isEmailConfirmed().

User::getFirstEditTimestamp (  ) 

Get the timestamp of the first edit.

Returns:
String : or Boolean : : string Timestamp of first edit, or false for non-existent/anonymous user accounts.

Definition at line 3052 of file User.php.

References $dbr, getId(), wfGetDB(), and wfTimestamp().

Referenced by Autopromote::checkCondition().

static User::getGroupMember ( group  )  [static]

Get the localized descriptive name for a member of a group, if it exists.

Parameters:
$group  String : Internal group name
Returns:
String : Localized name for group member

Definition at line 3122 of file User.php.

References $key, $name, $wgMessageCache, wfEmptyMsg(), and wfMsg().

Referenced by UsersPager::buildGroupLink(), and UserrightsPage::groupCheckboxes().

static User::getGroupName ( group  )  [static]

Get the localized descriptive name for a group, if it exists.

Parameters:
$group  String : Internal group name
Returns:
String : Localized descriptive group name

Definition at line 3106 of file User.php.

References $key, $name, $wgMessageCache, wfEmptyMsg(), and wfMsg().

Referenced by UserrightsPage::buildGroupLink(), UsersPager::getAllGroups(), makeGroupLinkHTML(), and makeGroupLinkWiki().

static User::getGroupPage ( group  )  [static]

Get the title of a page describing a particular group.

Parameters:
$group  String : Internal group name
Returns:
Title : or Boolean : : Title of the page if it exists, false otherwise

Definition at line 3180 of file User.php.

References $page, $title, $wgMessageCache, Title::newFromText(), wfEmptyMsg(), and wfMsgForContent().

Referenced by makeGroupLinkHTML(), and makeGroupLinkWiki().

static User::getGroupPermissions ( groups  )  [static]

Get the permissions associated with a given list of groups.

Parameters:
$groups  { String :} : List of internal group names
Returns:
{ String :} : List of permission key names for given groups combined

Definition at line 3070 of file User.php.

References $wgGroupPermissions.

Referenced by addGroup(), getRights(), and removeGroup().

User::getGroups (  ) 

Get the list of explicit group memberships this user has.

The implicit * and user groups are not included.

Returns:
{ String :} : Array of internal group names

Definition at line 1988 of file User.php.

References load().

Referenced by Autopromote::checkCondition(), getEffectiveGroups(), and pingLimiter().

static User::getGroupsWithPermission ( role  )  [static]

Get all the groups who have a given permission.

Parameters:
$role  String : Role to check
Returns:
{ String :} : List of internal group names with the given permission

Definition at line 3089 of file User.php.

References $wgGroupPermissions.

Referenced by Title::getUserPermissionsErrorsInternal(), ApiMain::makeHelpMsg(), OutputPage::permissionRequired(), and wfSpecialNewimages().

User::getId (  ) 

Get the user's ID.

Returns:
Integer : The user's ID; 0 if the user is anonymous or nonexistent

Definition at line 1403 of file User.php.

References isIP(), and load().

Referenced by addGroup(), addNewUserLogEntry(), addNewUserLogEntryAutoCreate(), checkTemporaryPassword(), clearNotification(), getEditCount(), getEffectiveGroups(), getFirstEditTimestamp(), getRegistration(), incEditCount(), pingLimiter(), setNewtalk(), and UploadForm::userCanReUpload().

static User::getImplicitGroups (  )  [static]

Get a list of implicit groups.

Returns:
{ String :} : Array of internal group names

Definition at line 3167 of file User.php.

References $wgImplicitGroups, and wfRunHooks().

User::getIntOption ( oname,
defaultOverride = 0 
)

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

Parameters:
$oname  String : The option to check
$defaultOverride  Integer : A default value returned if the option does not exist
Returns:
Integer : User's current value for the option
See also:
getOption()

Definition at line 1906 of file User.php.

References getOption().

User::getMaxID (  )  [static]

Get the maximum valid user ID.

Returns:
Integer : User ID

Definition at line 2658 of file User.php.

References $dbr, $res, and wfGetDB().

User::getName (  ) 

Get the user name, or the IP of an anonymous user.

Returns:
String : User's name or IP address

Definition at line 1428 of file User.php.

References load(), IP::sanitizeIP(), and wfGetIP().

Referenced by addNewUserLogEntry(), clearNotification(), getNewtalk(), getTitleKey(), getUserPage(), idForName(), isActiveEditor(), isBlockedFrom(), isBlockedGlobally(), Credits::link(), RdfMetaData::person(), pingLimiter(), sendConfirmationMail(), setCookies(), and setNewtalk().

User::getNewMessageLinks (  ) 

Return the talk page(s) this user has new messages on.

Returns:
{ String :} : Array of page URLs

Definition at line 1505 of file User.php.

References getNewtalk(), getUserPage(), wfRunHooks(), and wfWikiID().

User::getNewtalk (  ) 

Check if the user has new messages.

Returns:
Boolean : True if the user has new messages

Definition at line 1472 of file User.php.

References $key, $wgMemc, checkNewtalk(), getName(), load(), and wfMemcKey().

Referenced by getNewMessageLinks().

User::getOption ( oname,
defaultOverride = '' 
)

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

Parameters:
$oname  String : The option to check
$defaultOverride  String : A default value returned if the option does not exist
Returns:
String : User's current value for the option
See also:
getBoolOption()

getIntOption()

Reimplemented in PPFuzzUser.

Definition at line 1869 of file User.php.

References getDefaultOptions(), and load().

Referenced by canReceiveEmail(), getBoolOption(), getDatePreference(), getIntOption(), getPageRenderingHash(), getSkin(), and setCookies().

User::getPageRenderingHash (  ) 

Generate a string which will be different for any combination of user options which would produce different parser output.

This will be used as part of the hash key for the parser cache, so users will the same options can share the same cached data safely.

Extensions which require it should install 'PageRenderingHash' hook, which will give them a chance to modify this key based on their own settings.

Returns:
String : Page rendering hash

Definition at line 2568 of file User.php.

References $wgContLang, $wgLang, $wgRenderHashAppend, $wgUseDynamicDates, getDatePreference(), getOption(), and wfRunHooks().

User::getRealName (  ) 

Get the user's real name.

Returns:
String : User's real name

Definition at line 1846 of file User.php.

References load().

Referenced by Credits::link(), RdfMetaData::person(), and Credits::userLink().

User::getRegistration (  ) 

Get the timestamp of account creation.

Returns:
String : or Boolean : : string Timestamp of account creation, or false for non-existent/anonymous user accounts.

Definition at line 3040 of file User.php.

References getId().

Referenced by Autopromote::checkCondition().

static User::getRightDescription ( right  )  [static]

Get the description of a given right.

Parameters:
$right  String : Right to query
Returns:
String : Localized description of the right

Definition at line 3285 of file User.php.

References $key, $name, $wgMessageCache, wfEmptyMsg(), and wfMsg().

Referenced by SpecialListGroupRights::formatPermissions().

User::getRights (  ) 

Get the permissions this user has.

Returns:
{ String :} : Array of permission names

Definition at line 1973 of file User.php.

References getEffectiveGroups(), getGroupPermissions(), and wfRunHooks().

Referenced by isAllowed().

& User::getSkin (  ) 

Get the current skin, loading it if required.

Returns:
Skin : Current skin
Todo:
FIXME : need to check the old failback system [AV]

Definition at line 2151 of file User.php.

References $wgAllowUserSkin, $wgDefaultSkin, $wgRequest, getOption(), Skin::newFromKey(), wfProfileIn(), and wfProfileOut().

User::getTalkPage (  ) 

Get this user's talk page title.

Returns:
Title : User's talk page title

Definition at line 2648 of file User.php.

References $title, and getUserPage().

User::getTitleKey (  ) 

Get the user's name escaped by underscores.

Returns:
String : Username escaped by underscores.

Definition at line 1464 of file User.php.

References getName().

static User::getToggles (  )  [static]

Get a list of user toggle names.

Returns:
{ String :} : Array of user toggle names

Definition at line 1025 of file User.php.

References $wgContLang, $wgUseRCPatrol, and wfRunHooks().

User::getToken (  ) 

Get the user's current token.

Returns:
String : Token

Definition at line 1743 of file User.php.

References load().

User::getTokenUrl ( page,
token 
) [protected]

Internal function to format the e-mail validation/invalidation URLs.

This uses $wgArticlePath directly as a quickie hack to use the hardcoded English names of the Special: pages, for ASCII safety.

Note:
Since these URLs get dropped directly into emails, using the short English names avoids insanely long URL-encoded links, which also sometimes can get corrupted in some browsers/mailers (bug 6957 with Gmail and Internet Explorer).
Parameters:
$page  String : Special page
$token  String : Token
Returns:
String : Formatted URL

Definition at line 2928 of file User.php.

References $wgArticlePath, and wfExpandUrl().

Referenced by confirmationTokenUrl(), and invalidationTokenUrl().

User::getTouched (  ) 

Get the user touched timestamp.

Definition at line 1677 of file User.php.

References load().

User::getUserPage (  ) 

Get this user's personal page title.

Returns:
Title : User's personal page title

Definition at line 2639 of file User.php.

References getName(), and Title::makeTitle().

Referenced by addNewUserLogEntry(), addNewUserLogEntryAutoCreate(), getNewMessageLinks(), getTalkPage(), Credits::link(), RdfMetaData::person(), and saveSettings().

User::idForName (  ) 

If only this user's username is known, and it exists, return the user ID.

Definition at line 2443 of file User.php.

References $dbr, $s, getName(), and wfGetDB().

static User::idFromName ( name  )  [static]

User::incEditCount (  ) 

Increment the user's edit-count field.

Will have no effect for anonymous users.

Definition at line 3239 of file User.php.

References $count, $dbr, $dbw, getId(), invalidateCache(), isAnon(), and wfGetDB().

User::inDnsBlacklist ( ip,
base 
)

Whether the given IP is in a given DNS blacklist.

Parameters:
$ip  String : IP to check
$base  String : URL of the DNS blacklist
Returns:
Boolean : True if blacklisted.

Definition at line 1135 of file User.php.

References IP::isIPv4(), wfDebug(), wfProfileIn(), and wfProfileOut().

Referenced by inSorbsBlacklist().

User::inSorbsBlacklist ( ip  ) 

Whether the given IP is in the SORBS blacklist.

Parameters:
$ip  String : IP to check
Returns:
Boolean : True if blacklisted.

Definition at line 1121 of file User.php.

References $wgEnableSorbs, $wgSorbsUrl, and inDnsBlacklist().

Referenced by getBlockedStatus().

User::invalidateCache (  ) 

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 1650 of file User.php.

References $dbw, clearSharedCache(), load(), newTouchedTimestamp(), and wfGetDB().

Referenced by addGroup(), addWatch(), incEditCount(), removeGroup(), removeWatch(), and setNewtalk().

User::invalidateEmail (  ) 

Invalidate the user's e-mail confirmation, and unauthenticate the e-mail address if it was already confirmed.

Note:
Call saveSettings() after calling this function to commit the change.

Definition at line 2953 of file User.php.

References load(), and setEmailAuthenticationTimestamp().

User::invalidationTokenUrl ( token  ) 

Return a URL the user can use to invalidate their email address.

Parameters:
$token  String : Accepts the email confirmation token
Returns:
String : New token URL
Access:
private

Definition at line 2910 of file User.php.

References getTokenUrl().

Referenced by sendConfirmationMail().

User::isActiveEditor (  ) 

Is the user active? We check to see if they've made at least X number of edits in the last Y days.

Returns:
Boolean : True if the user is active, false if not.

Definition at line 2684 of file User.php.

References $count, $dbr, $res, $wgActiveUserDays, $wgActiveUserEditCount, getName(), and wfGetDB().

User::isAllowed ( action = ''  ) 

Check if user is allowed to access a feature / make an action.

Parameters:
$action  String : action to be checked
Returns:
Boolean : True if action is allowed, else false

Definition at line 2114 of file User.php.

References $action, $wgUseNPPatrol, $wgUseRCPatrol, and getRights().

Referenced by getBlockedStatus(), isAllowedToCreateAccount(), isBot(), isNewbie(), isPingLimitable(), useNPPatrol(), UploadForm::userCanReUpload(), and useRCPatrol().

User::isAllowedToCreateAccount (  ) 

Get whether the user is allowed to create an account.

Returns:
Boolean : True if allowed

Definition at line 2623 of file User.php.

References isAllowed(), and isBlockedFromCreateAccount().

User::isAnon (  ) 

Get whether the user is anonymous.

Returns:
Boolean : True or false

Definition at line 2095 of file User.php.

References isLoggedIn().

Referenced by clearNotification(), editToken(), incEditCount(), isEmailConfirmed(), RdfMetaData::person(), saveToCache(), setNewtalk(), and Credits::userLink().

User::isBlocked ( bFromSlave = true  ) 

Check if user is blocked.

Parameters:
$bFromSlave Whether to check the slave database instead of the master
Returns:
True if blocked, false otherwise

Definition at line 1284 of file User.php.

References getBlockedStatus(), and wfDebug().

Referenced by isBlockedFrom().

User::isBlockedFrom ( title,
bFromSlave = false 
)

Check if user is blocked from editing a particular article.

Parameters:
$title Title to check
$bFromSlave Whether to check the slave database instead of the master
Returns:
True if blocked, false otherwise

Definition at line 1297 of file User.php.

References $title, $wgBlockAllowsUTEdit, getName(), isBlocked(), wfDebug(), wfProfileIn(), and wfProfileOut().

User::isBlockedFromCreateAccount (  ) 

Get whether the user is explicitly blocked from account creation.

Returns:
Boolean : True if blocked

Definition at line 2605 of file User.php.

References getBlockedStatus().

Referenced by isAllowedToCreateAccount().

User::isBlockedFromEmailuser (  ) 

Get whether the user is blocked from using Special:Emailuser.

Returns:
Boolean : True if blocked

Definition at line 2614 of file User.php.

References getBlockedStatus().

User::isBlockedGlobally ( ip = ''  ) 

Check if user is blocked on all wikis.

Do not use for actual edit permission checks! This is intented for quick UI checks.

Parameters:
$ip  String : : IP address, uses current client if none given
Returns:
Boolean : : True if blocked, false otherwise

Definition at line 1350 of file User.php.

References getName(), IP::isIPAddress(), wfGetIP(), and wfRunHooks().

User::isBot (  ) 

Get whether the user is a bot.

Returns:
Boolean : True or false
Deprecated:

Definition at line 2104 of file User.php.

References isAllowed(), and wfDeprecated().

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 character blacklisting may be added here rather than in isValidUserName() to avoid disrupting existing accounts.

Parameters:
$name  String : String to match
Returns:
Boolean : True or false

Definition at line 590 of file User.php.

References $name, $wgInvalidUsernameCharacters, and isUsableName().

Referenced by getCanonicalName().

User::isEmailConfirmationPending (  ) 

Check whether there is an outstanding request for e-mail confirmation.

Returns:
Boolean : True if pending

Definition at line 3026 of file User.php.

References $wgEmailAuthentication, isEmailConfirmed(), and wfTimestamp().

User::isEmailConfirmed (  ) 

Is this user's e-mail address valid-looking and confirmed within limits of the current site configuration?

Note:
If $wgEmailAuthentication is on, this may require the user to have confirmed their address by returning a code or using a password sent to the address from the wiki.
Returns:
Boolean : True if confirmed

Definition at line 3005 of file User.php.

References $wgEmailAuthentication, getEmailAuthenticationTimestamp(), isAnon(), load(), and wfRunHooks().

Referenced by canReceiveEmail(), canSendEmail(), and isEmailConfirmationPending().

User::isHidden (  ) 

Check if user account is hidden.

Returns:
Boolean : : True if hidden, false otherwise

Definition at line 1386 of file User.php.

References $wgAuth, and getBlockedStatus().

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 {1,3}\.{1,3}\.{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.

Parameters:
$name  String : String to match
Returns:
Boolean : True or false

Definition at line 483 of file User.php.

References $name, and IP::isIPv6().

Referenced by bottomLinks(), SkinTemplate::buildNavUrls(), Article::editUpdates(), ApiRollback::execute(), getId(), SearchEngine::getNearMatch(), DeletedContributionsPage::getSubTitle(), SkinMonoBookCBT::getUserPageIdIp(), initialiseUser(), isValidUserName(), ApiQueryContributions::prepareUsername(), ApiQueryBlocks::prepareUsername(), SkinStandard::quickBar(), EditPage::showIntro(), and wfSpecialRestrictUser().

User::isLocked (  ) 

Check if user account is locked.

Returns:
Boolean : : True if locked, false otherwise

Definition at line 1371 of file User.php.

References $wgAuth.

User::isLoggedIn (  ) 

Get whether the user is logged in.

Returns:
Boolean : True or false

Definition at line 2087 of file User.php.

Referenced by getBlockedStatus(), and isAnon().

User::isNewbie (  ) 

Determine whether the user is a newbie.

Newbies are either anonymous IPs, or the most recently created accounts.

Returns:
Boolean : True if the user is a newbie

Definition at line 2674 of file User.php.

References isAllowed().

Referenced by pingLimiter().

User::isPasswordReminderThrottled (  ) 

Has password reminder email been sent within the last $wgPasswordReminderResendTime hours?

Returns:
Boolean : True or false

Definition at line 1802 of file User.php.

References $wgPasswordReminderResendTime, load(), and wfTimestamp().

User::isPingLimitable (  ) 

Is this user subject to rate limiting?

Returns:
Boolean : True if rate limited

Definition at line 1165 of file User.php.

References $wgRateLimitsExcludedGroups, $wgRateLimitsExcludedIPs, getEffectiveGroups(), isAllowed(), and wfGetIP().

Referenced by pingLimiter().

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.

Parameters:
$name  String : String to match
Returns:
Boolean : True or false

Definition at line 552 of file User.php.

References $name, $wgReservedUsernames, wfMsgForContent(), and wfRunHooks().

Referenced by LoginForm::authenticateUserData(), getCanonicalName(), and isCreatableName().

static User::isValidEmailAddr ( addr  )  [static]

Does a string look like an e-mail address?

There used to be a regular expression here, it got removed because it rejected valid addresses. Actually just check if there is '@' somewhere in the given address.

Todo:
Check for RFC 2822 compilance (bug 959)
Parameters:
$addr  String : E-mail address
Returns:
Boolean : True or false

Definition at line 631 of file User.php.

References $result, and wfRunHooks().

Referenced by LoginForm::addNewAccount(), LoginForm::addNewAccountInternal(), Autopromote::checkCondition(), and EmailConfirmation::execute().

User::isValidPassword ( password  ) 

Is the input a valid password for this user?

Parameters:
$password  String : Desired password
Returns:
Boolean : True or false

Definition at line 605 of file User.php.

References $password, $result, $wgContLang, $wgMinimalPasswordLength, and wfRunHooks().

Referenced by checkPassword(), and setPassword().

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 containins slashes (would mess up subpages), is longer than the maximum allowed username size or doesn't begin with a capital letter.

Parameters:
$name  String : String to match
Returns:
Boolean : True or false

Definition at line 498 of file User.php.

References $name, $wgContLang, $wgMaxNameChars, isIP(), Title::newFromText(), and wfDebugLog().

Referenced by getCanonicalName(), and checkUsernames::main().

User::isWatched ( title  ) 

Check the watched status of an article.

Parameters:
$title {Title} Title of the article to look at
Returns:
True if article is watched

Definition at line 2176 of file User.php.

References $title, and WatchedItem::fromUserTitle().

User::load (  ) 

User::loadDefaults ( name = false  ) 

Set cached properties to default.

Note:
This no longer clears uncached lazy-initialised properties; the constructor does that instead.
Access:
private

Definition at line 762 of file User.php.

References $name, $wgCookiePrefix, setToken(), wfProfileIn(), wfProfileOut(), wfRunHooks(), and wfTimestamp().

Referenced by PPFuzzUser::load(), load(), loadFromDatabase(), loadFromId(), and loadFromSession().

User::loadFromDatabase (  ) 

Load user and user_group data from the database.

$this::mId must be set, this is how the user is identified.

Returns:
Boolean : True if the user exists, false if the user is anonymous
Access:
private

Definition at line 884 of file User.php.

References $dbr, $s, getEditCount(), loadDefaults(), loadFromRow(), wfGetDB(), and wfRunHooks().

Referenced by loadFromId().

User::loadFromId (  ) 

Load user table data, given mId has already been set.

Returns:
Boolean : false if the ID does not exist, true otherwise
Access:
private

Definition at line 274 of file User.php.

References $key, $name, $wgMemc, loadDefaults(), loadFromDatabase(), saveToCache(), wfDebug(), and wfMemcKey().

Referenced by load(), and loadFromSession().

User::loadFromRow ( row  ) 

Initialize this object from a row from the user table.

Parameters:
$row  { Mixed :} : Row from the user table to load.

Definition at line 918 of file User.php.

References $row, decodeOptions(), wfTimestamp(), and wfTimestampOrNull().

Referenced by loadFromDatabase().

User::loadFromSession (  )  [private]

Load user data from the session or login cookie.

If there are no valid credentials, initialises the user as an anonymous user.

Returns:
Boolean : True if the user is logged in, false otherwise.

Definition at line 806 of file User.php.

References $result, $wgCookiePrefix, $wgMemc, loadDefaults(), loadFromId(), wfDebug(), wfDebugLog(), and wfRunHooks().

Referenced by load().

User::loadGroups (  ) 

Load the groups from the database if they aren't already loaded.

Access:
private

Definition at line 944 of file User.php.

References $dbr, $res, $row, and wfGetDB().

Referenced by addGroup(), removeGroup(), and saveToCache().

User::logout (  ) 

Log this user out.

Definition at line 2381 of file User.php.

References $wgUser, doLogout(), and wfRunHooks().

static User::makeGroupLinkHTML ( group,
text = '' 
) [static]

Create a link to the group in HTML, if available; else return the group name.

Parameters:
$group  String : Internal name of the group
$text  String : The text of the link
Returns:
String : HTML link to the group

Definition at line 3200 of file User.php.

References $text, $title, $wgUser, getGroupName(), and getGroupPage().

Referenced by PreferencesForm::mainPrefsForm().

static User::makeGroupLinkWiki ( group,
text = '' 
) [static]

Create a link to the group in Wikitext, if available; else return the group name.

Parameters:
$group  String : Internal name of the group
$text  String : The text of the link
Returns:
String : Wikilink to the group

Definition at line 3222 of file User.php.

References $page, $text, $title, getGroupName(), and getGroupPage().

User::matchEditToken ( val,
salt = '' 
)

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.

Parameters:
$val  String : Input value to compare
$salt  String : Optional function-specific data for hashing
Returns:
Boolean : Whether the token matches

Definition at line 2807 of file User.php.

References editToken(), and wfDebug().

User::matchEditTokenNoSuffix ( val,
salt = '' 
)

Check given value against the token value stored in the session, ignoring the suffix.

Parameters:
$val  String : Input value to compare
$salt  String : Optional function-specific data for hashing
Returns:
Boolean : Whether the token matches

Definition at line 2823 of file User.php.

References editToken().

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.

Parameters:
$code Confirmation code
Returns:
{User}

Definition at line 385 of file User.php.

References $code, $dbr, newFromId(), and wfGetDB().

Referenced by EmailConfirmation::attemptConfirm(), and EmailInvalidation::attemptInvalidate().

static User::newFromId ( id  )  [static]

Static factory method for creation from a given user ID.

Parameters:
$id Valid user ID
Returns:
{User} The corresponding User object

Definition at line 368 of file User.php.

References $u.

Referenced by LogPage::addEntry(), RdfMetaData::basics(), userOptions::CHANGER(), SpecialContributions::contributionsSub(), createNew(), Credits::getAuthor(), UsersPager::getGroups(), newFromConfirmationCode(), EnotifNotifyJob::run(), showEmailUser(), and userOptions::USAGER().

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.

Parameters:
$name Username, validated by Title::newFromText()
$validate Validate username. Takes the same parameters as User::getCanonicalName(), except that true is accepted as an alias for 'valid', for BC.
Returns:
{User} The User object, or null if the username is invalid. If the username is not present in the database, the result will be a user object with a name, zero user ID and default settings.

Definition at line 346 of file User.php.

References $name, $u, and getCanonicalName().

Referenced by EmailNotification::actuallyNotifyOnPageChange(), LoginForm::addNewAccountInternal(), SpecialResetpass::attemptReset(), LoginForm::authenticateUserData(), ChangePassword::ChangePassword(), deleteDefaultMessages(), IPBlockForm::doMassUserBlock(), Article::editUpdates(), UserrightsPage::fetchUser(), CoreParserFunctions::gender(), DoubleRedirectJob::getUser(), WikiRevision::importOldRevision(), initialiseUser(), LoginForm::mailPassword(), EmailUserForm::newFromURL(), Article::onArticleDelete(), EnotifNotifyJob::run(), RecentChange::save(), IPBlockForm::showForm(), IPUnblockForm::showList(), EmailUserForm::validateEmailTarget(), and wfSpecialBlockme().

static User::newFromRow ( row  )  [static]

Create a new user object from a user row.

The row should have all fields from the user table in it.

Parameters:
$row array A row from the user table
Returns:
{User}

Definition at line 416 of file User.php.

References $row, and $user.

Referenced by ApiQueryUsers::execute(), and UserArrayFromResult::setCurrent().

static User::newFromSession (  )  [static]

Create a new user object using data from session or cookies.

If the login credentials are invalid, the result is an anonymous user.

Returns:
{User}

Definition at line 404 of file User.php.

References $user.

Referenced by StubUser::_newObject().

static User::newTouchedTimestamp (  )  [static, private]

Generate a current or new-future timestamp to be stored in the user_touched field when we update things.

Returns:
String : Timestamp in TS_MW format

Definition at line 1625 of file User.php.

References $wgClockSkewFudge, and wfTimestamp().

Referenced by invalidateCache(), and saveSettings().

static User::oldCrypt ( password,
userId 
) [static]

Make an old-style password hash.

Parameters:
$password  String : Plain-text password
$userId  String : User ID
Returns:
String : Password hash

Definition at line 3302 of file User.php.

References $password, and $wgPasswordSalt.

Referenced by comparePasswords(), and wfEncryptPassword().

User::pingLimiter ( action = 'edit'  ) 

Primitive rate limits: enforce maximum actions per time period to put a brake on flooding.

Note:
When using a shared cache like memcached, IP-address last-hit counters will be shared across wikis.
Parameters:
$action  String : Action to enforce; 'edit' if unspecified
Returns:
Boolean : True if a rate limiter was tripped

Definition at line 1191 of file User.php.

References $action, $count, $key, $keys, $result, $summary, $wgMemc, $wgRateLimitLog, $wgRateLimits, getGroups(), getId(), getName(), isNewbie(), isPingLimitable(), wfDebug(), wfGetIP(), wfMemcKey(), wfProfileIn(), wfProfileOut(), wfRunHooks(), wfTimestamp(), and wfWikiID().

static User::randomPassword (  )  [static]

Return a random password.

Sourced from mt_rand, so it's not particularly secure.

Todo:
hash random numbers to improve security, like generateToken()
Returns:
String : New random password

Definition at line 741 of file User.php.

References $i, and $wgMinimalPasswordLength.

User::removeGroup ( group  ) 

Remove the user from the given group.

This takes immediate effect.

Parameters:
$group  String : Name of the group to remove

Definition at line 2065 of file User.php.

References $dbw, getEffectiveGroups(), getGroupPermissions(), invalidateCache(), load(), loadGroups(), and wfGetDB().

User::removeWatch ( title  ) 

Stop watching an article.

Parameters:
$title {Title} Title of the article to look at

Definition at line 2195 of file User.php.

References $title, WatchedItem::fromUserTitle(), and invalidateCache().

User::restoreOptions (  ) 

Reset all options to the site defaults.

Definition at line 1947 of file User.php.

References getDefaultOptions().

User::saveSettings (  ) 

Save this user's settings into the database.

Todo:
Only rarely do all these fields need to be set!

Definition at line 2409 of file User.php.

References $dbw, clearSharedCache(), encodeOptions(), getUserPage(), load(), newTouchedTimestamp(), wfGetDB(), wfReadOnly(), and wfRunHooks().

Referenced by sendConfirmationMail().

User::saveToCache (  ) 

Save user data to the shared cache.

Definition at line 310 of file User.php.

References $key, $name, $wgMemc, isAnon(), load(), loadGroups(), and wfMemcKey().

Referenced by loadFromId().

User::sendConfirmationMail (  ) 

Generate a new e-mail confirmation token and send a confirmation/invalidation mail to the user's given address.

Returns:
Boolean : or WikiError : : True on success, a WikiError object on failure.

Definition at line 2834 of file User.php.

References $url, $wgLang, confirmationToken(), confirmationTokenUrl(), getName(), invalidationTokenUrl(), saveSettings(), sendMail(), wfGetIP(), and wfMsg().

User::sendMail ( subject,
body,
from = null,
replyto = null 
)

Send an e-mail to this user's account.

Does not check for confirmed status or validity.

Parameters:
$subject  String : Message subject
$body  String : Message body
$from  String : Optional From address; if unspecified, default $wgPasswordSender will be used
$replyto  String : Reply-To address
Returns:
Boolean : or WikiError : : True on success, a WikiError object on failure

Definition at line 2861 of file User.php.

References $wgPasswordSender, and UserMailer::send().

Referenced by sendConfirmationMail().

User::setCookie ( name,
value,
exp = 0 
) [protected]

Set a cookie on the user's client.

Wrapper for WebResponse::setCookie

Parameters:
$name  String : Name of the cookie to set
$value  String : Value to set
$exp  Integer : Expiration time, as a UNIX time value; if 0 or not specified, use the default $wgCookieExpiration

Definition at line 2330 of file User.php.

References $name, and $wgRequest.

Referenced by clearCookie(), doLogout(), and setCookies().

User::setCookiePassword ( str  ) 

Set the cookie password.

Parameters:
$str  String : New cookie password
Access:
private

Definition at line 1778 of file User.php.

References load().

User::setCookies (  ) 

Set the default cookies for this session on the user's client.

Definition at line 2346 of file User.php.

References $name, $session, clearCookie(), getName(), getOption(), load(), setCookie(), and wfRunHooks().

User::setEmail ( str  ) 

Set the user's e-mail address.

Parameters:
$str  String : New e-mail address

Definition at line 1836 of file User.php.

References load(), and wfRunHooks().

User::setEmailAuthenticationTimestamp ( timestamp  ) 

Set the e-mail authentication timestamp.

Parameters:
$timestamp  String : TS_MW timestamp

Definition at line 2965 of file User.php.

References load(), and wfRunHooks().

Referenced by confirmEmail(), and invalidateEmail().

User::setId ( v  ) 

Set the user and reload all fields according to a given ID.

Parameters:
$v  Integer : User ID to reload

Definition at line 1419 of file User.php.

References clearInstanceCache().

User::setInternalPassword ( str  ) 

Set the password and reset the random token unconditionally.

Parameters:
$str  String : New password to set

Definition at line 1725 of file User.php.

References crypt(), load(), and setToken().

Referenced by setPassword().

User::setLoaded ( loaded  ) 

Deprecated:

Definition at line 2630 of file User.php.

References wfDeprecated().

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.

Note:
User::newFromName() has rougly the same function, when the named user does not exist.
Parameters:
$str  String : New user name to set

Definition at line 1455 of file User.php.

References load().

User::setNewpassword ( str,
throttle = true 
)

Set the password for a password reminder or new account email.

Parameters:
$str  String : New password to set
$throttle  Boolean : If true, reset the throttle timestamp to the present

Definition at line 1789 of file User.php.

References crypt(), load(), and wfTimestampNow().

User::setNewtalk ( val  ) 

Update the 'You have new messages!' status.

Parameters:
$val  Boolean : Whether the user has new messages

Definition at line 1586 of file User.php.

References $changed, $key, $wgMemc, deleteNewtalk(), getId(), getName(), invalidateCache(), isAnon(), load(), updateNewtalk(), wfMemcKey(), and wfReadOnly().

Referenced by clearAllNotifications(), and clearNotification().

User::setOption ( oname,
val 
)

Set the given option for a user.

Parameters:
$oname  String : The option to set
$val  Mixed : New value to set

Definition at line 1920 of file User.php.

References $wgDefaultUserOptions, getDefaultOptions(), and load().

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.

Parameters:
$str  String : New password to set
Exceptions:
PasswordError on failure

Definition at line 1696 of file User.php.

References $wgAuth, $wgMinimalPasswordLength, isValidPassword(), setInternalPassword(), wfMsg(), and wfMsgExt().

User::setRealName ( str  ) 

Set the user's real name.

Parameters:
$str  String : New real name

Definition at line 1855 of file User.php.

References load().

User::setToken ( token = false  ) 

Set the random token (used for persistent authentication) Called from loadDefaults() among other places.

Parameters:
$token  String : If specified, set the token to this value
Access:
private

Definition at line 1755 of file User.php.

References $key, $wgProxyKey, $wgSecretKey, load(), and wfWikiID().

Referenced by loadDefaults(), and setInternalPassword().

User::SetupSession (  ) 

Deprecated:
Use wfSetupSession().

Definition at line 796 of file User.php.

References wfDeprecated(), and wfSetupSession().

User::spreadBlock (  ) 

If this (non-anonymous) user is blocked, block any IP address they've successfully logged in from.

Definition at line 2539 of file User.php.

References load(), Block::newFromDB(), and wfDebug().

Referenced by getBlockedStatus().

User::updateNewtalk ( field,
id 
)

Add or update the new messages flag.

Parameters:
$field  String : 'user_ip' for anonymous users, 'user_id' otherwise
$id  String : or Integer : : User's IP address for anonymous users, User ID otherwise
Returns:
Boolean : True if successful, false otherwise
Access:
private

Definition at line 1546 of file User.php.

References $dbw, wfDebug(), and wfGetDB().

Referenced by setNewtalk().

User::useNPPatrol (  ) 

Check whether to enable new pages patrol features for this user.

Returns:
Boolean : True or false

Definition at line 2141 of file User.php.

References $wgUseNPPatrol, $wgUseRCPatrol, and isAllowed().

User::User (  ) 

Lightweight constructor for an anonymous user.

Use the User::newFrom* factory functions for other kinds of users.

See also:
newFromName()

newFromId()

newFromConfirmationCode()

newFromSession()

newFromRow()

Definition at line 227 of file User.php.

References clearInstanceCache().

User::useRCPatrol (  ) 

Check whether to enable recent changes patrol features for this user.

Returns:
Boolean : True or false

Definition at line 2132 of file User.php.

References $wgUseRCPatrol, and isAllowed().

User::validateCache ( timestamp  ) 

Validate the cache for this account.

Parameters:
$timestamp  String : A timestamp in TS_MW format

Definition at line 1669 of file User.php.

References load().

static User::whoIs ( id  )  [static]

Get the username corresponding to a given user ID.

Parameters:
$id User ID
Returns:
The corresponding username

Definition at line 430 of file User.php.

References $dbr, and wfGetDB().

Referenced by OutputPage::blockedPage(), UserrightsPage::fetchUser(), ApiQueryUserInfo::getCurrentUserInfo(), Title::getUserPermissionsErrors(), Title::getUserPermissionsErrorsInternal(), LoginForm::userBlockedMessage(), and Block::validateBlockParams().

static User::whoIsReal ( id  )  [static]

Get the real name of a user given their user ID.

Parameters:
$id User ID
Returns:
The corresponding user's real name

Definition at line 441 of file User.php.

References $dbr, and wfGetDB().


Member Data Documentation

User::$mAllRights = false [static]

String : Cached results of getAllRights()

Definition at line 185 of file User.php.

User::$mAuthLoaded

Definition at line 197 of file User.php.

User::$mBlock

Definition at line 212 of file User.php.

User::$mBlockedby

Definition at line 212 of file User.php.

User::$mBlockedGlobally

Definition at line 212 of file User.php.

User::$mBlockreason

Definition at line 212 of file User.php.

User::$mCacheVars [static]

Initial value:

 array(
                
                'mId',
                'mName',
                'mRealName',
                'mPassword',
                'mNewpassword',
                'mNewpassTime',
                'mEmail',
                'mOptions',
                'mTouched',
                'mToken',
                'mEmailAuthenticated',
                'mEmailToken',
                'mEmailTokenExpires',
                'mRegistration',
                'mEditCount',
                
                'mGroups',
        )
{ String :} : 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.

Definition at line 103 of file User.php.

User::$mCoreRights [static]

Initial value:

 array(
                'apihighlimits',
                'autoconfirmed',
                'autopatrol',
                'bigdelete',
                'block',
                'blockemail',
                'bot',
                'browsearchive',
                'createaccount',
                'createpage',
                'createtalk',
                'delete',
                'deletedhistory',
                'deleterevision',
                'edit',
                'editinterface',
                'editusercssjs',
                'hideuser',
                'import',
                'importupload',
                'ipblock-exempt',
                'markbotedits',
                'minoredit',
                'move',
                'movefile',
                'move-rootuserpages',
                'move-subpages',
                'nominornewtalk',
                'noratelimit',
                'override-export-depth',
                'patrol',
                'protect',
                'proxyunbannable',
                'purge',
                'read',
                'reupload',
                'reupload-shared',
                'rollback',
                'siteadmin',
                'suppressionlog',
                'suppressredirect',
                'suppressrevision',
                'trackback',
                'undelete',
                'unwatchedpages',
                'upload',
                'upload_by_url',
                'userrights',
                'userrights-interwiki',
                'writeapi',
        )
{ String :} : Core rights.

Each of these should have a corresponding message of the form "right-$right".

Definition at line 130 of file User.php.

User::$mDataLoaded

Boolean : Whether the cache variables have been loaded.

Definition at line 197 of file User.php.

User::$mDatePreference

Definition at line 212 of file User.php.

User::$mEffectiveGroups

Definition at line 212 of file User.php.

User::$mEmail

Definition at line 189 of file User.php.

User::$mEmailAuthenticated

Definition at line 189 of file User.php.

User::$mEmailToken

Definition at line 189 of file User.php.

User::$mEmailTokenExpires

Definition at line 189 of file User.php.

User::$mFrom

String : Initialization data source if mDataLoaded==false.

May be one of:

  • 'defaults' anonymous user initialised from class defaults
  • 'name' initialise from mName
  • 'id' initialise from mId
  • 'session' log in from cookies or session if possible

Use the User::newFrom*() family of functions to set this.

Definition at line 208 of file User.php.

User::$mGroups

Definition at line 189 of file User.php.

User::$mHash

Definition at line 212 of file User.php.

User::$mHideName

Definition at line 212 of file User.php.

User::$mId

Definition at line 189 of file User.php.

User::$mLocked

Definition at line 212 of file User.php.

User::$mName

Definition at line 189 of file User.php.

User::$mNewpassTime

Definition at line 189 of file User.php.

User::$mNewpassword

Definition at line 189 of file User.php.

User::$mNewtalk

Definition at line 212 of file User.php.

User::$mOptions

Definition at line 189 of file User.php.

User::$mPassword

Definition at line 189 of file User.php.

User::$mRealName

Definition at line 189 of file User.php.

User::$mRegistration

Definition at line 189 of file User.php.

User::$mRights

Definition at line 212 of file User.php.

User::$mSkin

Definition at line 212 of file User.php.

User::$mToggles [static]

Initial value:

 array(
                'highlightbroken',
                'justify',
                'hideminor',
                'extendwatchlist',
                'usenewrc',
                'numberheadings',
                'showtoolbar',
                'editondblclick',
                'editsection',
                'editsectiononrightclick',
                'showtoc',
                'rememberpassword',
                'editwidth',
                'watchcreations',
                'watchdefault',
                'watchmoves',
                'watchdeletion',
                'minordefault',
                'previewontop',
                'previewonfirst',
                'nocache',
                'enotifwatchlistpages',
                'enotifusertalkpages',
                'enotifminoredits',
                'enotifrevealaddr',
                'shownumberswatching',
                'fancysig',
                'externaleditor',
                'externaldiff',
                'showjumplinks',
                'uselivepreview',
                'forceeditsummary',
                'watchlisthideminor',
                'watchlisthidebots',
                'watchlisthideown',
                'watchlisthideanons',
                'watchlisthideliu',
                'ccmeonemails',
                'diffonly',
                'showhiddencats',
                'noconvertlink',
                'norollbackdiff',
        )
{ String :} : A list of default user toggles, i.e., boolean user preferences that are displayed by Special:Preferences as checkboxes.

This list can be extended via the UserToggles hook or by $wgContLang::getExtraUserToggles().

Definition at line 52 of file User.php.

User::$mToken

Definition at line 189 of file User.php.

User::$mTouched

Definition at line 189 of file User.php.


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

Generated on Sat Sep 5 02:08:49 2009 for MediaWiki by  doxygen 1.5.9