PHP Class Elgg\Database\UsersTable

Since: 1.10.0
Show file Open project: elgg/elgg

Protected Properties

Property Type Description
$config Elgg\Config
$db Elgg\Database
$entities EntityTable
$entity_cache Elgg\Cache\EntityCache
$events Elgg\EventsService
$table string

Public Methods

Method Description
__construct ( Config $config, Database $db, EntityTable $entities, EntityCache $cache, EventsService $events ) Constructor
ban ( integer $user_guid, string $reason = "" ) : boolean Ban a user (calls events, stores the reason)
disableEntities ( integer $owner_guid ) : boolean Disables all of a user's entities
findActive ( array $options = [] ) : ElggUser[] | integer Return users (or the number of them) who have been active within a recent period.
generateInviteCode ( string $username ) : string Generates a unique invite code for a user
getByEmail ( string $email ) : array Get an array of users from an email address
getByUsername ( string $username ) : ElggUse\ElggUser | false Get user by username
getRow ( integer $guid ) : mixed Return the user specific details of a user by a row.
getValidationStatus ( integer $user_guid ) : boolean | null Gets the validation status of a user.
makeAdmin ( integer $user_guid ) : boolean Makes user $guid an admin.
markBanned ( integer $guid, boolean $banned ) : integer Mark a user entity banned or unbanned.
register ( string $username, string $password, string $name, string $email, boolean $allow_multiple_emails = false ) : integer | false Registers a user, returning false if the username already exists
removeAdmin ( integer $user_guid ) : boolean Removes user $guid's admin flag.
setLastAction ( ElggUse\ElggUser $user ) : void Sets the last action time of the given user to right now.
setLastLogin ( ElggUse\ElggUser $user ) : void Sets the last logon time of the given user to right now.
setValidationStatus ( integer $user_guid, boolean $status, string $method = '' ) : boolean Set the validation status for a user.
unban ( integer $user_guid ) : boolean Unban a user (calls events, removes the reason)
validateInviteCode ( string $username, string $code ) : boolean Validate a user's invite code

Method Details

__construct() public method

Constructor
public __construct ( Config $config, Database $db, EntityTable $entities, EntityCache $cache, EventsService $events )
$config Elgg\Config Config
$db Elgg\Database Database
$entities EntityTable Entity table
$cache Elgg\Cache\EntityCache Entity cache
$events Elgg\EventsService Event service

ban() public method

Ban a user (calls events, stores the reason)
public ban ( integer $user_guid, string $reason = "" ) : boolean
$user_guid integer The user guid
$reason string A reason
return boolean

disableEntities() public method

Disables all of a user's entities
Deprecation: 2.3
public disableEntities ( integer $owner_guid ) : boolean
$owner_guid integer The owner GUID
return boolean Depending on success

findActive() public method

Return users (or the number of them) who have been active within a recent period.
public findActive ( array $options = [] ) : ElggUser[] | integer
$options array Array of options with keys: seconds (int) => Length of period (default 600 = 10min) limit (int) => Limit (default 10) offset (int) => Offset (default 0) count (bool) => Return a count instead of users? (default false)
return ElggUser[] | integer

generateInviteCode() public method

Generates a unique invite code for a user
See also: validateInviteCode
public generateInviteCode ( string $username ) : string
$username string The username of the user sending the invitation
return string Invite code

getByEmail() public method

Get an array of users from an email address
public getByEmail ( string $email ) : array
$email string Email address
return array

getByUsername() public method

Get user by username
public getByUsername ( string $username ) : ElggUse\ElggUser | false
$username string The user's username
return ElggUse\ElggUser | false Depending on success

getRow() public method

Return the user specific details of a user by a row.
public getRow ( integer $guid ) : mixed
$guid integer The \ElggUser guid
return mixed

getValidationStatus() public method

Gets the validation status of a user.
public getValidationStatus ( integer $user_guid ) : boolean | null
$user_guid integer The user's GUID
return boolean | null Null means status was not set for this user.

makeAdmin() public method

Makes user $guid an admin.
public makeAdmin ( integer $user_guid ) : boolean
$user_guid integer User guid
return boolean

markBanned() public method

Mark a user entity banned or unbanned.
public markBanned ( integer $guid, boolean $banned ) : integer
$guid integer User GUID
$banned boolean Mark the user banned?
return integer Num rows affected

register() public method

Registers a user, returning false if the username already exists
public register ( string $username, string $password, string $name, string $email, boolean $allow_multiple_emails = false ) : integer | false
$username string The username of the new user
$password string The password
$name string The user's display name
$email string The user's email address
$allow_multiple_emails boolean Allow the same email address to be registered multiple times?
return integer | false The new user's GUID; false on failure

removeAdmin() public method

Removes user $guid's admin flag.
public removeAdmin ( integer $user_guid ) : boolean
$user_guid integer User GUID
return boolean

setLastAction() public method

Sets the last action time of the given user to right now.
See also: _elgg_session_boot The session boot calls this at the beginning of every request
public setLastAction ( ElggUse\ElggUser $user ) : void
$user ElggUse\ElggUser User entity
return void

setLastLogin() public method

Sets the last logon time of the given user to right now.
public setLastLogin ( ElggUse\ElggUser $user ) : void
$user ElggUse\ElggUser User entity
return void

setValidationStatus() public method

Set the validation status for a user.
public setValidationStatus ( integer $user_guid, boolean $status, string $method = '' ) : boolean
$user_guid integer The user's GUID
$status boolean Validated (true) or unvalidated (false)
$method string Optional method to say how a user was validated
return boolean

unban() public method

Unban a user (calls events, removes the reason)
public unban ( integer $user_guid ) : boolean
$user_guid integer Unban a user
return boolean

validateInviteCode() public method

Validate a user's invite code
See also: generateInviteCode
public validateInviteCode ( string $username, string $code ) : boolean
$username string The username
$code string The invite code
return boolean

Property Details

$config protected property

protected Config,Elgg $config
return Elgg\Config

$db protected property

protected Database,Elgg $db
return Elgg\Database

$entities protected property

protected EntityTable,Elgg\Database $entities
return EntityTable

$entity_cache protected property

protected EntityCache,Elgg\Cache $entity_cache
return Elgg\Cache\EntityCache

$events protected property

protected EventsService,Elgg $events
return Elgg\EventsService

$table protected property

protected string $table
return string