LimesurveyApi

Class exposing a Limesurvey API to plugins.

This class is instantiated by the plugin manager, plugins can obtain it by calling getAPI() on the plugin manager.

package

Default

Methods

Adds a new user group

addUserGroup(string $groupName,string $groupDescription): boolean
Throws
\InvalidArgumentException

if user group name was not supplied

Arguments

$groupName

string

Name of user group to be created

$groupDescription

string

Description of user group to be created

Response

boolean

True or false if user group was added or not

Adds a user to a user group

addUserInGroup(integer $ugid,integer $uid): boolean
Throws
\InvalidArgumentException

if user or group does not exist or group owner was supplied

Arguments

$ugid

integer

The user group ID

$uid

integer

The user ID

Response

boolean

True if user was added to group or false if not

checkAccess

checkAccess(string $operation,array $params = array(),boolean $allowCaching = true): boolean
see http://www.yiiframework.com/doc/api/1.1/CWebUser#checkAccess-detail

Arguments

$operation

string

$params

array

$allowCaching

boolean

Response

boolean

Builds and executes a SQL statement for creating a new DB table.

createTable(\LimeSurvey\PluginManager\PluginBase $plugin,string $sTableName,array $aColumns,\LimeSurvey\PluginManager\?string $sOptions = null): integer|false

Arguments

$plugin

\LimeSurvey\PluginManager\PluginBase

The plugin object, id or name.

$sTableName

string

the name of the table to be created. The name will be properly quoted and prefixed by the method.

$aColumns

array

the columns (name=>definition) in the new table.

$sOptions

\LimeSurvey\PluginManager\?string

additional SQL fragment that will be appended to the generated SQL.

Response

integer|false

number of rows affected by the execution.

createUrl

createUrl( $route,array $params)

Arguments

$route

$params

array

Builds and executes a SQL statement for dropping a DB table.

dropTable(mixed $plugin,string $sTableName)

Arguments

$plugin

mixed

The plugin object, id or name.

$sTableName

string

the name of the table to be created. The name will be properly quoted and prefixed by the method.

Evaluates an expression via ExpressionScript Engine Uses the current context.

EMevaluateExpression(string $expression): string

Arguments

$expression

string

Response

string

Read a key from the application config, and when not set return the default value

getConfigKey(string $key,mixed $defaultValue = false): string

Arguments

$key

string

The key to search for in the application config

$defaultValue

mixed

Value to return when not found, default is false

Response

string

Get the current Response

getCurrentResponses(integer $surveyId = null): \Response|null

Arguments

$surveyId

integer

Response

\Response|null

Retrieves user details for the currently logged in user

getCurrentUser(): \LimeSurvey\PluginManager\?User|false

Response

\LimeSurvey\PluginManager\?User|false

Returns false if the user is not logged and returns null if the user does not exist anymore for some reason (should not really happen)

Gets a key value list using the group name as value and the group id as key.

getGroupList(integer $surveyId): array<mixed,\QuestionGroup>

Arguments

$surveyId

integer

Response

array<mixed,\QuestionGroup>

Gets an array of old response table names for a survey.

getOldResponseTables(integer $surveyId): array<mixed,string>

Arguments

$surveyId

integer

Response

array<mixed,string>

Retrieves Participant data

getParticipant(integer $iParticipantID): \LimeSurvey\PluginManager\?\Participant

Arguments

$iParticipantID

integer

The Participant ID

Response

\LimeSurvey\PluginManager\?\Participant

Returns null if the user does not exist anymore for some reason (should not really happen)

Retrieves user permission details for a user

getPermissionSet(integer $iUserID, $iEntityID = null,\LimeSurvey\PluginManager\?string $sEntityName = null): \LimeSurvey\PluginManager\?array

Arguments

$iUserID

integer

The User ID

$iEntityID

$sEntityName

\LimeSurvey\PluginManager\?string

Response

\LimeSurvey\PluginManager\?array

Returns null if the user does not exist anymore for some reason (should not really happen)

Returns an array of all the question attributes and their values for the specified question.

getQuestionAttributes(integer $questionId,string|null $language = null): \LimeSurvey\PluginManager\array<string,
Throws
\InvalidArgumentException

Arguments

$questionId

integer

the ID of the question

$language

string|null

restrict to this language

Response

\LimeSurvey\PluginManager\array

mixed> array of question attributes and values (name=>value)

getQuestions

getQuestions(integer $surveyId,string $language = 'en', $conditions = array()): array<mixed,\Question>

Arguments

$surveyId

integer

$language

string

$param array $conditions

$conditions

Response

array<mixed,\Question>

Get the current request object

getRequest(): \LSHttpRequest

Response

\LSHttpRequest

Gets a survey response from the database.

getResponse(integer $surveyId,integer $responseId,boolean $bMapQuestionCodes = true): array|\SurveyDynamic|null

Arguments

$surveyId

integer

$responseId

