Actions

BeforeSurveyActivate: Difference between revisions

From LimeSurvey Manual

(Created page with "{{FeatureStarting|2.5}} '''When''' This event is fired just before the survey deactivation screen. '''Input''' The event receives the following information: ''surveyId''...")
 
No edit summary
(10 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{FeatureStarting|2.5}}
'''When'''


'''When'''
This event is fired just before the survey is activated.


This event is fired just before the survey deactivation screen.


'''Input'''
'''Input'''
Line 9: Line 8:
The event receives the following information:
The event receives the following information:


''surveyId'' the id of the current survey
{|
 
! Name !! Type !! Description
''simulate''
|-
| surveyid || integer || The id of the current survey
|-
| simulate || boolean || -
|}




Line 18: Line 21:
The following information can be set in the event:
The following information can be set in the event:


''success'' False will abort the activation
{|
 
! Name !! Type !! Description
''message'' Error message to show. This will be shown independent of ''success''
|-
| success || boolean || False will abort the activation
|-
| message || string || Error message to show. This will be shown independent of ''success''
|-
| pluginFeedback || string || If set, will show this HTML instead of the default success feedback message
|}




Line 26: Line 35:


<syntaxhighlight lang="php">
<syntaxhighlight lang="php">
public function beforeSurveyActivate()
{
  $event = $this->getEvent();
  if ($this->checkSomeCondition())
  {
    $event->set('success', false);
    $event->set('message', 'Can\'t activate survey - some condition is not met.');
  }
}
</syntaxhighlight>
</syntaxhighlight>


[[Category:Plugins events]]
[[Category:Plugins events]]

Revision as of 12:45, 6 November 2018

When

This event is fired just before the survey is activated.


Input

The event receives the following information:

Name Type Description
surveyid integer The id of the current survey
simulate boolean -


Possible output

The following information can be set in the event:

Name Type Description
success boolean False will abort the activation
message string Error message to show. This will be shown independent of success
pluginFeedback string If set, will show this HTML instead of the default success feedback message


Example

public function beforeSurveyActivate()
{
  $event = $this->getEvent();
  if ($this->checkSomeCondition())
  {
    $event->set('success', false);
    $event->set('message', 'Can\'t activate survey - some condition is not met.');
  }
}