model/modx/moduser.class.php

Classes 
package
modx
Classes
modUser

Description

The core MODX user class.

\modUser

Extends from
\modPrincipal
package
modx
Properties
$sessionContexts
Methods
activatePassword
addSessionContext
changePassword
countMessages
endSession
generatePassword
generateToken
getResourceGroups
getSessionContexts
getSettings
getUserGroupNames
getUserGroups
hasSessionContext
isAuthenticated
isMember
joinGroup
leaveGroup
loadAttributes
passwordMatches
remove
removeLocks
removeSessionContext
removeSessionContextVars
removeSessionCookie
save
sendEmail
set

Description

The core MODX user class.

{@internal Implement a derivative to define the behavior and attributes of an actual user or system that is intended to access modX or a modX service.}

Properties

$sessionContexts

array $sessionContexts = 'array'

A collection of contexts which the current principal is authenticated in.

Details

array
visibility
public
default
array
final
false
static
false
access
public

Methods

activatePassword

activatePassword( string $key ) : boolean|integer

Activate a reset user password if the proper activation key is provided.

{@internal This does not mark the user active, but rather moves the cachepwd to the password field if the activation key matches.}

Arguments
$key
string
The activation key provided to the user and stored in the registry for matching.
Output
boolean|integer
True if the activation was successful, false if unsuccessful, and -1 if there is no activation to perform.
Details
visibility
public
final
false
static
false

addSessionContext

addSessionContext( string $context ) :

Adds a new context to the user session context array.

Arguments
$context
string
The context to add to the user session.
Details
visibility
public
final
false
static
false
access
public

changePassword

changePassword( string $newPassword, string $oldPassword ) : boolean

Change the user password.

Arguments
$newPassword
string
Password to set.
$oldPassword
string
Current password for validation.
Output
boolean
Indicates if password was successfully changed.
Details
visibility
public
final
false
static
false
access
public
todo
Add support for configurable password encoding.

countMessages

countMessages( mixed $read ) : integer

Gets a count of {@link modUserMessage} objects ascribed to the user.

Arguments
$read
mixed
Output
integer
The number of messages.
Details
visibility
public
final
false
static
false
access
public

endSession

endSession( ) :

Ends a user session completely, including all contexts.

Details
visibility
public
final
false
static
false
access
public

generatePassword

generatePassword( integer $length = 10 ) : string

Returns a randomly generated password

Arguments
$length
integer
The length of the password
Output
string
The newly generated password
Details
visibility
public
final
false
static
false

generateToken

generateToken(  $salt ) :
Arguments
$salt
Details
visibility
public
final
false
static
false

getResourceGroups

getResourceGroups(  $ctx ) : array

Gets all Resource Groups this user is assigned to. This may not work in the new model.

Arguments
$ctx
Output
array
An array of Resource Group names.
Details
visibility
public
final
false
static
false
access
public
deprecated
todo
refactor this to actually work.

getSessionContexts

getSessionContexts( ) : array

Returns an array of user session context keys.

Output
array
An array of session contexts.
Details
visibility
public
final
false
static
false
access
public

getSettings

getSettings( ) : array

Gets all user settings in array format.

Output
array
A key -> value array of settings.
Details
visibility
public
final
false
static
false
access
public

getUserGroupNames

getUserGroupNames( ) : array

Gets all the User Group names of the groups this user belongs to.

Output
array
An array of User Group names.
Details
visibility
public
final
false
static
false
access
public

getUserGroups

getUserGroups( ) : array

Gets all the User Group IDs of the groups this user belongs to.

Output
array
An array of User Group IDs.
Details
visibility
public
final
false
static
false
access
public

hasSessionContext

hasSessionContext( mixed $context ) : boolean

Checks if the user has a specific session context.

Arguments
$context
mixed
Either a name of a context or array of context names to check against.
Output
boolean
True if the user has the context(s) specified.
Details
visibility
public
final
false
static
false
access
public

isAuthenticated

isAuthenticated( string $sessionContext = web ) : boolean

Determines if this user is authenticated in a specific context.

Separate session contexts can allow users to login/out of specific sub-sites individually (or in collections).

