Skip to content

Commit

Permalink
Fixed issue: Cannot install on MSSQL
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Sep 29, 2017
1 parent b415521 commit 9e4cf69
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 147 deletions.
2 changes: 1 addition & 1 deletion application/controllers/admin/surveyadmin.php
Expand Up @@ -333,7 +333,7 @@ public function changetemplate($iSurveyID, $template)
$survey->save();

$oTemplateConfiguration = $survey->surveyTemplateConfiguration;
$oTemplateConfiguration->templates_name = $sTemplate;
$oTemplateConfiguration->template_name = $sTemplate;
$oTemplateConfiguration->save();

}
Expand Down
16 changes: 8 additions & 8 deletions application/helpers/update/updatedb_helper.php
Expand Up @@ -799,7 +799,7 @@ function upgradeTemplateTables304($oDB)
'description' => 'TEXT',
'last_update' => 'DATETIME DEFAULT NULL',
'owner_id' => 'INT(11) DEFAULT NULL',
'extends_templates_name' => 'string(150) DEFAULT NULL',
'extends_template_name' => 'string(150) DEFAULT NULL',
'PRIMARY KEY (name)'
));

Expand All @@ -820,7 +820,7 @@ function upgradeTemplateTables304($oDB)
'files_folder' => 'files',
'description' => "<strong>LimeSurvey Advanced Template</strong><br>A template with custom options to show what it's possible to do with the new engines. Each template provider will be able to offer its own option page (loaded from template)",
'owner_id' => '1',
'extends_templates_name' => '',
'extends_template_name' => '',
));

// Add minimal template
Expand All @@ -840,7 +840,7 @@ function upgradeTemplateTables304($oDB)
'files_folder' => 'files',
'description' => '<strong>LimeSurvey Minimal Template</strong><br>A clean and simple base that can be used by developers to create their own solution.',
'owner_id' => '1',
'extends_templates_name' => '',
'extends_template_name' => '',
));


Expand All @@ -862,14 +862,14 @@ function upgradeTemplateTables304($oDB)
'files_folder' => 'files',
'description' => "<strong>LimeSurvey Advanced Template</strong><br> A template extending default, to show the inheritance concept. Notice the options, differents from Default.<br><small>uses FezVrasta's Material design theme for Bootstrap 3</small>",
'owner_id' => '1',
'extends_templates_name' => 'default',
'extends_template_name' => 'default',
));


