User Object

The User object is used for all user related operations.

copyright CONTREXX CMS - COMVATION AG
author Thomas Daeppen
version 2.0.0
package contrexx
subpackage lib_framework

 Methods

__clone()

__clone() 

__construct()

__construct() 

Authenticate user against username and password

auth(string $username, string $password, boolean $backend, $captchaCheckResult) : boolean

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 MD5 hash of the password

$backend

boolean

Tries to authenticate for the backend if true, false otherwise

$captchaCheckResult

Returns

booleanTrue on success, false otherwise

Checks username, password and captcha.

checkLoginData(string $username, string $password, bool $captchaCheckResult) : mixed

Parameters

$username

string

$password

string

$captchaCheckResult

bool

Returns

mixedfalse or user id

checkMandatoryCompliance()

checkMandatoryCompliance() 
Inherited
inherited_from \User_Profile::checkMandatoryCompliance()

Returns TRUE if the given password matches the current user, FALSE otherwise.

checkPassword(string $password) : boolean

Parameters

$password

string

Returns

boolean

Delete the current loaded user account

delete(boolean $deleteOwnAccount) : boolean

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.

see \isLastAdmin()

Parameters

$deleteOwnAccount

boolean

Returns

boolean

finishSignUp()

finishSignUp() 

Load first user

first() 

forceDefaultEmailAccess()

forceDefaultEmailAccess() 
Static

forceDefaultProfileAccess()

forceDefaultProfileAccess() 
Static

getActiveStatus()

getActiveStatus() 

getAdminStatus()

getAdminStatus() 

getAssociatedGroupIds()

getAssociatedGroupIds() 

getBackendLanguage()

getBackendLanguage() 

Check whether it exists a user with the data

getByNetwork(string $oauth_provider, string $oauth_id) : object

Parameters

$oauth_provider

string

the name of the provider

$oauth_id

string

the user id on the side of the provider

Returns

objectthe user object

Checks whether the user account is connected with a crm customer

getCrmUserId() : int | null

Returns

intnullid of crm user if the user is associated with a customer of crm module

getDynamicPermissionIds()

getDynamicPermissionIds($reload) 

Parameters

$reload

getEmail()

getEmail() 

getEmailAccess()

getEmailAccess() 

getErrorMsg()

getErrorMsg() 

getExpirationDate()

getExpirationDate() 

getFilteredSearchUserCount()

getFilteredSearchUserCount() 

getFrontendLanguage()

getFrontendLanguage() 

getId()

getId() 

getLastActivityTime()

getLastActivityTime() 

getLastAuthenticationTime()

getLastAuthenticationTime() 

getNetworks()

getNetworks() : object

Returns

object

getPrimaryGroupId()

getPrimaryGroupId() 

getPrimaryGroupName()

getPrimaryGroupName() 

getPrivacyAccessMenu()

getPrivacyAccessMenu($attrs, $option) 

Parameters

$attrs

$option

getProfileAccess()

getProfileAccess() 

getProfileAttribute()

getProfileAttribute($attributeId, $historyId) 

Parameters

$attributeId

$historyId

getRealUsername()

getRealUsername() 

getRegistrationDate()

getRegistrationDate() 

getRestoreKey()

getRestoreKey() 

getRestoreKeyTime()

getRestoreKeyTime() 

getStaticPermissionIds()

getStaticPermissionIds($reload) 

Parameters

$reload

Returns an array of all newsletter-list-IDs the user did subscribe to

getSubscribedNewsletterListIDs() : array

Returns

arrayNewsletter-list-IDs

getUser()

getUser($id) 

Parameters

$id

getUsername()

getUsername() 

Returns a User object according to the given criteria

getUsers(mixed $filter, string $search, array $arrSort, array $arrAttributes, integer $limit, integer $offset) : \User

Parameters

$filter

mixed

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
array(
     'is_active' => 1,
     'last_auth' => array(
         '>' => time()-3600
     )
);
$objUser = \User::getUsers($filter);

