Skip to content

Commit

Permalink
Fixed issue #12357: Survey List page Variable token replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed May 30, 2018
1 parent 750f0f0 commit 4d83aee
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
36 changes: 34 additions & 2 deletions application/helpers/frontend_helper.php
Expand Up @@ -228,6 +228,38 @@ function getLanguageChangerDatasPublicList($sSelectedLanguage)
}
}

/**
* Construct flash message container
* Used in templatereplace to replace {FLASHMESSAGE} in startpage.tstpl
*
* @return string
*/
function makeFlashMessage() {
global $surveyid;
$html = "";

$language = Yii::app()->getLanguage();
$originalPrefix = Yii::app()->user->getStateKeyPrefix();
// Bug in Yii? Getting the state-key prefix changes the locale, so set the language manually after.

This comment has been minimized.

Copy link
@Shnoulle

Shnoulle May 31, 2018

Collaborator

Bug in LS : here : https://github.com/LimeSurvey/LimeSurvey/blob/master/application/core/LSYii_Application.php#L111

This set user language always. Strange i think we fix it in 2.7X ?

This comment has been minimized.

Copy link
@LouisGac

LouisGac May 31, 2018

Contributor

I should have remove this comment yep.
I copy/paste the function from 2.73

This comment has been minimized.

Copy link
@Shnoulle

Shnoulle May 31, 2018

Collaborator

Then maybe reset language are not needed anymore :)

Yii::app()->setLanguage($language);
Yii::app()->user->setStateKeyPrefix('frontend');

$mapYiiToBootstrapClass = array(
'error' => 'danger',
'success' => 'success',
'notice' => 'info'
// no warning in Yii?
);

foreach (Yii::app()->user->getFlashes() as $key => $message) {
$html .= "<div class='alert alert-" . $mapYiiToBootstrapClass[$key] . " alert-dismissible flash-" . $key . "'>" . $message . "</div>\n";
}

Yii::app()->user->setStateKeyPrefix($originalPrefix);

return $html;
}

/**
* checkUploadedFileValidity used in SurveyRuntimeHelper
*/
Expand Down Expand Up @@ -1263,8 +1295,8 @@ function renderRenderWayForm($renderWay, array $scenarios, $sTemplateViewPath, $
$thissurvey["aForm"] = $aForm;
$thissurvey['surveyUrl'] = App()->createUrl("/survey/index", array("sid"=>$surveyid));
$thissurvey['include_content'] = 'userforms';


Yii::app()->twigRenderer->renderTemplateFromFile("layout_user_forms.twig", array('aSurveyInfo'=>$thissurvey), false);
break;

Expand Down
1 change: 1 addition & 0 deletions application/helpers/replacements_helper.php
Expand Up @@ -439,6 +439,7 @@ function getStandardsReplacementFields($thissurvey)

// Set the array of replacement variables here - don't include curly braces
$coreReplacements = array();
$coreReplacements['FLASHMESSAGE'] = makeFlashMessage();
$coreReplacements['NUMBEROFGROUPS'] = QuestionGroup::model()->getTotalGroupsWithQuestions($_surveyid);
$coreReplacements['NUMBEROFQUESTIONS'] = $_SESSION['survey_'.$surveyid]['totalquestions'];
$coreReplacements['ACTIVE'] = (isset($thissurvey['active']) && !($thissurvey['active'] != "Y"));
Expand Down

0 comments on commit 4d83aee

Please sign in to comment.