Skip to content

Commit

Permalink
Fixed issue #12641: When register : any lang can be set and accepted.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnoulle committed Sep 1, 2017
1 parent f6db4d4 commit 185fa0c
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions application/controllers/RegisterController.php
Expand Up @@ -85,25 +85,21 @@ public function actionIndex($sid = null)
$iSurveyId=Yii::app()->request->getPost('sid');

$oSurvey=Survey::model()->find("sid=:sid",array(':sid'=>$iSurveyId));

$sLanguage = Yii::app()->request->getParam('lang');
if (!$sLanguage)
{
$sLanguage = Survey::model()->findByPk($iSurveyId)->language;
}

if (!$oSurvey){
/* Throw 404 if needed */
if (!$oSurvey) {
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.");
}elseif($oSurvey->allowregister!='Y' || !tableExists("{{tokens_{$iSurveyId}}}")){
} elseif($oSurvey->allowregister!='Y' || !tableExists("{{tokens_{$iSurveyId}}}")) {
throw new CHttpException(404,"The survey in which you are trying to register don't accept registration. It may have been updated or the link you were given is outdated or incorrect.");
}
elseif(!is_null($oSurvey->expires) && $oSurvey->expires < dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig('timeadjust'))){
} elseif(!is_null($oSurvey->expires) && $oSurvey->expires < dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig('timeadjust'))) {
$this->redirect(array('survey/index','sid'=>$iSurveyId,'lang'=>$sLanguage));
}

/* Fix language accoridng to existing language in survey */

This comment has been minimized.

Copy link
@tammoterhark

tammoterhark Sep 1, 2017

Contributor

according

This comment has been minimized.

Copy link
@Shnoulle

Shnoulle Sep 1, 2017

Author Collaborator

oups … can edit directly in github ;)

This comment has been minimized.

Copy link
@Shnoulle

Shnoulle Sep 1, 2017

Author Collaborator

done

$sLanguage = Yii::app()->request->getParam('lang');
if (!$sLanguage || !in_array($sLanguage,$oSurvey->getAllLanguages())) {
$sLanguage = $oSurvey->language;
}
Yii::app()->setLanguage($sLanguage);


$event = new PluginEvent('beforeRegister');
$event->set('surveyid', $iSurveyId);
$event->set('lang', $sLanguage);
Expand Down

0 comments on commit 185fa0c

Please sign in to comment.