LimeSurvey API - Master branch

SurveyAdministrationController extends LSBaseController
in package

Class SurveyAdministrationController

Table of Contents

Properties

$aData  : array<string|int, mixed>
$navData  : array<string|int, mixed>
This array contains the survey / group / question id used by the menu widget.
$sTemplate  : null
$userId  : int

Methods

__construct()  : mixed
SurveyAdministrationController constructor.
accessRules()  : array<string|int, mixed>
It's import to have the accessRules set (security issue).
actionActivate()  : void
This action activates the survey with selected options.
actionActivateSurvey()  : void
This action renders the view for survey activation where the user can preselect some options like "ipanonymize" etc.
actionApplythemeoptions()  : void
Apply current theme options for imported survey theme
actionChangeFormat()  : void
Called via ajax request from survey summary quick action "Show questions group by group".
actionChangeMultipleSurveyGroup()  : void
Change survey group for multiple survey at once.
actionChangeMultipleTheme()  : void
Massive action in ListSurveysWidget ... Ajax request
actionCopy()  : void
Function responsible to import/copy a survey based on $action.
actionDatetimesettings()  : void
Ajaxrequest returning 'session['dateformat']' and some other parameters to the frontend
actionDeactivate()  : void
Function responsible to deactivate a survey.
actionDelete()  : string
Function responsible to delete a survey.
actionDeleteMultiple()  : void
Delete multiple survey
actionDeleteUrlParam()  : void
Method to delete URL Params (Panel Integration)
actionExpire()  : void
Expires the survey.
actionExpireMultipleSurveys()  : void
Action to set expiry date to multiple surveys.
actionFakebrowser()  : void
todo: what is this? why do we need it? (it'S just an js-script alert window rendert here ...)
actionFixNumbering()  : array<string|int, mixed>|false|string|array<string|int, string>|null
fixes the numbering of questions This can happen if question 1 have subquestion code 1 and have question 11 in same survey and group (then same SGQA).
actionGetAjaxMenuArray()  : string|array<string|int, string>
Ajaxified get MenuItems with containing questions
actionGetAjaxQuestionGroupArray()  : string|array<string|int, string>
AjaxRequest get questionGroup with containing questions
actionGetCurrentEditorValues()  : JSON
Function to call current Editor Values by Ajax
actionGetDataSecTextSettings()  : JSON
Collect the data necessary for the data security settings and return a JSON document
actionGetDateFormatOptions()  : JSON
Method to call current date information by ajax
actionGetTokenTopBar()  : string
Returns JSON Data for Token Top Bar.
actionGetUrlParamsJSON()  : void
actionImportsurveyresources()  : void
Function responsible to import survey resources from a '.zip' file.
actionInsert()  : string
Saves the new survey after the creation screen is submitted
actionListsurveys()  : void
List Surveys.
actionNewSurvey()  : void
This function prepares the view for a new survey
actionOrganize()  : void
Load ordering of question group screen.
actionPurge()  : void
Remove files not deleted properly.
actionRegenerateQuestionCodes()  : void
Regeerates the question code Automatically renumbers the "question codes" so that they follow a methodical numbering method.
actionRenderItemsSelected()  : void
Render selected items for massive action
actionRendersidemenulink()  : void
New system of rendering content Based on yii submenu rendering
actionSaveDataSecTextData()  : JSON
Method to store data edited in the data security text editor component
actionSaveTextData()  : JSON
Method to store data edited in the text editor component
actionSaveUrlParam()  : mixed
Method to save URL Params (Panel Integration)
actionToggleQuickAction()  : string
Toggles Quick action
actionUploadimagefile()  : json
Upload an image in directory
actionView()  : void
Load complete view of survey properties and actions specified by $iSurveyID
changeTemplate()  : mixed
Update the theme of a survey
createAbsoluteUrl()  : string
Returns an absolute URL based on the given controller and action information.
filters()  : array<string|int, string>
Set filters for all actions
getSurveyAndSidemenueDirectionURL()  : string
This method will return the url for the current survey and set the direction for the sidemenue.
loadHelper()  : void
Loads a helper
loadLibrary()  : void
Loads a library
run()  : void
Checks for action specific authorization and then executes an action
_checkInstallation()  : void
Check that installation was already done by looking for config.php Will redirect to the installer script if not exists.
beforeRender()  : bool
This part comes from renderWrappedTemplate
customInit()  : mixed
generalTabEditSurvey()  : mixed
Returns Data for Tab General Edit Survey.
getDataSecurityEditData()  : array<string|int, mixed>
Returns Date for Data Security Edit.
getTextEditData()  : array<string|int, mixed>
Returns data for text edit.
loadPageStates()  : array<string|int, mixed>
Loads page states from a hidden input.
pluginTabSurvey()  : array<string|int, mixed>
Returns Data for Plugin tab.
renderJSON()  : void
Method to render an array as a json document (this one called by a lot of actions in different controllers)
sessionControl()  : void
Load and set session vars
tabNotificationDataManagement()  : array<string|int, mixed>
Returns the data for Tab Notification and Data Management.
tabPanelIntegration()  : array<string|int, mixed>
Returns the data for Tab Panel Integration.
tabPresentationNavigation()  : array<string|int, mixed>
Returns data for tab Presentation navigation.
tabPublicationAccess()  : array<string|int, mixed>
Returns the data for Tab Publication Access control.
tabResourceManagement()  : array<string|int, mixed>
Returns data for Tab Resourves.
tabTokens()  : array<string|int, mixed>
Returns the data for Tab Tokens.
createSampleGroup()  : int
This private function creates a sample group
createSampleQuestion()  : int
This private function creates a sample question
fetchSurveyInfo()  : void
Load survey information based on $action.
generalTabNewSurvey()  : array<string|int, mixed>
Load "General" tab of new survey screen.
getGeneralTemplateData()  : array<string|int, mixed>
Returns Data for general template.
getOrgdata()  : array<string|int, mixed>
Get the new question organization from the post data.
getSurveyIdFromGetRequest()  : int
Try to get the get-parameter from request.
showReorderForm()  : array<string|int, mixed>
Show the form for Organize question groups/questions
surveysummary()  : mixed
Adds some other important adata variables for frontend

Properties

$aData

public array<string|int, mixed> $aData = []

import for all new controllers/actions (REFACTORING) to pass data before rendering the content

$navData

This array contains the survey / group / question id used by the menu widget.

public array<string|int, mixed> $navData = array()

$sTemplate

public null $sTemplate = \null

this is needed for the preview rendering inside the questioneditor

Methods

__construct()

SurveyAdministrationController constructor.

public __construct( $id[, null $module = null ]) : mixed
Parameters
$id :
$module : null = null
Tags
throws
CException

accessRules()

It's import to have the accessRules set (security issue).

public accessRules() : array<string|int, mixed>

Only logged in users should have access to actions. All other permissions should be checked in the action itself.

Return values
array<string|int, mixed>

actionActivateSurvey()

This action renders the view for survey activation where the user can preselect some options like "ipanonymize" etc.

public actionActivateSurvey() : void

It is also possible to switch between the "open access mode" and the "close-access-mode" before the survey is activated. The action also checks if it is even possible to activate the survey (see checkGroup() and checkQuestions() for more information).

actionApplythemeoptions()

Apply current theme options for imported survey theme

public actionApplythemeoptions([int $surveyid = 0 ]) : void
Parameters
$surveyid : int = 0

actionChangeFormat()

Called via ajax request from survey summary quick action "Show questions group by group".

public actionChangeFormat(int $iSurveyID, string $format) : void
Parameters
$iSurveyID : int

Given Survey ID

$format : string

Given Format

actionChangeMultipleSurveyGroup()

Change survey group for multiple survey at once.

public actionChangeMultipleSurveyGroup() : void

Called from survey list massive actions

Tags
throws
CException

actionChangeMultipleTheme()

Massive action in ListSurveysWidget ... Ajax request

public actionChangeMultipleTheme() : void
Tags
throws
CException

actionCopy()

Function responsible to import/copy a survey based on $action.

public actionCopy() : void
Tags
todo

this should be separated in two actions import and copy ...

access

public

actionDatetimesettings()

Ajaxrequest returning 'session['dateformat']' and some other parameters to the frontend

public actionDatetimesettings() : void
Tags
todo

this function should be moved to another controller (?)

actionDeactivate()

Function responsible to deactivate a survey.

public actionDeactivate() : void
Tags
access

public

throws
CException

actionDelete()

Function responsible to delete a survey.

public actionDelete() : string
Tags
access

public

Return values
string

actionDeleteUrlParam()

Method to delete URL Params (Panel Integration)

public actionDeleteUrlParam() : void
Tags
throws
CDbException
throws
CHttpException

actionExpireMultipleSurveys()

Action to set expiry date to multiple surveys.

public actionExpireMultipleSurveys() : void

(ajax request)

Tags
throws
CException

actionFakebrowser()

todo: what is this? why do we need it? (it'S just an js-script alert window rendert here ...)

public actionFakebrowser() : void
Tags
throws
CException

actionFixNumbering()

fixes the numbering of questions This can happen if question 1 have subquestion code 1 and have question 11 in same survey and group (then same SGQA).

public actionFixNumbering() : array<string|int, mixed>|false|string|array<string|int, string>|null
Tags
todo:

maybe this one could not happen anymore ?

throws
CException
Return values
array<string|int, mixed>|false|string|array<string|int, string>|null

actionGetAjaxMenuArray()

Ajaxified get MenuItems with containing questions

public actionGetAjaxMenuArray(int $surveyid[, string $position = '' ]) : string|array<string|int, string>
Parameters
$surveyid : int

Given Survey ID

$position : string = ''

Given Position

Tags
todo

this could go into surveymenucontroller

throws
CException
Return values
string|array<string|int, string>

actionGetAjaxQuestionGroupArray()

AjaxRequest get questionGroup with containing questions

public actionGetAjaxQuestionGroupArray(int $surveyid) : string|array<string|int, string>
Parameters
$surveyid : int

Given Survey ID

Tags
todo

this could go to the questiongroupAdministrationController ?

throws
CException
Return values
string|array<string|int, string>

actionGetCurrentEditorValues()

Function to call current Editor Values by Ajax

public actionGetCurrentEditorValues(int $sid) : JSON
Parameters
$sid : int

Given Survey ID

is still used in sidemenu Text elemnts (see vue.js ajaxcall)

Tags
throws
CException
Return values
JSON

actionGetDataSecTextSettings()

Collect the data necessary for the data security settings and return a JSON document

public actionGetDataSecTextSettings([int|null $sid = null ]) : JSON
Parameters
$sid : int|null = null

Survey ID

Tags
throws
CException
Return values
JSON

| string

actionGetDateFormatOptions()

Method to call current date information by ajax

public actionGetDateFormatOptions() : JSON
Tags
throws
CException
Return values
JSON

| string

actionGetTokenTopBar()

Returns JSON Data for Token Top Bar.

public actionGetTokenTopBar(int $sid) : string
Parameters
$sid : int

Given Survey ID

Tags
todo:

this should go into tokens controller ...

Return values
string

actionGetUrlParamsJSON()

public actionGetUrlParamsJSON(int $surveyid) : void
Parameters
$surveyid : int

Given Survey ID.

Tags
todo

Add TypeDoc.

actionImportsurveyresources()

Function responsible to import survey resources from a '.zip' file.

public actionImportsurveyresources() : void
Tags
todo

is this function used? the function editlocalsetting does not exists (also not in old controller surveyadmin)

access

public

actionInsert()

Saves the new survey after the creation screen is submitted

public actionInsert() : string
Tags
throws
CException
Return values
string

actionOrganize()

Load ordering of question group screen.

public actionOrganize() : void

questiongroup::organize()

Tags
TODO

Reordering should be handled by existing function in new QuestionGroupService class

actionPurge()

Remove files not deleted properly.

public actionPurge(int $purge_sid) : void

Purge is only available for surveys that were already deleted but for some reason left files behind.

Parameters
$purge_sid : int

Given ID

actionRegenerateQuestionCodes()

Regeerates the question code Automatically renumbers the "question codes" so that they follow a methodical numbering method.

public actionRegenerateQuestionCodes() : void

New system of rendering content Based on yii submenu rendering

public actionRendersidemenulink(int $surveyid, string $subaction) : void
Parameters
$surveyid : int

Given Survey ID

$subaction : string

Given subaction (subaction decides which view to render)

Tags
throws
Exception

The below 'uses' are mentioned

uses
self::generalTabEditSurvey()
uses
self::pluginTabSurvey()
uses
self::tabPresentationNavigation()
uses
self::tabPublicationAccess()
uses
self::tabNotificationDataManagement()
uses
self::tabTokens()
uses
self::tabPanelIntegration()
uses
self::tabResourceManagement()

actionSaveDataSecTextData()

Method to store data edited in the data security text editor component

public actionSaveDataSecTextData(int $sid) : JSON
Parameters
$sid : int

Survey ID

Tags
throws
CException
Return values
JSON

| string

actionSaveTextData()

Method to store data edited in the text editor component

public actionSaveTextData(mixed $sid) : JSON

integer $sid Survey ID

Parameters
$sid : mixed
Tags
throws
CException
Return values
JSON

| string

actionToggleQuickAction()

Toggles Quick action

public actionToggleQuickAction() : string
Tags
throws
CException
Return values
string

| null

actionUploadimagefile()

Upload an image in directory

public actionUploadimagefile() : json
Tags
throws
CException
Return values
json

|string

actionView()

Load complete view of survey properties and actions specified by $iSurveyID

public actionView() : void
Tags
access

public

throws
CException

changeTemplate()

Update the theme of a survey

public changeTemplate(int $iSurveyID, string $template[, array<string|int, mixed> $aResults = null ][, bool $bReturn = false ]) : mixed
Parameters
$iSurveyID : int

Survey ID

$template : string

The survey theme name

$aResults : array<string|int, mixed> = null

If the method is called from changeMultipleTheme(), it will update its array of results

$bReturn : bool = false

Should the method update and return aResults

Tags
access

public

Return values
mixed

null or array

createAbsoluteUrl()

Returns an absolute URL based on the given controller and action information.

public createAbsoluteUrl(string $route[, array<string|int, mixed> $params = array() ][, string $schema = '' ][, string $ampersand = '&' ]) : string

The functionalty was moved to \LSYii_Application::createPublicUrl, to be safe the function remains here.

Parameters
$route : string

the URL route. This should be in the format of 'ControllerID/ActionID'.

$params : array<string|int, mixed> = array()

additional GET parameters (name=>value). Both the name and value will be URL-encoded.

$schema : string = ''

schema to use (e.g. http, https). If empty, the schema used for the current request will be used.

$ampersand : string = '&'

the token separating name-value pairs in the URL.

Return values
string

the constructed URL

getSurveyAndSidemenueDirectionURL()

This method will return the url for the current survey and set the direction for the sidemenue.

public getSurveyAndSidemenueDirectionURL(int $sid, int $gid, int $qid, string $landOnSideMenuTab) : string
Parameters
$sid : int

Given Survey ID

$gid : int

Given Group ID

$qid : int

Given Question ID

$landOnSideMenuTab : string

Given SideMenuTab

Return values
string

loadHelper()

Loads a helper

public loadHelper(string $helper) : void
Parameters
$helper : string
Tags
access

public

loadLibrary()

Loads a library

public loadLibrary(string $library) : void
Parameters
$library : string
Tags
access

public

run()

Checks for action specific authorization and then executes an action

public run(string $action) : void

TODO: check the dbupdate mechanism, do we really want to check db update before every action??

Parameters
$action : string
Tags
access

public

throws
CException
throws
CHttpException

_checkInstallation()

Check that installation was already done by looking for config.php Will redirect to the installer script if not exists.

protected _checkInstallation() : void
Tags
access

protected

beforeRender()

This part comes from renderWrappedTemplate

protected beforeRender(string $view) : bool
Parameters
$view : string
Return values
bool

generalTabEditSurvey()

Returns Data for Tab General Edit Survey.

protected generalTabEditSurvey(Survey $survey) : mixed

survey::_generalTabEditSurvey() Load "General" tab of edit survey screen.

Parameters
$survey : Survey

Given Survey

getDataSecurityEditData()

Returns Date for Data Security Edit.

protected getDataSecurityEditData(Survey $survey) : array<string|int, mixed>

tab_edit_view_datasecurity editDataSecurityLocalSettings_view

Parameters
$survey : Survey

Given Survey

Return values
array<string|int, mixed>

getTextEditData()

Returns data for text edit.

protected getTextEditData(Survey $survey) : array<string|int, mixed>

BE CAREFUL (this function is not called directly, but by call_user_func_array and the name of function in db .. )

Parameters
$survey : Survey

Given Survey.

Return values
array<string|int, mixed>

loadPageStates()

Loads page states from a hidden input.

protected loadPageStates() : array<string|int, mixed>
Return values
array<string|int, mixed>

the loaded page states

pluginTabSurvey()

Returns Data for Plugin tab.

protected pluginTabSurvey(Survey $survey) : array<string|int, mixed>

survey::_pluginTabSurvey() Load "Simple Plugin" page in specific survey.

Parameters
$survey : Survey

Given Survey

Tags
SuppressWarnings

(PHPMD.UnusedPrivateMethod)

Return values
array<string|int, mixed>

This method is called via call_user_func in self::rendersidemenulink()

renderJSON()

Method to render an array as a json document (this one called by a lot of actions in different controllers)

protected renderJSON(array<string|int, mixed> $aData[, mixed $success = true ]) : void
Parameters
$aData : array<string|int, mixed>
$success : mixed = true

sessionControl()

Load and set session vars

protected sessionControl() : void

todo REFACTORING see comments in mehtod

Tags
access

protected

tabNotificationDataManagement()

Returns the data for Tab Notification and Data Management.

protected tabNotificationDataManagement(mixed $survey) : array<string|int, mixed>

survey::_tabNotificationDataManagement() Load "Notification & data management" tab.

Parameters
$survey : mixed

?

Return values
array<string|int, mixed>

tabPanelIntegration()

Returns the data for Tab Panel Integration.

protected tabPanelIntegration(Survey $survey[, string|null $sLang = null ]) : array<string|int, mixed>
Parameters
$survey : Survey

Given Survey

$sLang : string|null = null

Given Language

Return values
array<string|int, mixed>

tabPresentationNavigation()

Returns data for tab Presentation navigation.

protected tabPresentationNavigation(mixed $survey) : array<string|int, mixed>

survey::_tabPresentationNavigation() Load "Presentation & navigation" tab.

Parameters
$survey : mixed

?

Return values
array<string|int, mixed>

tabPublicationAccess()

Returns the data for Tab Publication Access control.

protected tabPublicationAccess(Survey $survey) : array<string|int, mixed>

survey::_tabPublicationAccess() Load "Publication * access control" tab.

Parameters
$survey : Survey

Given Survey

Return values
array<string|int, mixed>

tabResourceManagement()

Returns data for Tab Resourves.

protected tabResourceManagement(Survey $survey) : array<string|int, mixed>

survey::_tabResourceManagement() Load "Resources" tab.

Parameters
$survey : Survey

Given Survey

Tags
todo

is this new implementation???

Return values
array<string|int, mixed>

tabTokens()

Returns the data for Tab Tokens.

protected tabTokens(mixed $survey) : array<string|int, mixed>

survey::_tabTokens() Load "Tokens" tab.

Parameters
$survey : mixed

?

Return values
array<string|int, mixed>

createSampleGroup()

This private function creates a sample group

private createSampleGroup(int $iSurveyID) : int
Parameters
$iSurveyID : int

The survey ID that the sample group will belong to

Return values
int

createSampleQuestion()

This private function creates a sample question

private createSampleQuestion(int $iSurveyID, int $iGroupID) : int
Parameters
$iSurveyID : int

The survey ID that the sample question will belong to

$iGroupID : int

The group ID that the sample question will belong to

Return values
int

fetchSurveyInfo()

Load survey information based on $action.

private fetchSurveyInfo(string $action[, int $iSurveyID = null ]) : void

survey::_fetchSurveyInfo()

Parameters
$action : string

Given Action

$iSurveyID : int = null

Given Survey ID

Tags
deprecated

use Survey objects instead

Return values
void

| array

generalTabNewSurvey()

Load "General" tab of new survey screen.

private generalTabNewSurvey() : array<string|int, mixed>

survey::_generalTabNewSurvey()

Return values
array<string|int, mixed>

getGeneralTemplateData()

Returns Data for general template.

private getGeneralTemplateData(int $iSurveyID) : array<string|int, mixed>
Parameters
$iSurveyID : int

Given Survey ID

Return values
array<string|int, mixed>

getOrgdata()

Get the new question organization from the post data.

private getOrgdata() : array<string|int, mixed>

This function replaces parse_str, since parse_str is bound by max_input_vars.

Return values
array<string|int, mixed>

getSurveyIdFromGetRequest()

Try to get the get-parameter from request.

private getSurveyIdFromGetRequest() : int

At the moment there are three namings for a survey ID: 'sid' 'surveyid' 'iSurveyID'

Returns the id as integer or null if not exists any of them.

Tags
todo

While refactoring (at some point) this function should be removed and only one unique identifier should be used

Return values
int

| null

showReorderForm()

Show the form for Organize question groups/questions

private showReorderForm(int $iSurveyID) : array<string|int, mixed>
Parameters
$iSurveyID : int

Given Survey ID

Tags
todo

Change function name to _showOrganizeGroupsAndQuestions?

todo

Does actually not show anything, but gets data. So getReorderFormData()?

Return values
array<string|int, mixed>

surveysummary()

Adds some other important adata variables for frontend

private surveysummary(array<string|int, mixed> &$aData) : mixed

this function came from Layouthelper

Parameters
$aData : array<string|int, mixed>

pointer to array (this array will be changed here!!)

Tags
throws
CException

        
On this page

Search results