Tilmeld Server API  1.0.0
Nymph user and group management with access controls.
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | List of all members
Tilmeld\Entities\User Class Reference

A user entity. More...

Inheritance diagram for Tilmeld\Entities\User:
Tilmeld\Entities\AbleObject

Public Member Functions

 __construct ($id=0)
 Load a user. More...
 
__get ($name)
 Override the magic method, for email usernames. More...
 
 __isset ($name)
 Override the magic method, for email usernames. More...
 
 __set ($name, $value)
 Override the magic method, for email usernames. More...
 
 __unset ($name)
 Override the magic method, for email usernames. More...
 
 login ($data)
 
 logout ()
 Log a user out of the system. More...
 
 getAvatar ()
 
 getDescendantGroups ()
 Get the user's group descendants.
 
 getTimezone ($returnDateTimeZoneObject=false)
 Return the user's timezone. More...
 
 putData ($data, $sdata=[])
 
 updateDataProtection ($user=null)
 Update the data protection arrays for a user. More...
 
 gatekeeper ($ability=null)
 Check to see if a user has an ability. More...
 
 clearCache ()
 
 sendEmailVerification ()
 Send the user email verification/change/cancellation links. More...
 
 addGroup ($group)
 Add the user to a (secondary) group. More...
 
 checkPassword ($password)
 Check the given password against the user's. More...
 
 delGroup ($group)
 Remove the user from a (secondary) group. More...
 
 inGroup ($group=null)
 Check whether the user is in a (primary or secondary) group. More...
 
 isDescendant ($group=null)
 Check whether the user is a descendant of a group. More...
 
 changePassword ($data)
 A frontend accessible method to change the user's password. More...
 
 password ($password)
 Change the user's password. More...
 
 checkUsername ()
 Check that a username is valid. More...
 
 checkEmail ()
 Check that an email is unique. More...
 
 checkPhone ()
 Check that a phone number is unique. More...
 
 register ($data)
 
 save ()
 
 saveSkipAC ()
 This should never be accessible on the client.
 
 tilmeldSaveSkipAC ()
 
 delete ()
 
- Public Member Functions inherited from Tilmeld\Entities\AbleObject
 grant ($ability)
 Grant an ability. More...
 
 revoke ($ability)
 Revoke an ability. More...
 

Static Public Member Functions

static current ($returnObjectIfNotExist=false)
 
static sendRecoveryLink ($data)
 Send an account recovery link. More...
 
static recover ($data)
 Recover account details. More...
 
static getClientConfig ()
 
static generateSecret ($user)
 
static loginUser ($data)
 

Public Attributes

const ETYPE = 'tilmeld_user'
 
const DEFAULT_CLIENT_ENABLED_METHODS
 
const DEFAULT_PRIVATE_DATA
 
const DEFAULT_WHITELIST_DATA = []
 

Static Public Attributes

static $clientEnabledStaticMethods
 
static $searchRestrictedData = User::DEFAULT_PRIVATE_DATA
 

Protected Attributes

 $tags = []
 
 $clientEnabledMethods = User::DEFAULT_CLIENT_ENABLED_METHODS
 
 $privateData = User::DEFAULT_PRIVATE_DATA
 
 $whitelistData = User::DEFAULT_WHITELIST_DATA
 
 $whitelistTags = []
 

Detailed Description

A user entity.

Properties:

Author
Hunter Perrin hperr.nosp@m.in@g.nosp@m.mail..nosp@m.com
See also
http://tilmeld.org/

Definition at line 59 of file User.php.

Constructor & Destructor Documentation

◆ __construct()

Tilmeld\Entities\User::__construct (   $id = 0)

Load a user.

Parameters
int | string$idThe ID or username of the user to load, 0 for a new user.

Definition at line 142 of file User.php.

Member Function Documentation

◆ __get()

& Tilmeld\Entities\User::__get (   $name)

Override the magic method, for email usernames.

Parameters
string$nameThe name of the variable.
Returns
mixed The value of the variable or nothing if it doesn't exist.

Definition at line 193 of file User.php.

◆ __isset()

Tilmeld\Entities\User::__isset (   $name)

Override the magic method, for email usernames.

Parameters
string$nameThe name of the variable.
Returns
bool

Definition at line 209 of file User.php.

◆ __set()

Tilmeld\Entities\User::__set (   $name,
  $value 
)

Override the magic method, for email usernames.

Parameters
string$nameThe name of the variable.
string$valueThe value of the variable.
Returns
mixed The value of the variable.

Definition at line 223 of file User.php.

◆ __unset()

Tilmeld\Entities\User::__unset (   $name)

Override the magic method, for email usernames.

Parameters
string$nameThe name of the variable.

Definition at line 239 of file User.php.

◆ addGroup()

Tilmeld\Entities\User::addGroup (   $group)

Add the user to a (secondary) group.

Parameters
\Tilmeld\Entities\Group$groupThe group.
Returns
mixed True if the user is already in the group. The resulting array of groups if the user was not.

Definition at line 808 of file User.php.

◆ changePassword()

Tilmeld\Entities\User::changePassword (   $data)

A frontend accessible method to change the user's password.

Returns
array An associative array with a boolean 'result' entry and a 'message' entry.

Definition at line 900 of file User.php.

◆ checkEmail()