$search

string

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

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

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

integer

The maximal number of Users to load from the database. If not set, all matched users will be loaded.

$offset

integer

The optional parameter $offset can be used to specify the number of found records to skip in the result set.

Returns

getValidityTimePeriod()

getValidityTimePeriod() 

hasModeAccess()

hasModeAccess($backend) 

Parameters

$backend

isAllowedToChangeEmailAccess()

isAllowedToChangeEmailAccess() 

isAllowedToChangeProfileAccess()

isAllowedToChangeProfileAccess() 

isAllowedToDeleteAccount()

isAllowedToDeleteAccount() 

Returns true if $email is a unique e-mail address in the system

isUniqueEmail(string $email, integer $id) : boolean
Static
static

Parameters

$email

string

$id

integer

Returns

boolean

Returns true if the given $password is valid

isValidPassword(string $password) : boolean
Static

Parameters

$password

string

Returns

boolean

Returns true if the given $username is valid

isValidUsername(string $username) : boolean
Static
static

Parameters

$username

string

Returns

boolean

Load the network data

loadNetworks() 

Returns a valid password

make_password(integer $length, boolean $use_special) : string
Static

Generated passwords consist of - at most 4 lower caps letters [qwertzupasdfghjkyxcvbnm], - at most 4 upper caps letters [QWERTZUPASDFGHJKLYXCVBNM], - at most 2 digits [23456789], and - at most 1 special character [-+_!?%&], if enabled. If $length is less than 6, the length will be 6 characters. If $length is bigger than 8, the length will be 8 characters.

Parameters

$length

integer

Desired password length, 6 to 8 characters. Defaults to 8

$use_special

boolean

Use "special" characters [-+_!?%&] if true. Defaults to false

Returns

stringThe new password

Tries to form a valid and unique username from the words given

make_username($word1, $word2) : string
Static

Usually, you would use first and last names as parameters.

Parameters

$word1

$word2

Returns

stringThe new user name on success, false otherwise

Load next user

next() 

Register a failed login.

registerFailedLogin(string $username) 
Static

This causes that the user needs to fill out the captcha the next time he logs on.

static
access public
global ADONewConnection $objDatabase

Parameters

$username

string

Register a successful login.

registerSuccessfulLogin() 
Static
static
access public
global ADONewConnection $objDatabase

releaseRestoreKey()

releaseRestoreKey() 

reset()

reset() 

Set active status of user

setActiveStatus(boolean $status) : void

This will set the attribute is_active of this object either to TRUE or FALSE, depending of $status.

Parameters

$status

boolean

Set administration status of user

setAdminStatus(boolean $status) : boolean

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.

global array

Parameters

$status

boolean

Returns

boolean

Set backend language ID of user

setBackendLanguage(integer $langId) : void

This will set the attribute backend_lang_id of this object to $langId.

Parameters

$langId

integer

Sets email address of user

setEmail(string $email) : boolean

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

Returns

boolean

setEmailAccess()

setEmailAccess($emailAccess) 

Parameters

$emailAccess

setExpirationDate()

setExpirationDate($expiration) 

Parameters

$expiration

Set frontend language ID of user

setFrontendLanguage(integer $langId) : void

This will set the attribute frontend_lang_id of this object to $langId.

Parameters

$langId

integer

Set ID's of groups to which this user should belong to

setGroups(array $arrGroups) : void
see UserGroup::getGroups(), UserGroup::getId()

Parameters

$arrGroups

array

Add or update a network connection of the user

setNetwork(string $oauth_provider, string $oauth_id) 

Parameters

$oauth_provider

string

the name of the provider

$oauth_id

string

the user id on the side of the provider

Sets password of user

setPassword(string $password, string $confirmedPassword, $reset) : boolean

This will set the attribute password of this object to the md5 hash of $password if $password is a valid password and if it was confirmed by the second parameter $confirmedPassword.

global array $_CORELANG

Parameters

$password

string

The new password

$confirmedPassword

