LimeSurvey API - Master branch

TFAUser extends User
in package

Abstracted user model for TFA admin view.

Incorporating an alternative seach method.

Tags
inheritDoc

Table of Contents

Constants

MAX_EXPIRATION_TIME_IN_DAYS  = 2
MAX_EXPIRATION_TIME_IN_HOURS  = 48
MAX_VALIDATION_KEY_LENGTH  = 38

Properties

$bEncryption  : mixed
$created  : string
$dateformat  : int
$email  : string
$full_name  : string
$groups  : array<string|int, UserGroup>
$htmleditormode  : string
$lang  : string
$lang  : string
$last_forgot_email_password  : string
$last_login  : string
$modified  : string
$one_time_pw  : string
$parent_id  : int
$parentUser  : User
$parentUserName  : string
$password  : string
$permissions  : array<string|int, Permission>
$questionselectormode  : string
$roles  : array<string|int, Permissiontemplates>
$searched_value  : mixed
$templateeditormode  : string
$uid  : int
$user_status  : int
$users_name  : string
$validation_key  : string
$validation_key_expiration  : string
$xssFilterAttributes  : array<string|int, string>

Methods

attributeLabels()  : mixed
behaviors()  : array<string|int, mixed>
Lists the behaviors of this model
canEdit()  : bool
Return true if user with id $managerId can edit this user
canLogin()  : bool
Check if user can login
checkPassword()  : bool
Check if password is OK for current \User
checkPasswordStrength()  : mixed
decrypt()  : mixed
Decrypt values from database
decryptEncryptAttributes()  : mixed
Encrypt/decrypt values
decryptSingle()  : string
Decrypt single value
decryptSingleOld()  : string
Decrypt single value
deleteAllByAttributes()  : int
dispatchPluginModelEvent()  : PluginEvent
encrypt()  : mixed
Encrypt values
encryptAttributeValues()  : array<string|int, mixed>
Attribute values are encrypted ( if needed )to be used for searching purposes
encryptSave()  : mixed
Encrypt values before saving to the database
encryptSingle()  : mixed
Enrypt single value
findAllAsArray()  : array<string|int, mixed>
Finds all active records satisfying the specified condition but returns them as array
findAllByAttributes()  : array<string|int, static>
Overriding of Yii's findAllByAttributes method to provide encrypted attribute value search
findByAttributes()  : static|null
Overriding of Yii's findByAttributes method to provide encrypted attribute value search
findByUsername()  : User
Finds user by username
getAllEncryptedAttributes()  : array<string|int, mixed>
getAuthTypeDescription()  : string
Return the related descriptive UserKey value for this auth type
getButtons()  : string
Returns the action columsn buttons
getColumns()  : array<string|int, mixed>
getColums()  : array<string|int, mixed>
getCommonUID()  : CDbDataReader
Returns User ID common in Survey_Permissions and User_in_groups
getDateFormat()  : string
getDisplayName()  : string
Get the decription to be used in list
getFormattedDateCreated()  : mixed
getGroupList()  : mixed
getGroupMemberListButtons()  : string
Returns button for gridview.
getHasAuthSet()  : bool
Returns a check value of if the user has a bound 2FA secret key
getLastloginFormatted()  : string
Returns the last login formatted for displaying.
getManagementButtons()  : string
Gets the buttons for the GridView
getManagementCheckbox()  : mixed
getManagementColums()  : array<string|int, mixed>
getMaxId()  : false|int
Return the max value for a field
getMinId()  : false|int
Return the min value for a field
getParentUserName()  : mixed
getPasswordHelpText()  : mixed
getRoleList()  : mixed
getSuperAdmins()  : array<string|int, User>
Return all super admins in the system
getSurveysCreated()  : string
insertRecords()  : string
Adds user record
insertUser()  : int|bool
Creates new user
isActive()  : bool
Check if user is active
isExpired()  : bool
Returns true if the user has expired.
model()  : User
primaryKey()  : mixed
relations()  : mixed
rules()  : mixed
scopes()  : mixed
search()  : mixed
searchUserGroupMembers()  : CActiveDataProvider
setActivationStatus()  : bool
Set user activation status
setEncryptedAttributeLabel()  : string
Function to show encryption symbol in gridview attribute header if value ois encrypted
setPassword()  : User
Set user password with hash
setValidationExpiration()  : bool
Creates the validation key expiration date and save it in db
setValidationKey()  : bool
Creates a validation key and saves it in table user for this user.
tableName()  : mixed
updateAll()  : int
Updates records with the specified condition.
updatePassword()  : int
Updates user password hash
validateNewPassword()  : string
Checks if -- password strength -- oldpassword is correct -- oldpassword and newpassword are identical -- newpassword and repeatpassword are identical -- newpassword is not empty
afterDelete()  : mixed
query()  : mixed
Modified version that default to do the same as the original, but allows via a third parameter to retrieve the result as array instead of active records. This solves a joining problem. Usage via findAllAsArray method

