Skip to content

Commit

Permalink
New feature: New event onSurveyDenied
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Aug 19, 2016
1 parent dfe7889 commit 485f592
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions application/controllers/survey/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ function action()
gT("We are sorry but you don't have permissions to do this."),
sprintf(gT("Please contact %s ( %s ) for further assistance."),$thissurvey['adminname'],$thissurvey['adminemail'])
);

$event = new PluginEvent('onSurveyDenied');
$event->set('surveyId', $surveyid);
$event->set('reason', 'noPreviewPermission');
App()->getPluginManager()->dispatchEvent($event);

$this->_niceExit($redata, __LINE__, null, $asMessage);
}
}
Expand All @@ -216,6 +222,12 @@ function action()
gT("Either you have been inactive for too long, you have cookies disabled for your browser, or there were problems with your connection."),
sprintf(gT("Please contact %s ( %s ) for further assistance."),$thissurvey['adminname'],$thissurvey['adminemail'])
);

$event = new PluginEvent('onSurveyDenied');
$event->set('surveyId', $surveyid);
$event->set('reason', 'sessionExpired');
App()->getPluginManager()->dispatchEvent($event);

$this->_niceExit($redata, __LINE__, null, $asMessage);
};

Expand All @@ -233,6 +245,11 @@ function action()
}
else
{
$event = new PluginEvent('onSurveyDenied');
$event->set('surveyId', $surveyid);
$event->set('reason', 'surveyDoesNotExist');
App()->getPluginManager()->dispatchEvent($event);

throw new CHttpException(404, "The survey in which you are trying to participate does not seem to exist. It may have been deleted or the link you were given is outdated or incorrect.");
}

Expand Down Expand Up @@ -282,6 +299,11 @@ function action()
sprintf(gT("Please contact %s ( %s ) for further assistance."),$thissurvey['adminname'],$thissurvey['adminemail'])
);

$event = new PluginEvent('onSurveyDenied');
$event->set('surveyId', $surveyid);
$event->set('reason', 'surveyNoLongerAvailable');
App()->getPluginManager()->dispatchEvent($event);

$this->_niceExit($redata, __LINE__, $thissurvey['templatedir'], $asMessage);
}

Expand All @@ -294,6 +316,12 @@ function action()
gT("This survey is not yet started."),
sprintf(gT("Please contact %s ( %s ) for further assistance."),$thissurvey['adminname'],$thissurvey['adminemail'])
);

$event = new PluginEvent('onSurveyDenied');
$event->set('surveyId', $surveyid);
$event->set('reason', 'surveyNotYetStarted');
App()->getPluginManager()->dispatchEvent($event);

$this->_niceExit($redata, __LINE__, $thissurvey['templatedir'], $asMessage);
}

Expand All @@ -309,6 +337,11 @@ function action()
sprintf(gT("Please contact %s ( %s ) for further assistance."),$thissurvey['adminname'],$thissurvey['adminemail'])
);

$event = new PluginEvent('onSurveyDenied');
$event->set('surveyId', $surveyid);
$event->set('reason', 'alreadyCompleted');
App()->getPluginManager()->dispatchEvent($event);

$this->_niceExit($redata, __LINE__, $thissurvey['templatedir'], $asMessage);
}

Expand Down Expand Up @@ -434,6 +467,11 @@ function action()
sprintf(gT("For further information please contact %s"), $thissurvey['adminname']." (<a href='mailto:{$thissurvey['adminemail']}'>"."{$thissurvey['adminemail']}</a>)")
);

$event = new PluginEvent('onSurveyDenied');
$event->set('surveyId', $surveyid);
$event->set('reason', 'invalidToken');
App()->getPluginManager()->dispatchEvent($event);

$this->_niceExit($redata, __LINE__, $thistpl, $asMessage, true);
}
else
Expand Down

0 comments on commit 485f592

Please sign in to comment.