class User extends JObject

User class. Handles all application interaction with a user

Properties

integer $id Unique id
string $name The user's real name (or nickname)
string $username The login name
string $email The email
string $password MD5 encrypted password
string $password_clear Clear password, only available when a new password is set for a user
integer $block Block status
integer $sendEmail Should this user receive system email
DateTime $registerDate Date the user was registered
DateTime $lastvisitDate Date of last visit
string $activation Activation hash
Registry $params User parameters
array $groups Associative array of user names => group ids
integer $guest Guest status
string $lastResetTime Last Reset Time
int $resetCount Count since last Reset Time
int $requireReset Flag to require the user's password be reset

Methods

__construct( integer $identifier, UserWrapper $userHelper = null)

Constructor activating the default information of the language

static  User
getInstance( integer $identifier, UserWrapper $userHelper = null)

Returns the global User object, only creating it if it doesn't already exist.

mixed
getParam( string $key, mixed $default = null)

Method to get a parameter value

mixed
setParam( string $key, mixed $value)

Method to set a parameter

mixed
defParam( string $key, mixed $value)

Method to set a default parameter if it does not exist

boolean
authorise( string $action, string $assetname = null)

Method to check User object authorisation against an access control object and optionally an access extension object

array
getAuthorisedCategories( string $component, string $action)

Method to return a list of all categories that a user has permission for a given action

array
getAuthorisedViewLevels()

Gets an array of the authorised access levels for the user

array
getAuthorisedGroups()

Gets an array of the authorised user groups

void
clearAccessRights()

Clears the access rights cache of this user

boolean
setLastVisit( integer $timestamp = null)

Pass through method to the table for setting the last visit date

object
getParameters()

Method to get the user parameters

getTimezone()

Method to get the user timezone.

void
setParameters( object $params)

Method to get the user parameters

static  object
getTable( string $type = null, string $prefix = 'JTable')

Method to get the user table object

boolean
bind( array $array)

Method to bind an associative array of data to a user object

boolean
save( boolean $updateOnly = false)

Method to save the User object to the database

boolean
delete()

Method to delete the User object from the database

boolean
load( mixed $id)

Method to load a User object by user id number

array
__sleep()

Method to allow serialize the object with minimal properties.

void
__wakeup()

Method to recover the full object on unserialize.

Details

__construct( integer $identifier, UserWrapper $userHelper = null)

Constructor activating the default information of the language

Parameters

integer $identifier The primary key of the user to load (optional).
UserWrapper $userHelper The UserWrapper for the static methods. [@deprecated 4.0]

static User getInstance( integer $identifier, UserWrapper $userHelper = null)

Returns the global User object, only creating it if it doesn't already exist.

Parameters

integer $identifier The primary key of the user to load (optional).
UserWrapper $userHelper The UserWrapper for the static methods. [@deprecated 4.0]

Return Value

User The User object.

mixed getParam( string $key, mixed $default = null)

Method to get a parameter value

Parameters

string $key Parameter key
mixed $default Parameter default value

Return Value

mixed The value or the default if it did not exist

mixed setParam( string $key, mixed $value)

Method to set a parameter

Parameters

string $key Parameter key
mixed $value Parameter value

Return Value

mixed Set parameter value

mixed defParam( string $key, mixed $value)

Method to set a default parameter if it does not exist

Parameters

string $key Parameter key
mixed $value Parameter value

Return Value

mixed Set parameter value

boolean authorise( string $action, string $assetname = null)

Method to check User object authorisation against an access control object and optionally an access extension object

Parameters

string $action The name of the action to check for permission.
string $assetname The name of the asset on which to perform the action.

Return Value

boolean True if authorised

array getAuthorisedCategories( string $component, string $action)

Method to return a list of all categories that a user has permission for a given action

Parameters

string $component The component from which to retrieve the categories
string $action The name of the section within the component from which to retrieve the actions.

Return Value

array List of categories that this group can do this action to (empty array if none). Categories must be published.

array getAuthorisedViewLevels()

Gets an array of the authorised access levels for the user

Return Value

array

array getAuthorisedGroups()

Gets an array of the authorised user groups

Return Value

array

void clearAccessRights()

Clears the access rights cache of this user

Return Value

void

boolean setLastVisit( integer $timestamp = null)

Pass through method to the table for setting the last visit date

Parameters

integer $timestamp The timestamp, defaults to 'now'.

Return Value

boolean True on success.

object getParameters()

Method to get the user parameters

This method used to load the user parameters from a file.

Return Value

object The user parameters object.

DateTimeZone getTimezone()

Method to get the user timezone.

If the user didn't set a timezone, it will return the server timezone

Return Value

DateTimeZone

void setParameters( object $params)

Method to get the user parameters

Parameters

object $params The user parameters object

Return Value

void

static object getTable( string $type = null, string $prefix = 'JTable')

Method to get the user table object

This function uses a static variable to store the table name of the user table to instantiate. You can call this function statically to set the table name if needed.

Parameters

string $type The user table name to be used
string $prefix The user table prefix to be used

Return Value

object The user table object

boolean bind( array $array)

Method to bind an associative array of data to a user object

Parameters

array $array &$array The associative array to bind to the object

Return Value

boolean True on success

boolean save( boolean $updateOnly = false)

Method to save the User object to the database

Parameters

boolean $updateOnly Save the object only if not a new user Currently only used in the user reset password method.

Return Value

boolean True on success

Exceptions

RuntimeException

boolean delete()

Method to delete the User object from the database

Return Value

boolean True on success

boolean load( mixed $id)

Method to load a User object by user id number

Parameters

mixed $id The user id of the user to load

Return Value

boolean True on success

array __sleep()

Method to allow serialize the object with minimal properties.

Return Value

array The names of the properties to include in serialization.

void __wakeup()

Method to recover the full object on unserialize.

Return Value

void