Constants

MAX_EXPIRATION_TIME_IN_DAYS

public int MAX_EXPIRATION_TIME_IN_DAYS = 2

maximum days the validation key is valid

MAX_EXPIRATION_TIME_IN_HOURS

public int MAX_EXPIRATION_TIME_IN_HOURS = 48

maximum time the validation_key is valid

MAX_VALIDATION_KEY_LENGTH

public int MAX_VALIDATION_KEY_LENGTH = 38

maximum length for the validation_key

Properties

$created

public string $created

Time created Time user was created as 'YYYY-MM-DD hh:mm:ss'

$dateformat

public int $dateformat

Date format type 1-12

$email

public string $email

User's e-mail address

$full_name

public string $full_name

User's full name

$htmleditormode

public string $htmleditormode

User's prefferred HTML editor mode:(default|inline|popup|none)

$lang

public string $lang = 'auto'

Default value for user language

$lang

public string $lang

User's preferred language: (auto: automatic | languagecodes eg 'en')

$last_forgot_email_password

public string $last_forgot_email_password

datetime when user send email for forgot pw the last time (prevent bot)

$last_login

public string $last_login

$modified

public string $modified

Time modified Time created Time user was modified as 'YYYY-MM-DD hh:mm:ss'

$one_time_pw

public string $one_time_pw

User's one-time-password hash

$parent_id

public int $parent_id

$parentUser

public User $parentUser

Parent user

$parentUserName

public string $parentUserName

Parent user's name

$password

public string $password

User's password hash

$questionselectormode

public string $questionselectormode

User's prefferred Question type selector:(default|full|none)

$searched_value

public mixed $searched_value

$templateeditormode

public string $templateeditormode

User's prefferred template editor mode:(default|full|none)

$uid

public int $uid

User ID - primary key

$user_status

public int $user_status

User's account status (1: activated | 0: deactivated)

$users_name

public string $users_name

Users username

$validation_key

public string $validation_key

used for email link to reset or create a password for a survey participant Link is send when user is created or password has been reset

$validation_key_expiration

public string $validation_key_expiration

datetime when the validation key expires

$xssFilterAttributes

protected array<string|int, string> $xssFilterAttributes = []

Array of attributes that should be XSS filtered on mass updates

Methods

attributeLabels()

public attributeLabels() : mixed

behaviors()

Lists the behaviors of this model

public behaviors() : array<string|int, mixed>

Below is a list of all behaviors we register:

Tags
see
PluginEventBehavior
see
CTimestampBehavior
Return values
array<string|int, mixed>

canEdit()

Return true if user with id $managerId can edit this user

public canEdit([int|null $managerId = null ]) : bool
Parameters
$managerId : int|null = null

default to current user

Return values
bool

canLogin()

Check if user can login

public canLogin() : bool
Return values
bool

checkPassword()

Check if password is OK for current \User

public checkPassword(string $sPassword) : bool
Parameters
$sPassword : string

The clear password

Return values
bool

checkPasswordStrength()

public checkPasswordStrength(string $password) : mixed
Parameters
$password : string
Tags
todo

document me

decrypt()

Decrypt values from database

public decrypt([mixed $value = '' ]) : mixed
Parameters
$value : mixed = ''

