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.

Methods

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

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

Arguments

$key

string

The key to search for in the application config

$defaultValue

mixed

Value to return when not found, default is false

Response

mixed

Generates the real table name from plugin and tablename.

getTableName(\ls\pluginmanager\iPlugin $plugin, string $tableName) 

Arguments

$tableName

string

Sets a flash message to be shown to the user.

setFlash(\ls\pluginmanager\html $message, $key = 'api') 

Arguments

$message

\ls\pluginmanager\html

$key

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.

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.

createUrl

createUrl($route, array $params) 

Arguments

$route

$params

array

Gets an activerecord object associated to the table.

getTable(\ls\pluginmanager\iPlugin $plugin, string $sTableName, string $bPluginTable = true) : \PluginDynamic

Arguments

$sTableName

string

Name of the table.

$bPluginTable

string

True if the table is plugin specific.

Response

\PluginDynamic

checkAccess

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

Arguments

$operation

string

$params

array

$allowCaching

boolean

Response

boolean

Creates a new active record object instance.

newModel(\ls\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

removeResponse

removeResponse($surveyId, $responseId) 

Arguments

$surveyId

$responseId

Check if a table does exist in the database

tableExists(\ls\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

Evaluates an expression via Expression Manager Uses the current context.

EMevaluateExpression(string $expression) : string

Arguments

$expression

string

Response

string

Get the current request object

getRequest() : \LSHttpRequest

Response

\LSHttpRequest

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

getTemplateList() : array

Response

array

Gets a survey response from the database.

getResponse(int $surveyId, int $responseId, bool $bMapQuestionCodes = true) 

Arguments

$surveyId

int

$responseId

int

$bMapQuestionCodes

bool

getResponses

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

Arguments

$surveyId

$attributes

$condition

$params

getToken

getToken($surveyId, $token) 

Arguments

$surveyId

$token

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

getTokenById(integer $iSurveyId, integer $iTokenId) : object

Arguments

$iSurveyId

integer

$iTokenId

integer

Response

object

Token

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

getGroupList(boolean $surveyId) : \ls\pluginmanager\type

Arguments

$surveyId

boolean

Response

\ls\pluginmanager\type

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 the table name for responses for the specified survey id.

getResponseTable(int $surveyId) : string

Arguments

$surveyId

int

Response

string

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

getOldResponseTables(int $surveyId) : string[]

Arguments

$surveyId

int

Response

string[]

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

getUser(int $iUserID) : \User

Arguments

$iUserID

int

The userid

Response

\User

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

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

Retrieves user permission details for a user

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

Arguments

$iUserID

mixed

int The User ID

$iEntityID

$sEntityName

Response

\User

Retrieves Participant data

getParticipant(mixed $iParticipantID) : \User

Arguments

$iParticipantID

mixed

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

Response

\User

getQuestions

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

Arguments

$surveyId

$language

$conditions

Gets the metadata for a table.

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

For details on the object check: http://www.yiiframework.com/doc/api/1.1/CDbTableSchema

Arguments

$table

string

Table name.

$forceRefresh

boolean

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

Response

\ls\pluginmanager\CDbTableSchema

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

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

pluginExists(string $name) : boolean
throws

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

if $name is not a string

if no plugin with name $name is found

Arguments

$name

string

Name of plugin

Response

boolean