diff --git a/application/controllers/survey/index.php b/application/controllers/survey/index.php index 6b855fe7bcc..60699315dca 100644 --- a/application/controllers/survey/index.php +++ b/application/controllers/survey/index.php @@ -143,17 +143,17 @@ function action() // recompute $redata since $saved_id used to be a global $redata = compact(array_keys(get_defined_vars())); - // set up a script that redirects the user to an error page when his session expires - Yii::app()->clientScript->registerScript('sessionexpires', "setTimeout(function(){location.href='?sessionExpired=yes'}, ".(Yii::app()->getConfig('iSessionExpirationTime')*1000).")", CClientScript::POS_READY); - if (Yii::app()->request->getQuery('sessionExpired') === 'yes') + + if ( $this->_didSessionTimeOut($surveyid) ) { - $asMessage = array( - $clang->gT("Error"), - $clang->gT("We are sorry but your session has expired."), - $clang->gT("Either you have been inactive for too long, you have cookies disabled for your browser, or there were problems with your connection."), - sprintf($clang->gT("Please contact %s ( %s ) for further assistance."),$thissurvey['adminname'],$thissurvey['adminemail']) - ); - $this->_niceExit($redata, __LINE__, null, $asMessage); + // @TODO is this still required ? + $asMessage = array( + $clang->gT("Error"), + $clang->gT("We are sorry but your session has expired."), + $clang->gT("Either you have been inactive for too long, you have cookies disabled for your browser, or there were problems with your connection."), + sprintf($clang->gT("Please contact %s ( %s ) for further assistance."),$thissurvey['adminname'],$thissurvey['adminemail']) + ); + $this->_niceExit($redata, __LINE__, null, $asMessage); }; // Set the language of the survey, either from POST, GET parameter of session var @@ -584,9 +584,9 @@ function _surveyCantBeViewedWithCurrentPreviewAccess($surveyid, $bIsSurveyActive return $surveyid && $bIsSurveyActive === false && $bSurveyExists && isset($bSurveyPreviewRequireAuth) && $bSurveyPreviewRequireAuth == true && !$this->_canUserPreviewSurvey($surveyid); } - function _didSessionTimeout() + function _didSessionTimeout($surveyid) { - return !isset($_SESSION['survey_'.$surveyid]['s_lang']); + return !isset($_SESSION['survey_'.$surveyid]['s_lang']) && isset($_POST['thisstep']); } function _canUserPreviewSurvey($iSurveyID)