JUser

Extends \JObject

User class. Handles all application interaction with a user

This class allows for simple but smart objects with get and set methods and an internal error handler.

package

Joomla.Platform

subpackage

User

since

11.1

Methods

__construct

Class constructor, overridden in descendant classes.

__construct(mixed $properties = null) 
inherited
since

11.1

Arguments

$properties

mixedEither and associative array or another object to set the initial properties of the object.

__toString

Magic method to convert the object to a string gracefully.

__toString() : string
inherited deprecated
since

11.1

deprecated

12.3 Classes should provide their own __toString() implementation.

Response

stringThe classname.

authorise

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

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

11.1

Arguments

$action

stringThe name of the action to check for permission.

$assetname

stringThe name of the asset on which to perform the action.

Response

booleanTrue if authorised

authorisedLevels

Gets an array of the authorised access levels for the user

authorisedLevels() : array
deprecated
deprecated

12.1

note

Use the getAuthorisedViewLevels method instead.

since

11.1

Response

array

authorize

Proxy to authorise

authorize(string $action, string $assetname = null) : boolean
deprecated
deprecated

12.1

note

Use the authorise method instead.

since

11.1

Arguments

$action

stringThe name of the action to check for permission.

$assetname

stringThe name of the asset on which to perform the action.

Response

booleanTrue if authorised

bind

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

bind( &$array) : boolean
since

11.1

Arguments

$array

Response

booleanTrue on success

def

Sets a default value if not alreay assigned

def(string $property, mixed $default = null) : mixed
inherited
since

11.1

Arguments

$property

stringThe name of the property.

$default

mixedThe default value.

Response

mixed

defParam

Method to set a default parameter if it does not exist

defParam(string $key, mixed $value) : mixed
since

11.1

Arguments

$key

stringParameter key

$value

mixedParameter value

Response

mixedSet parameter value

delete

Method to delete the JUser object from the database

delete() : boolean
since

11.1

Response

booleanTrue on success

get

Returns a property of the object or the default value if the property is not set.

get(string $property, mixed $default = null) : mixed
inherited
since

11.1

see \JObject::getProperties()

Arguments

$property

stringThe name of the property.

$default

mixedThe default value.

Response

mixedThe value of the property.

getAuthorisedCategories

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

getAuthorisedCategories(string $component, string $action) : array
since

11.1

Arguments

$component

stringThe component from which to retrieve the categories

$action

stringThe name of the section within the component from which to retrieve the actions.

Response

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

getAuthorisedGroups

Gets an array of the authorised user groups

getAuthorisedGroups() : array
since

11.1

Response

array

getAuthorisedViewLevels

Gets an array of the authorised access levels for the user

getAuthorisedViewLevels() : array
since

11.1

Response

array

getError

Get the most recent error message.

getError(integer $i = null, boolean $toString = true) : string
inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Arguments

$i

integerOption error index.

$toString

booleanIndicates if JError objects should return their error message.

Response

stringError message

getErrors

Return all errors, if any.

getErrors() : array
inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Response

arrayArray of error messages or JErrors.

getInstance

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

getInstance(integer $identifier) : \JUser
static
since

11.1

Arguments

$identifier

integerThe user to load - Can be an integer or string - If string, it is converted to ID automatically.

Response

\JUserThe User object.

getParam

Method to get a parameter value

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

11.1

Arguments

$key

stringParameter key

$default

mixedParameter default value

Response

mixedThe value or the default if it did not exist

getParameters

Method to get the user parameters

getParameters(boolean $loadsetupfile = false, \path $path = null) : object

This function tries to load an XML file based on the user's usertype. The filename of the xml file is the same as the usertype. The functionals has a static variable to store the parameters setup file base path. You can call this function statically to set the base path if needed.

since

11.1

Arguments

$loadsetupfile

booleanIf true, loads the parameters setup file. Default is false.

$path

\pathSet the parameters setup file base path to be used to load the user parameters.