integer

$bMapQuestionCodes

boolean

Response

array|\SurveyDynamic|null

getResponses

getResponses( $surveyId, $attributes = array(), $condition = '', $params = array()): array<mixed,\Response>|null

Arguments

$surveyId

$attributes

$condition

$params

Response

array<mixed,\Response>|null

Gets the table name for responses for the specified survey id.

getResponseTable(integer $surveyId): string

Arguments

$surveyId

integer

Response

string

Gets an activerecord object associated to the table.

getTable(\LimeSurvey\PluginManager\iPlugin $plugin,string $sTableName,\LimeSurvey\PluginManager\?boolean $bPluginTable = true): \Plugin|null

Arguments

$sTableName

string

Name of the table.

$bPluginTable

\LimeSurvey\PluginManager\?boolean

True if the table is plugin specific.

Response

\Plugin|null

Generates the real table name from plugin and tablename.

getTableName(\LimeSurvey\PluginManager\iPlugin $plugin,string $tableName)

Arguments

$tableName

string

Gets the metadata for a table.

getTableSchema(string $table,boolean $forceRefresh = false): \CDbTableSchema

Arguments

$table

string

Table name.

$forceRefresh

boolean

False if cached information is acceptable; setting this to true could affect performance.

Response

\CDbTableSchema

Table schema object, NULL if the table does not exist.

Returns an array of all available template names - does a basic check if the template might be valid

getTemplateList(): array

Response

array

getToken

getToken( $surveyId, $token): \LimeSurvey\PluginManager\?\Token

Arguments

$surveyId

$token

Response

\LimeSurvey\PluginManager\?\Token

Return a token object from a token id and a survey id

getTokenById(integer $iSurveyId,integer $iTokenId): \LimeSurvey\PluginManager\?\Token

Arguments

$iSurveyId

integer

$iTokenId

integer

Response

\LimeSurvey\PluginManager\?\Token

Token

Retrieves user details for a user Returns null if the user does not exist anymore for some reason (should not really happen)

getUser(integer $iUserID): \LimeSurvey\PluginManager\?User

Arguments

$iUserID

integer

The userid

Response

\LimeSurvey\PluginManager\?User

Get the user object for a given email

getUserByEmail(string|null $email): \User|null

Arguments

$email

string|null

Response

\User|null

Returns the user, or null when not found

Get the user object for a given username

getUserByName(string $username): \User|null

Arguments

$username

string

Response

\User|null

Returns the user, or null when not found

Returns a UserGroup object by ugid Returns null if the object does not exist

getUserGroup(integer $ugid): \UserGroup|null

Arguments

$ugid

integer

The user group ID

Response

\UserGroup|null

Returns an array of all user groups

getUserGroups(): array

Response

array

Returns a UserInGroup object Returns null if the object does not exist

getUserInGroup(integer $ugid,integer $uid): \UserInGroup|null

Arguments

$ugid

integer

The user group ID

$uid

integer

The user ID

Response

\UserInGroup|null

Creates a new active record object instance.

newModel(\LimeSurvey\PluginManager\iPlugin $plugin,string $sTableName,\LimeSurvey\PluginManager\?string $scenario = 'insert',\LimeSurvey\PluginManager\?boolean $bPluginTable = true): \LimeSurvey\PluginManager\?\PluginDynamic

Arguments

$sTableName

string

$scenario

\LimeSurvey\PluginManager\?string

$bPluginTable

\LimeSurvey\PluginManager\?boolean

True if the table is plugin specific.

Response

\LimeSurvey\PluginManager\?\PluginDynamic

Returns true if a plugin exists with name $name (active or not)

pluginExists(string $name): boolean
Throws
\InvalidArgumentException

if $name is not a string

Arguments

$name

string

Name of plugin

Response

boolean

Returns true if plugin with name $name is active; otherwise false

pluginIsActive(string $name): boolean
Throws
\InvalidArgumentException

if $name is not a string

\Exception

if no plugin with name $name is found

Arguments

$name

string

Name of plugin

Response

boolean

removeResponse

removeResponse( $surveyId, $responseId)

Arguments

$surveyId

$responseId

Removes a user from a user group

removeUserInGroup(integer $ugid,integer $uid): boolean
Throws
\InvalidArgumentException

if user or group does not exist or group owner was supplied

Arguments

$ugid

integer

The user group ID

$uid

integer

The user ID

Response

boolean

True if user was removed to group or false if not

renderTwig

renderTwig(string $file,array $data): string

Arguments

$file

string

$data

array

Response

string

Sets a flash message to be shown to the user.

setFlash(string $message,string $key = 'api'): void

Arguments

$message

string

$key

string

Check if a table does exist in the database

tableExists(\LimeSurvey\PluginManager\iPlugin $plugin,string $sTableName): boolean

Arguments

$sTableName

string

Table name to check for (without dbprefix!))

Response

boolean

True or false if table exists or not