User
extends User_Profile
in package
User Object
The User object is used for all user related operations.
Tags
Table of Contents
Properties
- $arrAttributeHistories : mixed
- $arrNoAvatar : array<string|int, mixed>
- $arrNoPicture : mixed
- $arrUpdatedAttributeHistories : mixed
- $EOF : mixed
- $error_msg : string
- Contains the message if an error occurs
- $objAttribute : User_Profile_Attribute
- $arrCachedUsers : array<string|int, mixed>
- Array that holds all users which were ever loaded
- $arrLoadedUsers : array<string|int, mixed>
- Array which holds all loaded users for later usage
- $auth_token : string
- Token used for auto login
- $auth_token_timeout : int
- Timeout used for auto login
- $defaultHashAlgorithm : string
- Contains the default hash algorithm to be used for password generation
- $id : int
- ID of loaded user
- $password : string
- Password of user
- $verified : bool
- verification status of user
- $arrAttributes : mixed
- $arrGroups : array<string|int, mixed>
- Contains an array of all group IDS which the user is associated to
- $arrNewsletterListIDs : array<string|int, mixed>
- Contains an array of all newsletter-list-IDs of which the user has a subscription of
- $arrPrivacyAccessTypes : mixed
- $backend_language : int
- Language ID used for the backend
- $defaultEmailAccessType : mixed
- $defaultProfileAccessTyp : mixed
- $email : string
- E-Mail address of user
- $email_access : bool
- Determines who is allowed to see the user's e-mail address
- $expiration : int
- Expiration date of the account (timestamp)
- $filtered_search_count : int
- Contains the number of currently loaded users
- $frontend_language : int
- Language ID used for the frontend
- $is_active : bool
- Active status of user
- $is_admin : bool
- Administrator status
- $lang_id : int
- Language ID of user
- $last_activity : int
- The last time that the user was active (timestamp)
- $last_auth : int
- The last time the user had logged in (timestamp)
- $loggedIn : bool
- TRUE if user is authenticated
- $primary_group : int
- The ID of a user group that should be used as the primary one
- $profile_access : string
- Determines who is allowed to see the user's profile data.
- $regdate : int
- Registration date of user (timestamp)
- $restore_key : string
- Key which will be used to reset the password
- $restore_key_time : int
- Date as timestamp when a new password was requested
- $username : string
- Username of user
- $validity : int
- Validity time period
Methods
- __clone() : mixed
- __construct() : mixed
- auth() : bool
- Authenticate user against username and password
- authByToken() : mixed
- checkAuthToken() : mixed
- checkLoginData() : mixed
- Checks username, password and captcha.
- checkMandatoryCompliance() : mixed
- checkPassword() : bool
- Returns TRUE if the given password matches the current user, FALSE otherwise.
- clearCache() : mixed
- Clears the cache
- delete() : bool
- Delete the current loaded user account
- finishSignUp() : mixed
- first() : mixed
- Load first user
- forceDefaultEmailAccess() : mixed
- forceDefaultProfileAccess() : mixed
- generateAuthToken() : mixed
- getActiveStatus() : mixed
- getAdminStatus() : mixed
- getAssociatedGroupIds() : array<string|int, mixed>
- Returns an array containing the ids of the user's associated groups
- getBackendLanguage() : mixed
- getCrmUserId() : int|null
- Checks whether the user account is connected with a crm customer
- getDynamicPermissionIds() : mixed
- getEmail() : mixed
- getEmailAccess() : mixed
- getErrorMsg() : mixed
- getExpirationDate() : mixed
- getFilteredSearchUserCount() : mixed
- getFrontendLanguage() : mixed
- getHashedPassword() : string
- Returns the hash of the newly set password of the user account if it has been changed.
- getId() : mixed
- getLastActivityTime() : mixed
- getLastAuthenticationTime() : mixed
- getPrimaryGroupId() : mixed
- getPrimaryGroupName() : mixed
- getPrivacyAccessMenu() : mixed
- getProfileAccess() : mixed
- getProfileAttribute() : mixed
- getRealUsername() : mixed
- getRegistrationDate() : mixed
- getRestoreKey() : mixed
- getRestoreKeyTime() : mixed
- getStaticPermissionIds() : mixed
- getSubscribedNewsletterListIDs() : array<string|int, mixed>
- Returns an array of all newsletter-list-IDs the user did subscribe to
- getTimezone() : DateTimeZone
- Returns this user's timezone
- getUser() : mixed
- Fetch instance of User specified by ID $id.
- getUsername() : mixed
- getUsernameOrEmail() : mixed
- getUsers() : User
- Returns a User object according to the given criteria
- getValidityTimePeriod() : mixed
- hasBackendAccess() : bool
- Tells whether this user has access to the backend
- hashPassword() : string
- Generate hash of password with default hash algorithm
- hasModeAccess() : bool
- Tells whether this user has access to back- or frontend
- isAllowedToChangeEmailAccess() : mixed
- isAllowedToChangeProfileAccess() : mixed
- isAllowedToDeleteAccount() : mixed
- isLoggedIn() : bool
- Returns true if the User is logged in
- isUniqueEmail() : bool
- Returns true if $email is a unique e-mail address in the system
- isValidPassword() : bool
- Returns true if the given $password is valid
- isValidUsername() : bool
- Returns true if the given $username is valid
- isVerified() : mixed
- login() : bool
- This will check if there is an active session present for the current requester and if the requester has successfully been authenticated. If so, then the associated user object will be loaded into this user instance and {@see static::$loggedIn} will be set to `true`.
- make_password() : string
- Return a valid password
- make_username() : string
- Tries to form a valid and unique username from the words given
- next() : mixed
- Load next user
- registerFailedLogin() : mixed
- Register a failed login.
- registerSuccessfulLogin() : mixed
- Register a successful login.
- releaseRestoreKey() : mixed
- reset() : mixed
- set_active() : void
- Set the active status of one or more Users
- setActiveStatus() : void
- Set active status of user
- setAdminStatus() : bool
- Set administration status of user
- setAuthToken() : mixed
- setBackendLanguage() : void
- Set backend language ID of user
- setEmail() : bool
- Sets email address of user
- setEmailAccess() : mixed
- setExpirationDate() : mixed
- setFrontendLanguage() : void
- Set frontend language ID of user
- setGroups() : void
- Set ID's of groups to which this user should belong to
- setHashedPassword() : mixed
- Set new password as hash of password
- setPassword() : bool
- Sets password of user
- setPrimaryGroup() : void
- Set the Id of a user group that should be used as the user's primary group
- setProfile() : mixed
- setProfileAccess() : mixed
- setRestoreKey() : mixed
- Set the restore-key
- setRestoreKeyTime() : mixed
- Set the restore-key validity timeout
- setSubscribedNewsletterListIDs() : void
- Set ID's of newsletter-list the which the user subscribed to
- setUsername() : bool
- Sets username of user
- setValidityTimePeriod() : bool
- Sets the validity period of the account
- setVerification() : bool
- Set verification status of user
- signUp() : mixed
- store() : bool
- Store user account
- toArray() : mixed
- Get object data as array
- validateEmail() : bool
- Returns true if this Users' e-mail address is valid and unique.
- validateUsername() : bool
- Returns true if the User name is valid and unique
- createProfile() : bool
- Create a profile for the loaded user
- createUser() : mixed
- fetchPasswordHashFromDatabase() : string
- Fetch the password hash of the currently loaded user from the database
- isUniqueUsername() : bool
- Returns true if $username is a unique user name
- loadCustomAttributeProfileData() : bool
- Load custom attribute profile data
- loadUsers() : mixed
- parseAttributeSearchConditions() : array<string|int, mixed>
- Enter description here... Matches single (scalar) or multiple (array) search terms against a number of fields. Generally, the term(s) are enclosed in percent signs ("%term%"), so any fields that contain them will match.
- parseCoreAttributeFilterConditions() : array<string|int, mixed>
- Parse core attribute filter conditions
- parseCustomAttributeFilterConditions() : array<string|int, mixed>
- Parse custom attribute filter conditions
- parseFilterConditions() : array<string|int, mixed>
- Parse and translate an array of filter rules into SQL statements to be used for filtering users.
- randomChar() : string
- Return a random character picked from the given string
- sendUserAccountInvitationMail() : mixed
- Send a invitation mail to the created user.
- storeProfile() : mixed
- updateLoadedUserData() : mixed
- Update a specific profile attribute of the user
- updatePasswordHash() : mixed
- Verify that the password is properly hashed
- updateUser() : mixed
- clean() : mixed
- Clean user metadata
- getFilteredUserIdList() : mixed
- isLastAdmin() : bool
- Returns true if the current User has the only active admin account present in the system.
- load() : bool
- Load user data
- loadGroups() : mixed
- Load group ID's of user
- loadPermissionIds() : mixed
- loadSubscribedNewsletterListIDs() : mixed
- parseAccountFilterConditions() : array<string|int, mixed>
- Parse account filter conditions
- parseAccountSearchConditions() : array<string|int, mixed>
- Creates the SQL query snippet to match username (and e-mail in the backend) fields against the search term(s)
- removeOutdatedAccounts() : mixed
- setSortedUserIdList() : mixed
- storeGroupAssociations() : bool
- Store group associations
- storeNewsletterSubscriptions() : bool
- Store the user's newsletter-list-subscriptions to the database
- updateLastActivityTime() : mixed
- updateLastAuthTime() : mixed
- validateLanguageId() : mixed
- Validate language id
Properties
$arrAttributeHistories
public
mixed
$arrAttributeHistories
$arrNoAvatar
public
static array<string|int, mixed>
$arrNoAvatar
= array('src' => '0_noavatar.gif', 'width' => 121, 'height' => 160)
Tags
$arrNoPicture
public
static mixed
$arrNoPicture
= array('src' => '0_no_picture.gif', 'width' => 80, 'height' => 84)
$arrUpdatedAttributeHistories
public
mixed
$arrUpdatedAttributeHistories
$EOF
public
mixed
$EOF
Tags
$error_msg
Contains the message if an error occurs
public
string
$error_msg
= array()
$objAttribute
public
User_Profile_Attribute
$objAttribute
$arrCachedUsers
Array that holds all users which were ever loaded
protected
array<string|int, mixed>
$arrCachedUsers
= array()
Tags
$arrLoadedUsers
Array which holds all loaded users for later usage
protected
array<string|int, mixed>
$arrLoadedUsers
= array()
Tags
$auth_token
Token used for auto login
protected
string
$auth_token
$auth_token_timeout
Timeout used for auto login
protected
int
$auth_token_timeout
$defaultHashAlgorithm
Contains the default hash algorithm to be used for password generation
protected
string
$defaultHashAlgorithm
$id
ID of loaded user
protected
int
$id
Tags
$password
Password of user
protected
string
$password
Tags
$verified
verification status of user
protected
bool
$verified
$arrAttributes
private
mixed
$arrAttributes
= array('id' => 'int', 'is_admin' => 'int', 'username' => 'string', 'regdate' => 'int', 'expiration' => 'int', 'validity' => 'int', 'last_auth' => 'int', 'last_activity' => 'int', 'primary_group' => 'int', 'email' => 'string', 'email_access' => 'string', 'frontend_lang_id' => 'int', 'backend_lang_id' => 'int', 'active' => 'int', 'verified' => 'int', 'profile_access' => 'string', 'restore_key' => 'string', 'restore_key_time' => 'int')
Tags
$arrGroups
Contains an array of all group IDS which the user is associated to
private
array<string|int, mixed>
$arrGroups
Tags
$arrNewsletterListIDs
Contains an array of all newsletter-list-IDs of which the user has a subscription of
private
array<string|int, mixed>
$arrNewsletterListIDs
= array()
Tags
$arrPrivacyAccessTypes
private
mixed
$arrPrivacyAccessTypes
= array('everyone' => array('email' => 'TXT_ACCESS_EVERYONE_ALLOWED_SEEING_EMAIL', 'profile' => 'TXT_ACCESS_EVERYONE_ALLOWED_SEEING_PROFILE'), 'members_only' => array('email' => 'TXT_ACCESS_MEMBERS_ONLY_ALLOWED_SEEING_EMAIL', 'profile' => 'TXT_ACCESS_MEMBERS_ONLY_ALLOWED_SEEING_PROFILE'), 'nobody' => array('email' => 'TXT_ACCESS_NOBODY_ALLOWED_SEEING_EMAIL', 'profile' => 'TXT_ACCESS_NOBODY_ALLOWED_SEEING_PROFILE'))
Tags
$backend_language
Language ID used for the backend
private
int
$backend_language
Tags
$defaultEmailAccessType
private
mixed
$defaultEmailAccessType
Tags
$defaultProfileAccessTyp
private
mixed
$defaultProfileAccessTyp
Tags
E-Mail address of user
private
string
$email
Tags
$email_access
Determines who is allowed to see the user's e-mail address
private
bool
$email_access
Tags
$expiration
Expiration date of the account (timestamp)
private
int
$expiration
Tags
$filtered_search_count
Contains the number of currently loaded users
private
int
$filtered_search_count
= 0
Tags
$frontend_language
Language ID used for the frontend
private
int
$frontend_language
Tags
$is_active
Active status of user
private
bool
$is_active
Tags
$is_admin
Administrator status
private
bool
$is_admin
Tags
$lang_id
Language ID of user
private
int
$lang_id
Tags
$last_activity
The last time that the user was active (timestamp)
private
int
$last_activity
Tags
$last_auth
The last time the user had logged in (timestamp)
private
int
$last_auth
Tags
$loggedIn
TRUE if user is authenticated
private
bool
$loggedIn
If this is TRUE the methods and will be looked for further usage.
Tags
$primary_group
The ID of a user group that should be used as the primary one
private
int
$primary_group
Tags
$profile_access
Determines who is allowed to see the user's profile data.
private
string
$profile_access
Tags
$regdate
Registration date of user (timestamp)
private
int
$regdate
Tags
$restore_key
Key which will be used to reset the password
private
string
$restore_key
Tags
$restore_key_time
Date as timestamp when a new password was requested
private
int
$restore_key_time
Tags
$username
Username of user
private
string
$username
Tags
$validity
Validity time period
private
int
$validity
This integer represents the expiration of the user. A user won't be able to authenticate again after his validity time period has exceeded. A validity time period of zero mean that the account has no expiration date.
Tags
Methods
__clone()
public
__clone() : mixed
Attributes
- #[ReturnTypeWillChange]
__construct()
public
__construct() : mixed
auth()
Authenticate user against username and password
public
auth(string $username, string $password[, bool $backend = false ][, mixed $captchaCheckResult = false ]) : bool
Verifies the password of a username within the database. If the password matches the appropriate users gets loaded and the users last authentication time gets updated. Returns TRUE on success or FALSE on failure.
Parameters
- $username : string
-
The username
- $password : string
-
The raw password
- $backend : bool = false
-
Tries to authenticate for the backend if true, false otherwise
- $captchaCheckResult : mixed = false
Return values
bool —True on success, false otherwise
authByToken()
public
authByToken(mixed $userId, mixed $authToken[, mixed $backend = false ]) : mixed
Parameters
- $userId : mixed
- $authToken : mixed
- $backend : mixed = false
checkAuthToken()
public
checkAuthToken(mixed $userId, mixed $authToken) : mixed
Parameters
- $userId : mixed
- $authToken : mixed
checkLoginData()
Checks username, password and captcha.
public
checkLoginData(string $username, string $password[, bool $captchaCheckResult = false ]) : mixed
Parameters
- $username : string
- $password : string
- $captchaCheckResult : bool = false
Return values
mixed —false or user id
checkMandatoryCompliance()
public
checkMandatoryCompliance() : mixed
checkPassword()
Returns TRUE if the given password matches the current user, FALSE otherwise.
public
checkPassword(string $password[, string $passwordHash = '' ]) : bool
Parameters
- $password : string
-
Raw password to be verified
- $passwordHash : string = ''
-
The hash of the password to verify the supplied password with. If not supplied, it will be fetched from the database.
Return values
boolclearCache()
Clears the cache
public
clearCache() : mixed
Only use this when loading lots of users (export)!
delete()
Delete the current loaded user account
public
delete([bool $deleteOwnAccount = false ]) : bool
In the case that the current loaded user is the last available administrator in the system, then the request will be refused and FALSE will be returned instead. A user isn't able to delete its own account with which he is actually authenticated at the moment unless the parameter $deleteOwnAccount is set to TRUE. Returns TRUE on success or FALSE on failure.
Parameters
- $deleteOwnAccount : bool = false
Tags
Return values
boolfinishSignUp()
public
finishSignUp() : mixed
first()
Load first user
public
first() : mixed
forceDefaultEmailAccess()
public
static forceDefaultEmailAccess() : mixed
forceDefaultProfileAccess()
public
static forceDefaultProfileAccess() : mixed
generateAuthToken()
public
generateAuthToken() : mixed
getActiveStatus()
public
getActiveStatus() : mixed
getAdminStatus()
public
getAdminStatus() : mixed
getAssociatedGroupIds()
Returns an array containing the ids of the user's associated groups
public
getAssociatedGroupIds([bool $activeOnly = false ]) : array<string|int, mixed>
Parameters
- $activeOnly : bool = false
-
Wether to load only the active groups or all
Return values
array<string|int, mixed>getBackendLanguage()
public
getBackendLanguage() : mixed
getCrmUserId()
Checks whether the user account is connected with a crm customer
public
getCrmUserId() : int|null
Return values
int|null —id of crm user if the user is associated with a customer of crm module
getDynamicPermissionIds()
public
getDynamicPermissionIds([mixed $reload = false ]) : mixed
Parameters
- $reload : mixed = false
getEmail()
public
getEmail() : mixed
getEmailAccess()
public
getEmailAccess() : mixed
getErrorMsg()
public
getErrorMsg() : mixed
getExpirationDate()
public
getExpirationDate() : mixed
getFilteredSearchUserCount()
public
getFilteredSearchUserCount() : mixed
getFrontendLanguage()
public
getFrontendLanguage() : mixed
getHashedPassword()
Returns the hash of the newly set password of the user account if it has been changed.
public
getHashedPassword() : string
This method only returns the password (its hash) of the user account in case it has been changed using User::setPassword(). This method's purpose is to have the newly set password (its hash) available in the model events through it.
Return values
string —The newly set password of the user account
getId()
public
getId() : mixed
getLastActivityTime()
public
getLastActivityTime() : mixed
getLastAuthenticationTime()
public
getLastAuthenticationTime() : mixed
getPrimaryGroupId()
public
getPrimaryGroupId() : mixed
getPrimaryGroupName()
public
getPrimaryGroupName() : mixed
getPrivacyAccessMenu()
public
getPrivacyAccessMenu(mixed $attrs, mixed $option) : mixed
Parameters
- $attrs : mixed
- $option : mixed
getProfileAccess()
public
getProfileAccess() : mixed
getProfileAttribute()
public
getProfileAttribute(mixed $attributeId[, mixed $historyId = 0 ]) : mixed
Parameters
- $attributeId : mixed
- $historyId : mixed = 0
getRealUsername()
public
getRealUsername() : mixed
getRegistrationDate()
public
getRegistrationDate() : mixed
getRestoreKey()
public
getRestoreKey() : mixed
getRestoreKeyTime()
public
getRestoreKeyTime() : mixed
getStaticPermissionIds()
public
getStaticPermissionIds([mixed $reload = false ]) : mixed
Parameters
- $reload : mixed = false
getSubscribedNewsletterListIDs()
Returns an array of all newsletter-list-IDs the user did subscribe to
public
getSubscribedNewsletterListIDs() : array<string|int, mixed>
Return values
array<string|int, mixed> —Newsletter-list-IDs
getTimezone()
Returns this user's timezone
public
getTimezone() : DateTimeZone
Tags
Return values
DateTimeZone —User's timezone
getUser()
Fetch instance of User specified by ID $id.
public
getUser(int|array<string|int, mixed> $id[, bool $forceReload = false ]) : mixed
Parameters
- $id : int|array<string|int, mixed>
-
The ID of the user to fetch. Alternatively, $id may be an array of filter criteria defined by \User::getUsers($filter). If this matches multiple users, then the first user matching the filter criteria will be returned.
- $forceReload : bool = false
-
Set to TRUE to refetch the user from the database. Otherwise, the user will be loaded from cache, in case it has been loaded before. Defaults to FALSE.
Return values
mixed —Instance of \User if successful. Otherwise FALSE.
getUsername()
public
getUsername() : mixed
getUsernameOrEmail()
public
getUsernameOrEmail() : mixed
Tags
getUsers()
Returns a User object according to the given criteria
public
getUsers([mixed $filter = null ][, string $search = null ][, array<string|int, mixed> $arrSort = null ][, array<string|int, mixed> $arrAttributes = null ][, int $limit = null ][, int $offset = 0 ]) : User
Parameters
- $filter : mixed = null
-
An integer or array defining a filter to apply on the lookup. $filter can be an integer, where its value is treated as the ID of a user account. This will cause the method to return the user account specified by that ID. Addtitionally, $filter can be an array specifing a complex set of filter conditions. Each key-value pair represents a user-account's attribute and its filter condition to apply to. Depending on the attribute's type, the filter condition must be either an integer or a string. It is also possible to define a complex filter condition. This is done by defining an array containing a list of conditions to apply to. Each key-value pair represents the condition operator and the condition expression of the condition. Allowed condition operators are for user-account attributes of type Integer: =, <, > and for attributes of type String: !=, <, >, REGEXP
Fetch user with ID 3
$objUser = \User::getUsers(3);
Fetch all users who's firstname contains the string 'nicole'
$filter = array( 'firstname' => '%nicole%', ); $objUser = \User::getUsers($filter);
Fetch all users whose lastname starts with one of the following letters (case insensitive): a, b, c, e
$filter = array( 'lastname' => array( 'a%', 'b%', 'c%', 'e%', ) ); $objUser = \User::getUsers($filter);
This does the same as the preview example but is written in a different notation
$filter = array( 'lastname' => array( array( '>' => 'a', '<' => 'e%' '!=' => 'd%' ), 'LIKE' => 'e%' ) ); $objUser = \User::getUsers($filter);
Fetch all active users that have been signed in within the last hour
$filter = array( 'is_active' => 1, 'last_auth' => array( '>' => time()-3600 ) ); $objUser = \User::getUsers($filter);
Fetch all active users named 'John Doe' or 'Max Muster'
$filter = array( 'AND' => array( 0 => array( 'active' => true, ), 1 => array( 'OR' => array( 0 => array( 'AND' => array( 0 => array( 'firstname' => 'John', ), 1 => array( 'lastname' => 'Doe', ), ), ), 1 => array( 'AND' => array( 0 => array( 'firstname' => 'Max', ), 1 => array( 'lastname' => 'Muster', ), ), ), ), ), ), ); $objUser = \User::getUsers($filter);
- $search : string = null
-
The optional parameter $search can be used to do a fulltext search on the user accounts. $search is an array whereas its key-value pairs represent a user-account's attribute and its search pattern to apply to. If multiple search conditions are set, only one of the search conditions must match on a user to get included in the result.
Fetch users that contain the literal nicole in their firstname or smith in their lastname
array( 'firstname' => 'nicole', 'lastname' => 'smith', ); $objUser = \User::getUsers(null, $search);
- $arrSort : array<string|int, mixed> = null
-
Normally, the users are ordered by their ID. Optionally the order can be specified by an array. Whereas each key-value pair represents the user-account's attribute and its order direction (asc/desc) to order the result by.
Order the users first by their active-status and then by their firstname
$arrSort = array( 'is_active' => 'desc', 'firstname' => 'asc', ); $objUser = \User::getUsers(null, null, $arrSort);
- $arrAttributes : array<string|int, mixed> = null
-
Normally, all user-account data is loaded from the database. The optional parameter $arrAttributes can be used to limit the data that is loaded from the database by explicitly specifying which user-account attributes should be loaded from the database. $arrAttributes is an array containing a list of user-account attributes to be loaded.
Load all user-account data (default)
$objUser = \User::getUsers();
Load only user-account data firstname and lastname from database
$arrAttributes = array('firstname', 'lastname') $objUser = \User::getUsers(null, null, null, $arrAttributes);
- $limit : int = null
-
The maximal number of Users to load from the database. If not set, all matched users will be loaded.
- $offset : int = 0
-
The optional parameter $offset can be used to specify the number of found records to skip in the result set. Note that this parameter only works if the limit is set!
Return values
UsergetValidityTimePeriod()
public
getValidityTimePeriod() : mixed
hasBackendAccess()
Tells whether this user has access to the backend
public
hasBackendAccess() : bool
Tags
Return values
bool —True if user has access to backend
hashPassword()
Generate hash of password with default hash algorithm
public
hashPassword(string $password) : string
Parameters
- $password : string
-
Password to be hashed
Tags
Return values
string —The generated hash of the supplied password
hasModeAccess()
Tells whether this user has access to back- or frontend
public
hasModeAccess([bool $backend = false ]) : bool
Parameters
- $backend : bool = false
-
True for backend access check, defaults to false
Tags
Return values
bool —Whether this user has access to the given mode
isAllowedToChangeEmailAccess()
public
isAllowedToChangeEmailAccess() : mixed
isAllowedToChangeProfileAccess()
public
isAllowedToChangeProfileAccess() : mixed
isAllowedToDeleteAccount()
public
isAllowedToDeleteAccount() : mixed
isLoggedIn()
Returns true if the User is logged in
public
isLoggedIn() : bool
Return values
bool —True if the User is logged in, false otherwise
isUniqueEmail()
Returns true if $email is a unique e-mail address in the system
public
static isUniqueEmail(string $email[, int $id = 0 ]) : bool
Parameters
- $email : string
- $id : int = 0
Tags
Return values
boolisValidPassword()
Returns true if the given $password is valid
public
static isValidPassword(string $password) : bool
Parameters
- $password : string
Return values
boolisValidUsername()
Returns true if the given $username is valid
public
static isValidUsername(string $username) : bool
Parameters
- $username : string
Tags
Return values
boolisVerified()
public
isVerified() : mixed
login()
This will check if there is an active session present for the current requester and if the requester has successfully been authenticated. If so, then the associated user object will be loaded into this user instance and {@see static::$loggedIn} will be set to `true`.
public
login([bool $backend = false ]) : bool
Parameters
- $backend : bool = false
-
Set to
true
to constrain the login to backend access. Meaning that users without permission to access the backend will not succeed to login.
Tags
Return values
bool —true
if the current requester is successfully authenticated
and authorized to access the requested mode (set through $backend
).
Otherwise false
.
make_password()
Return a valid password
public
static make_password([int $length = 8 ][, bool $use_special = false ]) : string
Generated passwords consist of
- at least one lower case letter [qwertzupasdfghjkyxcvbnm],
- at least one upper case letter [QWERTZUPASDFGHJKLYXCVBNM],
- at least one digit [23456789], and
- if required, at least one special character [-+_!?%&]. If $length is less than 6, the length will be 6 characters. If $length is greater than 64, the length will be 64 characters. Returns the empty string if isValidPassword() doesn't accept the result, in order to avoid endless loops. Fix the parameters if that occurs.
Parameters
- $length : int = 8
-
Desired password length. Defaults to 8
- $use_special : bool = false
-
Require at least one special character if true. Defaults to false
Return values
string —The new password
make_username()
Tries to form a valid and unique username from the words given
public
static make_username(mixed $word1, mixed $word2) : string
Usually, you would use first and last names as parameters.
Parameters
- $word1 : mixed
- $word2 : mixed
Return values
string —The new user name on success, false otherwise
next()
Load next user
public
next() : mixed
registerFailedLogin()
Register a failed login.
public
static registerFailedLogin(string $username) : mixed
This causes that the user needs to fill out the captcha the next time he logs on.
Parameters
- $username : string
Tags
registerSuccessfulLogin()
Register a successful login.
public
registerSuccessfulLogin() : mixed
Tags
releaseRestoreKey()
public
releaseRestoreKey() : mixed
reset()
public
reset() : mixed
set_active()
Set the active status of one or more Users
public
static set_active(mixed $mix_user_id, bool $active) : void
The $mix_user_id parameter may either be a user ID or an array thereof. Sets appropriate messages.
Parameters
- $mix_user_id : mixed
-
The User ID or an array of those
- $active : bool
-
Activate (true) or deactivate (false) the User(s).
setActiveStatus()
Set active status of user
public
setActiveStatus(bool $status) : void
This will set the attribute is_active of this object either to TRUE or FALSE, depending of $status.
Parameters
- $status : bool
setAdminStatus()
Set administration status of user
public
setAdminStatus(bool $status[, bool $force = false ]) : bool
This will set the attribute is_admin of this object to $status. If $status is FALSE then it will only be accepted if this object isn't the only administrator.
Parameters
- $status : bool
- $force : bool = false
Tags
Return values
boolsetAuthToken()
public
setAuthToken(mixed $authToken) : mixed
Parameters
- $authToken : mixed
setBackendLanguage()
Set backend language ID of user
public
setBackendLanguage(int $langId) : void
This will set the attribute backend_lang_id of this object to $langId.
Parameters
- $langId : int
setEmail()
Sets email address of user
public
setEmail(string $email) : bool
This will set the attribute email of this object to $email if the parameter $email is valid and isn't yet used by an other user.
Parameters
- $email : string
Return values
boolsetEmailAccess()
public
setEmailAccess(mixed $emailAccess) : mixed
Parameters
- $emailAccess : mixed
setExpirationDate()
public
setExpirationDate(mixed $expiration) : mixed
Parameters
- $expiration : mixed
setFrontendLanguage()
Set frontend language ID of user
public
setFrontendLanguage(int $langId) : void
This will set the attribute frontend_lang_id of this object to $langId.
Parameters
- $langId : int
setGroups()
Set ID's of groups to which this user should belong to
public
setGroups(array<string|int, mixed> $arrGroups) : void
Parameters
- $arrGroups : array<string|int, mixed>
-
List of group IDs
Tags
setHashedPassword()
Set new password as hash of password
public
setHashedPassword(string $hashedPassword) : mixed
Parameters
- $hashedPassword : string
-
The hash of the new password to be set
setPassword()
Sets password of user
public
setPassword(string $password[, string $confirmedPassword = null ][, bool $reset = false ][, bool $verify = true ]) : bool
This will set the attribute password of this object to the hash of $password if $password is a valid password and if it was confirmed by the second parameter $confirmedPassword.
Parameters
- $password : string
-
The new password
- $confirmedPassword : string = null
-
The new password, again
- $reset : bool = false
- $verify : bool = true
-
Whether or not to verify if $password is a valid password according to the set password complexity rules.
Tags
Return values
bool —True on success, false otherwise
setPrimaryGroup()
Set the Id of a user group that should be used as the user's primary group
public
setPrimaryGroup(int $groupId) : void
Parameters
- $groupId : int
setProfile()
public
setProfile(mixed $arrProfile[, mixed $ignoreAccessPermissions = false ]) : mixed
Parameters
- $arrProfile : mixed
- $ignoreAccessPermissions : mixed = false
setProfileAccess()
public
setProfileAccess(mixed $profileAccess) : mixed
Parameters
- $profileAccess : mixed
setRestoreKey()
Set the restore-key
public
setRestoreKey([string $restoreKey = null ]) : mixed
The restore-key is used to reset the password or used for the user verification process.
Parameters
- $restoreKey : string = null
-
The restore-key to set. Must be a MD5-hash. If left empty, a new restore-key will be generated.
setRestoreKeyTime()
Set the restore-key validity timeout
public
setRestoreKeyTime(int $seconds[, bool $absolute = false ]) : mixed
Parameters
- $seconds : int
-
Timeout specified in seconds.
- $absolute : bool = false
-
If set to TRUE, the argument $seconds will be interpreted as timestamp instead. Defaults to FALSE.
setSubscribedNewsletterListIDs()
Set ID's of newsletter-list the which the user subscribed to
public
setSubscribedNewsletterListIDs(array<string|int, mixed> $arrNewsletterListIDs) : void
Parameters
- $arrNewsletterListIDs : array<string|int, mixed>
setUsername()
Sets username of user
public
setUsername(string $username) : bool
This will set the attribute username of this object to $username if the parameter $username is valid and isn't yet used by an other user.
Parameters
- $username : string
Return values
boolsetValidityTimePeriod()
Sets the validity period of the account
public
setValidityTimePeriod(mixed $validity) : bool
Administrators cannot be restricted in their validity. Returns TRUE.
Parameters
- $validity : mixed
Return values
boolsetVerification()
Set verification status of user
public
setVerification(bool $verified) : bool
This will set the attribute verified of this object either to TRUE or FALSE, depending of $verified.
Parameters
- $verified : bool
Return values
bool —TRUE
signUp()
public
signUp() : mixed
store()
Store user account
public
store() : bool
This stores the metadata of the user, which includes the username, password, email, language ID, activ status and the administration status, to the database. If it is a new user, it also sets the registration time to the current time.
Tags
Return values
booltoArray()
Get object data as array
public
toArray() : mixed
validateEmail()
Returns true if this Users' e-mail address is valid and unique.
public
validateEmail() : bool
Otherwise, adds appropriate error messages, and returns false. Required to be public by the Shop!
Return values
bool —True for valid and unique e-mail addresses, false otherwise
validateUsername()
Returns true if the User name is valid and unique
public
validateUsername() : bool
Tags
Return values
bool —True if the User name is valid and unique, false otherwise
createProfile()
Create a profile for the loaded user
protected
createProfile() : bool
This creates an entry in the dabase table contrexx_access_user_profile which is related to the entry in the table cotnrexx_access_users of the same user. This methode will be obsolete as soon as we're using InnoDB as storage engine.
Return values
boolcreateUser()
protected
createUser() : mixed
fetchPasswordHashFromDatabase()
Fetch the password hash of the currently loaded user from the database
protected
fetchPasswordHashFromDatabase() : string
Return values
string —Password hash of currently loaded user.
isUniqueUsername()
Returns true if $username is a unique user name
protected
static isUniqueUsername(string $username[, int $id = 0 ]) : bool
Returns false if the test for uniqueness fails, or if the $username exists already. If non-empty, the given User ID is excluded from the search, so the User does not match herself.
Parameters
- $username : string
-
The username to test
- $id : int = 0
-
The optional current User ID
Tags
Return values
bool —True if the username is available, false otherwise
loadCustomAttributeProfileData()
Load custom attribute profile data
protected
loadCustomAttributeProfileData([array<string|int, mixed> $arrAttributes = array() ]) : bool
Gets the data of the custom profile attributes from the database an puts it into the class variables $this->arrLoadedUsers and $this->arrCachedUsers. On the other hand it fills the class variables $this->arrAttributeHistories and $this->arrUpdataedAttributeHistories with the history IDs of each attribute. Returns FALSE if a database error had occurred, otherwise TRUE.
Parameters
- $arrAttributes : array<string|int, mixed> = array()
Return values
boolloadUsers()
protected
loadUsers([mixed $filter = null ][, mixed $search = null ][, mixed $arrSort = null ][, mixed $arrAttributes = null ][, mixed $limit = null ][, mixed $offset = 0 ]) : mixed
Parameters
- $filter : mixed = null
- $search : mixed = null
- $arrSort : mixed = null
- $arrAttributes : mixed = null
- $limit : mixed = null
- $offset : mixed = 0
parseAttributeSearchConditions()
Enter description here... Matches single (scalar) or multiple (array) search terms against a number of fields. Generally, the term(s) are enclosed in percent signs ("%term%"), so any fields that contain them will match.
protected
parseAttributeSearchConditions(mixed $search[, unknown_type $core = false ][, unknown_type $attributeId = 0 ]) : array<string|int, mixed>
However, if the search parameter is a string and does contain a percent sign already, none will be added to the query. This allows searches using custom patterns, like "fields beginning with "a" ("a%"). (You might even want to extend this to work with arrays, too. Currently, only the shop module uses this feature.) -- RK 20100910
Parameters
- $search : mixed
-
The term or array of terms
- $core : unknown_type = false
- $attributeId : unknown_type = 0
Return values
array<string|int, mixed> —The array of SQL snippets
parseCoreAttributeFilterConditions()
Parse core attribute filter conditions
protected
parseCoreAttributeFilterConditions(array<string|int, mixed> $arrFilter) : array<string|int, mixed>
Generate conditions of the core attributes for the SQL WHERE statement. The filter conditions are defined through the two dimensional array $arrFilter. Each key-value pair represents an attribute and its associated condition to which it must fit to. The condition could either be a integer or string depending on the attributes type, or it could be a collection of integers or strings represented in an array.
Parameters
- $arrFilter : array<string|int, mixed>
Return values
array<string|int, mixed>parseCustomAttributeFilterConditions()
Parse custom attribute filter conditions
protected
parseCustomAttributeFilterConditions(mixed $arrFilter[, string $forceTableIdx = null ][, bool $uniqueJoins = true ][, int &$joinIdx = 0 ]) : array<string|int, mixed>
Generate conditions of the custom attributes for the SQL WHERE statement. The filter conditions are defined through the two dimensional array $arrFilter. Each key-value pair represents an attribute and its associated condition to which it must fit to. The condition could either be a integer or string depending on the attributes type, or it could be a collection of integers or strings represented in an array.
Matches single (scalar) or multiple (array) search terms against a number of fields. Generally, the term(s) are enclosed in percent signs ("%term%"), so any fields that contain them will match. However, if the search parameter is a string and does contain a percent sign already, none will be added to the query. This allows searches using custom patterns, like "fields beginning with "a" ("a%"). (You might even want to extend this to work with arrays, too. Currently, only the shop module uses this feature.) -- RK 20100910
Parameters
- $arrFilter : mixed
-
The term or array of terms
- $forceTableIdx : string = null
-
Argument must not be used directly. Will internally be used for recursion (parsing child attributes of complex profile attributes like gender or country). If $forceTableIdx is set then its value will be used as prefix for the table alias of the SQL statement.
- $uniqueJoins : bool = true
-
Whether the filter arguments shall be joined by separate unique JOINs or by a single common JOIN statement.
- $joinIdx : int = 0
-
The current index used for separate unique JOINs.
Return values
array<string|int, mixed> —The array of SQL snippets
parseFilterConditions()
Parse and translate an array of filter rules into SQL statements to be used for filtering users.
protected
parseFilterConditions(array<string|int, mixed> $filter, bool &$tblCoreAttributes, bool &$tblGroup, array<string|int, mixed> &$customAttributeJoins, bool &$groupTables[, bool $uniqueJoins = true ][, int &$joinIdx = 0 ]) : array<string|int, mixed>
Parameters
- $filter : array<string|int, mixed>
-
A nested array defining filter rules
- $tblCoreAttributes : bool
-
Will be set to TRUE if the supplied filter arguments $filter will need a join to the core-attribute-table
- $tblGroup : bool
-
Will be set to TRUE if the supplied filter arguments $filter will need a join to the user-group-table
- $customAttributeJoins : array<string|int, mixed>
-
Will be filled with SQL JOIN statements to be used for filtering the custom attributes
- $groupTables : bool
-
Will be set to TRUE if the SQL statement should be grouped (GROUP BY)
- $uniqueJoins : bool = true
-
Whether the filter arguments shall be joined by separate unique JOINs or by a single common JOIN statement.
- $joinIdx : int = 0
-
The current index used for separate unique JOINs.
Return values
array<string|int, mixed> —List of SQL statements to be used as WHERE arguments
randomChar()
Return a random character picked from the given string
protected
static randomChar(string $chars) : string
Returns the empty string if the given one has length 0 (zero).
Parameters
- $chars : string
Return values
stringsendUserAccountInvitationMail()
Send a invitation mail to the created user.
protected
sendUserAccountInvitationMail(string $generatedPassword) : mixed
It used the old mail function
Parameters
- $generatedPassword : string
storeProfile()
protected
storeProfile([mixed &$profileUpdated = null ]) : mixed
Parameters
- $profileUpdated : mixed = null
-
If $profileUpdated is provided, then in case any profile changes are being flushed to the database, $profileUpdated will be set to TRUE, otherwise it'll be left untouched.
updateLoadedUserData()
Update a specific profile attribute of the user
protected
updateLoadedUserData(string $attribute, string|int|bool $value) : mixed
Parameters
- $attribute : string
-
ID of profile attribute to update
- $value : string|int|bool
-
Value to set the profile attribute to
updatePasswordHash()
Verify that the password is properly hashed
protected
updatePasswordHash(string $password[, string $passwordHash = '' ]) : mixed
If the hashed password is outdated it will be updated in the database.
Parameters
- $password : string
-
Current raw password
- $passwordHash : string = ''
-
The matching hash of the password. If not supplied, it will be fetched from the database.
Tags
updateUser()
protected
updateUser([mixed &$userChanged = null ]) : mixed
Parameters
- $userChanged : mixed = null
-
If $userChanged is provided, then in case any account changes are being flushed to the database, $userChanged will be set to TRUE, otherwise it'll be left untouched.
clean()
Clean user metadata
private
clean() : mixed
Reset all user metadata for a new user. The metadata includes the ID of the user, the username, e-mail address, password, language ID, active and administration status, registration date, restore key and restore key timeout and the ID's of the associated groups.
getFilteredUserIdList()
private
getFilteredUserIdList([mixed $arrFilter = null ][, mixed $search = null ]) : mixed
Parameters
- $arrFilter : mixed = null
- $search : mixed = null
isLastAdmin()
Returns true if the current User has the only active admin account present in the system.
private
isLastAdmin() : bool
Returns false if either
- the current User is not an admin, or
- there are at least two active admins present Note that true is returned if the database query fails, so the User will not be allowed to be deleted. You might have a whole different kind of problem in that case anyway.
Tags
Return values
boolload()
Load user data
private
load(int $id[, bool $forceReload = false ]) : bool
Load all user data (username, email, lang_id, is_active, etc.) of the user specified by ID $id into the current instance.
Parameters
- $id : int
-
The ID of the user to load
- $forceReload : bool = false
-
Set to TRUE to refetch the user from the database. Otherwise, the user will be loaded from cache, in case it has been loaded before. Defaults to FALSE.
Tags
Return values
bool —TRUE on success, otherwise FALSE
loadGroups()
Load group ID's of user
private
loadGroups([bool $onlyActiveGroups = false ]) : mixed
Returns an array with the ID's of all groups to which the user is associated to.
Parameters
- $onlyActiveGroups : bool = false
Tags
Return values
mixed —array on success, FALSE on failure
loadPermissionIds()
private
loadPermissionIds(mixed $type) : mixed
Parameters
- $type : mixed
loadSubscribedNewsletterListIDs()
private
loadSubscribedNewsletterListIDs() : mixed
parseAccountFilterConditions()
Parse account filter conditions
private
parseAccountFilterConditions(array<string|int, mixed> $arrFilter) : array<string|int, mixed>
Generate conditions of the account attributes for the SQL WHERE statement. The filter conditions are defined through the two dimensional array $arrFilter. Each key-value pair represents an attribute and its associated condition to which it must fit to. The condition could either be a integer or string depending on the attributes type, or it could be a collection of integers or strings represented in an array.
Examples of the filer array:
array( 'firstname' => '%nicole%', ) // will return all users who's firstname include 'nicole'
array( 'firstname' => array( 'd%', 'e%', 'f%', 'g%' ) ) // will return all users which have a firstname of which its first letter is and between 'd' to 'g' (case less)
array( 'firstname' => array( array( '>' => 'd', '<' => 'g' ), 'LIKE' => 'g%' ) ) // same as the preview example but in an other way
array( 'is_active' => 1, 'last_auth' => array( '>' => time()-3600 ) ) // will return all users that are active and have been logged in at least in the last one hour
Parameters
- $arrFilter : array<string|int, mixed>
Return values
array<string|int, mixed>parseAccountSearchConditions()
Creates the SQL query snippet to match username (and e-mail in the backend) fields against the search term(s)
private
parseAccountSearchConditions(mixed $search) : array<string|int, mixed>
Matches single (scalar) or multiple (array) search terms against a number of fields. Generally, the term(s) are enclosed in percent signs ("%term%"), so any fields that contain them will match. However, if the search parameter is a string and does contain a percent sign already, none will be added to the query. This allows searches using custom patterns, like "fields beginning with "a" ("a%"). (You might even want to extend this to work with arrays, too. Currently, only the shop module uses this feature.) -- RK 20100910
Parameters
- $search : mixed
-
The term or array of terms
Return values
array<string|int, mixed> —The array of SQL snippets
removeOutdatedAccounts()
private
static removeOutdatedAccounts() : mixed
setSortedUserIdList()
private
setSortedUserIdList(mixed $arrSort[, mixed $sqlCondition = array() ][, mixed $limit = null ][, mixed $offset = null ][, mixed $groupless = false ][, mixed $crmUser = false ]) : mixed
Parameters
- $arrSort : mixed
- $sqlCondition : mixed = array()
- $limit : mixed = null
- $offset : mixed = null
- $groupless : mixed = false
- $crmUser : mixed = false
storeGroupAssociations()
Store group associations
private
storeGroupAssociations([mixed &$associationChange = null ]) : bool
Stores the group associations of the loaded user. Returns TRUE on success, FALSE on failure.
Parameters
- $associationChange : mixed = null
-
If $associationChange is provided, then in case any group association changes are being flushed to the database, $associationChange will be set to TRUE, otherwise it'll be left untouched.
Tags
Return values
boolstoreNewsletterSubscriptions()
Store the user's newsletter-list-subscriptions to the database
private
storeNewsletterSubscriptions([mixed &$subscriptionChange = null ]) : bool
Parameters
- $subscriptionChange : mixed = null
-
If $subscriptionChange is provided, then in case any newsletter list subscription changes are being flushed to the database, $subscriptionChange will be set to TRUE, otherwise it'll be left untouched.
Return values
boolupdateLastActivityTime()
private
updateLastActivityTime() : mixed
updateLastAuthTime()
private
updateLastAuthTime() : mixed
validateLanguageId()
Validate language id
private
validateLanguageId(string $scope) : mixed
Checks if the language ids frontend_lang_id and backend_lang_id are valid language IDs. In the case that the specified language isn't valid, the ID 0 is taken instead. $scope could either be 'frontend' or 'backend'
Parameters
- $scope : string