Skip to content

Commit

Permalink
Dev: updated Templates box on homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Jul 17, 2017
1 parent f48156b commit 452ca6c
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 23 deletions.
2 changes: 1 addition & 1 deletion application/config/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

$config['versionnumber'] = '3.0.0-alpha'; //The current version of this branch
$config['masterversion'] = '2.62.2'; //The current masters version merged into this branch
$config['dbversionnumber'] = 297;
$config['dbversionnumber'] = 298;
$config['buildnumber'] = '';
$config['updatable'] = true;
$config['assetsversionnumber'] = '2671';
Expand Down
46 changes: 36 additions & 10 deletions application/helpers/update/updatedb_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,16 +269,27 @@ function db_upgrade_all($iOldDBVersion, $bSilent=false) {
$oTransaction->commit();
}

/**
* Template tables
* @since 2017-07-12
*/
if ($iOldDBVersion < 297) {
$oTransaction = $oDB->beginTransaction();
upgradeTemplateTables297($oDB);
$oTransaction->commit();
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>297),"stg_name='DBVersion'");
}
/**
* Template tables
* @since 2017-07-12
*/
if ($iOldDBVersion < 297) {
$oTransaction = $oDB->beginTransaction();
upgradeTemplateTables297($oDB);
$oTransaction->commit();
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>297),"stg_name='DBVersion'");
}

/**
* Template tables
* @since 2017-07-12
*/
if ($iOldDBVersion < 298) {
$oTransaction = $oDB->beginTransaction();
upgradeTemplateTables298($oDB);
$oTransaction->commit();
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>298),"stg_name='DBVersion'");
}

}
catch(Exception $e)
Expand Down Expand Up @@ -504,6 +515,21 @@ function upgradeTemplateTables297($oDB)

}


/**
* @param $oDB
* @return void
*/
function upgradeTemplateTables298($oDB)
{
// Add global configuration for Advanced Template
$oDB->createCommand()->update('{{boxes}}',array(
'url'=>'admin/templateoptions',
'title'=>'Templates',
'desc'=>'View templates list',
) ,"id=6");
}

function fixLanguageConsistencyAllSurveys()
{
$surveyidquery = "SELECT sid,additional_languages FROM ".dbQuoteID('{{surveys}}');
Expand Down
131 changes: 131 additions & 0 deletions application/models/TemplateOptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<?php

/**
* This is the model class for table "{{template_configuration}}".
*
* The followings are the available columns in table '{{template_configuration}}':
* @property integer $id
* @property string $templates_name
* @property integer $sid
* @property integer $gsid
* @property integer $uid
* @property string $files_css
* @property string $files_js
* @property string $files_print_css
* @property string $options
* @property string $cssframework_name
* @property string $cssframework_css
* @property string $cssframework_js
* @property string $packages_to_load
*/
class TemplateOptions extends CActiveRecord
{

/**
* @return string the associated database table name
*/
public function tableName()
{
return '{{template_configuration}}';
}

/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('templates_name', 'required'),
array('sid, gsid, uid', 'numerical', 'integerOnly'=>true),
array('templates_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().
// @todo Please remove those attributes that should not be searched.
array('id, templates_name, sid, gsid, uid, files_css, files_js, files_print_css, options, cssframework_name, cssframework_css, cssframework_js, packages_to_load', 'safe', 'on'=>'search'),
);
}

/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
);
}

/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'templates_name' => 'Templates Name',
'sid' => 'Sid',
'gsid' => 'Gsid',
'uid' => 'Uid',
'files_css' => 'Files Css',
'files_js' => 'Files Js',
'files_print_css' => 'Files Print Css',
'options' => 'Options',
'cssframework_name' => 'Cssframework Name',
'cssframework_css' => 'Cssframework Css',
'cssframework_js' => 'Cssframework Js',
'packages_to_load' => 'Packages To Load',
);
}

