Participant

Extends \LSActiveRecord

This is the model class for table "{{participants}}".

The followings are the available columns in table '{{participants}}':

Methods

Returns the static model of Settings table

model(string $class = __CLASS__) : \Participants
static
static
access

public

Arguments

$class

string

Response

\Participants

tableName

tableName() : string

Response

string

the associated database table name

rules

rules() : array

Response

array

validation rules for model attributes.

relations

relations() : array

Response

array

relational rules.

getButtons

getButtons() : string

Response

string

getCheckbox

getCheckbox() : string

Response

string

html

attributeLabels

attributeLabels() : array

Response

array

customized attribute labels (name=>label)

getAllExtraAttributes

getAllExtraAttributes() : array

Response

array

Get options for a drop-down attribute

getOptionsForAttribute($attribute_id) : array

Arguments

$attribute_id

Response

array

getAllUsedLanguagesWithRealName

getAllUsedLanguagesWithRealName() 

getParticipantAttribute

getParticipantAttribute(string $attributeTextId, mixed $attribute_id = false) 

Arguments

$attributeTextId

string

E.g. ea_145

$attribute_id

mixed

getCountActiveSurveys

getCountActiveSurveys() 

getBlacklistSwitchbutton

getBlacklistSwitchbutton() : string

Response

string

HTML

getColumns

getColumns() : array

Response

array

getOwnersList

getOwnersList(int $selected) : string

Arguments

$selected

int

Owner id

Response

string

HTML

addSurveyFilter

addSurveyFilter($conditions) 

Arguments

$conditions

Funcion for generation of unique id

gen_uuid() : string
static

Response

string

This function is responsible for adding the participant to the database

insertParticipant(array $aData) : string|\Participant

Arguments

$aData

array

Participant data

Response

string|\Participant

Error message on failure, participant object on success

Takes result from model->getErrors() and creates a long string of all messages.

flattenErrorMessages(array $errors) : string

Arguments

$errors

array

Response

string

Returns the primary key of this table

primaryKey() : string
access

public

Response

string

This function updates the data edited in the view

updateRow(\aray $data) : void

Arguments

$data

\aray

getParticipantsOwner

getParticipantsOwner($userid) 

Arguments

$userid

getParticipantsOwnerCount

getParticipantsOwnerCount($userid) : int

Arguments

$userid

Response

int

Get the number of participants, no restrictions

getParticipantsCountWithoutLimit() : int

Response

int

getParticipantsWithoutLimit

getParticipantsWithoutLimit() : \Participant[]

Response

\Participant[]

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

getParticipantsSharedCount(int $userid) : int

Arguments

$userid

int

The id of the owner

Response

int

The number of participants owned by $userid who are shared

getParticipants

getParticipants(int $page, int $limit, array $attid, $order = null, $search = null, $userid = null) : array

Arguments

$page

int

$limit

int

$attid

array

$order

$search

$userid

Response

array

Duplicated from getparticipants, only to have a count

getParticipantsCount(int $attid, \CDbCriteria $search = null, int $userid = null) : int

Arguments

$attid

int

$search

\CDbCriteria

$userid

int

Response

int

getParticipantsSelectCommand

getParticipantsSelectCommand($count = false, $attid, $search = null, $userid = null, integer $page = null, integer $limit = null, $order = null) : \CDbCommand

Arguments

$count

$attid

$search

$userid

$page

integer

$limit

integer

$order

Response

\CDbCommand

getSurveyCount

getSurveyCount($participant_id) : int

Arguments

$participant_id

Response

int

This function deletes the participant from the participants table, references in the survey_links table (but not in matching tokens tables) and then all the participants attributes.

deleteParticipants(mixed $rows, $bFilter = true) : int

Arguments

$rows

mixed

Participants ID separated by comma

$bFilter

Response

int

Filter an array of participants IDs according to permissions of the person being logged in

filterParticipantIDs(mixed $aParticipantIDs) : int[]

Arguments

$aParticipantIDs

mixed

Response

int[]

Deletes CPDB participants identified by their participant ID from token tables

deleteParticipantToken(mixed $sParticipantsIDs) : void

Arguments

$sParticipantsIDs

mixed

This function deletes the participant from the participants table, 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.

deleteParticipantTokenAnswer(mixed $sParticipantsIDs) : void

Arguments

$sParticipantsIDs

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'"

getParticipantsSearchMultiple(array $condition, int $page, \in $limit) : array

Arguments

$condition

array

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

\in

The limit/number of reords to return

Response

array

$output

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(array $condition) : \CDbCriteria

Arguments

$condition

array

an array containing the search string exploded using || so that "firstname||equal||jason" is $condition(1=>'firstname', 2=>'equal', 3=>'jason')

Response

\CDbCriteria

$output

Returns true if participant_id has ownership or shared rights over this participant false if not

is_owner(mixed $participant_id) : bool

Arguments

$participant_id

mixed

Response

bool

true/false

This funciton is responsible for showing all the participant's shared by a particular user based on the user id

getParticipantShared($userid) 

Arguments

$userid

This funciton is responsible for showing all the participant's shared to the superadmin

getParticipantSharedAll() 

Get column names from token attributes for a survey.

getTokenAttributes(int $surveyId) : array

A token attribute has id (auto increment), attribute field (always "attribte_" + number), and field description (e.g. "my attribute" or "gender")

Arguments

$surveyId

int

Response

array

E.g. [11 => 'attribute_36', ...]

Update stuff? If automapping is enabled then update the token field properties with the mapped CPDB field ID TODO: What is this?

