Permission

Extends\LSActiveRecord

Class Permission

package

Default

Methods

Lists the behaviors of this model

behaviors(): array
inherited

Below is a list of all behaviors we register:

see \PluginEventBehavior\CTimestampBehavior

Response

array

function used to order Permission by language string

comparePermissionTitle(array $aApermission,array $aBpermission): integer
static

Arguments

$aApermission

array

The first permission information

$aBpermission

array

The second permission information

Response

integer

copySurveyPermissions

copySurveyPermissions(integer $iSurveyIDSource,integer $iSurveyIDTarget)

Arguments

$iSurveyIDSource

integer

$iSurveyIDTarget

integer

Decrypt values from database

decrypt( $value = '')
inherited

Arguments

$value

Encrypt/decrypt values

decryptEncryptAttributes( $action = 'decrypt')
inherited

Arguments

$action

Decrypt single value

decryptSingle(string $value = ''): string
inheritedstatic

Arguments

$value

string

String value which needs to be decrypted

Response

string

the decrypted string

Decrypt single value

decryptSingleOld(string $value = ''): string
inheritedstatic

Arguments

$value

string

String value which needs to be decrypted

Response

string

the decrypted string

deleteAllByAttributes

deleteAllByAttributes(array $attributes,string $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

string

query condition or criteria.

$params

array

parameters to be bound to an SQL statement.

Response

integer

number of rows affected by the execution.

dispatchPluginModelEvent

dispatchPluginModelEvent(string $sEventName,\CDbCriteria $criteria = null,array $eventParams = []): \PluginEvent
inherited

Arguments

$sEventName

string

$criteria

\CDbCriteria

$eventParams

array

Response

\PluginEvent

Saves the updated values of a users themepermissions.

editThemePermissionsUser( $userId, $aTemplatePermissions): array
static

Arguments

$userId

integer -- this user themepermission values should be updated

$aTemplatePermissions

array -- permissions to be set

Response

array

Encrypt values

encrypt()
inherited

Attribute values are encrypted ( if needed )to be used for searching purposes

encryptAttributeValues(array $attributes = null, $bEncryptedOnly = false, $bReplaceValues = true): array
inherited

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.

$bEncryptedOnly

$bReplaceValues

Response

array

attributes array with encrypted atrribute values is returned

Encrypt values before saving to the database

encryptSave( $runValidation = false)
inherited

Arguments

$runValidation

Enrypt single value

encryptSingle(string $value = '')
inheritedstatic

Arguments

$value

string

String value which needs to be encrypted

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

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

See \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.

Overriding of Yii's findAllByAttributes method to provide encrypted attribute value search

findAllByAttributes(array $attributes,mixed $condition = '',array $params = array()): array<mixed,static>
inherited

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

array<mixed,static>

the records found. An empty array is returned if none is found.

Overriding of Yii's findByAttributes method to provide encrypted attribute value search

findByAttributes(array $attributes,mixed $condition = '',array $params = array()): static|null
inherited

Arguments

$attributes

array

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

parameters to be bound to an SQL statement.

Response

static|null

the record found. Null if none is found.

getAllEncryptedAttributes

getAllEncryptedAttributes(integer $iSurveyId,string $sClassName): array
inherited

Arguments

$iSurveyId

integer

$sClassName

string

Response

array

TODO: Should be split into seperate functions in the appropiate model or helper class TODO: Make an interface for records that support encryption.

Get object with $iEntityID of type $sEntityName NB: This method needs to be public so that it can be mocked.

getEntity(string $sEntityName,integer $iEntityID): Object

Arguments

$sEntityName

string

$iEntityID

integer

Response

Object

Return Permission for an object, using object::getPermissionData directly

getEntityBasePermissions(string $sEntityName): array
static

Arguments

$sEntityName

string

must be an existing object child of LSActiveRecord

Response

array

of permission : each permission with array of available crud

Return minimal permission name (for read value)

getEntityMinimalPermissionRead(string $sEntityName): null|string
static

Arguments

$sEntityName

string

must be an existing object child of LSActiveRecord

Response

null|string

get the owner if of an entity if exist

getEntityOwnerId(integer $iEntityID,string $sEntityName): integer|null

Arguments

$iEntityID

integer

the entity id

$sEntityName

string

string name (model)

Response

integer|null

user id if exist

Returns the global permissions including description and title

getGlobalBasePermissions(): array
static

Response

array

of array of permission

Return the global permission list as array

getGlobalPermissionData(string $key = null): array
static
todo

Use data value object instead of array.

Arguments

$key

string

the specific permission

Response

array

of crud if $key is set, array of permissio array by crud …

Return the max value for a field

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

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

Throws
\Exception

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|integer

Return the min value for a field

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

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

Throws
\Exception

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|integer

Get the translation of each CRUD

getPermissionGradeList(): array
static

Response

array

crud=>translation

Used in application/views/admin/surveymenu_entries/_form.php

getPermissionList(): array
static

Response

array

get current permissions list Seems used in LimeSurvey\PluginManager\LimesurveyApi->getPermissionSet

getPermissions(integer $iUserID,integer $iEntityID = null,string $sEntityName = null): array
static

Arguments

$iUserID

integer

$iEntityID

integer

$sEntityName

string

Response

array

Returns the base permissions for survey

getSurveyBasePermissions(): array
static
see self::getEntityBasePermissions

Response

array

get the default/fixed $iUserID

getUserId(integer|null $iUserID = null): integer
Throws
\Exception

Arguments

$iUserID

integer|null

optional user id

Response

integer

user id

get the connected user role

getUserRole(integer $iUserID): integer
static
Throws
\Exception

Arguments

$iUserID

integer

user id

Response

integer

roleId

Give all permission of a specific user without permission control of current user Used when create survey

giveAllSurveyPermissions(integer $iUserID,integer $iSurveyID)
see \mantis

16967: https://bugs.limesurvey.org/view.php?id=16967

Arguments

$iUserID

integer

$iSurveyID

integer

Returns true if a user has global permission for a certain action.

hasGlobalPermission(string $sPermission, $sCRUD = 'read', $iUserID = null): boolean

Arguments

$sPermission

string

string Name of the permission - see function getGlobalPermissions

$sCRUD

string The permission detailsyou want to check on: 'create','read','update','delete','import' or 'export'

$iUserID

integer User ID - if not given the one of the current user is used

Response

boolean

True if user has the permission

Checks if a user has a certain permission

hasPermission( $iEntityID,string $sEntityName, $sPermission, $sCRUD = 'read', $iUserID = null): boolean

Arguments

$iEntityID

integer The entity ID

$sEntityName

string

string The entity name

$sPermission

string Name of the permission

$sCRUD

string The permission detail you want to check on: 'create','read','update','delete','import' or 'export'

$iUserID

integer User ID - if empty : use the current user

Response

boolean

True if user has the permission

Checks if a user has a certain permission in the given survey

hasSurveyPermission( $iSurveyID, $sPermission, $sCRUD = 'read', $iUserID = null): boolean

Arguments

$iSurveyID

integer The survey ID

$sPermission

string Name of the permission

$sCRUD

string The permission detail you want to check on: 'create','read','update','delete','import' or 'export'

$iUserID

integer User ID - if not given the one of the current user is used

Response

boolean

True if user has the permission

Returns true if a user has permission to read/create/update a certain template

hasTemplatePermission(string $sTemplateName, $sCRUD = 'read',integer $iUserID = null): boolean

Arguments

$sTemplateName

string

$sCRUD

string The permission detailsyou want to check on: 'create','read','update','delete','import' or 'export'

$iUserID

integer

integer User ID - if not given the one of the current user is used

Response

boolean

True if user has the permission

insertRecords

insertRecords(array $data)
deprecated

at 2018-01-29 use $model->attributes = $data && $model->save()

Arguments

$data

array

insertSomeRecords

insertSomeRecords(array $data): boolean

Arguments

$data

array

Response

boolean

Returns true if user is a forced superadmin (can not disable superadmin rights)

isForcedSuperAdmin( $iUserID): boolean
static
var

Arguments

$iUserID

Response

boolean

Returns the static model of Settings table

model( $className = __CLASS__): \Permission
static
static
access

public

Arguments

$className

Response

\Permission

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,boolean $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

boolean

Response

mixed

the AR objects populated with the query result

relations

relations()
inheritdoc

Returns true if a role has permission for crud

roleHasPermission( $iRoleId,string $sPermission,string $sCRUD = 'read'): boolean

Arguments

$iRoleId

$sPermission

string

$sCRUD

string

The permission detailsyou want to check on: 'create','read','update','delete','import' or 'export'

Response

boolean

allowed permssion

rules

rules(): array

Response

array

validation rules for model attributes.

Function to show encryption symbol in gridview attribute header if value ois encrypted

setEncryptedAttributeLabel(integer $surveyId,string $className,string $attributeName): string
inherited
Throws
\CException

Arguments

$surveyId

integer

$className

string

$attributeName

string

Response

string

Set global permissions to the user id

setGlobalPermission(integer $iNewUID,string $sPermType,array<mixed,string> $aPermissions = array('read_p'))

Arguments

$iNewUID

integer

$sPermType

string

$aPermissions

array<mixed,string>

Set global permissions to the user id

setMinimalEntityPermission(integer $iUserID,mixed $iEntityID,string $sEntityName): null|\self::model()
static

Arguments

$iUserID

integer

the user id

$iEntityID

mixed

the entity id

$sEntityName

string

the entity name (Object)

Response

null|\self::model()

Sets permissions (global or survey-specific) for a survey administrator Checks what permissions may be set and automatically filters invalid ones.

setPermissions(mixed $iUserID,mixed $iEntityID,string $sEntityName,mixed $aPermissions,boolean $bBypassCheck = false): null|boolean
static

A permission may be invalid if the permission does not exist or that particular user may not give that permission

deprecated

: usage only for global Permission currently

Throws
\Exception

Arguments

$iUserID

mixed

$iEntityID

mixed

$sEntityName

string

$aPermissions

mixed

$bBypassCheck

boolean

: by pass control of current permission for current user only for global permission

Response

null|boolean

tableName

tableName()
inheritdoc

Updates records with the specified condition.

updateAll(array $attributes,mixed $condition = '',array $params = array()): integer
inherited

XSS filtering is enforced for attributes listed in model's $xssFilterAttributes property. See \find() for detailed explanation about $condition and $params. Note, the attributes are not checked for safety and no validation is done.

Arguments

$attributes

array

list of attributes (name=>$value) to be updated

$condition

mixed

query condition or criteria.

$params

array

parameters to be bound to an SQL statement.

Response

integer

the number of rows being updated

Properties

aGlobalBasePermissions

aGlobalBasePermissions :
static

Type(s)

Array of attributes that should be XSS filtered on mass updates

xssFilterAttributes :array<mixed,string>
inherited
var

Array of attributes that should be XSS filtered on mass updates

Type(s)

array<mixed,string>

bEncryption

bEncryption :
inherited

Type(s)

id

id :integer

Type(s)

integer

entity

entity :string

Type(s)

string

entity_id

entity_id :integer

Type(s)

integer

uid

uid :integer

Type(s)

integer

permission

permission :string

Type(s)

string

create_p

create_p :integer

Type(s)

integer

read_p

read_p :integer

Type(s)

integer

update_p

update_p :integer

Type(s)

integer

delete_p

delete_p :integer

Type(s)

integer

import_p

import_p :integer

Type(s)

integer

export_p

export_p :integer

Type(s)

integer