User object that mimicks the old $this->session behaviour

package Gems
subpackage User
copyright Copyright (c) 2011 Erasmus MC
license New BSD License
since Class available since version 1.5

 Methods

Creates the class for this user.

__construct(mixed $settings, \Gems_User_UserDefinitionInterface $definition) 

Parameters

$settings

mixed

Array, \Zend_Session_Namespace or \ArrayObject for this user.

$definition

\Gems_User_UserDefinitionInterface

The user class definition.

Set menu parameters from this user

applyToMenuSource(\Gems_Menu_ParameterSource $source) : \Gems_User_User

Parameters

$source

\Gems_Menu_ParameterSource

Returns

\Gems_User_User

Authenticate a users credentials using the submitted form

authenticate(string $password, boolean $testPassword = true) : \Zend_Auth_Result

Parameters

$password

string

The password to test

$testPassword

boolean

Set to false to test the non-password checks only

Returns

\Zend_Auth_Result

True when the current url is one where this user is allowed to login.

canLoginHere() : boolean

If the url is a fixed organization url and the user is not allowed to access this organization, then this function returns false.

Returns

boolean

Return true if a password reset key can be created.

canResetPassword() : boolean

Returns

boolean

Return true if the password can be set.

canSetPassword() : boolean

Returns

boolean

Should be called after answering the request to allow the Target to check if all required registry values have been set correctly.

checkRegistryRequestsAnswers() : boolean

Returns

booleanFalse if required values are missing.

Returns the list of allowed IP ranges (separated by colon)

getAllowedIPRanges() : string

Returns

string

Get an array of OrgId => Org Name for all allowed organizations for the current loggedin user

getAllowedOrganizations() : array

Returns

array

Returns the current roles a user may set.

getAllowedRoles() : array

NOTE! A user can set a role, unless it requires a higher role level.

I.e. an admin is not allowed to set a super role as super inherits and expands admin. But it is allowed to set the nologin and respondent roles that are not inherited by the admin as they are in a different hierarchy.

An exception is the role master as it is set by the system. You gotta be a master to set the master role.

Returns

arrayWith identical keys and values roleId => roleId

Retrieve an array of groups the user is allowed to assign: his own group and all groups he/she inherits rights from

getAllowedStaffGroups() : array

Returns

array

Returns the original (not the current) organization used by this user.

getBaseOrganization() : \Gems_User_Organization

Returns

\Gems_User_Organization

Returns the original (not the current) organization id of this user.

getBaseOrganizationId() : integer

Returns

integer

Returns a form to change the possword for this user.

getChangePasswordForm($args_array = null) : \Gems_Form

Parameters

$args_array

Returns

\Gems_Form

Returns the organization that is currently used by this user.

getCurrentOrganization() : \Gems_User_Organization

Returns

\Gems_User_Organization

Returns the organization id that is currently used by this user.

getCurrentOrganizationId() : integer

Returns

integer

Return true if this user has a password.

getEmailAddress() : boolean

Returns

boolean

Returns the from address

getFrom() : string

Returns

stringE-Mail address

Returns the full user name (first, prefix, last).

getFullName() : string

Returns

string

Returns a standard greeting for the current user.

getGreeting(string $locale = null) : integer

Parameters

$locale

string

Returns

integer

Returns the group number of the current user.

getGroup() : integer

Returns

integer

The locale set for this user.

getLocale() : string

.

Returns

string

getLoginName()

getLoginName() : string

Returns

string

Array of field name => values for sending E-Mail

getMailFields(string $locale = null) : array

Parameters

$locale

string

Returns

array

Return the number of days since last change of password

getPasswordAge() : integer

Returns

integer

Return a password reset key

getPasswordResetKey() : string

Returns

string

Return the Request object

getRequest() : \Zend_Controller_Request_Abstract

Returns

\Zend_Controller_Request_Abstract

Array of field name => values for sending a reset password E-Mail

getResetPasswordMailFields(string $locale = null) : array

Parameters

$locale

string

Returns

array

Get an array of OrgId's for filtering on all allowed organizations that can have respondents for the current logged in user

getRespondentOrgFilter() : array

Returns

array

Get a where statement containing orgId's for combi field where statements on all allowed organizations that can have respondents for the current logged in user

getRespondentOrgWhere(string $fieldName, string $sep = '|') : string

Parameters

$fieldName

string

Field name separator

$sep

string

Optional different value seperator

Returns

string

Get an array of OrgId => Org Name for all allowed organizations that can have respondents for the current logged in user

getRespondentOrganizations() : array

Returns

array

Returns the current user role.

getRole() : string

Returns

string

Returns the current user roles.

getRoles() : array