/**
* Retrieves a list of models based on the current search/filter conditions.
*
* Typical usecase:
* - Initialize the model fields with values from filter form.
* - Execute this method to get CActiveDataProvider instance which will filter
* models according to data in model fields.
* - Pass data provider to CGridView, CListView or any similar widget.
*
* @return CActiveDataProvider the data provider that can return the models
* based on the search/filter conditions.
*/
public function search()
{
// @todo Please modify the following code to remove attributes that should not be searched.

$criteria=new CDbCriteria;

$criteria->compare('id',$this->id);
$criteria->compare('templates_name',$this->templates_name,true);
$criteria->compare('sid',$this->sid);
$criteria->compare('gsid',$this->gsid);
$criteria->compare('uid',$this->uid);
$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);
$criteria->compare('options',$this->options,true);
$criteria->compare('cssframework_name',$this->cssframework_name,true);
$criteria->compare('cssframework_css',$this->cssframework_css,true);
$criteria->compare('cssframework_js',$this->cssframework_js,true);
$criteria->compare('packages_to_load',$this->packages_to_load,true);

return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}

/**
* Returns the static model of the specified AR class.
* Please note that you should have this exact method in all your CActiveRecord descendants!
* @param string $className active record class name.
* @return TemplateOptions the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
}
6 changes: 3 additions & 3 deletions application/views/admin/super/welcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
gT('Stay safe and up to date');
gT('Label sets');
gT('Edit label sets');
gT('Template editor');
gT('Edit LimeSurvey templates');
gT('Templates');
gT('View templates list');
?>

<!-- Welcome view -->
Expand Down Expand Up @@ -126,7 +126,7 @@
<div class="panel-body">
<a href='<?php echo $this->createUrl("admin/survey/sa/listsurveys") ?>'>
<span class="icon-list" style="font-size: 4em"></span>
<span class="sr-only"><?php eT('List surveys');?></span>
<span class="sr-only"><?php eT('List surveys');?></span>
</a><br><br>
<a href='<?php echo $this->createUrl("admin/survey/sa/listsurveys") ?>'><?php eT('List surveys');?></a>
</div>
Expand Down
7 changes: 3 additions & 4 deletions installer/sql/create-mssql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,7 @@ INSERT INTO prefix_boxes ([position], [url], [title], [ico], [desc], [page], [us
(3, 'admin/globalsettings', 'Global settings', 'settings', 'Edit global settings', 'welcome', '-2'),
(4, 'admin/update', 'ComfortUpdate', 'shield', 'Stay safe and up to date', 'welcome', '-2'),
(5, 'admin/labels/sa/view', 'Label sets', 'label','Edit label sets', 'welcome', '-2'),
(6, 'admin/templates/sa/view', 'Template editor', 'templates', 'Edit LimeSurvey templates', 'welcome', '-2');

(6, 'admin/templateoptions', 'Templates', 'templates', 'View templates list', 'welcome', '-2');


--
Expand Down Expand Up @@ -624,7 +623,7 @@ CREATE TABLE prefix_settings_user (

--
-- Surveymenu
--
--

CREATE TABLE prefix_surveymenu (
[id] int(11) NOT NULL ,
Expand Down Expand Up @@ -687,7 +686,7 @@ create index [user_index] on [prefix_surveymenu] ([user]);
create index [title_index] on [prefix_surveymenu] ([title]);
create index [menu_title_index] on [prefix_surveymenu] ([menu_title]);

INSERT INTO prefix_surveymenu_entries VALUES
INSERT INTO prefix_surveymenu_entries VALUES
(1,1,NULL,1,'overview','Survey overview','Overview','Open general survey overview and quick action','list','fontawesome','','admin/survey/sa/view','','','','','','',NULL,'','en-GB',NOW(),0,NOW(),0),
(2,1,NULL,2,'generalsettings','Edit survey general settings','General settings','Open general survey settings','gears','fontawesome','','','updatesurveylocalesettings','editLocalSettings_main_view','/admin/survey/subview/accordion/_generaloptions_panel','','surveysettings','read',NULL,'_generalTabEditSurvey','en-GB',NOW(),0,NOW(),0),
(3,1,NULL,3,'surveytexts','Edit survey text elements','Survey texts','Edit survey text elements','file-text-o','fontawesome','','','updatesurveylocalesettings','editLocalSettings_main_view','/admin/survey/subview/tab_edit_view','','surveylocale','read',NULL,'_getTextEditData','en-GB',NOW(),0,NOW(),0),
Expand Down
2 changes: 1 addition & 1 deletion installer/sql/create-mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ INSERT INTO `prefix_boxes` (`id`, `position`, `url`, `title`, `ico`, `desc`, `pa
(3, 3, 'admin/globalsettings', 'Global settings', 'settings', 'Edit global settings', 'welcome', '-2'),
(4, 4, 'admin/update', 'ComfortUpdate', 'shield', 'Stay safe and up to date', 'welcome', '-2'),
(5, 5, 'admin/labels/sa/view', 'Label sets', 'label', 'Edit label sets', 'welcome', '-2'),
(6, 6, 'admin/templates/sa/view', 'Template editor', 'templates', 'Edit LimeSurvey templates', 'welcome', '-2');
(6, 6, 'admin/templateoptions', 'Templates', 'templates', 'View templates list', 'welcome', '-2');
--
-- Secondary indexes
--
Expand Down
8 changes: 4 additions & 4 deletions installer/sql/create-pgsql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ INSERT INTO "prefix_boxes" ("id", "position", "url", "title", "ico", "desc", "pa
(3, 3, 'admin/globalsettings', 'Global settings', 'settings', 'Edit global settings', 'welcome', '-2'),
(4, 4, 'admin/update', 'ComfortUpdate', 'shield', 'Stay safe and up to date', 'welcome', '-2'),
(5, 5, 'admin/labels/sa/view', 'Label sets', 'label', 'Edit label sets', 'welcome', '-2'),
(6, 6, 'admin/templates/sa/view', 'Template editor', 'templates', 'Edit LimeSurvey templates', 'welcome', '-2');
(6, 6, 'admin/templateoptions', 'Templates', 'templates', 'View templates list', 'welcome', '-2');

--
-- Secondary indexes
Expand Down Expand Up @@ -622,7 +622,7 @@ CREATE TABLE prefix_settings_user (

--
-- Surveymenu
--
--

CREATE TABLE prefix_surveymenu (
"id" integer NOT NULL,
Expand Down Expand Up @@ -685,7 +685,7 @@ create index entry_user_index on prefix_surveymenu_entries ("user_id");
create index entry_title_index on prefix_surveymenu_entries (title);
create index entry_menu_title_index on prefix_surveymenu_entries (menu_title);

INSERT INTO prefix_surveymenu_entries VALUES
INSERT INTO prefix_surveymenu_entries VALUES
(1,1,NULL,1,'overview','Survey overview','Overview','Open general survey overview and quick action','list','fontawesome','','admin/survey/sa/view','','','','','','',NULL,'','en-GB',NOW(),0,NOW(),0),
(2,1,NULL,2,'generalsettings','Edit survey general settings','General settings','Open general survey settings','gears','fontawesome','','','updatesurveylocalesettings','editLocalSettings_main_view','/admin/survey/subview/accordion/_generaloptions_panel','','surveysettings','read',NULL,'_generalTabEditSurvey','en-GB',NOW(),0,NOW(),0),
(3,1,NULL,3,'surveytexts','Edit survey text elements','Survey texts','Edit survey text elements','file-text-o','fontawesome','','','updatesurveylocalesettings','editLocalSettings_main_view','/admin/survey/subview/tab_edit_view','','surveylocale','read',NULL,'_getTextEditData','en-GB',NOW(),0,NOW(),0),
Expand Down Expand Up @@ -718,7 +718,7 @@ INSERT INTO prefix_surveymenu_entries VALUES
(30,2,NULL,16,'reorder','Reorder questions/question groups','Reorder questions/question groups','Reorder questions/question groups','icon-organize','iconclass','','admin/survey/sa/organize/','','','','','surveycontent','update','{\"render\"\: {\"isActive\"\: false}}','','en-GB',NOW(),0,NOW(),0);


-- CREATE OR REPLACE FUNCTION upd_timestamp() RETURNS TRIGGER
-- CREATE OR REPLACE FUNCTION upd_timestamp() RETURNS TRIGGER
-- LANGUAGE plpgsql
-- AS
-- $$
Expand Down

0 comments on commit 452ca6c

Please sign in to comment.