Participant
extends LSActiveRecord
in package
This is the model class for table "{{participants}}".
The following are the available columns in table '{{participants}}':
Table of Contents
Properties
- $allExtraAttributes : array<string|int, mixed>
- $bEncryption : mixed
- $blacklisted : string
- $blacklistSwitchButton : string
- $buttons : string
- $checkbox : string
- $columns : array<string|int, mixed>
- $countActiveSurveys : int|string
- $countActiveSurveys : mixed
- $created : string
- $created_by : int
- $email : string
- $extraCondition : mixed
- $firstname : string
- $id : mixed
- $language : string
- $lastname : string
- $modified : string
- $owner : User
- $owner_uid : int
- $ownersList : string
- $participant_id : string
- $participantAttributes : array<string|int, ParticipantAttribute>
- $shares : array<string|int, ParticipantShare>
- $surveylinks : array<string|int, SurveyLink>
- $sid : int
- $xssFilterAttributes : array<string|int, string>
Methods
- addSurveyFilter() : mixed
- Add Survey Filter
- attributeLabels() : array<string|int, mixed>
- behaviors() : array<string|int, mixed>
- Lists the behaviors of this model
- checkforDuplicate() : string|bool
- The purpose of this function is to check for duplicate in participants
- copyCPDBAttributesToTokens() : array<string|int, mixed>
- Copies central attributes/participants to an individual survey survey participant list
- copyToCentral() : array<string|int, mixed>
- Copies token participants to the central participant list, and also copies token attribute values where applicable. It checks for matching entries using firstname/lastname/email combination.
- decrypt() : mixed
- Decrypt values from database
- decryptEncryptAttributes() : mixed
- Encrypt/decrypt values
- decryptSingle() : string
- Decrypt single value
- decryptSingleOld() : string
- Decrypt single value
- deleteAllByAttributes() : int
- deleteParticipants() : int
- This function deletes the participant from the participant list, references in the survey_links table (but not in matching tokens tables) and then all the participants attributes.
- deleteParticipantToken() : int
- Deletes CPDB participants identified by their participant ID from survey participant lists
- deleteParticipantTokenAnswer() : int
- This function deletes the participant from the participant list, the participant from any tokens table they're in (using the survey_links table to find them), all responses in surveys they've been linked to, and then all the participants attributes.
- 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
- Encrypt single value
- filterParticipantIDs() : array<string|int, int>
- Filter an array of participants IDs according to permissions of the person being logged in
- 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
- genUuid() : string
- Function for generation of unique id
- getAllEncryptedAttributes() : array<string|int, mixed>
- getAllExtraAttributes() : array<string|int, mixed>
- getAllUsedLanguagesWithRealName() : mixed
- getBlacklistedParticipantIds() : array<string|int, string>
- Returns the list of blocklisted participant IDs
- getBlacklistSwitchbutton() : string
- getButtons() : string
- Returns buttons for grid view
- getCheckbox() : string
- getColumns() : array<string|int, mixed>
- getCountActiveSurveys() : int|string
- getCreatedFormatted() : string
- 'created' field formatted; empty string if no timestamp in database
- getDefaultEncryptionOptions() : array<string|int, mixed>
- Return Default Encryption Options
- getLanguageOptions() : mixed
- Get Language Options.
- getMaxId() : false|int
- Return the max value for a field
- getMinId() : false|int
- Return the min value for a field
- getOptionsForAttribute() : array<string|int, mixed>
- Get options for a drop-down attribute
- getOwnerOptions() : mixed
- Get Owner Options
- getOwnersList() : string
- getParticipantAttribute() : string
- getParticipants() : array<string|int, mixed>
- getParticipantsCount() : int
- Duplicated from getparticipants, only to have a count
- getParticipantsCountWithoutLimit() : string
- Get the number of participants, no restrictions
- getParticipantsEncryptionOptions() : array<string|int, mixed>
- decodes the tokenencryptionoptions to be used anywhere necessary
- getParticipantShared() : array<string|int, mixed>
- This function is responsible for showing all the participant's shared by a particular user based on the user id
- getParticipantSharedAll() : array<string|int, mixed>
- This function is responsible for showing all the participant's shared to the superadmin
- getParticipantsOwner() : array<string|int, Participant>
- This function returns a list of participants who are either owned or shared with a specific user
- getParticipantsOwnerCount() : int
- getParticipantsSearchMultiple() : array<string|int, mixed>
- Function builds a select query for searches through participants using the $condition field passed which is in the format "firstfield||sqloperator||value||booleanoperator||secondfield||sqloperator||value||booleanoperator||etc||etc||etc" for example: "firstname||equal||Jason||and||lastname||equal||Cleeland" will produce SQL along the lines of "WHERE firstname = 'Jason' AND lastname=='Cleeland'"
- getParticipantsSearchMultipleCondition() : CDbCriteria
- Function builds a select query for searches through participants using the $condition field passed which is in the format "firstfield||sqloperator||value||booleanoperator||secondfield||sqloperator||value||booleanoperator||etc||etc||etc" for example: "firstname||equal||Jason||and||lastname||equal||Cleeland" will produce SQL along the lines of "WHERE firstname = 'Jason' AND lastname=='Cleeland'"
- getParticipantsSharedCount() : int
- This function combines the shared participant and the central participant table and searches for any reference of owner id in the combined record of the two tables
- getParticipantsWithoutLimit() : array<string|int, Participant>
- getSurveyCount() : int
- getSurveyId() : int
- Get current surveyId for other model/function
- insertParticipant() : string|Participant
- This function is responsible for adding the participant to the database
- insertParticipantCSV() : void
- isOwner() : bool
- Returns true if participant_id has ownership or shared rights over this participant false if not
- isOwnerOrSuperAdmin() : bool
- Returns true if user is either owner of this participant or superadmin Used to decide is user can change owner of participant
- model() : Participant
- permissionCheckedActionsArray() : array<string|int, mixed>
- Checks Permissions for given $aActions and returns them as array
- primaryKey() : string
- Returns the primary key of this table
- relations() : mixed
- rules() : mixed
- search() : CActiveDataProvider
- Retrieves a list of models based on the current search/filter conditions.
- setEncryptedAttributeLabel() : string
- Function to show encryption symbol in gridview attribute header if value ois encrypted
- tableName() : mixed
- updateAll() : int
- Updates records with the specified condition.
- updateAttributeValueToken() : bool|null
- Updates or creates a field in the survey participant list with a value from the participant attributes table
- updateRow() : void
- This function updates the data edited in the view
- updateTokenAttributeValue() : bool
- Updates a field in the survey participant list with a value from the participant attributes table
- userHasPermissionToEdit() : bool
- Returns true if logged in user has edit rights to this participant
- 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
- addNewAttributesToSurveysAttributeDescriptions() : array<string|int, mixed>
- Adds new participant attributes to the survey's attribute descriptions.
- checkColumnDuplicates() : bool
- Check for column duplicates from CPDB to token attributes Throws error message if an attribute already exists; otherwise false.
- createColumnsInTokenTable() : void
- Creates new columns in the survey's token table for participant attributes.
- fetchAttributeData() : array<string|int, mixed>
- Fetches attribute data for multiple attributes in a single query.
- fetchDropdownOptions() : array<string|int, mixed>
- Fetches dropdown options for multiple attributes in a single query.
- flattenErrorMessages() : string
- Takes result from model->getErrors() and creates a long string of all messages.
- getParticipantsSelectCommand() : CDbCommand
- handleNewTokenAttributes() : array<string|int, mixed>
- Handles the creation of new token attributes by adding them to survey descriptions and creating corresponding columns.
- selectBestLanguageName() : string
- Selects the best language name based on priority: default survey language, admin language, or first available.
- updateSurveyAttributeDescriptions() : void
- Updates the survey's attribute descriptions with new field contents.
- updateTokenFieldProperties() : void
- Updates the token attribute properties of a survey to include the mapping to Central Participant Database (CPDB) attributes.
- writeParticipantsToTokenTable() : array<string|int, int>
- Write participants as tokens or something
Properties
$allExtraAttributes
public
array<string|int, mixed>
$allExtraAttributes
$bEncryption
public
mixed
$bEncryption
= \false
$blacklisted
public
string
$blacklisted
$blacklistSwitchButton
public
string
$blacklistSwitchButton
$buttons
public
string
$buttons
$checkbox
public
string
$checkbox
$columns
public
array<string|int, mixed>
$columns
$countActiveSurveys
public
int|string
$countActiveSurveys
$countActiveSurveys
public
mixed
$countActiveSurveys
$created
public
string
$created
Date-time of creation
$created_by
public
int
$created_by
public
string
$email
$extraCondition
public
mixed
$extraCondition
$firstname
public
string
$firstname
$id
public
mixed
$id
$language
public
string
$language
$lastname
public
string
$lastname
$modified
public
string
$modified
Date-time of modification
$owner
public
User
$owner
$owner_uid
public
int
$owner_uid
$ownersList
public
string
$ownersList
$participant_id
public
string
$participant_id
Primary Key
$participantAttributes
public
array<string|int, ParticipantAttribute>
$participantAttributes
$shares
public
array<string|int, ParticipantShare>
$shares
$surveylinks
public
array<string|int, SurveyLink>
$surveylinks
$sid
protected
static int
$sid
= 0
$xssFilterAttributes
protected
array<string|int, string>
$xssFilterAttributes
= []
Array of attributes that should be XSS filtered on mass updates
Methods
addSurveyFilter()
Add Survey Filter
public
addSurveyFilter( $conditions) : mixed
Parameters
attributeLabels()
public
attributeLabels() : array<string|int, mixed>
Return values
array<string|int, mixed> —customized attribute labels (name=>label)
behaviors()
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>checkforDuplicate()
The purpose of this function is to check for duplicate in participants
public
checkforDuplicate(string $fields[, string $output = "bool" ]) : string|bool
Parameters
- $fields : string
- $output : string = "bool"
Tags
Return values
string|boolcopyCPDBAttributesToTokens()
Copies central attributes/participants to an individual survey survey participant list
public
copyCPDBAttributesToTokens(int $surveyId, string $participantIds, array<string|int, mixed> $mappedAttributes, array<string|int, mixed> $newAttributes, array<string|int, mixed> $options) : array<string|int, mixed>
Parameters
- $surveyId : int
-
The survey ID
- $participantIds : string
-
Array containing the participant ids of the participants we are adding
- $mappedAttributes : array<string|int, mixed>
-
An array containing a list of /mapped attributes in the form of "token_field_name" => "participant_attribute_id"
- $newAttributes : array<string|int, mixed>
-
An array containing new attributes to create in the tokens table
- $options : array<string|int, mixed>
-
Array with following options: overwriteauto - If true, overwrite automatically mapped data overwriteman - If true, overwrite manually mapped data overwritest - If true, overwrite standard fields (ie: names, email, participant_id, token) createautomap - If true, rename the fieldnames of automapped attributes so that in future they are automatically mapped
Return values
array<string|int, mixed>copyToCentral()
Copies token participants to the central participant list, and also copies token attribute values where applicable. It checks for matching entries using firstname/lastname/email combination.
public
copyToCentral(int $surveyid, array<string|int, mixed> $aAttributesToBeCreated, array<string|int, mixed> $aMapped[, bool $overwriteauto = false ][, bool $overwriteman = false ][, bool $createautomap = true ]) : array<string|int, mixed>
TODO: Most of this belongs in the participantsaction.php controller file, not here in the model file. Portions of this should be moved out at some stage.
Parameters
- $surveyid : int
-
The id of the survey, used to find the appropriate tokens table
- $aAttributesToBeCreated : array<string|int, mixed>
-
An array containing the names of token attributes that have to be created in the cpdb
- $aMapped : array<string|int, mixed>
-
An array containing the names of token attributes that are to be mapped to an existing cpdb attribute
- $overwriteauto : bool = false
-
If true, overwrites existing automatically mapped attribute values
- $overwriteman : bool = false
-
If true, overwrites manually mapped attribute values (where token fieldname=attribute_n)
- $createautomap : bool = true
-
If true, updates tokendescription field with new mapping
Return values
array<string|int, mixed> —An array containing list of successful and list of failed ids
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
Return values
int —number of rows affected by the execution.
deleteParticipants()
This function deletes the participant from the participant list, references in the survey_links table (but not in matching tokens tables) and then all the participants attributes.
public
deleteParticipants(string $rows[, bool $bFilter = true ]) : int
Parameters
- $rows : string
-
Participants ID separated by comma
- $bFilter : bool = true
Return values
int —number of deleted participants
deleteParticipantToken()
Deletes CPDB participants identified by their participant ID from survey participant lists
public
deleteParticipantToken(string $sParticipantsIDs) : int
Parameters
- $sParticipantsIDs : string
Tags
Return values
int —Number of deleted participants
deleteParticipantTokenAnswer()
This function deletes the participant from the participant list, the participant from any tokens table they're in (using the survey_links table to find them), all responses in surveys they've been linked to, and then all the participants attributes.
public
deleteParticipantTokenAnswer(string $sParticipantsIDs) : int
Parameters
- $sParticipantsIDs : string
Tags
Return values
int —Number of deleted participants
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
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 attribute values is returned
encryptSave()
Encrypt values before saving to the database
public
encryptSave([mixed $runValidation = false ]) : mixed
Parameters
- $runValidation : mixed = false
encryptSingle()
Encrypt single value
public
static encryptSingle([string $value = '' ]) : mixed
Parameters
- $value : string = ''
-
String value which needs to be encrypted
filterParticipantIDs()
Filter an array of participants IDs according to permissions of the person being logged in
public
filterParticipantIDs(mixed $aParticipantIDs) : array<string|int, int>
Parameters
- $aParticipantIDs : mixed
Return values
array<string|int, int>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>
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.
genUuid()
Function for generation of unique id
public
static genUuid() : string
Return values
stringgetAllEncryptedAttributes()
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 separate functions in the appropriate model or helper class TODO: Make an interface for records that support encryption.
getAllExtraAttributes()
public
getAllExtraAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed>getAllUsedLanguagesWithRealName()
public
getAllUsedLanguagesWithRealName() : mixed
getBlacklistedParticipantIds()
Returns the list of blocklisted participant IDs
public
getBlacklistedParticipantIds() : array<string|int, string>
Return values
array<string|int, string>getBlacklistSwitchbutton()
public
getBlacklistSwitchbutton() : string
Return values
string —HTML
getButtons()
Returns buttons for grid view
public
getButtons() : string
Return values
stringgetCheckbox()
public
getCheckbox() : string
Return values
string —html
getColumns()
public
getColumns() : array<string|int, mixed>
Return values
array<string|int, mixed>getCountActiveSurveys()
public
getCountActiveSurveys() : int|string
Return values
int|stringgetCreatedFormatted()
'created' field formatted; empty string if no timestamp in database
public
getCreatedFormatted() : string
Return values
stringgetDefaultEncryptionOptions()
Return Default Encryption Options
public
static getDefaultEncryptionOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>getLanguageOptions()
Get Language Options.
public
getLanguageOptions() : 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
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|intgetOptionsForAttribute()
Get options for a drop-down attribute
public
getOptionsForAttribute(string $attribute_id) : array<string|int, mixed>
Parameters
- $attribute_id : string
Return values
array<string|int, mixed>getOwnerOptions()
Get Owner Options
public
getOwnerOptions() : mixed
getOwnersList()
public
getOwnersList(int $selected) : string
Parameters
- $selected : int
-
Owner id
Return values
string —HTML
getParticipantAttribute()
public
getParticipantAttribute(string $attributeTextId[, mixed $attribute_id = false ]) : string
Parameters
- $attributeTextId : string
-
E.g. ea_145
- $attribute_id : mixed = false
Return values
stringgetParticipants()
public
getParticipants(int $page, int $limit, array<string|int, mixed> $attid[, string|null $order = null ][, CDbCriteria $search = null ][, int $userid = null ]) : array<string|int, mixed>
Parameters
- $page : int
- $limit : int
- $attid : array<string|int, mixed>
- $order : string|null = null
- $search : CDbCriteria = null
- $userid : int = null
Tags
Return values
array<string|int, mixed>getParticipantsCount()
Duplicated from getparticipants, only to have a count
public
getParticipantsCount(array<string|int, mixed> $attid[, CDbCriteria $search = null ][, int $userid = null ]) : int
Parameters
- $attid : array<string|int, mixed>
- $search : CDbCriteria = null
- $userid : int = null
Return values
intgetParticipantsCountWithoutLimit()
Get the number of participants, no restrictions
public
getParticipantsCountWithoutLimit() : string
Return values
stringgetParticipantsEncryptionOptions()
decodes the tokenencryptionoptions to be used anywhere necessary
public
static getParticipantsEncryptionOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>getParticipantShared()
This function is responsible for showing all the participant's shared by a particular user based on the user id
public
getParticipantShared(int $userid) : array<string|int, mixed>
Parameters
- $userid : int
Return values
array<string|int, mixed>getParticipantSharedAll()
This function is responsible for showing all the participant's shared to the superadmin
public
getParticipantSharedAll() : array<string|int, mixed>
Return values
array<string|int, mixed>getParticipantsOwner()
This function returns a list of participants who are either owned or shared with a specific user
public
getParticipantsOwner(int $userid) : array<string|int, Participant>
Parameters
- $userid : int
-
The ID of the user that we are listing participants for
Return values
array<string|int, Participant> —objects containing all the users
getParticipantsOwnerCount()
public
getParticipantsOwnerCount(int $userid) : int
Parameters
- $userid : int
Return values
intgetParticipantsSearchMultiple()
Function builds a select query for searches through participants using the $condition field passed which is in the format "firstfield||sqloperator||value||booleanoperator||secondfield||sqloperator||value||booleanoperator||etc||etc||etc" for example: "firstname||equal||Jason||and||lastname||equal||Cleeland" will produce SQL along the lines of "WHERE firstname = 'Jason' AND lastname=='Cleeland'"
public
getParticipantsSearchMultiple(array<string|int, mixed> $condition, int $page, int $limit) : array<string|int, mixed>
Parameters
- $condition : array<string|int, mixed>
-
an array containing the search string exploded using || so that "firstname||equal||jason" is $condition(1=>'firstname', 2=>'equal', 3=>'jason')
- $page : int
-
Which page number to display
- $limit : int
-
The limit/number of records to return
Return values
array<string|int, mixed> —$output
getParticipantsSearchMultipleCondition()
Function builds a select query for searches through participants using the $condition field passed which is in the format "firstfield||sqloperator||value||booleanoperator||secondfield||sqloperator||value||booleanoperator||etc||etc||etc" for example: "firstname||equal||Jason||and||lastname||equal||Cleeland" will produce SQL along the lines of "WHERE firstname = 'Jason' AND lastname=='Cleeland'"
public
getParticipantsSearchMultipleCondition(array<string|int, mixed> $condition) : CDbCriteria
Parameters
- $condition : array<string|int, mixed>
-
an array containing the search string exploded using || so that "firstname||equal||jason" is $condition(1=>'firstname', 2=>'equal', 3=>'jason')
Return values
CDbCriteria —$output
getParticipantsSharedCount()
This function combines the shared participant and the central participant table and searches for any reference of owner id in the combined record of the two tables
public
getParticipantsSharedCount(int $userid) : int
Parameters
- $userid : int
-
The id of the owner
Return values
int —The number of participants owned by $userid who are shared
getParticipantsWithoutLimit()
public
getParticipantsWithoutLimit() : array<string|int, Participant>
Return values
array<string|int, Participant>getSurveyCount()
public
getSurveyCount(mixed $participant_id) : int
Parameters
- $participant_id : mixed
Return values
intgetSurveyId()
Get current surveyId for other model/function
public
getSurveyId() : int
Return values
intinsertParticipant()
This function is responsible for adding the participant to the database
public
insertParticipant(array<string|int, mixed> $aData) : string|Participant
Parameters
- $aData : array<string|int, mixed>
-
Participant data
Return values
string|Participant —Error message on failure, participant object on success
insertParticipantCSV()
public
insertParticipantCSV(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
isOwner()
Returns true if participant_id has ownership or shared rights over this participant false if not
public
isOwner(string $participant_id) : bool
Parameters
- $participant_id : string
Return values
boolisOwnerOrSuperAdmin()
Returns true if user is either owner of this participant or superadmin Used to decide is user can change owner of participant
public
isOwnerOrSuperAdmin() : bool
Return values
boolmodel()
public
static model([mixed $className = __CLASS__ ]) : Participant
Parameters
- $className : mixed = __CLASS__
Tags
Return values
ParticipantpermissionCheckedActionsArray()
Checks Permissions for given $aActions and returns them as array
public
permissionCheckedActionsArray(array<string|int, mixed> $aActions, array<string|int, mixed> $permissions) : array<string|int, mixed>
Parameters
- $aActions : array<string|int, mixed>
- $permissions : array<string|int, mixed>
Return values
array<string|int, mixed>primaryKey()
Returns the primary key of this table
public
primaryKey() : string
Tags
Return values
stringrelations()
public
relations() : mixed
Tags
rules()
public
rules() : mixed
Tags
search()
Retrieves a list of models based on the current search/filter conditions.
public
search() : CActiveDataProvider
Return values
CActiveDataProvider —the data provider that can return the models based on the search/filter conditions.
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
Return values
stringtableName()
public
tableName() : mixed
Tags
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
updateAttributeValueToken()
Updates or creates a field in the survey participant list with a value from the participant attributes table
public
updateAttributeValueToken(int $surveyId, int $participantId, int $participantAttributeId, int $tokenFieldname) : bool|null
Parameters
- $surveyId : int
-
Survey ID number
- $participantId : int
-
unique key for the participant
- $participantAttributeId : int
-
the unique key for the participant_attribute table
- $tokenFieldname : int
-
fieldname in the survey participant list
Return values
bool|null —true/false
updateRow()
This function updates the data edited in the view
public
updateRow(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
updateTokenAttributeValue()
Updates a field in the survey participant list with a value from the participant attributes table
public
updateTokenAttributeValue(int $surveyId, string $participantId, int $participantAttributeId, int $tokenFieldname) : bool
Parameters
- $surveyId : int
-
Survey ID number
- $participantId : string
-
unique key for the participant
- $participantAttributeId : int
-
the unique key for the participant_attribute table
- $tokenFieldname : int
-
fieldname in the survey participant list
Return values
bool —true/false
userHasPermissionToEdit()
Returns true if logged in user has edit rights to this participant
public
userHasPermissionToEdit() : bool
Return values
boolquery()
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
addNewAttributesToSurveysAttributeDescriptions()
Adds new participant attributes to the survey's attribute descriptions.
private
addNewAttributesToSurveysAttributeDescriptions(int $surveyId, array<string|int, mixed> $newAttributes) : array<string|int, mixed>
This function retrieves participant attribute information from the CPDB (Central Participant Database), creates field definitions for new token attributes, and updates the survey's attributedescriptions field in the database. It handles attribute names in multiple languages and supports dropdown type attributes with their associated options.
Parameters
- $surveyId : int
-
The ID of the survey to which attributes will be added.
- $newAttributes : array<string|int, mixed>
-
An array of participant attribute IDs from the CPDB to be added as token attributes.
Return values
array<string|int, mixed> —A two-element array containing:
- [0] array $addedAttributes: Array of participant attribute IDs that were successfully added.
- [1] array $addedAttributeIds: Array of token field names (e.g., 'attribute_1', 'attribute_2') for the added attributes.
checkColumnDuplicates()
Check for column duplicates from CPDB to token attributes Throws error message if an attribute already exists; otherwise false.
private
checkColumnDuplicates(int $surveyId, array<string|int, string> $newAttributes) : bool
Parameters
- $surveyId : int
- $newAttributes : array<string|int, string>
-
Array of CPDB attributes ids like ['42', '32', ...]
Tags
Return values
boolcreateColumnsInTokenTable()
Creates new columns in the survey's token table for participant attributes.
private
createColumnsInTokenTable(array<string|int, mixed> $addedAttributeIds, int $surveyId) : void
This function adds new attribute columns to the tokens table for a specific survey, then refreshes the database schema cache and model metadata to ensure the new columns are recognized by the application.
Parameters
- $addedAttributeIds : array<string|int, mixed>
-
An array of attribute field names (e.g., 'attribute_1', 'attribute_2') to be added as columns in the token table.
- $surveyId : int
-
The ID of the survey whose token table will be modified.
fetchAttributeData()
Fetches attribute data for multiple attributes in a single query.
private
fetchAttributeData(array<string|int, mixed> $attributeIds) : array<string|int, mixed>
Parameters
- $attributeIds : array<string|int, mixed>
-
Array of attribute IDs to fetch.
Return values
array<string|int, mixed> —Associative array with attribute IDs as keys and their data as values.
fetchDropdownOptions()
Fetches dropdown options for multiple attributes in a single query.
private
fetchDropdownOptions(array<string|int, mixed> $attributeIds) : array<string|int, mixed>
Parameters
- $attributeIds : array<string|int, mixed>
-
Array of attribute IDs to fetch dropdown options for.
Return values
array<string|int, mixed> —Associative array with attribute IDs as keys and arrays of option values.
flattenErrorMessages()
Takes result from model->getErrors() and creates a long string of all messages.
private
flattenErrorMessages(array<string|int, mixed> $errors) : string
Parameters
- $errors : array<string|int, mixed>
Return values
stringgetParticipantsSelectCommand()
private
getParticipantsSelectCommand(bool $count, array<string|int, mixed> $attid[, CDbCriteria $search = null ][, int $userid = null ][, int $page = null ][, int $limit = null ][, string|null $order = null ]) : CDbCommand
Parameters
- $count : bool
- $attid : array<string|int, mixed>
- $search : CDbCriteria = null
- $userid : int = null
- $page : int = null
- $limit : int = null
- $order : string|null = null
Return values
CDbCommandhandleNewTokenAttributes()
Handles the creation of new token attributes by adding them to survey descriptions and creating corresponding columns.
private
handleNewTokenAttributes(int $surveyId, array<string|int, mixed> $newAttributes) : array<string|int, mixed>
This function orchestrates the process of adding new participant attributes to a survey by:
- Adding the attributes to the survey's attribute descriptions in the database
- Creating corresponding columns in the survey's token table
Parameters
- $surveyId : int
-
The ID of the survey to which the new token attributes will be added.
- $newAttributes : array<string|int, mixed>
-
An array of participant attribute IDs from the CPDB to be added as token attributes.
Return values
array<string|int, mixed> —A two-element array containing:
- [0] array $addedAttributes: Array of participant attribute IDs that were successfully added.
- [1] array $addedAttributeIds: Array of token field names (e.g., 'attribute_1', 'attribute_2') for the added attributes.
selectBestLanguageName()
Selects the best language name based on priority: default survey language, admin language, or first available.
private
selectBestLanguageName(array<string|int, mixed> $languages, string $defaultSurveyLang, string $adminLang) : string
Parameters
- $languages : array<string|int, mixed>
-
Associative array of language codes to attribute names.
- $defaultSurveyLang : string
-
The default survey language code.
- $adminLang : string
-
The admin language code.
Return values
string —The selected attribute name.
updateSurveyAttributeDescriptions()
Updates the survey's attribute descriptions with new field contents.
private
updateSurveyAttributeDescriptions(int $surveyId, array<string|int, mixed> $fieldContents) : void
Parameters
- $surveyId : int
-
The survey ID.
- $fieldContents : array<string|int, mixed>
-
New field contents to merge with existing attributes.
updateTokenFieldProperties()
Updates the token attribute properties of a survey to include the mapping to Central Participant Database (CPDB) attributes.
private
updateTokenFieldProperties(int $surveyId, array<string|int, mixed> $mappedAttributes) : void
If automapping is enabled, this function updates the token field properties with the mapped CPDB field ID.
Parameters
- $surveyId : int
-
The ID of the survey.
- $mappedAttributes : array<string|int, mixed>
-
An associative array where keys are token attribute field names and values are the corresponding CPDB attribute IDs.
writeParticipantsToTokenTable()
Write participants as tokens or something
private
writeParticipantsToTokenTable(int $surveyId, array<string|int, mixed> $participantIds, array<string|int, mixed> $mappedAttributes, array<string|int, mixed> $newAttributes, array<string|int, mixed> $addedAttributes, array<string|int, mixed> $addedAttributeIds, array<string|int, mixed> $options) : array<string|int, int>
Parameters
- $surveyId : int
- $participantIds : array<string|int, mixed>
- $mappedAttributes : array<string|int, mixed>
- $newAttributes : array<string|int, mixed>
- $addedAttributes : array<string|int, mixed>
-
?? Result from createColumnsInTokenTable
- $addedAttributeIds : array<string|int, mixed>
-
?? Result from createColumnsInTokenTable
- $options : array<string|int, mixed>
-
As in calling function
Tags
Return values
array<string|int, int> —(success, duplicate, blacklistSkipped)