Skip to content

Commit

Permalink
Fixed issue #CR-1287: fixed invalid options string throwing errors wh…
Browse files Browse the repository at this point in the history
…en exporting a survey
  • Loading branch information
ptelu committed Jul 27, 2023
1 parent bf81965 commit 751073b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 8 deletions.
2 changes: 1 addition & 1 deletion application/config/version.php
Expand Up @@ -12,7 +12,7 @@
*/

$config['versionnumber'] = '6.2.0-dev';
$config['dbversionnumber'] = 611;
$config['dbversionnumber'] = 612;
$config['buildnumber'] = '';
$config['updatable'] = true;
$config['templateapiversion'] = 3;
Expand Down
3 changes: 1 addition & 2 deletions application/core/LsDefaultDataSets.php
Expand Up @@ -978,8 +978,7 @@ public static function getTemplateConfigurationData()
'files_print_css' => '{"add":["css/print_theme.css"]}',
'options' => '{"hideprivacyinfo":"off","showpopups":"1","showclearall":"off","questionhelptextposition":"top","fixnumauto":"enable","backgroundimage":"off","backgroundimagefile":".\/files\/pattern.png",
"brandlogo":"off","brandlogofile":"image::theme::files\/logo.png","font":"ibm-sans",
"cssframework":{"@attributes":{"type":"dropdown","category":"Simple options",
"width":"12","title":"Variations","parent":"cssframework"}}}',
"cssframework":"Apple"}',
'cssframework_name' => '',
'cssframework_css' => '',
'cssframework_js' => '',
Expand Down
39 changes: 39 additions & 0 deletions application/helpers/update/updates/Update_612.php
@@ -0,0 +1,39 @@
<?php

namespace LimeSurvey\Helpers\Update;

use CException;

class Update_612 extends DatabaseUpdateBase
{
/**
* @inheritDoc
* @throws CException
*/
public function up()
{
$templateConfigurations = $this->db->createCommand()
->select('id, options')
->from('{{template_configuration}}')
->where('template_name = :template_name', [':template_name' => 'fruity_twentythree'])
->andWhere(['NOT IN', 'options', 'inherit'])
->queryAll();

if (!empty($templateConfigurations)) {
foreach ($templateConfigurations as $templateConfiguration) {
if ($templateConfiguration['options'] !== 'inherit') {
$sOptionsJson = $templateConfiguration['options'];
$oOldOptions = json_decode($sOptionsJson);
$oOldOptions->cssframework = 'Apple';
$oNewOtionsJson = json_encode($oOldOptions);
$this->db->createCommand()->update(
'{{template_configuration}}',
['options' => $oNewOtionsJson],
'id = :id',
[':id' => $templateConfiguration['id']]
);
}
}
}
}
}
14 changes: 9 additions & 5 deletions themes/survey/fruity_twentythree/config.xml
Expand Up @@ -104,7 +104,8 @@
</brandlogofile>
<!-- fonts -->
<!-- When adding new items, please keep them ordered alphabetically -->
<font type="dropdown" category="Fonts" width="12" title="Fonts" parent="font">ibm-sans
<font type="dropdown" category="Fonts" width="12" title="Fonts" parent="font">
ibm-sans
<dropdownoptions>
<optgroup label="User browser">
<option class="font-arial " value="arial" data-font-package="websafe">Arial</option>
Expand Down Expand Up @@ -133,11 +134,14 @@
</dropdownoptions>
</font>
<cssframework type="dropdown" category="Simple options" width="12" title="Variations" parent="cssframework">
Apple
<dropdownoptions>
<option data-value="css/variations/theme_apple.css" value="apple">Apple</option>
<option data-value="css/variations/theme_blueberry.css" value="blueberry">Blueberry</option>
<option data-value="css/variations/theme_grape.css" value="grape">Grape</option>
<option data-value="css/variations/theme_mango.css" value="mango">Mango</option>
<optgroup>
<option data-value="css/variations/theme_apple.css" value="apple">Apple</option>
<option data-value="css/variations/theme_blueberry.css" value="blueberry">Blueberry</option>
<option data-value="css/variations/theme_grape.css" value="grape">Grape</option>
<option data-value="css/variations/theme_mango.css" value="mango">Mango</option>
</optgroup>
</dropdownoptions>
</cssframework>
</options>
Expand Down

0 comments on commit 751073b

Please sign in to comment.