Skip to content

Commit

Permalink
Fixed issue #08477: a clear error message is now displayed when a ses…
Browse files Browse the repository at this point in the history
…sion expires

Dev Also reverted commit 22b0ced
  • Loading branch information
c-schmitz committed Jan 17, 2014
1 parent 22b0ced commit f5b5a01
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions application/controllers/survey/index.php
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

3 comments on commit f5b5a01

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @c-schmitz : it's OK to add same link than https://github.com/LimeSurvey/LimeSurvey/blob/master/application/controllers/survey/index.php#L84 ?
Think user can click directly to this link if needed.

@c-schmitz
Copy link
Contributor Author

@c-schmitz c-schmitz commented on f5b5a01 Jan 17, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're totally rigth ! ANd we DON'T have to put token here.

  $sReloadUrl=$this->getController()->createUrl("/survey/index/sid/{$surveyid}")

Please sign in to comment.