Skip to content

Commit

Permalink
Fixed issue #13356: Crash at optin and optout
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Feb 27, 2018
1 parent 5409f1f commit 96d100f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 34 deletions.
54 changes: 20 additions & 34 deletions application/controllers/OptoutController.php
Expand Up @@ -62,7 +62,7 @@ function actiontokens()
} else {
$sMessage = "<p>".gT('Please confirm that you want to opt out of this survey by clicking the button below.').'<br>'.gT("After confirmation you won't receive any invitations or reminders for this survey anymore.")."</p>";
$sMessage .= '<p><a href="'.Yii::app()->createUrl('optout/removetokens', array('surveyid'=>$iSurveyID, 'langcode'=> $sBaseLanguage, 'token' => $sToken)).'" class="btn btn-default btn-lg">'.gT("I confirm").'</a><p>';
$this->_renderHtml($sMessage, $aSurveyInfo, $iSurveyID);
$this->renderHtml($sMessage, $aSurveyInfo, $iSurveyID);
}


Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -178,7 +178,7 @@ function actionparticipants()
}
}

$this->_renderHtml($sMessage, $aSurveyInfo, $iSurveyID);
$this->renderHtml($sMessage, $aSurveyInfo, $iSurveyID);
}

/**
Expand All @@ -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();
}

}
1 change: 1 addition & 0 deletions themes/survey/vanilla/views/subviews/content/optout.twig
@@ -0,0 +1 @@
<p>{{ aSurveyInfo.optin_message }} </p>

2 comments on commit 96d100f

@LouisGac
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great

@vajiralasantha
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

Please sign in to comment.