JUser
Extends \JObjectUser 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)
since |
11.1 |
---|
Arguments
- $properties
mixed
Either 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
since |
11.1 |
---|---|
deprecated |
12.3 Classes should provide their own __toString() implementation. |
Response
string
The 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
string
The name of the action to check for permission.- $assetname
string
The name of the asset on which to perform the action.
Response
boolean
True if authorised
authorisedLevels
Gets an array of the authorised access levels for the user
authorisedLevels() : array
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 |
12.1 |
---|---|
note |
Use the authorise method instead. |
since |
11.1 |
Arguments
- $action
string
The name of the action to check for permission.- $assetname
string
The name of the asset on which to perform the action.
Response
boolean
True if authorised
bind
Method to bind an associative array of data to a user object
bind( &$array) : boolean
since |
11.1 |
---|
Arguments
- $array
Response
boolean
True on success
def
Sets a default value if not alreay assigned
def(string $property, mixed $default = null) : mixed
since |
11.1 |
---|
Arguments
- $property
string
The name of the property.- $default
mixed
The 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
string
Parameter key- $value
mixed
Parameter value
Response
mixed
Set parameter value
delete
Method to delete the JUser object from the database
delete() : boolean
since |
11.1 |
---|
Response
boolean
True 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
since |
11.1 |
---|---|
see | \JObject::getProperties() |
Arguments
- $property
string
The name of the property.- $default
mixed
The default value.
Response
mixed
The 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
string
The component from which to retrieve the categories- $action
string
The name of the section within the component from which to retrieve the actions.
Response
array
List 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
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Arguments
- $i
integer
Option error index.- $toString
boolean
Indicates if JError objects should return their error message.
Response
string
Error message
getErrors
Return all errors, if any.
getErrors() : array
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Response
array
Array of error messages or JErrors.
getInstance
Returns the global User object, only creating it if it doesn't already exist.
getInstance(integer $identifier) : \JUser
since |
11.1 |
---|
Arguments
- $identifier
integer
The user to load - Can be an integer or string - If string, it is converted to ID automatically.
Response
\JUser
The User object.
getParam
Method to get a parameter value
getParam(string $key, mixed $default = null) : mixed
since |
11.1 |
---|
Arguments
- $key
string
Parameter key- $default
mixed
Parameter default value
Response
mixed
The 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
boolean
If true, loads the parameters setup file. Default is false.- $path
\path
Set the parameters setup file base path to be used to load the user parameters.
Response
object
The user parameters object.
getProperties
Returns an associative array of object properties.
getProperties(boolean $public = true) : array
since |
11.1 |
---|---|
see | \JObject::get() |
Arguments
- $public
boolean
If true, returns only the public properties.
Response
array
getTable
Method to get the user table object
getTable(string $type = null, string $prefix = 'JTable') : 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.
since |
11.1 |
---|
Arguments
- $type
string
The user table name to be used- $prefix
string
The user table prefix to be used
Response
object
The user table object
load
Method to load a JUser object by user id number
load(mixed $id) : boolean
since |
11.1 |
---|
Arguments
- $id
mixed
The user id of the user to load
Response
boolean
True on success
save
Method to save the JUser object to the database
save(boolean $updateOnly = false) : boolean
since |
11.1 |
---|---|
throws |
|
Arguments
- $updateOnly
boolean
Save the object only if not a new user Currently only used in the user reset password method.
Response
boolean
True on success
set
Modifies a property of the object, creating it if it does not already exist.
set(string $property, mixed $value = null) : mixed
since |
11.1 |
---|
Arguments
- $property
string
The name of the property.- $value
mixed
The value of the property to set.
Response
mixed
Previous value of the property.
setError
Add an error message.
setError(string $error) : void
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Arguments
- $error
string
Error message.
setLastVisit
Pass through method to the table for setting the last visit date
setLastVisit(integer $timestamp = null) : boolean
since |
11.1 |
---|
Arguments
- $timestamp
integer
The timestamp, defaults to 'now'.
Response
boolean
True on success.
setParam
Method to set a parameter
setParam(string $key, mixed $value) : mixed
since |
11.1 |
---|
Arguments
- $key
string
Parameter key- $value
mixed
Parameter value
Response
mixed
Set parameter value
setParameters
Method to get the user parameters
setParameters(object $params) : void
since |
11.1 |
---|
Arguments
- $params
object
The user parameters object
setProperties
Set the object properties based on a named array/hash.
setProperties(mixed $properties) : boolean
since |
11.1 |
---|---|
see | \JObject::set() |
Arguments
- $properties
mixed
Either an associative array or another object.
Response
boolean
toString
Converts the object to a string (the class name).
toString() : 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
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.
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.
since |
11.3 |
---|
Type(s)
array
_errors
An array of error messages or Exception objects.