Skip to content

Commit

Permalink
New feature: New event beforeSurveyActivate
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Aug 10, 2016
1 parent f372cfa commit 86203ec
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
7 changes: 6 additions & 1 deletion application/controllers/admin/surveyadmin.php
Expand Up @@ -718,7 +718,12 @@ public function activate($iSurveyID)

$aResult=activateSurvey($iSurveyID);
$aViewUrls = array();
if (isset($aResult['error']))
if (isset($aResult['error']) && $aResult['error'] == 'plugin')
{
// Got false from plugin, redirect to survey front-page
$this->getController()->redirect(array('admin/survey','sa'=>'view','surveyid'=>$iSurveyID));
}
else if (isset($aResult['error']))
{
$aViewUrls['output']= "<br />\n<div class='messagebox ui-corner-all'>\n";
if ($aResult['error']=='surveytablecreation')
Expand Down
19 changes: 18 additions & 1 deletion application/helpers/admin/activate_helper.php
Expand Up @@ -250,10 +250,27 @@ function checkQuestions($postsid, $iSurveyID, $qtypes)
* Function to activate a survey
* @param int $iSurveyID The Survey ID
* @param bool $simulate
* @return string
* @return array
*/
function activateSurvey($iSurveyID, $simulate = false)
{
// Event beforeSurveyActivate
$event = new PluginEvent('beforeSurveyActivate');
$event->set('surveyId', $iSurveyID);
$event->set('simulate', $simulate);
App()->getPluginManager()->dispatchEvent($event);
$success = $event->get('success');
$message = $event->get('message');
if ($success === false)
{
Yii::app()->user->setFlash('error', $message);
return array('error' => 'plugin');
}
else if (!empty($message))
{
Yii::app()->user->setFlash('info', $message);
}

$createsurvey='';
$activateoutput='';
$createsurveytimings='';
Expand Down

0 comments on commit 86203ec

Please sign in to comment.