decryptEncryptAttributes()

Encrypt/decrypt values

public decryptEncryptAttributes([mixed $action = 'decrypt' ]) : mixed
Parameters
$action : mixed = 'decrypt'

decryptSingle()

Decrypt single value

public static decryptSingle([string $value = '' ]) : string
Parameters
$value : string = ''

String value which needs to be decrypted

Return values
string

the decrypted string

decryptSingleOld()

Decrypt single value

public static decryptSingleOld([string $value = '' ]) : string
Parameters
$value : string = ''

String value which needs to be decrypted

Return values
string

the decrypted string

deleteAllByAttributes()

public deleteAllByAttributes(array<string|int, mixed> $attributes[, string $condition = '' ][, array<string|int, mixed> $params = [] ]) : int
Parameters
$attributes : array<string|int, mixed>

list of attribute values (indexed by attribute names) that the active records should match. An attribute value can be an array which will be used to generate an IN condition.

$condition : string = ''

query condition or criteria.

$params : array<string|int, mixed> = []

parameters to be bound to an SQL statement.

Tags
todo

This should also be moved to the behavior at some point. This method overrides the parent in order to raise PluginEvents for Bulk delete operations.

Filter Criteria are wrapped into a CDBCriteria instance so we have a single instance responsible for holding the filter criteria to be passed to the PluginEvent, this also enables us to pass the fully configured CDBCriteria instead of the original Parameters.

See for detailed explanation about $condition and $params.

Return values
int

number of rows affected by the execution.

dispatchPluginModelEvent()

public dispatchPluginModelEvent(string $sEventName, CDbCriteria $criteria = null, array<string|int, mixed> $eventParams = []) : PluginEvent
Parameters
$sEventName : string
$criteria = null : CDbCriteria
$eventParams = [] : array<string|int, mixed>
Return values
PluginEvent

encryptAttributeValues()

Attribute values are encrypted ( if needed )to be used for searching purposes

public encryptAttributeValues([array<string|int, mixed> $attributes = null ][, mixed $bEncryptedOnly = false ][, mixed $bReplaceValues = true ]) : array<string|int, mixed>
Parameters
$attributes : array<string|int, mixed> = null

list of attribute values (indexed by attribute names) that the active records should match. An attribute value can be an array which will be used to generate an IN condition.

$bEncryptedOnly : mixed = false
$bReplaceValues : mixed = true
Return values
array<string|int, mixed>

attributes array with encrypted atrribute values is returned

encryptSave()

Encrypt values before saving to the database

public encryptSave([mixed $runValidation = false ]) : mixed
Parameters
$runValidation : mixed = false

encryptSingle()

Enrypt single value

public static encryptSingle([string $value = '' ]) : mixed
Parameters
$value : string = ''

String value which needs to be encrypted

findAllAsArray()

Finds all active records satisfying the specified condition but returns them as array