Arguments
$sessionContext
string
The context to determine if the user is authenticated in.
Output
boolean
true, if the user is authenticated in the specified context, false otherwise.
Details
visibility
public
final
false
static
false
access
public

isMember

isMember( \string/array $groups, boolean $matchAll = false ) : boolean

States whether a user is a member of a group or groups. You may specify either a string name of the group, or an array of names.

Arguments
$groups
\string/array
Either a string of a group name or an array of names.
$matchAll
boolean
If true, requires the user to be a member of all the groups specified. If false, the user can be a member of only one to pass. Defaults to false.
Output
boolean
True if the user is a member of any of the groups specified.
Details
visibility
public
final
false
static
false
access
public

joinGroup

joinGroup( mixed $groupId, mixed $roleId = null ) : boolean

Join a User Group, and optionally assign a Role.

Arguments
$groupId
mixed
Either the name or ID of the User Group to join.
$roleId
mixed
Optional. Either the name or ID of the Role to assign to for the group.
Output
boolean
True if successful.
Details
visibility
public
final
false
static
false
access
public

leaveGroup

leaveGroup( mixed $groupId ) : boolean

Removes the User from the specified User Group.

Arguments
$groupId
mixed
Either the name or ID of the User Group to join.
Output
boolean
True if successful.
Details
visibility
public
final
false
static
false
access
public

loadAttributes

loadAttributes(  $target, string $context, boolean $reload = false ) :

Loads the principal attributes that define a modUser security profile.

{@inheritdoc}

Arguments
$target
$context
string
Context to check within, defaults to current context.
$reload
boolean
If true, the attributes will be reloaded and the session updated.
Details
visibility
public
final
false
static
false

passwordMatches

passwordMatches( string $password, array $options = array ) : boolean

Determines if the provided password matches the hashed password stored for the user.

Arguments
$password
string
The password to determine if it matches.
$options
array
Optional settings for the hashing process.
Output
boolean
True if the provided password matches the stored password for the user.
Details
visibility
public
final
false
static
false

remove

remove( array $ancestors = array ) : boolean

Overrides xPDOObject::remove to fire modX-specific events

{@inheritDoc}

Arguments
$ancestors
array
Keeps track of classes which have already been removed to prevent loop with circular references.
Output
boolean
Returns true on success, false on failure.
Details
visibility
public
final
false
static
false

removeLocks

removeLocks( array $options = array ) : boolean

Remove any locks held by the user.

Arguments
$options
array
An array of options for controlling removal of specific locks or lock types.
Output
boolean
True if the process was successful, or false if an error was encountered.
Details
visibility
public
final
false
static
false

removeSessionContext

removeSessionContext( string|array $context ) :

Removes a user session context.

Arguments
$context
stringarray
The context key or an array of context keys.
Details
visibility
public
final
false
static
false
access
public

removeSessionContextVars

removeSessionContextVars( string $context ) :

Removes the session vars associated with a specific context.

Arguments
$context
string
The context key.
Details
visibility
public
final
false
static
false
access
public

removeSessionCookie

removeSessionCookie( string $context ) :

Removes a session cookie for a user.

TODO Implement this.

Arguments
$context
string
The context to remove.
Details
visibility
public
final
false
static
false
access
public

save

save( boolean $cacheFlag = false ) : boolean

Overrides xPDOObject::save to fire modX-specific events

{@inheritDoc}

Arguments
$cacheFlag
boolean
Output
boolean
True if the save was successful
Details
visibility
public
final
false
static
false

sendEmail

sendEmail( string $message, array $options = array ) : boolean

Send an email to the user

Arguments
$message
string
The body of the email
$options
array
An array of options
Output
boolean
True if successful
Details
visibility
public
final
false
static
false

set

set( string $k, mixed $v = null, string $vType ) : boolean

The modUser password field is hashed automatically.

{@inheritdoc}

Arguments
$k
string
The key to set
$v
mixed
The value to set
$vType
string
The validation type to set against
Output
boolean
True if successfully set
Details
visibility
public
final
false
static
false
Documentation was generated by DocBlox 0.11.2.