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

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(\QuickMenu $plugin, string $sTableName, array $aColumns, string $sOptions = null) : integer

Arguments

$plugin

\QuickMenu

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

string

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

Response

integer

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 Expression Manager 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

Retrieves user details for the currently logged in user 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)

getCurrentUser() : \User

Response

\User

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

getGroupList(boolean $surveyId) : \LimeSurvey\PluginManager\type

Arguments

$surveyId

boolean

Response

\LimeSurvey\PluginManager\type

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( $iParticipantID) : \Participant

Arguments

$iParticipantID

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

Response

\Participant

Retrieves user permission details for a user

getPermissionSet( $iUserID,  $iEntityID = null,  $sEntityName = null) : \User

Arguments

$iUserID

int The User ID

$iEntityID

$sEntityName

Response

\User

getQuestions

getQuestions( $surveyId,  $language = 'en',  $conditions = array()) 

Arguments

$surveyId

$language

$conditions

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

Arguments

$surveyId

integer

$responseId

integer

$bMapQuestionCodes

boolean

Response

array

getResponses

getResponses( $surveyId,  $attributes = array(),  $condition = '',  $params = array()) 

Arguments

$surveyId

$attributes

$condition

$params

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, string $bPluginTable = true) : \Plugin|null

Arguments

$sTableName

string

Name of the table.

$bPluginTable

string

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) 

Arguments

$surveyId

$token

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

getTokenById(integer $iSurveyId, integer $iTokenId) : \Token

Arguments

$iSurveyId

integer

$iTokenId

integer

Response

\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) : \User

Arguments

$iUserID

integer

The userid

Response

\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

Creates a new active record object instance.

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

Arguments

$sTableName

string

$scenario

string

$bPluginTable

string

True if the table is plugin specific.

Response

\PluginDynamic

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

pluginExists(string $name) : boolean
Throws
\LimeSurvey\PluginManager\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
\LimeSurvey\PluginManager\InvalidArgumentException

if $name is not a string

\LimeSurvey\PluginManager\Exception

if no plugin with name $name is found

Arguments

$name

string

Name of plugin

Response

boolean

removeResponse

removeResponse( $surveyId,  $responseId) 

Arguments

$surveyId

$responseId

Sets a flash message to be shown to the user.

setFlash(\LimeSurvey\PluginManager\html $message,  $key = 'api') 

Arguments

$message

\LimeSurvey\PluginManager\html

$key

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