Skip to content

Commit

Permalink
Fixed issue: Missing vanilla and fruity theme configuration after upg…
Browse files Browse the repository at this point in the history
…rading from 2.73
  • Loading branch information
olleharstedt committed Jan 15, 2018
1 parent c8523a1 commit 358d28d
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
2 changes: 1 addition & 1 deletion application/config/version.php
Expand Up @@ -13,7 +13,7 @@


$config['versionnumber'] = '3.0.3'; //The current version of this branch, LS3
$config['dbversionnumber'] = 343;
$config['dbversionnumber'] = 344;
$config['buildnumber'] = '';
$config['updatable'] = true;
$config['assetsversionnumber'] = '30004';
Expand Down
76 changes: 76 additions & 0 deletions application/helpers/update/updatedb_helper.php
Expand Up @@ -946,6 +946,82 @@ function db_upgrade_all($iOldDBVersion, $bSilent = false)
$oTransaction->commit();
}

/**
* Fix missing database values for templates after updating
* from 2.7x.
*/
if ($iOldDBVersion < 344) {
$oTransaction = $oDB->beginTransaction();

// All templates should inherit from vanilla as default (if extends is empty).
$oDB->createCommand()->update(
'{{templates}}',
[
'extends' => 'vanilla',
],
"extends=''"
);

// If vanilla template is missing, install it.
$vanilla = $oDB
->createCommand()
->select('*')
->from('{{templates}}')
->where('name=:name', ['name'=>'vanilla'])
->queryRow();
if (empty($vanilla)) {
$vanillaData = [
'name' => 'vanilla',
'folder' => 'vanilla',
'title' => 'Vanilla Theme',
'creation_date' => date('Y-m-d H:i:s'),
'author' =>'Louis Gac',
'author_email' => 'louis.gac@limesurvey.org',
'author_url' => 'https://www.limesurvey.org/',
'copyright' => 'Copyright (C) 2007-2017 The LimeSurvey Project Team\\r\\nAll rights reserved.',
'license' => 'License: GNU/GPL License v2 or later, see LICENSE.php\\r\\n\\r\\nLimeSurvey is free software. This version may have been modified pursuant to the GNU General Public License, and as distributed it includes or is derivative of works licensed under the GNU General Public License or other free or open source software licenses. See COPYRIGHT.php for copyright notices and details.',
'version' => '3.0',
'api_version' => '3.0',
'view_folder' => 'views',
'files_folder' => 'files',
'description' => '<strong>LimeSurvey Bootstrap Vanilla Survey Theme</strong><br>A clean and simple base that can be used by developers to create their own Bootstrap based theme.',
'last_update' => null,
'owner_id' => 1,
'extends' => '',
];
$oDB->createCommand()->insert('{{templates}}', $vanillaData);
}
$vanillaConf = $oDB
->createCommand()
->select('*')
->from('{{template_configuration}}')
->where('template_name=:template_name', ['template_name'=>'vanilla'])
->queryRow();
if (empty($vanillaConf)) {
$vanillaConfData = [
'template_name' => 'vanilla',
'sid' => NULL,
'gsid' => NULL,
'uid' => NULL,
'files_css' => '{"add":["css/ajaxify.css","css/theme.css","css/custom.css"]}',
'files_js' => '{"add":["scripts/theme.js","scripts/ajaxify.js","scripts/custom.js"]}',
'files_print_css' => '{"add":["css/print_theme.css"]}',
'options' => '{"ajaxmode":"on","brandlogo":"on","container":"on","brandlogofile":"./files/logo.png","font":"noto"}',
'cssframework_name' => 'bootstrap',
'cssframework_css' => '{}',
'cssframework_js' => '',
'packages_to_load' => '{"add":["pjax","font-noto"]}',
'packages_ltr' => NULL,
'packages_rtl' => NULL
];
$oDB->createCommand()->insert('{{template_configuration}}', $vanillaConfData);
}

$oDB->createCommand()->update('{{settings_global}}', ['stg_value'=>344], "stg_name='DBVersion'");
$oTransaction->commit();
}


} catch (Exception $e) {
Yii::app()->setConfig('Updating', false);
$oTransaction->rollback();
Expand Down

0 comments on commit 358d28d

Please sign in to comment.