// Add template configuration table
$oDB->createCommand()->createTable('{{template_configuration}}', array(
'id' => 'pk',
'templates_name' => 'string(150) NOT NULL',
'template_name' => 'string(150) NOT NULL',
'sid' => 'int(11) DEFAULT NULL',
'gsid' => 'int(11) DEFAULT NULL',
'uid' => 'int(11) DEFAULT NULL',
Expand All @@ -886,7 +886,7 @@ function upgradeTemplateTables304($oDB)
// Add global configuration for Advanced Template
$oDB->createCommand()->insert('{{template_configuration}}', array(
'id' => '1',
'templates_name' => 'default',
'template_name' => 'default',
'files_css' => '{"add": ["css/template.css", "css/animate.css"]}',
'files_js' => '{"add": ["scripts/template.js"]}',
'files_print_css' => '{"add":"css/print_template.css",}',
Expand All @@ -901,7 +901,7 @@ function upgradeTemplateTables304($oDB)
// Add global configuration for Minimal Template
$oDB->createCommand()->insert('{{template_configuration}}', array(
'id' => '2',
'templates_name' => 'minimal',
'template_name' => 'minimal',
'files_css' => '{"add": ["css/template.css"]}',
'files_js' => '{"add": ["scripts/template.js"]}',
'files_print_css' => '{"add":"css/print_template.css",}',
Expand All @@ -915,7 +915,7 @@ function upgradeTemplateTables304($oDB)
// Add global configuration for Material Template
$oDB->createCommand()->insert('{{template_configuration}}', array(
'id' => '3',
'templates_name' => 'material',
'template_name' => 'material',
'files_css' => '{"add": ["css/template.css", "css/bootstrap-material-design.css", "css/ripples.min.css"]}',
'files_js' => '{"add": ["scripts/template.js", "scripts/material.js", "scripts/ripples.min.js"]}',
'files_print_css' => '{"add":"css/print_template.css",}',
Expand Down
8 changes: 4 additions & 4 deletions application/models/Template.php
Expand Up @@ -51,14 +51,14 @@ public function rules()
return array(
array('name, title, creation_date', 'required'),
array('owner_id', 'numerical', 'integerOnly'=>true),
array('name, author, extends_templates_name', 'length', 'max'=>150),
array('name, author, extends_template_name', 'length', 'max'=>150),
array('folder, version, api_version, view_folder, files_folder', 'length', 'max'=>45),
array('title', 'length', 'max'=>100),
array('author_email, author_url', 'length', 'max'=>255),
array('copyright, license, description, last_update', 'safe'),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('name, folder, title, creation_date, author, author_email, author_url, copyright, license, version, api_version, view_folder, files_folder, description, last_update, owner_id, extends_templates_name', 'safe', 'on'=>'search'),
array('name, folder, title, creation_date, author, author_email, author_url, copyright, license, version, api_version, view_folder, files_folder, description, last_update, owner_id, extends_template_name', 'safe', 'on'=>'search'),
);
}

Expand Down Expand Up @@ -94,7 +94,7 @@ public function attributeLabels()
'description' => 'Description',
'last_update' => 'Last Update',
'owner_id' => 'Owner',
'extends_templates_name' => 'Extends Templates Name',
'extends_template_name' => 'Extends Templates Name',
);
}

Expand Down Expand Up @@ -487,7 +487,7 @@ public function search()
$criteria->compare('description',$this->description,true);
$criteria->compare('last_update',$this->last_update,true);
$criteria->compare('owner_id',$this->owner_id);
$criteria->compare('extends_templates_name',$this->extends_templates_name,true);
$criteria->compare('extends_template_name',$this->extends_template_name,true);

return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
Expand Down
42 changes: 21 additions & 21 deletions application/models/TemplateConfiguration.php
Expand Up @@ -19,7 +19,7 @@
*
* The followings are the available columns in table '{{template_configuration}}':
* @property string $id
* @property string $templates_name
* @property string $template_name
* @property string $gsid
* @property string $sid
* @property string $files_css
Expand Down Expand Up @@ -89,13 +89,13 @@ public function rules()
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('templates_name', 'required'),
array('template_name', 'required'),
array('id, sid, gsid', 'numerical', 'integerOnly'=>true),
array('templates_name', 'length', 'max'=>150),
array('template_name', 'length', 'max'=>150),
array('cssframework_name', 'length', 'max'=>45),
array('files_css, files_js, files_print_css, options, cssframework_css, cssframework_js, packages_to_load', 'safe'),
// The following rule is used by search().
array('id, templates_name, sid, gsid, files_css, files_js, files_print_css, options, cssframework_name, cssframework_css, cssframework_js, packages_to_load', 'safe', 'on'=>'search'),
array('id, template_name, sid, gsid, files_css, files_js, files_print_css, options, cssframework_name, cssframework_css, cssframework_js, packages_to_load', 'safe', 'on'=>'search'),
);
}

Expand All @@ -105,7 +105,7 @@ public function rules()
public function relations()
{
return array(
'template' => array(self::HAS_ONE, 'Template', array('name' => 'templates_name')),
'template' => array(self::HAS_ONE, 'Template', array('name' => 'template_name')),
);
}

Expand All @@ -116,7 +116,7 @@ public function attributeLabels()
{
return array(
'id' => 'ID',
'templates_name' => 'Templates Name',
'template_name' => 'Templates Name',
'sid' => 'Sid',
'gsid' => 'Gsid',
'files_css' => 'Files Css',
Expand All @@ -138,8 +138,8 @@ public function attributeLabels()
*/
public static function getInstanceFromTemplateName($sTemplateName){
return self::model()->find(
'templates_name=:templates_name AND sid IS NULL AND gsid IS NULL',
array(':templates_name'=>$sTemplateName)
'template_name=:template_name AND sid IS NULL AND gsid IS NULL',
array(':template_name'=>$sTemplateName)
);
}

Expand All @@ -158,8 +158,8 @@ public static function getInstanceFromSurveyGroup($iSurveyGroupId, $sTemplateNam

$criteria = new CDbCriteria();
$criteria->addCondition('gsid=:gsid');
$criteria->addCondition('templates_name=:templates_name');
$criteria->params = array('gsid' => $iSurveyGroupId, 'templates_name' => $sTemplateName);
$criteria->addCondition('template_name=:template_name');
$criteria->params = array('gsid' => $iSurveyGroupId, 'template_name' => $sTemplateName);
$oTemplateConfigurationModel = TemplateConfiguration::model()->find($criteria);

// No specific template configuration for this surveygroup => create one
Expand Down Expand Up @@ -192,8 +192,8 @@ public static function getInstanceFromSurveyId($iSurveyId, $sTemplateName=null){

$criteria = new CDbCriteria();
$criteria->addCondition('sid=:sid');
$criteria->addCondition('templates_name=:templates_name');
$criteria->params = array('sid' => $iSurveyId, 'templates_name' => $sTemplateName);
$criteria->addCondition('template_name=:template_name');
$criteria->params = array('sid' => $iSurveyId, 'template_name' => $sTemplateName);

$oTemplateConfigurationModel = TemplateConfiguration::model()->find($criteria);

Expand Down Expand Up @@ -264,7 +264,7 @@ public function search()
$criteria->addCondition('gsid IS NULL');

$criteria->compare('id',$this->id);
$criteria->compare('templates_name',$this->templates_name,true);
$criteria->compare('template_name',$this->template_name,true);
$criteria->compare('files_css',$this->files_css,true);
$criteria->compare('files_js',$this->files_js,true);
$criteria->compare('files_print_css',$this->files_print_css,true);
Expand Down Expand Up @@ -324,12 +324,12 @@ public static function importManifest($sTemplateName)
$oNewTemplate->files_folder = $oEditTemplateDb->files_folder;
//$oNewTemplate->description TODO: a more complex modal whith email, author, url, licence, desc, etc
$oNewTemplate->owner_id = Yii::app()->user->id;
$oNewTemplate->extends_templates_name = $oEditedTemplate->oMotherTemplate->sTemplateName;
$oNewTemplate->extends_template_name = $oEditedTemplate->oMotherTemplate->sTemplateName;

if ($oNewTemplate->save()){
$oNewTemplateConfiguration = new TemplateConfiguration;
$oNewTemplateConfiguration->templates_name = $oEditedTemplate->sTemplateName;
$oNewTemplateConfiguration->templates_name = $oEditedTemplate->sTemplateName;
$oNewTemplateConfiguration->template_name = $oEditedTemplate->sTemplateName;
$oNewTemplateConfiguration->template_name = $oEditedTemplate->sTemplateName;
$oNewTemplateConfiguration->options = json_encode($oEditedTemplate->oOptions);


Expand Down Expand Up @@ -551,8 +551,8 @@ protected function removeFileFromPackage( $sPackageName, $sType, $aSettings )
*/
protected function setMotherTemplates()
{
if(!empty($this->template->extends_templates_name)){
$sMotherTemplateName = $this->template->extends_templates_name;
if(!empty($this->template->extends_template_name)){
$sMotherTemplateName = $this->template->extends_template_name;
$this->oMotherTemplate = TemplateConfiguration::getInstanceFromTemplateName($sMotherTemplateName);
$this->oMotherTemplate->prepareTemplateRendering($sMotherTemplateName, null);
if ($this->oMotherTemplate->checkTemplate()){
Expand Down Expand Up @@ -630,8 +630,8 @@ protected function getOptionKey($key){

protected function addMotherTemplatePackage($packages)
{
if (!empty($this->template->extends_templates_name)){
$sMotherTemplateName = (string) $this->template->extends_templates_name;
if (!empty($this->template->extends_template_name)){
$sMotherTemplateName = (string) $this->template->extends_template_name;
$packages[] = 'survey-template-'.$sMotherTemplateName;
}
return $packages;
Expand Down Expand Up @@ -731,7 +731,7 @@ public function getParentConfiguration(){
}

//in the endcheck for general global template
$this->oParentTemplate = Template::getTemplateConfiguration($this->templates_name, null, null);
$this->oParentTemplate = Template::getTemplateConfiguration($this->template_name, null, null);
$this->oParentTemplate->bUseMagicInherit = $this->bUseMagicInherit;
return $this->oParentTemplate;
}
Expand Down
2 changes: 1 addition & 1 deletion application/models/TemplateManifest.php
Expand Up @@ -169,7 +169,7 @@ public function getFilesForPackages($type, $oRTemplate)
*/
public function addFileReplacementInDB($sFile, $sType)
{
$oTemplateConfigurationModels = TemplateConfiguration::model()->findAllByAttributes(array('templates_name'=>$this->sTemplateName));
$oTemplateConfigurationModels = TemplateConfiguration::model()->findAllByAttributes(array('template_name'=>$this->sTemplateName));
foreach($oTemplateConfigurationModels as $oTemplateConfigurationModel){
$oTemplateConfigurationModel->addFileReplacement($sFile, $sType);
}
Expand Down

0 comments on commit 9e4cf69

Please sign in to comment.