Returns

arrayWith identical keys and values roleId => roleId

get the parameters where the survey should return to

getSurveyReturn() : array

Returns

array

Returns the user id, that identifies this user within this installation.

getUserId() : integer

One user id might be connected to multiple logins for multiple organizations.

YES! This is the one you need, not getUserLoginId().

Returns

integer

Use ONLY in User package.

getUserLoginId() : integer

Returns the User package user id, that is unique for each login / organization id combination, but does not directly identify this person.

In other words, this is not the id you use to track who changed what. It is only used by parts of the User package.

Returns

integer

Redirects the user to his/her start page.

gotoStartPage(\Gems_Menu $menu, \Zend_Controller_Request_Abstract $request) : \Gems_Menu_SubMenuItem

Parameters

$menu

\Gems_Menu

$request

\Zend_Controller_Request_Abstract

Returns

\Gems_Menu_SubMenuItem

Return true if this user has a role that is accessible by the current user, i.e. is the current user allowed to change this specific user

hasAllowedRole() : boolean

Returns

boolean

Return true if this user has a password.

hasEmailAddress() : boolean

Returns

boolean

Return true if this user has a password.

hasPassword() : boolean

Returns

boolean

Returns true if the role of the current user has the given privilege

hasPrivilege(string $privilege) : boolean

Parameters

$privilege

string

Returns

boolean

Return true if this user has this role

hasRole(string $role) : boolean

Parameters

$role

string

Returns

boolean

True when the reset key is within it's timeframe and OK for the current organization

hasValidResetKey() : boolean

Returns

boolean

isActive()

isActive() : boolean

Returns

booleanTrue when a user can log in.

Is this organization in the list of currently allowed organizations?

isAllowedOrganization(integer $organizationId) : boolean

Parameters

$organizationId

integer

Returns

boolean

True when this user must enter a new password.

isBlockable() : boolean

Returns

boolean

Checks if this user is the current user

isCurrentUser() : boolean

Returns

boolean

True when this user requires a logout after answering a survey

isLogoutOnSurvey() : boolean

Returns

boolean

True when this user must enter a new password.

isPasswordResetRequired() : boolean

Returns

boolean

Returns true when this user is a staff member.

isStaff() : boolean

Returns

boolean

refresh()

refresh(string $defName = null) : \Gems_User_User

Parameters

$defName

string

Optional

Returns

\Gems_User_User(continuation pattern)

Allowes a refresh of the existing list of organizations for this user.

refreshAllowedOrganizations() : \Gems_User_User

Returns

\Gems_User_User(continuation pattern)

Allowes a refresh of the existing list of groups the user is allowed to assign: his own group and all groups he/she inherits rights from

refreshAllowedStaffGroups() : array

Returns

array

Check for password weakness.

reportPasswordWeakness(string $password = null) : mixed

Parameters

$password

string

Or null when you want a report on all the rules for this password.

Returns

mixedString or array of strings containing warning messages or nothing

Send an e-mail to this user

sendMail(string $subjectTemplate, string $bbBodyTemplate, boolean $useResetFields = false, string $locale = null) : mixed

Parameters

$subjectTemplate

string

A subject template in which {fields} are replaced

$bbBodyTemplate

string

A BB Code body template in which {fields} are replaced

$useResetFields

boolean

When true get a reset key for this user

$locale

string

Optional locale

Returns

mixedString or array of warnings when something went wrong

Set this user as the current user.

setAsCurrentUser(boolean $signalLoader = true, boolean $resetSessionId = true) : \Gems_User_User

This means that the data about this user will be stored in a session.

Parameters

$signalLoader

boolean

Do not set, except from UserLoader

$resetSessionId

boolean

Should the session be reset?

Returns

\Gems_User_User(continuation pattern)

Set the currently selected organization for this user

setCurrentOrganization(mixed $organization) : \Gems_User_User

Parameters

$organization

mixed

\Gems_User_Organization or an organization id.

Returns

\Gems_User_User(continuation pattern)

Set the locale for this user.

setLocale(string $locale) : \Gems_User_User

.

Parameters

$locale

string

Returns

\Gems_User_User(continuation pattern)

Set the password, if allowed for this user type.

setPassword(string $password) : \Gems_User_User

Parameters

$password

string

Returns

\Gems_User_User(continuation pattern)

setPasswordResetRequired()

setPasswordResetRequired(boolean $reset = true) : \Gems_User_User

Parameters

$reset

boolean

Returns

\Gems_User_User(continuation pattern)

Set the Request object

setRequest(\Zend_Controller_Request_Abstract $request) : \Gems_User_User

Parameters

$request

\Zend_Controller_Request_Abstract

