LimeSurvey API - Master branch

UserGroup extends LSActiveRecord
in package

Class UserGroup

Table of Contents

Properties

$bEncryption  : mixed
$countUsers  : int
$description  : string
$member_count  : int
$name  : string
$owner  : User
$owner_id  : int
$ugid  : int
$users  : array<string|int, User>
$xssFilterAttributes  : array<string|int, string>

Methods

addGroup()  : int
addUser()  : bool
Checks whether the specified UID is part of that group
behaviors()  : array<string|int, mixed>
Lists the behaviors of this model
decrypt()  : mixed
Decrypt values from database
decryptEncryptAttributes()  : mixed
Encrypt/decrypt values
decryptSingle()  : string
Decrypt single value
decryptSingleOld()  : string
Decrypt single value
delete()  : mixed
{@inheritdoc}
deleteAllByAttributes()  : int
deleteGroup()  : bool
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
getAllEncryptedAttributes()  : array<string|int, mixed>
getButtons()  : string
Returns the buttons for grid view
getColumns()  : mixed
getCountUsers()  : int
getManagementButtons()  : array<string|int, mixed>
Returns the buttons for grid view
getMaxId()  : false|int
Return the max value for a field
getMinId()  : false|int
Return the min value for a field
hasUser()  : bool
Checks whether the specified UID is part of that group
insertRecords()  : mixed
join()  : mixed
model()  : UserGroup
primaryKey()  : mixed
relations()  : mixed
requestEditGroup()  : static
Works as permission check on db level for editing user groups.
requestViewGroup()  : array<string|int, mixed>
rules()  : mixed
searchMine()  : CActiveDataProvider
This function searches user groups for a user If $isMine = true then user groups are those that have been created by the current user else this function provides s which contain the current user
sendUserEmails()  : string
Sending emails to all users of a specific group.
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.
updateGroup()  : bool
TODO should be in controller? When user is allowed to edit the group, it will be updated in the database.
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

Properties

$countUsers

public int $countUsers

Count of users in this group

$description

public string $description

Group description

$member_count

public int $member_count = \null

$name

public string $name

Group name (max 20 chars)

$owner_id

public int $owner_id

Group owner user ID

$ugid

public int $ugid

Model ID (primary key)

$xssFilterAttributes

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

Array of attributes that should be XSS filtered on mass updates

Methods

addGroup()

public addGroup(string $group_name, string $group_description) : int
Parameters
$group_name : string
$group_description : string
Tags
todo

should use save() and afterSave() methods!!

Return values
int

addUser()

Checks whether the specified UID is part of that group

public addUser(int $uid) : bool
Parameters
$uid : int
Return values
bool

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>

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

delete()

{@inheritdoc}

public delete() : mixed

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.

deleteGroup()

public deleteGroup(int $ugId, int $ownerId) : bool
Parameters
$ugId : int
$ownerId : int
Tags
deprecated

since 2018-04-21 use $this->delete and do the permissions check in controller!!

Return values
bool

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.

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()

Returns the buttons for grid view

public getButtons() : string
Tags
todo

where is this used??

Return values
string

getCountUsers()

public getCountUsers() : int
Return values
int

getManagementButtons()

Returns the buttons for grid view

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

hasUser()

Checks whether the specified UID is part of that group

public hasUser(int $uid) : bool
Parameters
$uid : int
Return values
bool

insertRecords()

public insertRecords( $data) : mixed
Parameters
$data :
Tags
deprecated

at 2018-02-03 use $model->attributes = $data && $model->save()

join()

public join(array<string|int, string> $fields, string $from[, mixed $condition = false ][, mixed $join = false ][, mixed $order = false ]) : mixed
Parameters
$fields : array<string|int, string>
$from : string
$condition : mixed = false
$join : mixed = false
$order : mixed = false

model()

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

primaryKey()

public primaryKey() : mixed
Tags
inheritdoc

relations()

public relations() : mixed
Tags
inheritdoc

requestEditGroup()

Works as permission check on db level for editing user groups.

public requestEditGroup(int $ugId, int $ownerId) : static

The user group needs to exist, and if the user is not a superadmin, user also has to be the owner of that group. If successful, the user group is returned.

Parameters
$ugId : int
$ownerId : int
Return values
static

requestViewGroup()

public requestViewGroup(int $ugId, int $userId) : array<string|int, mixed>
Parameters
$ugId : int
$userId : int
Tags
deprecated

Not needed anymore

Return values
array<string|int, mixed>

rules()

public rules() : mixed
Tags
inheritdoc

searchMine()

This function searches user groups for a user If $isMine = true then user groups are those that have been created by the current user else this function provides s which contain the current user

public searchMine(bool $isMine) : CActiveDataProvider

The object \CActiveDataProvider returned is used to generate the view in application/views/admin/usergroup/usergroups_view.php

Parameters
$isMine : bool
Return values
CActiveDataProvider

sendUserEmails()

Sending emails to all users of a specific group.

public sendUserEmails( $ugid,  $subject,  $body,  $copy) : string

Returns information about success/errors for sending emails to all single users

Parameters
$ugid :

integer

$subject :

string subject of email

$body :

string body of email

$copy :

integer 1->send copy to user

Tags
throws
Exception
Return values
string

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

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

updateGroup()

TODO should be in controller? When user is allowed to edit the group, it will be updated in the database.

public updateGroup(string $name, string $description, int $ugId) : bool

Returns true, when it was possible to save.

Parameters
$name : string
$description : string
$ugId : int
Return values
bool

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