Skip to content

Commit

Permalink
Fixed issue #11335: Wrong language when resuming saved survey
Browse files Browse the repository at this point in the history
Dev: set survey language before all the survey actions
  • Loading branch information
LouisGac committed Jun 17, 2016
1 parent 681ceb8 commit ef3e2b0
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions application/controllers/survey/index.php
Expand Up @@ -115,6 +115,31 @@ function action()

$this->_loadLimesurveyLang($surveyid);


// Set the language of the survey, either from POST, GET parameter of session var
// Keep the old value, because SetSurveyLanguage update $_SESSION
$sOldLang=isset($_SESSION['survey_'.$surveyid]['s_lang'])?$_SESSION['survey_'.$surveyid]['s_lang']:"";// Keep the old value, because SetSurveyLanguage update $_SESSION
if (!empty($param['lang']))
{
$sDisplayLanguage = $param['lang'];// $param take lang from returnGlobal and returnGlobal sanitize langagecode
}
elseif (isset($_SESSION['survey_'.$surveyid]['s_lang']))
{
$sDisplayLanguage = $_SESSION['survey_'.$surveyid]['s_lang'];
}
elseif(Survey::model()->findByPk($surveyid))
{
$sDisplayLanguage=Survey::model()->findByPk($surveyid)->language;
}
else
{
$sDisplayLanguage=Yii::app()->getConfig('defaultlang');
}
if ($surveyid && $surveyExists)
{
SetSurveyLanguage( $surveyid, $sDisplayLanguage);
}

if ( $this->_isClientTokenDifferentFromSessionToken($clienttoken,$surveyid) )
{
$sReloadUrl=$this->getController()->createUrl("/survey/index/sid/{$surveyid}",array('token'=>$clienttoken,'lang'=>App()->language,'newtest'=>'Y'));
Expand Down Expand Up @@ -194,30 +219,11 @@ function action()
$this->_niceExit($redata, __LINE__, null, $asMessage);
};

// Set the language of the survey, either from POST, GET parameter of session var
// Keep the old value, because SetSurveyLanguage update $_SESSION
$sOldLang=isset($_SESSION['survey_'.$surveyid]['s_lang'])?$_SESSION['survey_'.$surveyid]['s_lang']:"";// Keep the old value, because SetSurveyLanguage update $_SESSION
if (!empty($param['lang']))
{
$sDisplayLanguage = $param['lang'];// $param take lang from returnGlobal and returnGlobal sanitize langagecode
}
elseif (isset($_SESSION['survey_'.$surveyid]['s_lang']))
{
$sDisplayLanguage = $_SESSION['survey_'.$surveyid]['s_lang'];
}
elseif(Survey::model()->findByPk($surveyid))
{
$sDisplayLanguage=Survey::model()->findByPk($surveyid)->language;
}
else
{
$sDisplayLanguage=Yii::app()->getConfig('defaultlang');
}

//CHECK FOR REQUIRED INFORMATION (sid)
if ($surveyid && $surveyExists)
{
LimeExpressionManager::SetSurveyId($surveyid); // must be called early - it clears internal cache if a new survey is being used
SetSurveyLanguage( $surveyid, $sDisplayLanguage);
if($previewmode) LimeExpressionManager::SetPreviewMode($previewmode);
if (App()->language != $sOldLang) // Update the Session var only if needed
{
Expand Down Expand Up @@ -717,7 +723,7 @@ function _niceExit(&$redata, $iDebugLine, $sTemplateDir = null, $asMessage = arr
function _createNewUserSessionAndRedirect($surveyid, &$redata, $iDebugLine, $asMessage = array())
{

killSurveySession($surveyid);
//killSurveySession($surveyid);
$thissurvey=getSurveyInfo($surveyid);
if($thissurvey)
{
Expand Down

0 comments on commit ef3e2b0

Please sign in to comment.