Skip to content

Commit

Permalink
Fixed issue #11489: Session time out : get back to first step without…
Browse files Browse the repository at this point in the history
… any information

Dev: use Permission::model() to control preview access to survey
  • Loading branch information
Shnoulle committed Oct 31, 2016
1 parent e85bb86 commit 0bfb1c6
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions application/controllers/survey/index.php
Expand Up @@ -244,17 +244,26 @@ function action()
// recompute $redata since $saved_id used to be a global
$redata = compact(array_keys(get_defined_vars()));

if ( $this->_didSessionTimeOut($surveyid) )
if ( $this->_didSessionTimeout($surveyid) )
{
$aErrors=array(gT('We are sorry but your session has expired.'));
$aMessage = array(
gT("Either you have been inactive for too long, you have cookies disabled for your browser, or there were problems with your connection."),
);
$aReloadUrlParam=array('lang'=>App()->language,'newtest'=>'Y');
if($clienttoken){
$aReloadUrlParam['token']=$clienttoken;
}
$aUrl=array(
'url'=>$this->getController()->createUrl("/survey/index/sid/{$surveyid}",$aReloadUrlParam),
'type'=>'restart-survey',
'description'=>gT("Click here to start the survey.")
);
App()->getController()->renderExitMessage(
$surveyid,
'session-timeout',
$aMessage,
null,
$aUrl,
$aErrors
);
};
Expand Down Expand Up @@ -717,14 +726,11 @@ function _surveyCantBeViewedWithCurrentPreviewAccess($surveyid, $bIsSurveyActive

function _didSessionTimeout($surveyid)
{
return !isset($_SESSION['survey_'.$surveyid]['s_lang']) && isset($_POST['thisstep']);
return (!isset($_SESSION['survey_'.$surveyid]['step']) && null !== App()->request->getPost('thisstep') );
}

function _canUserPreviewSurvey($iSurveyID)
{
if ( !isset($_SESSION['loginID']) ) // This is not needed because Permission::model()->hasSurveyPermission control connexion
return false;

return Permission::model()->hasSurveyPermission($iSurveyID,'surveycontent','read');
}

Expand Down

0 comments on commit 0bfb1c6

Please sign in to comment.