Skip to content

Commit

Permalink
Fixed issue #13915: Cannot submit survey with mandatory question and …
Browse files Browse the repository at this point in the history
…cookie to prevent repeated participation
  • Loading branch information
olleharstedt committed Jul 27, 2018
1 parent 7d62f26 commit 669c5b8
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -576,15 +576,6 @@ private function setArgs()
//field for limereplace stuff, and do transformations!
$this->aSurveyInfo['surveyls_url'] = passthruReplace($this->aSurveyInfo['surveyls_url'], $this->aSurveyInfo);
$this->aSurveyInfo['surveyls_url'] = templatereplace($this->aSurveyInfo['surveyls_url'], array(), $redata, 'URLReplace', false, null, array(), true); // to do INSERTANS substitutions

//THE FOLLOWING DEALS WITH SUBMITTING ANSWERS AND COMPLETING AN ACTIVE SURVEY
//don't use cookies if tokens are being used
if (!empty($this->aSurveyInfo['active']) && $this->aSurveyInfo['active'] == "Y") {
global $tokensexist;
if ($this->aSurveyInfo['usecookie'] == "Y" && $tokensexist != 1 && ( array_key_exists('finished', $_SESSION['survey_'.$this->iSurveyid]) && $_SESSION['survey_'.$this->iSurveyid]['finished'] == true ) ) {
setcookie("LS_".$this->iSurveyid."_STATUS", "COMPLETE", time() + 31536000); //Cookie will expire in 365 days
}
}
}
}

Expand Down Expand Up @@ -1151,6 +1142,14 @@ private function moveSubmitIfNeeded()
$_SESSION[$this->LEMsessid]['finished'] = true;
$_SESSION[$this->LEMsessid]['sid'] = $this->iSurveyid;

//THE FOLLOWING DEALS WITH SUBMITTING ANSWERS AND COMPLETING AN ACTIVE SURVEY
//don't use cookies if tokens are being used
if (!empty($this->aSurveyInfo['active']) && $this->aSurveyInfo['active'] == "Y") {
global $tokensexist;

This comment has been minimized.

Copy link
@Shnoulle

Shnoulle Jul 27, 2018

Collaborator

We don't have it in aSurveyInfo ? If not i think it's better to use Survey::model()->findByPk($sid)->getHasTokensTable();

if ($this->aSurveyInfo['usecookie'] == "Y" && $tokensexist != 1 && $this->aMoveResult['finished'] == true ) {
setcookie("LS_".$this->iSurveyid."_STATUS", "COMPLETE", time() + 31536000); //Cookie will expire in 365 days
}
}
}

$redata['completed'] = $this->completed;
Expand Down

0 comments on commit 669c5b8

Please sign in to comment.