SurveyDynamic
extends LSActiveRecord
in package
Table of Contents
Properties
- $bEncryption : mixed
- $completed_filter : string
- $email_filter : string
- $firstname_filter : string
- $lastname_filter : string
- $lastpage : int
- $bHaveToken : bool
- $sid : int
- $survey : Survey
- $xssFilterAttributes : array<string|int, string>
Methods
- addTimingCriteria() : CDbCriteria
- Return criteria updated with the ones needed for including results from the timings table
- addTokenCriteria() : CDbCriteria
- Return criteria updated with the ones needed for including results from the survey participants table
- behaviors() : array<string|int, mixed>
- Lists the behaviors of this model
- countAllAndPartial() : array<string|int, mixed>
- decrypt() : mixed
- Decrypt values from database
- decryptBeforeOutput() : void
- Decrypts all encrypted response values for output (e.g. printanswers, detailed admin info)
- decryptEncryptAttributes() : mixed
- Encrypt/decrypt values
- decryptSingle() : string
- Decrypt single value
- decryptSingleOld() : string
- Decrypt single value
- deleteAllByAttributes() : int
- deleteSomeRecords() : int|CDbCriteria
- Deletes some records from survey's table according to specific condition
- 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
- exist() : bool
- Return true if actual response exist in database
- 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
- getAllEncryptedAttributes() : array<string|int, mixed>
- getButtons() : string
- Get buttons HTML for response browse view.
- getCompleted() : string
- For grid list
- getDefaultColumns() : array<string|int, string>
- Get the list of default columns for surveys
- getEllipsize_header_value() : mixed
- Define what value to use to ellipsize the headers of the grid It's using user state/default config, like for pagination
- getEllipsize_question_value() : mixed
- Define what value to use to ellipsize the question in the grid It's using user state/default config, like for pagination.
- getExtendedData() : string
- getFirstNameForGrid() : string
- getGridButtons() : string
- Return the buttons columns This is the button column for response table
- getLastNameForGrid() : string
- getMaxId() : false|int
- Return the max value for a field
- getMinId() : false|int
- Return the min value for a field
- getPrintAnswersArray() : mixed
- getQuestionArray() : array<string|int, mixed>
- Get an array to find question data responsively This should be part of the question object.
- getSurvey() : Survey
- Get current survey for other model/function Using a getter to avoid query during model creation
- getSurveyId() : int
- Get current surveyId for other model/function
- getTokenForGrid() : string
- insertRecords() : bool
- Insert records from $data array
- isCompleted() : bool
- Return true if actual survey is completed
- model() : SurveyDynamic
- next() : int
- Return next id if next response exist in database
- previous() : int
- Return previous id if previous response exist in database
- primaryKey() : mixed
- relations() : mixed
- search() : CActiveDataProvider
- setEncryptedAttributeLabel() : string
- Function to show encryption symbol in gridview attribute header if value ois encrypted
- sid() : void
- Sets the survey ID for the next model
- tableName() : mixed
- timeline() : array<string|int, mixed>|bool
- Function that returns a time-line of the surveys submissions
- updateAll() : int
- Updates records with the specified condition.
- filterColumns() : void
- Loop through columns and add filter if any value is given for this column Used in responses grid
- joinWithToken() : void
- 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
- getbHaveToken() : bool
Properties
$bEncryption
public
mixed
$bEncryption
= \false
$completed_filter
public
string
$completed_filter
$email_filter
public
string
$email_filter
$firstname_filter
public
string
$firstname_filter
$lastname_filter
public
string
$lastname_filter
$lastpage
public
int
$lastpage
$bHaveToken
protected
bool
$bHaveToken
$sid
protected
static int
$sid
= 0
$survey
protected
static Survey
$survey
$xssFilterAttributes
protected
array<string|int, string>
$xssFilterAttributes
= []
Array of attributes that should be XSS filtered on mass updates
Methods
addTimingCriteria()
Return criteria updated with the ones needed for including results from the timings table
public
addTimingCriteria(array<string|int, mixed> $condition) : CDbCriteria
Parameters
- $condition : array<string|int, mixed>
Return values
CDbCriteriaaddTokenCriteria()
Return criteria updated with the ones needed for including results from the survey participants table
public
addTokenCriteria(string $condition) : CDbCriteria
Parameters
- $condition : string
Return values
CDbCriteriabehaviors()
Lists the behaviors of this model
public
behaviors() : array<string|int, mixed>
Below is a list of all behaviors we register:
Tags
Return values
array<string|int, mixed>countAllAndPartial()
public
static countAllAndPartial(int $sid) : array<string|int, mixed>
Parameters
- $sid : int
Return values
array<string|int, mixed>decrypt()
Decrypt values from database
public
decrypt([mixed $value = '' ]) : mixed
Parameters
- $value : mixed = ''
decryptBeforeOutput()
Decrypts all encrypted response values for output (e.g. printanswers, detailed admin info)
public
decryptBeforeOutput() : void
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
Return values
int —number of rows affected by the execution.
deleteSomeRecords()
Deletes some records from survey's table according to specific condition
public
static deleteSomeRecords([array<string|int, mixed>|bool $condition = false ]) : int|CDbCriteria
Parameters
- $condition : array<string|int, mixed>|bool = false
Tags
Return values
int|CDbCriteriadispatchPluginModelEvent()
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
PluginEventencrypt()
Encrypt values
public
encrypt() : mixed
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
exist()
Return true if actual response exist in database
public
exist(int $srid) : bool
Parameters
- $srid : int
-
: actual save survey ID
Return values
boolfindAllAsArray()
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>
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.
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.
getButtons()
Get buttons HTML for response browse view.
public
getButtons() : string
Tags
Return values
string —HTML
getCompleted()
For grid list
public
getCompleted() : string
Return values
stringgetDefaultColumns()
Get the list of default columns for surveys
public
getDefaultColumns() : array<string|int, string>
Return values
array<string|int, string>getEllipsize_header_value()
Define what value to use to ellipsize the headers of the grid It's using user state/default config, like for pagination
public
getEllipsize_header_value() : mixed
Tags
getEllipsize_question_value()
Define what value to use to ellipsize the question in the grid It's using user state/default config, like for pagination.
public
getEllipsize_question_value() : mixed
Tags
getExtendedData()
public
getExtendedData(string $colName, string $sLanguage, string $base64jsonFieldMap) : string
Parameters
- $colName : string
- $sLanguage : string
- $base64jsonFieldMap : string
Return values
stringgetFirstNameForGrid()
public
getFirstNameForGrid() : string
Return values
stringgetGridButtons()
Return the buttons columns This is the button column for response table
public
getGridButtons() : string
Tags
Return values
stringgetLastNameForGrid()
public
getLastNameForGrid() : string
Return values
stringgetMaxId()
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
Return values
false|intgetMinId()
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
Return values
false|intgetPrintAnswersArray()
public
getPrintAnswersArray(mixed $sSRID, mixed $sLanguage[, mixed $bHonorConditions = false ]) : mixed
Parameters
- $sSRID : mixed
- $sLanguage : mixed
- $bHonorConditions : mixed = false
getQuestionArray()
Get an array to find question data responsively This should be part of the question object.
public
getQuestionArray(Question $oQuestion, SurveyDynamic $oResponses, bool $bHonorConditions[, bool $subquestion = false ][, bool $getCommentOnly = false ][, mixed $sLanguage = null ]) : array<string|int, mixed>
And in future development this should be part of the specific question type object
Parameters
- $oQuestion : Question
- $oResponses : SurveyDynamic
- $bHonorConditions : bool
- $subquestion : bool = false
- $getCommentOnly : bool = false
-
If should only returns the "comments" or "other" response.
- $sLanguage : mixed = null
Return values
array<string|int, mixed> —| boolean
getSurvey()
Get current survey for other model/function Using a getter to avoid query during model creation
public
getSurvey() : Survey
Return values
SurveygetSurveyId()
Get current surveyId for other model/function
public
getSurveyId() : int
Return values
intgetTokenForGrid()
public
getTokenForGrid() : string
Return values
stringinsertRecords()
Insert records from $data array
public
insertRecords(array<string|int, mixed> $data) : bool
Parameters
- $data : array<string|int, mixed>
Tags
Return values
boolisCompleted()
Return true if actual survey is completed
public
isCompleted(int $srid) : bool
Parameters
- $srid : int
-
: actual save survey ID
Return values
boolmodel()
public
static model([mixed $sid = null ]) : SurveyDynamic
Parameters
- $sid : mixed = null
Tags
Return values
SurveyDynamicnext()
Return next id if next response exist in database
public
next(int $srId[, bool $useFilterState = false ]) : int
Parameters
- $srId : int
-
: actual save survey ID
- $useFilterState : bool = false
Return values
intprevious()
Return previous id if previous response exist in database
public
previous(int $srId[, bool $useFilterState = false ]) : int
Parameters
- $srId : int
-
: actual save survey ID
- $useFilterState : bool = false
Return values
intprimaryKey()
public
primaryKey() : mixed
Tags
relations()
public
relations() : mixed
Tags
search()
public
search() : CActiveDataProvider
Return values
CActiveDataProvidersetEncryptedAttributeLabel()
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
Return values
stringsid()
Sets the survey ID for the next model
public
static sid(int $sid) : void
Parameters
- $sid : int
Tags
tableName()
public
tableName() : mixed
Tags
timeline()
Function that returns a time-line of the surveys submissions
public
timeline(string $sType, string $dStart, string $dEnd) : array<string|int, mixed>|bool
Parameters
- $sType : string
- $dStart : string
- $dEnd : string
Tags
Return values
array<string|int, mixed>|boolupdateAll()
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
filterColumns()
Loop through columns and add filter if any value is given for this column Used in responses grid
protected
filterColumns(CdbCriteria $criteria) : void
Parameters
- $criteria : CdbCriteria
joinWithToken()
protected
joinWithToken(CDbCriteria $criteria, CSort $sort) : void
Parameters
- $criteria : CDbCriteria
- $sort : CSort
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
Return values
mixed —the AR objects populated with the query result
getbHaveToken()
private
getbHaveToken() : bool