Skip to content

Commit

Permalink
Fixed issue #19527: surveys list throw error 500 with invalid template (
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnoulle committed Apr 25, 2024
1 parent c7dcdc0 commit 8250170
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
Expand Up @@ -10,8 +10,8 @@
<div class=" ">
<select id='theme' class="form-control custom-data" name='theme' >
<?php
$athemeList = Template::getTemplateListWithPreviews();
foreach ($athemeList as $themeName => $preview) {
$athemeList = Template::getTemplateList();
foreach ($athemeList as $themeName => $folder) {
if (Permission::model()->hasGlobalPermission('themes','read') || Permission::model()->hasTemplatePermission($themeName) ) { ?>
<option value='<?php echo CHtml::encode($themeName); /* sanitize_filename aloow single quote */?>'>
<?php echo CHtml::encode($themeName); ?>
Expand Down
19 changes: 11 additions & 8 deletions application/models/Template.php
Expand Up @@ -442,21 +442,24 @@ public static function getTemplateList()
}

/**
* @return array
* TODO: replace the calls to that function by a data provider based on search
* Return the array of existing and installed template with the preview images
* @todo deprecated to use directly Template::getTemplateList, usage of value seems deprecated
* @return array[]
*/
public static function getTemplateListWithPreviews()
{
$criteria = new CDBCriteria();
$criteria->select = 'template_name';
$criteria->condition = 'sid IS NULL AND gsid IS NULL';
$criteria->addInCondition('template_name', array_keys(self::getTemplateList()));

$oTemplateList = TemplateConfiguration::model()->with(array(
'template' => ['select' => 'id, name'],
))->findAll($criteria);
$aTemplateList = array();

$oTemplateList = TemplateConfiguration::model()->search();
$oTemplateList->setPagination(false);

foreach ($oTemplateList->getData() as $oTemplate) {
foreach ($oTemplateList as $oTemplate) {
$aTemplateList[$oTemplate->template_name]['preview'] = $oTemplate->preview;
}

return $aTemplateList;
}

Expand Down
Expand Up @@ -5,6 +5,7 @@
* @var Survey $oSurvey
*/
$count= 0;
/* Use $template['preview'] in ./application/views/admin/survey/subview/_template_carousel.php */
$templates = Template::getTemplateListWithPreviews();
$surveylocale = Permission::model()->hasSurveyPermission($oSurvey->sid, 'surveylocale', 'read');
// EDIT SURVEY SETTINGS BUTTON
Expand Down
Expand Up @@ -313,8 +313,8 @@ function checkSelect2Languages(mylangs) {
<option value="inherit" <?php echo ($oSurvey->template == 'inherit')?'selected="selected"':''; ?>><?php echo eT('Inherit').' ['. $oSurveyOptions->template . ']'; ?></option>
<?php } ?>
<?php
$aTemplateList = Template::getTemplateListWithPreviews();
foreach ($aTemplateList as $templateName => $preview) {
$aTemplateList = Template::getTemplateList();
foreach ($aTemplateList as $templateName => $folder) {
if (Permission::model()->hasGlobalPermission('templates','read') || Permission::model()->hasTemplatePermission($templateName) || $oSurvey->template==htmlspecialchars($templateName) ) { ?>
<option value='<?php echo CHtml::encode($templateName); ?>'
<?php if ($oSurvey->template && htmlspecialchars($templateName) == $oSurvey->template && $oSurvey->template != 'inherit') { ?>
Expand Down
3 changes: 0 additions & 3 deletions application/views/admin/survey/surveySummary_view.php
Expand Up @@ -9,9 +9,6 @@
// DO NOT REMOVE This is for automated testing to validate we see that page
echo viewHelper::getViewTestTag('surveySummary');

//TODO : move to controller
$templates = Template::getTemplateListWithPreviews();
//print_r($templates);
$count = 0;
$surveyid = $oSurvey->sid;
$templateModel = Template::model()->findByPk($oSurvey->oOptions->template);
Expand Down
3 changes: 0 additions & 3 deletions application/views/surveyAdministration/surveySummary_view.php
Expand Up @@ -14,9 +14,6 @@
// DO NOT REMOVE This is for automated testing to validate we see that page
echo viewHelper::getViewTestTag('surveySummary');

//TODO : move to controller
$templates = Template::getTemplateListWithPreviews();
//print_r($templates);
$count = 0;
$surveyid = $oSurvey->sid;
$templateModel = Template::model()->findByPk($oSurvey->oOptions->template);
Expand Down

0 comments on commit 8250170

Please sign in to comment.