LimeSurvey API - Master branch

Token extends Dynamic
in package

AbstractYes

Class Token

Table of Contents

Constants

DEFAULT_LENGTH  = 15
MAX_LENGTH  = 36

Properties

$bEncryption  : mixed
$blacklisted  : string
$completed  : string
$email  : string
$emailstatus  : string
$firstname  : string
$language  : string
$lastname  : string
$mpid  : int
$participant_id  : string
$remindercount  : int
$remindersent  : string
$responses  : array<string|int, Response>
$sent  : string
$survey  : Survey
$surveylink  : SurveyLink
$tableSchema  : CDbTableSchema
$tid  : int
$token  : string
$usesleft  : int
$validfrom  : string
$validuntil  : string
$dynamicId  : int
Prefixed with _ to not collide with column names.
$xssFilterAttributes  : array<string|int, string>

Methods

__construct()  : mixed
Dynamic constructor.
attributeLabels()  : mixed
beforeDelete()  : mixed
behaviors()  : array<string|int, mixed>
Lists the behaviors of this model
create()  : Token
createTable()  : CDbTableSchema
decrypt()  : mixed
Decrypt values from database
decryptEncryptAttributes()  : mixed
Encrypt/decrypt values
decryptSingle()  : string
Decrypt single value
decryptSingleOld()  : string
Decrypt single value
deleteAllByAttributes()  : mixed
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
findByToken()  : Token
generateToken()  : mixed
Generates a token for this object.
generateTokens()  : array<string|int, int>
Generates a token for all token objects in this survey.
getAllEncryptedAttributes()  : array<string|int, mixed>
getDefaultEncryptionOptions()  : mixed
getDynamicId()  : mixed
getMaxId()  : false|int
Return the max value for a field
getMinId()  : false|int
Return the min value for a field
getSurveyId()  : int
Get current surveyId for other model/function
getSurveyTokenLength()  : mixed
Get survey token length from survey.
init()  : mixed
Set defaults
model()  : Token
onBeforeSave()  : mixed
primaryKey()  : mixed
relations()  : mixed
rules()  : mixed
sanitizeAttribute()  : string
Sanitize string for any attribute
sanitizeToken()  : string
Sanitize token show to the user (replace sanitize_helper sanitize_token)
scopes()  : mixed
setEncryptedAttributeLabel()  : string
Function to show encryption symbol in gridview attribute header if value ois encrypted
summary()  : CDbDataReader|mixed
tableName()  : mixed
updateAll()  : int
Updates records with the specified condition.
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
generateRandomToken()  : string
Creates a random token string without special characters

Constants

DEFAULT_LENGTH

public int DEFAULT_LENGTH = 15

Default token length

MAX_LENGTH

public int MAX_LENGTH = 36

Maximum token length

Properties

$blacklisted

public string $blacklisted

Whether participant is blocklisted: (Y/N)

$completed

public string $completed

Participant completed status (N:Not completed; Q:Locked with quota; 'YYYY-MM-DD hh:mm': date of completion)

$email

public string $email

Participant's e-mail address

$emailstatus

public string $emailstatus

Participant's e-mail address status: OK/bounced/OptOut

$firstname

public string $firstname

Participant's first name

$language

public string $language

Participant's language eg: en

$lastname

public string $lastname

Participant's last name

$mpid

public int $mpid

//TODO Describe me!

$participant_id

public string $participant_id

Participant ID

$remindercount

public int $remindercount

$remindersent

public string $remindersent

$tableSchema

public CDbTableSchema $tableSchema

$tid

public int $tid

Token ID

$token

public string $token

Participant's token

$usesleft

public int $usesleft

How many uses left to fill questionnaire for this participant

$validfrom

public string $validfrom

$validuntil

public string $validuntil

$dynamicId

Prefixed with _ to not collide with column names.

protected int $dynamicId

The dynamic part of the class name.

$xssFilterAttributes

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

Array of attributes that should be XSS filtered on mass updates

Methods

__construct()

Dynamic constructor.

public __construct([string $scenario = 'insert' ]) : mixed
Parameters
$scenario : string = 'insert'

attributeLabels()

public attributeLabels() : mixed
Tags
inheritdoc

beforeDelete()

public beforeDelete() : mixed
Tags
inheritdoc

Delete related SurveyLink if it's deleted

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>

create()

public static create(int $id[, string $scenario = 'insert' ]) : Token
Parameters
$id : int

Survey id in this class

$scenario : string = 'insert'
Return values
Token

Description

createTable()

public static createTable(int $surveyId[, array<string|int, mixed> $extraFields = array() ]) : CDbTableSchema
Parameters
$surveyId : int
$extraFields : array<string|int, mixed> = array()
Return values
CDbTableSchema

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(mixed $attributes[, mixed $condition = '' ][, mixed $params = array() ]) : mixed
Parameters
$attributes : mixed
$condition : mixed = ''
$params : mixed = array()
Tags
inheritdoc

Delete related SurveyLink at same time

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.

findByToken()

public findByToken(string $token) : Token
Parameters
$token : string
Return values
Token

generateToken()

Generates a token for this object.

public generateToken([mixed $iTokenLength = null ]) : mixed
Parameters
$iTokenLength : mixed = null
Tags
throws
CHttpException

generateTokens()

Generates a token for all token objects in this survey.

public generateTokens() : array<string|int, int>

Syntax: Token::model(12345)->generateTokens();

Tags
throws
Exception
Return values
array<string|int, int>

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.

getDefaultEncryptionOptions()

public static getDefaultEncryptionOptions() : mixed

getDynamicId()

public getDynamicId() : 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

getSurveyId()

Get current surveyId for other model/function

public getSurveyId() : int
Return values
int

getSurveyTokenLength()

Get survey token length from survey.

public getSurveyTokenLength() : mixed

Use default if not possible.

init()

Set defaults

public init() : mixed
Tags
inheritdoc

model()

public static model([mixed $className = null ]) : Token
Parameters
$className : mixed = null
Tags
inheritdoc
Return values
Token

onBeforeSave()

public onBeforeSave(mixed $event) : mixed
Parameters
$event : mixed

primaryKey()

public primaryKey() : mixed
Tags
inheritdoc

relations()

public relations() : mixed

rules()

public rules() : mixed
Tags
inheritdoc

sanitizeAttribute()

Sanitize string for any attribute

public static sanitizeAttribute(string $attribute) : string
Parameters
$attribute : string

to sanitize

Return values
string

sanitized attribute

sanitizeToken()

Sanitize token show to the user (replace sanitize_helper sanitize_token)

public static sanitizeToken(string $token) : string
Parameters
$token : string

to sanitize

Return values
string

sanitized token

scopes()

public scopes() : mixed
Tags
inheritdoc

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

summary()

public summary() : CDbDataReader|mixed
Return values
CDbDataReader|mixed

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

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

generateRandomToken()

Creates a random token string without special characters

private generateRandomToken(int $iTokenLength) : string
Parameters
$iTokenLength : int
Return values
string

        
On this page

Search results