Returns

\Gems_User_User

Set the parameters where the survey should return to

setSurveyReturn(mixed $return = null) : \Gems_User_User

Parameters

$return

mixed

\Zend_Controller_Request_Abstract, array of something that can be turned into one.

Returns

\Gems_User_User

Unsets this user as the current user.

unsetAsCurrentUser(boolean $signalLoader = true) : \Gems_User_User

This means that the data about this user will no longer be stored in a session.

Parameters

$signalLoader

boolean

Do not set, except from UserLoader

Returns

\Gems_User_User(continuation pattern)

Get a value in whatever store is used by this object.

_getVar(string $name) : mixed

Parameters

$name

string

Returns

mixed

Checks for existence of a value in whatever store is used by this object.

_hasVar(string $name) : boolean

Parameters

$name

string

Returns

boolean

Sets a value in whatever store is used by this object.

_setVar(string $name, mixed $value) : void

Parameters

$name

string

$value

mixed

Sets a value in whatever store is used by this object.

_unsetVar(string $name) : void

Parameters

$name

string

Process everything after authentication.

afterAuthorization(\Zend_Auth_Result $result, $lastAuthorizer = null

Parameters

$result

\Zend_Auth_Result

$lastAuthorizer

Checks if the user is allowed to login or is blocked

authorizeBlock() : mixed

An adapter authorizes and if the end resultis boolean, string or array it is converted into a \Zend_Auth_Result.

Returns

mixed\Zend_Auth_Adapter_Interface|\Zend_Auth_Result|boolean|string|array

Checks if the user is allowed to login using the current IP address according to the group he is in

authorizeIp() : mixed

An adapter authorizes and if the end resultis boolean, string or array it is converted into a \Zend_Auth_Result.

Returns

mixed\Zend_Auth_Adapter_Interface|\Zend_Auth_Result|boolean|string|array

Checks if the user is allowed to login using the current IP address according to his BASE organization

authorizeOrgIp() : mixed

An adapter authorizes and if the end resultis boolean, string or array it is converted into a \Zend_Auth_Result.

Returns

mixed\Zend_Auth_Adapter_Interface|\Zend_Auth_Result|boolean|string|array

Returns the gender for use as part of a sentence, e.g. Dear Mr/Mrs

getGenderGreeting(string $locale = null) : array

In practice: starts lowercase

Parameters

$locale

string

Returns

arraygender => string

Returns the gender for use in stand-alone name display

getGenderHello(string $locale = null) : array

In practice: starts uppercase

Parameters

$locale

string

Returns

arraygender => string

Load the callables | results needed to authenticate/authorize this user

loadAuthorizers(string $password, boolean $testPassword = true) : array

A callable will be called, then an adapter authorizes and if the end result is boolean, string or array it is converted into a \Zend_Auth_Result.

Parameters

$password

string

$testPassword

boolean

Set to false to test on the non-password checks only

Returns

arrayOf Callable|\Zend_Auth_Adapter_Interface|\Zend_Auth_Result|boolean|string|array

Returns an array of elements for check fields during password reset and/or 'label name' => 'required value' pairs. vor asking extra questions before allowing a password change.

loadResetPasswordCheckFields() : array

Default is asking for the username but you can e.g. ask for someones birthday.

Returns

arrayOf 'label name' => 'required values' or \Zend_Form_Element elements

The store currently used.

_getVariableStore() : \ArrayObject

Returns

\ArrayObjector \Zend_Session_Namespace

 Properties

 

Array containing the parameter names that may point to an organization

$possibleOrgIds : array

Default

array(\MUtil_Model::REQUEST_ID2, 'gr2o_id_organization', 'gr2t_id_organization', 'gap_id_organization', 'gto_id_organization', 'gor_id_organization', 'gla_organization', 'grco_organization')
 

$_authResult

$_authResult : \Zend_Auth_Result

Default

 

Required

$acl : \MUtil_Acl

Default

 

Required

$db : \Zend_Db_Adapter_Abstract

Default

 

Required, set in constructor

$definition : \Gems_User_UserDefinitionInterface

Default

 

Sets number failed accounts that trigger a block

$failureBlockCount : integer

Default

6
 

Sets number of seconds until a previous failed login can be ignored

$failureIgnoreTime : integer

Default

600
 

$project

$project : \Gems_Project_ProjectSettings

Default

 

$request

$request : \Zend_Controller_Request_Abstract

Default

 

Required

$session : \Zend_Session_Namespace

Default

 

Required

$userLoader : \Gems_User_UserLoader

Default

 

$util

$util : \Gems_Util

Default

 

or \Zend_Session_Namespace

$_vars : \ArrayObject

Default