Skip to content

Commit

Permalink
Fixed issue #6628: Passthrough values not being handled
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Oct 4, 2012
1 parent 7124851 commit 771006b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
24 changes: 10 additions & 14 deletions application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -353,6 +353,15 @@ function run($surveyid,$args) {
}
}
resetTimers();

//Before doing the "templatereplace()" function, check the $thissurvey['url']
//field for limereplace stuff, and do transformations!
$thissurvey['surveyls_url'] = passthruReplace($thissurvey['surveyls_url'], $thissurvey);
$thissurvey['surveyls_url'] = templatereplace($thissurvey['surveyls_url'],array('SID'=>$thissurvey['sid'],
'SAVEDID'=>$_SESSION[$LEMsessid]['srid'],
'TOKEN'=>(isset($clienttoken) ? $clienttoken : ''),
)); // to do INSERTANS substitutions

//END PAGE - COMMIT CHANGES TO DATABASE
if ($thissurvey['active'] != "Y") //If survey is not active, don't really commit
{
Expand Down Expand Up @@ -403,10 +412,6 @@ function run($surveyid,$args) {
// setcookie("$cookiename", "COMPLETE", time() + 31536000); //Cookie will expire in 365 days //@todo fix - sometimes results in headers already sent error
}

//Before doing the "templatereplace()" function, check the $thissurvey['url']
//field for limereplace stuff, and do transformations!
$thissurvey['surveyls_url'] = passthruReplace($thissurvey['surveyls_url'], $thissurvey);
$thissurvey['surveyls_url']=templatereplace($thissurvey['surveyls_url']); // to do INSERTANS substitutions

$content = '';
$content .= templatereplace(file_get_contents($sTemplatePath."startpage.pstpl"), array(), $redata);
Expand Down Expand Up @@ -492,16 +497,7 @@ function run($surveyid,$args) {
if (isset($thissurvey['autoredirect']) && $thissurvey['autoredirect'] == "Y" && $thissurvey['surveyls_url'])
{
//Automatically redirect the page to the "url" setting for the survey

$url = passthruReplace($thissurvey['surveyls_url'], $thissurvey);
$url = templatereplace($url); // TODO - check safety of this - provides access to any replacement value
$url = str_replace("{SAVEDID}", $saved_id, $url); // to activate the SAVEDID in the END URL
if(isset($clienttoken) && $clienttoken) {
$url = str_replace("{TOKEN}", $clienttoken, $url); // to activate the TOKEN in the END URL
}
$url = str_replace("{SID}", $surveyid, $url); // to activate the SID in the END URL
$url = str_replace("{LANG}", $clang->getlangcode(), $url); // to activate the LANG in the END URL
header("Location: {$url}");
header("Location: {$thissurvey['surveyls_url']}");
}


Expand Down
8 changes: 3 additions & 5 deletions application/helpers/replacements_helper.php
Expand Up @@ -801,8 +801,6 @@ function templatereplace($line, $replacements = array(), &$redata = array(), $de
$coreReplacements['NAVIGATOR'] = isset($navigator) ? $navigator : ''; // global
$coreReplacements['NOSURVEYID'] = (isset($surveylist))?$surveylist['nosid']:'';
$coreReplacements['NUMBEROFQUESTIONS'] = $_totalquestionsAsked;
$coreReplacements['PASSTHRULABEL'] = '';
$coreReplacements['PASSTHRUVALUE'] = '';
$coreReplacements['PERCENTCOMPLETE'] = isset($percentcomplete) ? $percentcomplete : ''; // global
$coreReplacements['PRIVACY'] = isset($privacy) ? $privacy : ''; // global
$coreReplacements['PRIVACYMESSAGE'] = "<span style='font-weight:bold; font-style: italic;'>".$clang->gT("A Note On Privacy")."</span><br />".$clang->gT("This survey is anonymous.")."<br />".$clang->gT("The record kept of your survey responses does not contain any identifying information about you unless a specific question in the survey has asked for this. If you have responded to a survey that used an identifying token to allow you to access the survey, you can rest assured that the identifying token is not kept with your responses. It is managed in a separate database, and will only be updated to indicate that you have (or haven't) completed this survey. There is no way of matching identification tokens with survey responses in this survey.");
Expand Down Expand Up @@ -951,16 +949,16 @@ function PassthruReplace($line, $thissurvey)
{
$p1 = strpos($line,"{PASSTHRU:"); // startposition
$p2 = $p1 + 10; // position of the first arg char
$p3 = strpos($line,"}",10); // position of the last arg char
$p3 = strpos($line,"}",$p1); // position of the last arg char

$cmd=substr($line,$p1,$p3-$p1+1); // extract the complete passthru like "{PASSTHRU:myarg}"
$arg=substr($line,$p2,$p3-$p2); // extract the arg to passthru (like "myarg")

// lookup for the fitting arg
$sValue='';
if (isset(Yii::app()->session['urlparams'][$arg]))
if (isset($_SESSION['survey_'.$thissurvey['sid']]['urlparams'][$arg]))
{
$sValue=urlencode(Yii::app()->session['urlparams'][$arg]);
$sValue=urlencode($_SESSION['survey_'.$thissurvey['sid']]['urlparams'][$arg]);
}
$line=str_replace($cmd, $sValue, $line); // replace
}
Expand Down

0 comments on commit 771006b

Please sign in to comment.