updateTokenFieldProperties(integer $surveyId, array $mappedAttributes) : void

Arguments

$surveyId

integer

$mappedAttributes

array

Check for column duplicates from CPDB to token attributes Throws error message if an attribute already exists; otherwise false.

checkColumnDuplicates(int $surveyId, string[] $newAttributes) : boolean
throws

with error message

Arguments

$surveyId

int

$newAttributes

string[]

Array of CPDB attributes ids like ['42', '32', ...]

Response

boolean

Create new "fields"? in which table?

createColumnsInTokenTable(int $surveyId, array $newAttributes) : array

Arguments

$surveyId

int

$newAttributes

array

Response

array

[addedAttributes, addedAttributeIds]

Write participtants as tokens or something

writeParticipantsToTokenTable(int $surveyId, array $participantIds, array $mappedAttributes, array $newAttributes, array $addedAttributes, array $addedAttributeIds, array $options) : integer[]

Arguments

$surveyId

int

$participantIds

array

$mappedAttributes

array

$newAttributes

array

$addedAttributes

array

?? Result from createColumnsInTokenTable

$addedAttributeIds

array

?? Result from createColumnsInTokenTable

$options

array

As in calling function

Response

integer[]

(success, duplicate, blacklistSkipped)

Copies central attributes/participants to an individual survey token table

copyCPDBAttributesToTokens(int $surveyId, string $participantIds, array $mappedAttributes, array $newAttributes, array $options) 

Arguments

$surveyId

int

The survey id

$participantIds

string

Array containing the participant ids of the participants we are adding

$mappedAttributes

array

An array containing a list of /mapped attributes in the form of "token_field_name" => "participant_attribute_id"

$newAttributes

array

An array containing new attributes to create in the tokens table

$options

array

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

Updates a field in the token table with a value from the participant attributes table

updateTokenAttributeValue(int $surveyId, string $participantId, int $participantAttributeId, int $tokenFieldname) : bool

Arguments

$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 token table

Response

bool

true/false

Updates or creates a field in the token table with a value from the participant attributes table

updateAttributeValueToken(int $surveyId, int $participantId, int $participantAttributeId, int $tokenFieldname) : boolean|null

Arguments

$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 token table

Response

boolean|null

true/false

Copies token participants to the central participants table, and also copies token attribute values where applicable. It checks for matching entries using firstname/lastname/email combination.

copyToCentral(int $surveyid, array $aAttributesToBeCreated, array $aMapped, bool $overwriteauto = false, bool $overwriteman = false, bool $createautomap = true) : array

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.

Arguments

$surveyid

int

The id of the survey, used to find the appropriate tokens table

$aAttributesToBeCreated

array

An array containing the names of token attributes that have to be created in the cpdb

$aMapped

array

An array containing the names of token attributes that are to be mapped to an existing cpdb attribute

$overwriteauto

bool

If true, overwrites existing automatically mapped attribute values

$overwriteman

bool

If true, overwrites manually mapped attribute values (where token fieldname=attribute_n)

$createautomap

bool

If true, updates tokendescription field with new mapping

Response

array

An array contaning list of successful and list of failed ids

The purpose of this function is to check for duplicate in participants

checkforDuplicate(array $fields, string $output = "bool") : mixed

Arguments

$fields

array

$output

string

Response

mixed

insertParticipantCSV

insertParticipantCSV(array $data) : void

Arguments

$data

array

Returns true if logged in user has edit rights to this participant

userHasPermissionToEdit() : boolean

Response

boolean

Returns true if user is either owner of this participant or superadmin Used to decide is user can change owner of participant

isOwnerOrSuperAdmin() : boolean

Response

boolean

'created' field formatted; empty string if no timestamp in database

getCreatedFormatted() : string

Response

string

Lists the behaviors of this model

behaviors() : array
inherited

Below is a list of all behaviors we register:

see \CTimestampBehavior \PluginEventBehavior

Response

array

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

query(\CDbCriteria $criteria, boolean $all = false, $asAR = true) : mixed
inherited

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.

since 1.1.7

Arguments

$criteria

\CDbCriteria

the query criteria

$all

boolean

whether to return all data

$asAR

Response

mixed

the AR objects populated with the query result

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

findAllAsArray(mixed $condition = '', array $params = array()) : array
inherited

See {@link find()} for detailed explanation about $condition and $params.

Arguments

$condition

mixed

query condition or criteria.

$params

array

parameters to be bound to an SQL statement.

Response

array

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

Return the max value for a field

getMaxId(string $field = null, boolean $forceRefresh = false) : false|int
inherited

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

Arguments

$field

string

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

$forceRefresh

boolean

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

Response

false|int

Return the min value for a field

getMinId(string $field = null, boolean $forceRefresh = false) : false|int
inherited

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

Arguments

$field

string

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

$forceRefresh

boolean

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

Response

false|int

deleteAllByAttributes

deleteAllByAttributes(array $attributes, mixed $condition = '', array $params = array()) : integer
inherited
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 {@link find()} for detailed explanation about $condition and $params.

Arguments

$attributes

array

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

parameters to be bound to an SQL statement.

Response

integer

number of rows affected by the execution.

Properties

extraCondition

extraCondition : 

countActiveSurveys

countActiveSurveys : 

id

id : 

participant_id

participant_id : string

Type(s)

string

firstname

firstname : string

Type(s)

string

lastname

lastname : string

Type(s)

string

email

email : string

Type(s)

string

language

language : string

Type(s)

string

blacklisted

blacklisted : string

Type(s)

string

owner_uid

owner_uid : integer

Type(s)

integer