Skip to content

Commit

Permalink
Fixed issue #10162: Jump instead of navigate to avoid saving NULL-val…
Browse files Browse the repository at this point in the history
…ues for old question group cookie left-over
  • Loading branch information
olleharstedt committed Jan 4, 2016
1 parent 5c45275 commit 2460c69
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions application/controllers/survey/index.php
Expand Up @@ -553,6 +553,7 @@ function action()
}
}
}

// Preview action : Preview right already tested before
if ($previewmode)
{
Expand Down Expand Up @@ -583,6 +584,7 @@ function action()
{
echo "<script type='text/javascript'> $(document).ready( function() { alert('".gT("Your responses were successfully saved.","js")."');}) </script>";
}

}

function _getParameters($args = array(), $post = array())
Expand Down
11 changes: 10 additions & 1 deletion application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -223,6 +223,7 @@ function run($surveyid,$args) {
'token' => (isset($clienttoken) ? $clienttoken : NULL),
);


//Security Checked: POST, GET, SESSION, REQUEST, returnGlobal, DB
$previewgrp = false;
if ($surveyMode == 'group' && isset($param['action']) && ($param['action'] == 'previewgroup'))
Expand Down Expand Up @@ -252,7 +253,9 @@ function run($surveyid,$args) {
$sTemplatePath = $_SESSION[$LEMsessid]['templatepath'];

if($surveyid != LimeExpressionManager::getLEMsurveyId())
{
LimeExpressionManager::SetDirtyFlag();
}

LimeExpressionManager::StartSurvey($surveyid, $surveyMode, $surveyOptions, false, $LEMdebugLevel);
$_SESSION[$LEMsessid]['step'] = 0;
Expand All @@ -262,7 +265,13 @@ function run($surveyid,$args) {
}
elseif (isset($thissurvey['showwelcome']) && $thissurvey['showwelcome'] == 'N')
{
$moveResult = LimeExpressionManager::NavigateForwards();
// BUG: This will CLEAR and SAVE IN DB the last question group to NULL if it's still in the cookie (which it is if same browser is used).
//$moveResult = LimeExpressionManager::NavigateForwards();

// Jump WITHOUT saving anything (needed for e-mail link).
LimeExpressionManager::JumpTo(1, false, false, true);

// TODO: Delete this line?
//$_SESSION[$LEMsessid]['step']=1;
}
}
Expand Down
4 changes: 4 additions & 0 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -153,8 +153,10 @@ class LimeExpressionManager {
* @var type
*/
private $allOnOnePage=false;

/**
* survey mode. One of 'survey', 'group', or 'question'
* @todo Please add more information here. What does the alternatives mean?
* @var string
*/
private $surveyMode='group';
Expand Down Expand Up @@ -4839,6 +4841,7 @@ static function StartSurvey($surveyid,$surveyMode='group',$aSurveyOptions=NULL,$
$LEM->indexQseq=array();
$LEM->qrootVarName2arrayFilter=array();
templatereplace("{}"); // Needed for coreReplacements in relevance equation (in all mode)

if (isset($_SESSION[$LEM->sessid]['startingValues']) && is_array($_SESSION[$LEM->sessid]['startingValues']) && count($_SESSION[$LEM->sessid]['startingValues']) > 0)
{
$startingValues = array();
Expand Down Expand Up @@ -5508,6 +5511,7 @@ static function JumpTo($seq,$preview=false,$processPOST=true,$force=false,$chang

$LEM->ParseResultCache=array(); // to avoid running same test more than once for a given group
$LEM->updatedValues = array();
// TODO: Should seq be below 0? It will be -1 after survey submit and re-click on invitation link in e-mail (see issue #10162).
--$seq; // convert to 0-based numbering

switch ($LEM->surveyMode)
Expand Down
1 change: 0 additions & 1 deletion application/helpers/frontend_helper.php
Expand Up @@ -18,7 +18,6 @@ function loadanswers()
global $thissurvey, $thisstep;
global $clienttoken;


$scid=Yii::app()->request->getQuery('scid');
if (Yii::app()->request->getParam('loadall') == "reload")
{
Expand Down

0 comments on commit 2460c69

Please sign in to comment.