string

The new password, again

$reset

Returns

booleanTrue on success, false otherwise

Set the Id of a user group that should be used as the user's primary group

setPrimaryGroup(integer $groupId) : void

Parameters

$groupId

integer

setProfile()

setProfile($arrProfile) 
Inherited
inherited_from \User_Profile::setProfile()

Parameters

$arrProfile

setProfileAccess()

setProfileAccess($profileAccess) 

Parameters

$profileAccess

setRestoreKey()

setRestoreKey() 

setRestoreKeyTime()

setRestoreKeyTime($seconds) 

Parameters

$seconds

Set ID's of newsletter-list the which the user subscribed to

setSubscribedNewsletterListIDs(array $arrNewsletterListIDs) : void

Parameters

$arrNewsletterListIDs

array

Sets username of user

setUsername(string $username) : boolean

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

Returns

boolean

Sets the validity period of the account

setValidityTimePeriod($validity) : boolean

Administrators cannot be restricted in their validity. Returns TRUE.

Parameters

$validity

Returns

boolean

Set the active status of one or more Users

set_active(mixed $mix_user_id, boolean $active) : void
Static

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

boolean

Activate (true) or deactivate (false) the User(s).

Store user account

store() : boolean

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.

global ADONewConnection
global array

Returns

boolean

Returns true if this Users' e-mail address is valid and unique.

validateEmail() : boolean

Otherwise, adds appropriate error messages, and returns false. Required to be public by the Shop!

Returns

booleanTrue for valid and unique e-mail addresses, false otherwise

Create a profile for the loaded user

createProfile() : boolean
Inherited

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.

inherited_from \User_Profile::createProfile()

Returns

boolean

Returns true if $username is a unique user name

isUniqueUsername(string $username, integer $id) : boolean
Static

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.

static

Parameters

$username

string

The username to test

$id

integer

The optional current User ID

Returns

booleanTrue if the username is available, false otherwise

Load custom attribute profile data

loadCustomAttributeProfileData(array $arrAttributes) : boolean
Inherited

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.

inherited_from \User_Profile::loadCustomAttributeProfileData()

Parameters

$arrAttributes

array

Returns

boolean

loadUsers()

loadUsers($filter, $search, $arrSort, $arrAttributes, $limit, $offset) 

Parameters

$filter

$search

$arrSort

$arrAttributes

$limit

$offset

Enter description here.

parseAttributeSearchConditions(mixed $search, \unknown_type $core, \unknown_type $attributeId) : array
Inherited

..

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

inherited_from \User_Profile::parseAttributeSearchConditions()

Parameters

$search

mixed

The term or array of terms

$core

\unknown_type

$attributeId

\unknown_type

Returns

arrayThe array of SQL snippets

Parse core attribute filter conditions

parseCoreAttributeFilterConditions(array $arrFilter) : array
Inherited

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.

inherited_from \User_Profile::parseCoreAttributeFilterConditions()

Parameters

$arrFilter

array

Returns

array

Parse custom attribute filter conditions

parseCustomAttributeFilterConditions(mixed $arrFilter) : array
Inherited

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

inherited_from \User_Profile::parseCustomAttributeFilterConditions()

Parameters

$arrFilter

mixed

The term or array of terms

Returns

arrayThe array of SQL snippets

storeProfile()

storeProfile() 
Inherited
inherited_from \User_Profile::storeProfile()

Clean user metadata

clean() 

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()

getFilteredUserIdList($arrFilter, $search) 

Parameters

$arrFilter

$search

Returns the e-mail address if the User accounts has been created by the Shop.

getShopUserEmail() : string

Such accounts have e-mail addresses that look like "shop_customer_$orderId_$productId_$instance-$email" Note that this is a temporary workaround and will be changed in a future release.

todo All affected customers *MUST* be migrated properly from the Shop to the User administration

Returns

stringThe e-mail address if the account was autocreated by the Shop, the empty string otherwise.

initAttributes()