Response

objectThe user parameters object.

getProperties

Returns an associative array of object properties.

getProperties(boolean $public = true) : array
inherited
since

11.1

see \JObject::get()

Arguments

$public

booleanIf true, returns only the public properties.

Response

array

getTable

Method to get the user table object

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

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.

since

11.1

Arguments

$type

stringThe user table name to be used

$prefix

stringThe user table prefix to be used

Response

objectThe user table object

load

Method to load a JUser object by user id number

load(mixed $id) : boolean
since

11.1

Arguments

$id

mixedThe user id of the user to load

Response

booleanTrue on success

save

Method to save the JUser object to the database

save(boolean $updateOnly = false) : boolean
since

11.1

throws

\exception

Arguments

$updateOnly

booleanSave the object only if not a new user Currently only used in the user reset password method.

Response

booleanTrue on success

set

Modifies a property of the object, creating it if it does not already exist.

set(string $property, mixed $value = null) : mixed
inherited
since

11.1

Arguments

$property

stringThe name of the property.

$value

mixedThe value of the property to set.

Response

mixedPrevious value of the property.

setError

Add an error message.

setError(string $error) : void
inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Arguments

$error

stringError message.

setLastVisit

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

setLastVisit(integer $timestamp = null) : boolean
since

11.1

Arguments

$timestamp

integerThe timestamp, defaults to 'now'.

Response

booleanTrue on success.

setParam

Method to set a parameter

setParam(string $key, mixed $value) : mixed
since

11.1

Arguments

$key

stringParameter key

$value

mixedParameter value

Response

mixedSet parameter value

setParameters

Method to get the user parameters

setParameters(object $params) : void
since

11.1

Arguments

$params

objectThe user parameters object

setProperties

Set the object properties based on a named array/hash.

setProperties(mixed $properties) : boolean
inherited
since

11.1

see \JObject::set()

Arguments

$properties

mixedEither an associative array or another object.

Response

boolean

toString

Converts the object to a string (the class name).

toString() : string
inherited deprecated
since

11.1

deprecated

12.1 Use magic method __toString()

see \JObject::__toString()

Response

string

Properties

isRoot

A cached switch for if this user has root access rights.

since

11.1

Type(s)

boolean

id

Unique id

since

11.1

Type(s)

integer

name

The users real name (or nickname)

since

11.1

Type(s)

string

username

The login name

since

11.1

Type(s)

string

email

The email

since

11.1

Type(s)

string

password

MD5 encrypted password

since

11.1

Type(s)

string

password_clear

Clear password, only available when a new password is set for a user

since

11.1

Type(s)

string

usertype

User type Used in Joomla 1.0 and 1.5 for access control.

deprecated
deprecated

12.1

see \JUser::_authGroups \JAccess
since

11.1

Type(s)

string

block

Block status

since

11.1

Type(s)

integer

sendEmail

Should this user receive system email

since

11.1

Type(s)

integer

registerDate

Date the user was registered

since

11.1

Type(s)

\datetime

lastvisitDate

Date of last visit

since

11.1

Type(s)

\datetime

activation

Activation hash

since

11.1

Type(s)

string

params

User parameters

since

11.1

Type(s)

string

groups

Array of ids of groups that user belongs to

since

11.1

Type(s)

array

guest

Guest status

since

11.1

Type(s)

boolean

lastResetTime

Last Reset Time

since

Type(s)

string

resetCount

Count since last Reset Time

since

Type(s)

integer

_params

User parameters

since

11.1

Type(s)

object

_authGroups

Authorised access groups

since

11.1

Type(s)

array

_authLevels

Authorised access levels

since

11.1

Type(s)

array

_authActions

Authorised access actions

since

11.1

Type(s)

array

_errorMsg

Error message

since

11.1

Type(s)

string

instances

JUser instances container.

static
since

11.3

Type(s)

array

_errors

An array of error messages or Exception objects.

inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Type(s)

array