public findAllAsArray([mixed $condition = '' ][, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>

See for detailed explanation about $condition and $params.

Parameters
$condition : mixed = ''

query condition or criteria.

$params : array<string|int, mixed> = []

parameters to be bound to an SQL statement.

Return values
array<string|int, mixed>

list of active records satisfying the specified condition. An empty array is returned if none is found.

findAllByAttributes()

Overriding of Yii's findAllByAttributes method to provide encrypted attribute value search

public findAllByAttributes(array<string|int, mixed> $attributes[, mixed $condition = '' ][, array<string|int, mixed> $params = [] ]) : array<string|int, static>
Parameters
$attributes : array<string|int, mixed>

list of attribute values (indexed by attribute names) that the active records should match. An attribute value can be an array which will be used to generate an IN condition.

$condition : mixed = ''

query condition or criteria.

$params : array<string|int, mixed> = []

parameters to be bound to an SQL statement.

Return values
array<string|int, static>

the records found. An empty array is returned if none is found.

findByAttributes()

Overriding of Yii's findByAttributes method to provide encrypted attribute value search

public findByAttributes(array<string|int, mixed> $attributes[, mixed $condition = '' ][, array<string|int, mixed> $params = [] ]) : static|null
Parameters
$attributes : array<string|int, mixed>

list of attribute values (indexed by attribute names) that the active record should match. An attribute value can be an array which will be used to generate an IN condition.

$condition : mixed = ''

query condition or criteria.

$params : array<string|int, mixed> = []

parameters to be bound to an SQL statement.

Return values
static|null

the record found. Null if none is found.

findByUsername()

Finds user by username

public static findByUsername(string $sUserName) : User
Parameters
$sUserName : string
Return values
User

getAllEncryptedAttributes()

public getAllEncryptedAttributes(int $iSurveyId, string $sClassName) : array<string|int, mixed>
Parameters
$iSurveyId : int
$sClassName : string
Return values
array<string|int, mixed>

TODO: Should be split into seperate functions in the appropiate model or helper class TODO: Make an interface for records that support encryption.

getAuthTypeDescription()

Return the related descriptive UserKey value for this auth type

public getAuthTypeDescription() : string
Return values
string

getButtons()

Returns the action columsn buttons

public getButtons() : string
Return values
string

getColumns()

public getColumns() : array<string|int, mixed>
Tags
inheritDoc
Return values
array<string|int, mixed>

getColums()

public getColums() : array<string|int, mixed>
Return values
array<string|int, mixed>

getCommonUID()

Returns User ID common in Survey_Permissions and User_in_groups

public getCommonUID( $surveyid,  $postusergroupid) : CDbDataReader
Parameters
$surveyid :
$postusergroupid :
Return values
CDbDataReader

getDateFormat()

public getDateFormat() : string
Return values
string

getDisplayName()

Get the decription to be used in list

public getDisplayName() : string
Return values
string

getFormattedDateCreated()

public getFormattedDateCreated() : mixed
Tags
todo

Not used?

getGroupList()

public getGroupList() : mixed
Tags
todo

document me

getGroupMemberListButtons()

Returns button for gridview.

public getGroupMemberListButtons() : string
Return values
string

getHasAuthSet()

Returns a check value of if the user has a bound 2FA secret key

public getHasAuthSet() : bool
Return values
bool

getLastloginFormatted()

Returns the last login formatted for displaying.

public getLastloginFormatted() : string
Return values
string

getManagementButtons()

Gets the buttons for the GridView

public getManagementButtons() : string
Return values
string

getManagementCheckbox()

public getManagementCheckbox() : mixed

getManagementColums()

public getManagementColums() : array<string|int, mixed>
Return values
array<string|int, mixed>

getMaxId()

Return the max value for a field

public getMaxId([string $field = null ][, bool $forceRefresh = false ]) : false|int

This is a convenience method, that uses the primary key of the model to retrieve the highest value.

Parameters
$field : string = null

The field that contains the Id, when null primary key is used if it is a single field

$forceRefresh : bool = false

Don't use value from static cache but always requery the database

Tags
throws
Exception
Return values
false|int

getMinId()

Return the min value for a field

public getMinId([string $field = null ][, bool $forceRefresh = false ]) : false|int

This is a convenience method, that uses the primary key of the model to retrieve the highest value.

Parameters
$field : string = null

The field that contains the Id, when null primary key is used if it is a single field

$forceRefresh : bool = false

Don't use value from static cache but always requery the database

Tags
throws
Exception
Return values
false|int

getParentUserName()

public getParentUserName() : mixed

getPasswordHelpText()

public getPasswordHelpText() : mixed
Tags
todo

document me

getRoleList()

public getRoleList() : mixed

getSuperAdmins()

Return all super admins in the system

public getSuperAdmins() : array<string|int, User>
Return values
array<string|int, User>

getSurveysCreated()

public getSurveysCreated() : string
Return values
string

insertRecords()

Adds user record

public insertRecords(array<string|int, mixed> $data) : string
Parameters
$data : array<string|int, mixed>
Tags
access

public

deprecated

: just don't use it

Return values
string

insertUser()

Creates new user

public static insertUser(string $new_user, string $new_pass, string $new_full_name, int $parent_user, string $new_email[, string|null $expires = null ][, bool $status = true ]) : int|bool
Parameters
$new_user : string
$new_pass : string
$new_full_name : string
$parent_user : int
$new_email : string
$expires : string|null = null
$status : bool = true
Tags
access

public

Return values
int|bool

User ID if success

isActive()

Check if user is active

public isActive() : bool
Return values
bool

isExpired()

Returns true if the user has expired.

public isExpired() : bool
Return values
bool

model()

public static model([mixed $className = __CLASS__ ]) : User
Parameters
$className : mixed = __CLASS__
Tags
inheritDoc
Return values
User

primaryKey()

public primaryKey() : mixed
Tags
inheritdoc

relations()

public relations() : mixed
Tags
inheritDoc

rules()

public rules() : mixed
Tags
inheritDoc

scopes()

public scopes() : mixed
Tags
inheritdoc
public search() : mixed
Tags
inheritDoc

searchUserGroupMembers()

public searchUserGroupMembers( $userGroupId) : CActiveDataProvider
Parameters
$userGroupId :
Return values
CActiveDataProvider

setActivationStatus()

Set user activation status

public setActivationStatus([string $status = 'activate' ]) : bool
Parameters
$status : string = 'activate'
Return values
bool

setEncryptedAttributeLabel()

Function to show encryption symbol in gridview attribute header if value ois encrypted

public setEncryptedAttributeLabel(int $surveyId, string $className, string $attributeName) : string
Parameters
$surveyId : int
$className : string
$attributeName : string
Tags
throws
CException
Return values
string

setPassword()

Set user password with hash

public setPassword(string $sPassword[, mixed $save = false ]) : User
Parameters
$sPassword : string

The clear text password

$save : mixed = false
Return values
User

setValidationExpiration()

Creates the validation key expiration date and save it in db

public setValidationExpiration() : bool
Tags
throws
Exception
Return values
bool

true if datetime could be saved, false otherwise

setValidationKey()

Creates a validation key and saves it in table user for this user.

public setValidationKey() : bool
Return values
bool

true if validation_key could be saved in db, false otherwise

tableName()

public tableName() : mixed
Tags
inheritdoc

updateAll()

Updates records with the specified condition.

public updateAll(array<string|int, mixed> $attributes[, mixed $condition = '' ][, array<string|int, mixed> $params = array() ]) : int

XSS filtering is enforced for attributes listed in model's $xssFilterAttributes property. See for detailed explanation about $condition and $params. Note, the attributes are not checked for safety and no validation is done.

Parameters
$attributes : array<string|int, mixed>

list of attributes (name=>$value) to be updated

$condition : mixed = ''

query condition or criteria.

$params : array<string|int, mixed> = array()

parameters to be bound to an SQL statement.

Return values
int

the number of rows being updated

updatePassword()

Updates user password hash

public static updatePassword(int $iUserID, string $sPassword) : int
Parameters
$iUserID : int

The User ID

$sPassword : string

The clear text password

Return values
int

number of rows updated

validateNewPassword()

Checks if -- password strength -- oldpassword is correct -- oldpassword and newpassword are identical -- newpassword and repeatpassword are identical -- newpassword is not empty

public validateNewPassword(string $newPassword, string $oldPassword, string $repeatPassword) : string
Parameters
$newPassword : string
$oldPassword : string
$repeatPassword : string
Return values
string

empty string means everything is ok, otherwise error message is returned

afterDelete()

protected afterDelete() : mixed
Tags
inheritDoc

Delete user in related model after deletion return void

query()

Modified version that default to do the same as the original, but allows via a third parameter to retrieve the result as array instead of active records. This solves a joining problem. Usage via findAllAsArray method

protected query(CDbCriteria $criteria[, bool $all = false ][, bool $asAR = true ]) : mixed

Performs the actual DB query and populates the AR objects with the query result. This method is mainly internally used by other AR query methods.

Parameters
$criteria : CDbCriteria

the query criteria

$all : bool = false

whether to return all data

$asAR : bool = true
Tags
since
1.1.7
Return values
mixed

the AR objects populated with the query result


        
On this page

Search results