Tilmeld\Entities\User::checkEmail ( )

Check that an email is unique.

Returns
array An associative array with a boolean 'result' entry and a 'message' entry.

Definition at line 1022 of file User.php.

◆ checkPassword()

Tilmeld\Entities\User::checkPassword (   $password)

Check the given password against the user's.

Parameters
string$passwordThe password in question.
Returns
bool True if the passwords match, otherwise false.

Definition at line 822 of file User.php.

◆ checkPhone()

Tilmeld\Entities\User::checkPhone ( )

Check that a phone number is unique.

Returns
array An associative array with a boolean 'result' entry and a 'message' entry.

Definition at line 1073 of file User.php.

◆ checkUsername()

Tilmeld\Entities\User::checkUsername ( )

Check that a username is valid.

Returns
array An associative array with a boolean 'result' entry and a 'message' entry.

Definition at line 942 of file User.php.

◆ delGroup()

Tilmeld\Entities\User::delGroup (   $group)

Remove the user from a (secondary) group.

Parameters
\Tilmeld\Entities\Group$groupThe group.
Returns
mixed True if the user wasn't in the group. The resulting array of groups if the user was.

Definition at line 841 of file User.php.

◆ gatekeeper()

Tilmeld\Entities\User::gatekeeper (   $ability = null)

Check to see if a user has an ability.

This function will check both user and group abilities, if the user is marked to inherit the abilities of its group.

If $ability is null, it will check to see if the user is currently logged in.

If the user has the "system/admin" ability, this function will return true.

Parameters
string$abilityThe ability.
Returns
bool True or false.

Definition at line 663 of file User.php.

◆ getTimezone()

Tilmeld\Entities\User::getTimezone (   $returnDateTimeZoneObject = false)

Return the user's timezone.

First checks if the user has a timezone set, then the primary group, then the secondary groups, then the system default. The first timezone found is returned.

Parameters
bool$returnDateTimeZoneObjectWhether to return an object of the DateTimeZone class, instead of an identifier string.
Returns
string|DateTimeZone The timezone identifier or the DateTimeZone object.

Definition at line 544 of file User.php.

◆ inGroup()

Tilmeld\Entities\User::inGroup (   $group = null)

Check whether the user is in a (primary or secondary) group.

Parameters
mixed$groupThe group, or the group's GUID.
Returns
bool True or false.

Definition at line 859 of file User.php.

◆ isDescendant()

Tilmeld\Entities\User::isDescendant (   $group = null)

Check whether the user is a descendant of a group.

Parameters
mixed$groupThe group, or the group's GUID.
Returns
bool True or false.

Definition at line 875 of file User.php.

◆ logout()

Tilmeld\Entities\User::logout ( )

Log a user out of the system.

Returns
array An associative array with a boolean 'result' entry and a 'message' entry.

Definition at line 493 of file User.php.

◆ password()

Tilmeld\Entities\User::password (   $password)

Change the user's password.

Parameters
string$passwordThe new password.
Returns
string The resulting SHA-256 sum which is stored in the entity.

Definition at line 921 of file User.php.

◆ recover()

static Tilmeld\Entities\User::recover (   $data)
static

Recover account details.

Returns
array An associative array with a boolean 'result' entry and a 'message' entry.

Definition at line 388 of file User.php.

◆ sendEmailVerification()

Tilmeld\Entities\User::sendEmailVerification ( )

Send the user email verification/change/cancellation links.

Returns
bool True on success, false on failure.

Definition at line 705 of file User.php.

◆ sendRecoveryLink()

static Tilmeld\Entities\User::sendRecoveryLink (   $data)
static

Send an account recovery link.

Returns
array An associative array with a boolean 'result' entry and a 'message' entry.

Definition at line 263 of file User.php.

◆ updateDataProtection()

Tilmeld\Entities\User::updateDataProtection (   $user = null)

Update the data protection arrays for a user.

Parameters
\Tilmeld\Entities\User | null$userUser to update protection for. If null, will use the currently logged in user.

Definition at line 576 of file User.php.

Member Data Documentation

◆ $clientEnabledStaticMethods

Tilmeld\Entities\User::$clientEnabledStaticMethods
static
Initial value:
= [
'current',
'loginUser',
'sendRecoveryLink',
'recover',
'getClientConfig',
]

Definition at line 97 of file User.php.

◆ DEFAULT_CLIENT_ENABLED_METHODS

const Tilmeld\Entities\User::DEFAULT_CLIENT_ENABLED_METHODS
Initial value:
= [
'checkUsername',
'checkEmail',
'checkPhone',
'getAvatar',
'register',
]

Definition at line 61 of file User.php.

◆ DEFAULT_PRIVATE_DATA

const Tilmeld\Entities\User::DEFAULT_PRIVATE_DATA
Initial value:
= [
'email',
'originalEmail',
'phone',
'addressType',
'addressStreet',
'addressStreet2',
'addressCity',
'addressState',
'addressZip',
'addressInternational',
'group',
'groups',
'abilities',
'inheritAbilities',
'timezone',
'recoverSecret',
'recoverSecretTime',
'password',
'passwordTemp',
'salt',
'secret',
'cancelEmailAddress',
'cancelEmailSecret',
'emailChangeDate',
]

Definition at line 68 of file User.php.


The documentation for this class was generated from the following file: