GeneralSettings
in package
Service GeneralSettings
Service class for survey language setting updating.
Dependencies are injected to enable mocking.
Tags
Table of Contents
Constants
- FIELD_TYPE_DATETIME = 'datetime'
- FIELD_TYPE_GAKEY = 'gakey'
- FIELD_TYPE_USE_CAPTCHA = 'use_captcha'
- FIELD_TYPE_YN = 'yesorno'
- GA_GLOBAL_KEY = '9999useGlobal9999'
Properties
- $languageConsistency : LanguageConsistency
- $modelPermission : Permission
- $modelSurvey : Survey
- $modelUser : User
- $pluginManager : PluginManager
- $restMode : mixed
- $session : CHttpSession
- $yiiApp : LSYii_Application
Methods
- __construct() : mixed
- setRestMode() : mixed
- Set REST Mode
- update() : array<string|int, mixed>
- Update
- calculateUseCaptchaOption() : string|null
- Transcribe from 3 checkboxes to 1 char for captcha usages Uses variables from $_POST and transferred Surveyobject
- dispatchPluginEventBeforeSurveySettingsSave() : void
- Dispatch plugin event before survey settings save
- dispatchPluginEventNewSurveySettings() : void
- Dispatch plugin event new survey settings
- filterInput() : array<string|int, mixed>
- Filter Input
- formatDateTimeInput() : string
- Format date time input
- getAdditionalLanguagesArray() : mixed
- getFields() : array<string|int, mixed>
- Get Database Fields
- setField() : array<string|int, mixed>
- Set Field
- updateGeneralSettings() : array<string|int, mixed>
- Update General Settings
Constants
FIELD_TYPE_DATETIME
public
mixed
FIELD_TYPE_DATETIME
= 'datetime'
FIELD_TYPE_GAKEY
public
mixed
FIELD_TYPE_GAKEY
= 'gakey'
FIELD_TYPE_USE_CAPTCHA
public
mixed
FIELD_TYPE_USE_CAPTCHA
= 'use_captcha'
FIELD_TYPE_YN
public
mixed
FIELD_TYPE_YN
= 'yesorno'
GA_GLOBAL_KEY
public
mixed
GA_GLOBAL_KEY
= '9999useGlobal9999'
Properties
$languageConsistency
private
LanguageConsistency
$languageConsistency
$modelPermission
private
Permission
$modelPermission
$modelSurvey
private
Survey
$modelSurvey
$modelUser
private
User
$modelUser
$pluginManager
private
PluginManager
$pluginManager
$restMode
private
mixed
$restMode
= false
$session
private
CHttpSession
$session
$yiiApp
private
LSYii_Application
$yiiApp
Methods
__construct()
public
__construct(Permission $modelPermission, Survey $modelSurvey, LSYii_Application $yiiApp, CHttpSession $session, PluginManager $pluginManager, LanguageConsistency $languageConsistency, User $modelUser) : mixed
Parameters
- $modelPermission : Permission
- $modelSurvey : Survey
- $yiiApp : LSYii_Application
- $session : CHttpSession
- $pluginManager : PluginManager
- $languageConsistency : LanguageConsistency
- $modelUser : User
setRestMode()
Set REST Mode
public
setRestMode(bool $restMode) : mixed
In rest mode we have different expecations about data formats. For example datetime objects inputs/output as UTC JSON format Y-m-d\TH:i:s.000\Z.
Parameters
- $restMode : bool
update()
Update
public
update(int $surveyId, array<string|int, mixed> $input) : array<string|int, mixed>
Parameters
- $surveyId : int
- $input : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>calculateUseCaptchaOption()
Transcribe from 3 checkboxes to 1 char for captcha usages Uses variables from $_POST and transferred Surveyobject
private
calculateUseCaptchaOption(mixed $surveyaccess, mixed $registration, mixed $saveandload) : string|null
'A' = All three captcha enabled 'B' = All but save and load 'C' = All but registration 'D' = All but survey access 'X' = Only survey access 'R' = Only registration 'S' = Only save and load
'E' = All inherited 'F' = Inherited save and load + survey access + registration 'G' = Inherited survey access + registration + save and load 'H' = Inherited registration + save and load + survey access 'I' = Inherited save and load + inherited survey access + registration 'J' = Inherited survey access + inherited registration + save and load 'K' = Inherited registration + inherited save and load + survey access
'L' = Inherited survey access + save and load 'M' = Inherited survey access + registration 'O' = Inherited registration + survey access '1' = Inherited survey access + inherited registration '2' = Inherited survey access + inherited save and load '3' = Inherited registration + inherited save and load '4' = Inherited survey access '5' = Inherited save and load '6' = Inherited registration
'N' = None
Parameters
- $surveyaccess : mixed
- $registration : mixed
- $saveandload : mixed
Tags
Return values
string|null —One character that corresponds to captcha usage
dispatchPluginEventBeforeSurveySettingsSave()
Dispatch plugin event before survey settings save
private
dispatchPluginEventBeforeSurveySettingsSave(Survey $survey) : void
Parameters
- $survey : Survey
dispatchPluginEventNewSurveySettings()
Dispatch plugin event new survey settings
private
dispatchPluginEventNewSurveySettings(int $surveyId, array<string|int, mixed> $pluginSettings) : void
Parameters
- $surveyId : int
- $pluginSettings : array<string|int, mixed>
filterInput()
Filter Input
private
filterInput(mixed $input) : array<string|int, mixed>
Parameters
- $input : mixed
Return values
array<string|int, mixed>formatDateTimeInput()
Format date time input
private
formatDateTimeInput(string $inputDateTimeString) : string
Converts date time string from user local format to internal database format.
Parameters
- $inputDateTimeString : string
Return values
stringgetAdditionalLanguagesArray()
private
getAdditionalLanguagesArray(mixed $input, Survey $survey) : mixed
Parameters
- $input : mixed
- $survey : Survey
getFields()
Get Database Fields
private
getFields(Survey $survey) : array<string|int, mixed>
Parameters
- $survey : Survey
Tags
Return values
array<string|int, mixed>setField()
Set Field
private
setField(string $field, array<string|int, mixed> &$input, Survey $survey, array<string|int, mixed> $meta[, array<string|int, mixed>|null $fieldOpts = null ]) : array<string|int, mixed>
Parameters
- $field : string
- $input : array<string|int, mixed>
- $survey : Survey
- $meta : array<string|int, mixed>
- $fieldOpts : array<string|int, mixed>|null = null
Tags
Return values
array<string|int, mixed>updateGeneralSettings()
Update General Settings
private
updateGeneralSettings(Survey $survey, array<string|int, mixed> $input) : array<string|int, mixed>
Parameters
- $survey : Survey
- $input : array<string|int, mixed>