initAttributes() 
Inherited
inherited_from \User_Profile::initAttributes()

Returns true if the current User has the only active admin account present in the system.

isLastAdmin() : boolean

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.

global ADONewConnection

Returns

boolean

isLoggedIn()

isLoggedIn() 

Load user data

load(integer $id) : \unknown

Get username, email, lang_id, is_active and is_admin states from database and put them into the analogous class variables.

Parameters

$id

integer

Exceptions

\UserException

Returns

\unknown

Load group ID's of user

loadGroups(boolean $onlyActiveGroups) : mixed

Returns an array with the ID's of all groups to which the user is associated to.

global ADONewConnection

Parameters

$onlyActiveGroups

boolean

Returns

mixedarray on success, FALSE on failure

loadPermissionIds()

loadPermissionIds($type) 

Parameters

$type

loadSubscribedNewsletterListIDs()

loadSubscribedNewsletterListIDs() 

Parse account filter conditions

parseAccountFilterConditions(array $arrFilter) : array

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

Returns

array

Creates the SQL query snippet to match username (and e-mail in the backend) fields against the search term(s)

parseAccountSearchConditions(mixed $search) : 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

$search

mixed

The term or array of terms

Returns

arrayThe array of SQL snippets

removeOutdatedAccounts()

removeOutdatedAccounts() 
Static

setSortedUserIdList()

setSortedUserIdList($arrSort, $sqlCondition, $limit, $offset, $groupless, $crmUser) 

Parameters

$arrSort

$sqlCondition

$limit

$offset

$groupless

$crmUser

Store group associations

storeGroupAssociations() : boolean

Stores the group associations of the loaded user. Returns TRUE on success, FALSE on failure.

global ADONewConnection

Returns

boolean

Store the user's newsletter-list-subscriptions to the database

storeNewsletterSubscriptions() : bool

Returns

bool

updateLastActivityTime()

updateLastActivityTime() 

updateLastAuthTime()

updateLastAuthTime() 

Validate language id

validateLanguageId(string $scope) 

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

 Properties

 

$EOF 
access public
 

$arrAttributeHistories 
Inherited
inherited_from \User_Profile::$$arrAttributeHistories
 

$arrNoAvatar : array
Inherited
access private
inherited_from \User_Profile::$$arrNoAvatar
 

$arrNoPicture 
Inherited
inherited_from \User_Profile::$$arrNoPicture
 

$arrUpdatedAttributeHistories 
Inherited
inherited_from \User_Profile::$$arrUpdatedAttributeHistories
 

$error_msg : string
 

$objAttribute : \User_Profile_Attribute
Inherited
inherited_from \User_Profile::$$objAttribute
 

$arrCachedUsers : array
access protected
 

$arrLoadedUsers : array
access protected
 

$id : integer
access private
 

$password : string
access protected
 

$arrAttributes 
access private
 

$arrGroups : array
access private
 

$arrNewsletterListIDs : array
access protected
 

$arrPrivacyAccessTypes 
access private
 

$backend_language : integer
access private
 

$defaultEmailAccessType 
access private
 

$defaultProfileAccessTyp 
access private
 

$email : string
access private
 

$email_access : boolean
access private
 

$expiration : integer
access private
 

$filtered_search_count : integer
access private
 

$frontend_language : integer
access private
 

$is_active : boolean
access private
 

$is_admin : boolean
access private
 

$lang_id : integer
access private
 

$last_activity : integer
access private
 

$last_auth : integer
access private
 

$loggedIn : boolean

If this is TRUE the methods load() and loadUsers() will be looked for further usage.

todo Explain this method in plain english...
access private
 

$networks : object
access private
 

$primary_group : integer
access private
 

$profile_access : string
access private
 

$regdate : integer
access private
 

$restore_key : string
access private
 

$restore_key_time : integer
access private
 

$username : string
access private
 

$validity : integer

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.

access private
© Copyright 2014 by Comvation AG
Generated on 2014-07-11T08:39:26+02:00.