BeforeSurveyDeactivate: 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 |
||
Line 19: | Line 19: | ||
''message'' Error message to show. This will be shown independent of ''success'' | ''message'' Error message to show. This will be shown independent of ''success'' | ||
'''Example''' | '''Example''' | ||
Line 25: | Line 26: | ||
public function beforeSurveyDeactivate() | public function beforeSurveyDeactivate() | ||
{ | { | ||
$event = $this->getEvent(); | |||
$surveyId = $event->get('surveyId'); | |||
$survey = Survey::model()->findByPk($surveyId); | |||
if ($survey->owner_id == Yii::app()->user->id) | |||
{ | |||
$event->set('success', false); | |||
$event->set('message', 'User can\'t disable his/hers own survey. Silly.'); | |||
} | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Plugins events]] | [[Category:Plugins events]] |
Revision as of 12:27, 1 August 2016
When
This event is fired just before the survey deactivation screen.
Input
The event receives the following information:
surveyId the id of the current survey
Possible output
The following information can be set in the event:
success False will hide the deactivation options
message Error message to show. This will be shown independent of success
Example
public function beforeSurveyDeactivate()
{
$event = $this->getEvent();
$surveyId = $event->get('surveyId');
$survey = Survey::model()->findByPk($surveyId);
if ($survey->owner_id == Yii::app()->user->id)
{
$event->set('success', false);
$event->set('message', 'User can\'t disable his/hers own survey. Silly.');
}
}