From 96d100f31206ef6ef449b0d6b0d3c287c0254dc3 Mon Sep 17 00:00:00 2001 From: Olle Haerstedt Date: Tue, 27 Feb 2018 16:04:04 +0100 Subject: [PATCH] Fixed issue #13356: Crash at optin and optout --- application/controllers/OptoutController.php | 54 +++++++------------ .../views/subviews/content/optout.twig | 1 + 2 files changed, 21 insertions(+), 34 deletions(-) create mode 100644 themes/survey/vanilla/views/subviews/content/optout.twig diff --git a/application/controllers/OptoutController.php b/application/controllers/OptoutController.php index 090d465f35f..e67105d64af 100755 --- a/application/controllers/OptoutController.php +++ b/application/controllers/OptoutController.php @@ -62,7 +62,7 @@ function actiontokens() } else { $sMessage = "

".gT('Please confirm that you want to opt out of this survey by clicking the button below.').'
'.gT("After confirmation you won't receive any invitations or reminders for this survey anymore.")."

"; $sMessage .= '

'.gT("I confirm").'

'; - $this->_renderHtml($sMessage, $aSurveyInfo, $iSurveyID); + $this->renderHtml($sMessage, $aSurveyInfo, $iSurveyID); } @@ -112,12 +112,12 @@ function actionremovetokens() $oToken->save(); $sMessage = gT('You have been successfully removed from this survey.'); } else { - $sMessage = gT('You have been already removed from this survey.'); + $sMessage = gT('You have already been removed from this survey.'); } } } - $this->_renderHtml($sMessage, $aSurveyInfo, $iSurveyID); + $this->renderHtml($sMessage, $aSurveyInfo, $iSurveyID); } /** @@ -178,7 +178,7 @@ function actionparticipants() } } - $this->_renderHtml($sMessage, $aSurveyInfo, $iSurveyID); + $this->renderHtml($sMessage, $aSurveyInfo, $iSurveyID); } /** @@ -189,36 +189,22 @@ function actionparticipants() * @param int $iSurveyID * @return void */ - private function _renderHtml($html, $aSurveyInfo, $iSurveyID) + private function renderHtml($html, $aSurveyInfo, $iSurveyID) { - sendCacheHeaders(); - doHeader(); - $aSupportData = array('thissurvey'=>$aSurveyInfo); - - $oTemplate = Template::model()->getInstance(null, $iSurveyID); - if ($oTemplate->cssFramework == 'bootstrap') { - App()->bootstrap->register(); - } - $thistpl = $oTemplate->pstplPath; - if ($oTemplate->cssFramework == 'bootstrap') { - App()->bootstrap->register(); - } - App()->clientScript->registerPackage('survey-template'); - ob_start(function($buffer, $phase) - { - App()->getClientScript()->render($buffer); - App()->getClientScript()->reset(); - return $buffer; - }); - - echo templatereplace(file_get_contents($thistpl.'startpage.pstpl'), array(), $aSupportData); - - $aData['html'] = $html; - $aData['thistpl'] = $thistpl; - $this->renderPartial('/opt_view', $aData); - echo templatereplace(file_get_contents($thistpl.'endpage.pstpl'), array(), $aSupportData); - doFooter(); - ob_flush(); + $survey = Survey::model()->findByPk($iSurveyID); + + $aSurveyInfo['include_content'] = 'optout'; + $aSurveyInfo['optin_message'] = $html; + Template::model()->getInstance('', $iSurveyID); + + Yii::app()->twigRenderer->renderTemplateFromFile( + "layout_global.twig", + array( + 'oSurvey' => $survey, + 'aSurveyInfo' => $aSurveyInfo + ), + false + ); + Yii::app()->end(); } - } diff --git a/themes/survey/vanilla/views/subviews/content/optout.twig b/themes/survey/vanilla/views/subviews/content/optout.twig new file mode 100644 index 00000000000..f6f097ac3ac --- /dev/null +++ b/themes/survey/vanilla/views/subviews/content/optout.twig @@ -0,0 +1 @@ +

{{ aSurveyInfo.optin_message }}