diff --git a/build.xml b/build.xml index c1362ad..054084e 100644 --- a/build.xml +++ b/build.xml @@ -1,6 +1,6 @@ - + @@ -102,6 +102,11 @@ + + + + + diff --git a/changelog.txt b/changelog.txt index 61bc3e0..10acd26 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,9 @@ +calendarimporter 2.0.3: + - added sync support for ics files + calendarimporter 2.0.3: - fixed all day events - + calendarimporter 2.0.2: - fixed crash when public store does not exist - check if temporary directory is writeable diff --git a/config.php b/config.php index 88cf48c..f6c555b 100644 --- a/config.php +++ b/config.php @@ -3,6 +3,8 @@ define('PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE', false); /** Disable the export feature for all clients */ define('PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE_EXPORT', false); + /** Disable the sync feature for all clients */ + define('PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE_SYNC', true); /** The default calendar to import to*/ define('PLUGIN_CALENDARIMPORTER_DEFAULT', "calendar"); diff --git a/js/dialogs/ImportContentPanel.js b/js/dialogs/ImportContentPanel.js index 84e6961..e325d63 100644 --- a/js/dialogs/ImportContentPanel.js +++ b/js/dialogs/ImportContentPanel.js @@ -50,8 +50,8 @@ Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel = Ext.extend(Zarafa.c layout : 'fit', title : title, closeOnSave : true, - width : 620, - height : 465, + width : 800, + height : 700, //Add panel items : [ { diff --git a/js/plugin.calendarimporter.js b/js/plugin.calendarimporter.js index 5c93b33..5708961 100644 --- a/js/plugin.calendarimporter.js +++ b/js/plugin.calendarimporter.js @@ -55,6 +55,14 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, { this.registerInsertionPoint('common.contextmenu.attachment.actions', this.createAttachmentImportButton); /* add import button to south navigation */ this.registerInsertionPoint("navigation.south", this.createImportButton, this); + + /* ical sync stuff */ + if(container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/enable_sync") === true) { + /* edit panel */ + Zarafa.core.data.SharedComponentType.addProperty('plugins.calendarimporter.settings.dialogs.calsyncedit'); + /* enable the settings widget */ + this.registerInsertionPoint('context.settings.category.calendar', this.createSettingsWidget); + } }, /** @@ -82,6 +90,18 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, { return button; }, + /** + * Creates the button + * + * @return {Object} Configuration object for a {@link Ext.Button button} + * + */ + createSettingsWidget: function () { + return [{ + xtype : 'calendarimporter.settingscalsyncwidget' + }]; + }, + /** * Insert import button in all attachment suggestions @@ -208,6 +228,9 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, { case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents']: bid = 2; break; + case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit']: + bid = 2; + break; } return bid; }, @@ -225,6 +248,9 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, { case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents']: component = Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel; break; + case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit']: + component = Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel; + break; } return component; @@ -232,7 +258,7 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, { }); -/*############################################################################################################################ +/*############################################################################################################################* * STARTUP *############################################################################################################################*/ Zarafa.onReady(function() { diff --git a/js/settings/SettingsCalSyncWidget.js b/js/settings/SettingsCalSyncWidget.js index b203800..557026d 100644 --- a/js/settings/SettingsCalSyncWidget.js +++ b/js/settings/SettingsCalSyncWidget.js @@ -5,10 +5,8 @@ Ext.namespace('Zarafa.plugins.calendarimporter.settings'); * @extends Zarafa.settings.ui.SettingsWidget * @xtype calendarimporter.settingscalsyncwidget * - * The {@link Zarafa.settings.ui.SettingsWidget widget} for configuring - * delegation options in the {@link Zarafa.common.settings.SettingsSendAsCategory sendas category}. */ -Zarafa.common.settings.SettingsSendAsWidget = Ext.extend(Zarafa.settings.ui.SettingsWidget, { +Zarafa.plugins.calendarimporter.settings.SettingsCalSyncWidget = Ext.extend(Zarafa.settings.ui.SettingsWidget, { /** * @cfg {Zarafa.settings.SettingsContext} settingsContext */ @@ -91,17 +89,20 @@ Zarafa.common.settings.SettingsSendAsWidget = Ext.extend(Zarafa.settings.ui.Sett // Start reading the Grid store and convert the contents back into // an object which can be pushed to the settings. - var icslinks = this.sendasPanel.sendasGrid.getStore().getRange(); + var icslinks = this.calsyncPanel.calsyncGrid.getStore().getRange(); var icslinkData = {}; for (var i = 0, len = icslinks.length; i < len; i++) { var icslink = icslinks[i]; icslinkData[icslink.get('id')] = { - 'display_name' : icslink.get('display_name'), - 'email_address' : icslink.get('email_address') + 'icsurl' : icslink.get('icsurl'), + 'intervall' : icslink.get('intervall'), + 'user' : icslink.get('user'), + 'pass' : icslink.get('pass'), + 'lastsync' : icslink.get('lastsync') }; } - settingsModel.set('zarafa/v1/contexts/mail/sendas', icslinkData); + settingsModel.set('zarafa/v1/contexts/calendar/icssync', icslinkData); settingsModel.endEdit(); } diff --git a/js/settings/dialogs/CalSyncEditPanel.js b/js/settings/dialogs/CalSyncEditPanel.js index 4cd2483..b2dffd3 100644 --- a/js/settings/dialogs/CalSyncEditPanel.js +++ b/js/settings/dialogs/CalSyncEditPanel.js @@ -61,11 +61,15 @@ Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel = Ext.extend(E var id = 0; var record = undefined; + console.log(this); if(!this.currentItem) { record = new store.recordType({ id: this.hashCode(this.icsurl.getValue()), - display_name: this.display_name.getValue(), - icsurl: this.icsurl.getValue() + icsurl: this.icsurl.getValue(), + intervall: this.intervall.getValue(), + user: this.user.getValue(), + pass: this.pass.getValue(), + lastsync: 0 }); } @@ -73,43 +77,83 @@ Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel = Ext.extend(E if(record) { store.add(record); } else { - this.currentItem.set('display_name', this.display_name.getValue()); this.currentItem.set('icsurl', this.icsurl.getValue()); + this.currentItem.set('intervall', this.intervall.getValue()); + this.currentItem.set('user', this.user.getValue()); + this.currentItem.set('pass', this.pass.getValue()); } this.dialog.close(); } }, /** - * Function will create panel items for {@link Zarafa.common.sendas.dialogs.SendAsEditPanel SendAsEditPanel} + * Function will create panel items for {@link Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditPanel CalSyncEditPanel} * @return {Array} array of items that should be added to panel. * @private */ createPanelItems : function(config) { - var displayName = ""; - var icsUrl = ""; + var icsurl = ""; + var intervall = ""; + var user = ""; + var pass = ""; if(config.item){ - displayName = config.item.get('display_name'); - icsUrl = config.item.get('icsurl'); + icsurl = config.item.get('icsurl'); + intervall = config.item.get('intervall'); + user = config.item.get('user'); + pass = config.item.get('pass'); } return [{ - fieldLabel: _('Display Name'), - name: 'display_name', - ref: 'display_name', - value: displayName, - anchor: '100%' + xtype: 'fieldset', + title: _('ICAL Information'), + defaultType: 'textfield', + labelWidth: 120, + layout: 'anchor', + defaults: { + anchor: '100%' + }, + items: [{ + fieldLabel: _('ICS Url'), + name: 'icsurl', + ref: '../icsurl', + value: icsurl, + allowBlank: false + }, + { + xtype:'numberfield', + fieldLabel: _('Sync Intervall'), + name: 'intervall', + ref: '../intervall', + value: intervall, + allowBlank: false + }] }, { - fieldLabel: _('ICS Url'), - name: 'icsurl', - ref: 'icsurl', - allowBlank: false, - value: icsUrl, - vtype:'email', - anchor: '100%' + xtype: 'fieldset', + title: _('Authentication (optional)'), + defaultType: 'textfield', + labelWidth: 120, + layout: 'anchor', + defaults: { + anchor: '100%' + }, + items: [{ + fieldLabel: _('Username'), + name: 'user', + ref: '../user', + value: user, + allowBlank: true + }, + { + fieldLabel: _('Password'), + name: 'pass', + ref: '../pass', + value: pass, + inputType: 'password', + allowBlank: true + }] }]; }, diff --git a/js/settings/ui/CalSyncGrid.js b/js/settings/ui/CalSyncGrid.js index 5503999..a4cc692 100644 --- a/js/settings/ui/CalSyncGrid.js +++ b/js/settings/ui/CalSyncGrid.js @@ -5,8 +5,6 @@ Ext.namespace('Zarafa.plugins.calendarimporter.settings.ui'); * @extends Ext.grid.GridPanel * @xtype calendarimporter.calsyncgrid * - * {@link Zarafa.common.sendas.ui.SendAsGrid SendAsGrid} will be used to display - * sendas of the current user. */ Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid = Ext.extend(Ext.grid.GridPanel, { /** @@ -18,7 +16,7 @@ Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid = Ext.extend(Ext.grid.Gr config = config || {}; Ext.applyIf(config, { - xtype : 'calendarimporter.calsyncpanel', + xtype : 'calendarimporter.calsyncgrid', border : true, store : config.store, viewConfig : { @@ -46,7 +44,7 @@ Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid = Ext.extend(Ext.grid.Gr { Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid.superclass.initEvents.call(this); - // select first sendas when store has finished loading + // select first icssync when store has finished loading this.mon(this.store, 'load', this.onViewReady, this, {single : true}); }, @@ -126,7 +124,7 @@ Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid = Ext.extend(Ext.grid.Gr /** * Function will be called to remove a ics sync entry. */ - removeSendAs : function() + removeIcsSyncAs : function() { var icsRecord = this.getSelectionModel().getSelected(); if(!icsRecord) { @@ -152,4 +150,4 @@ Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid = Ext.extend(Ext.grid.Gr } }); -Ext.reg('calendarimporter.calsyncpanel', Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid); +Ext.reg('calendarimporter.calsyncgrid', Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid); diff --git a/js/settings/ui/CalSyncPanel.js b/js/settings/ui/CalSyncPanel.js index d48189a..bf4eddc 100644 --- a/js/settings/ui/CalSyncPanel.js +++ b/js/settings/ui/CalSyncPanel.js @@ -45,7 +45,7 @@ Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel = Ext.extend(Ext.Panel, { return [{ xtype : 'displayfield', - value : _('Here you can .ics files that will be synchronised.'), + value : _('Here you can enter .ics files that will be synchronised.'), fieldClass : 'x-form-display-field' }, { xtype : 'container', @@ -74,7 +74,7 @@ Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel = Ext.extend(Ext.Panel, items : [{ xtype : 'button', text : _('Add') + '...', - handler : this.onSendAsAdd, + handler : this.onCalSyncAdd, ref : '../../addButton', scope : this }, { @@ -85,7 +85,7 @@ Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel = Ext.extend(Ext.Panel, text : _('Remove') + '...', disabled : true, ref : '../../removeButton', - handler : this.onSendAsRemove, + handler : this.onCalSyncRemove, scope : this }] }] @@ -108,7 +108,7 @@ Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel = Ext.extend(Ext.Panel, * Handler function will be called when user clicks on 'Add' button. * @private */ - onSendAsAdd : function() + onCalSyncAdd : function() { Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit'], undefined, { store : this.store, @@ -133,9 +133,9 @@ Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel = Ext.extend(Ext.Panel, * Handler function will be called when user clicks on 'Remove' button. * @private */ - onSendAsRemove : function() + onCalSyncRemove : function() { - this.sendasGrid.removeSendAs(); + this.calsyncGrid.removeIcsSyncAs(); }, /** diff --git a/manifest.xml b/manifest.xml index 6cab256..f293d7d 100644 --- a/manifest.xml +++ b/manifest.xml @@ -27,7 +27,12 @@ js/plugin.calendarimporter.js js/data/ResponseHandler.js js/dialogs/ImportContentPanel.js - js/dialogs/ImportPanel.js + js/dialogs/ImportPanel.js + js/dialogs/settings/SettingsCalSyncWidget.js + js/dialogs/settings/ui/CalSyncGrid.js + js/dialogs/settings/ui/CalSyncPanel.js + js/dialogs/settings/dialogs/CalSyncEditContentPanel.js + js/dialogs/settings/dialogs/CalSyncEditPanel.js resources/css/calendarimporter-min.css diff --git a/php/plugin.calendarimporter.php b/php/plugin.calendarimporter.php index c5f3714..aae665e 100644 --- a/php/plugin.calendarimporter.php +++ b/php/plugin.calendarimporter.php @@ -48,6 +48,7 @@ class Plugincalendarimporter extends Plugin { 'calendarimporter' => Array( 'enable' => PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE, 'enable_export' => PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE_EXPORT, + 'enable_sync' => PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE_SYNC, 'default_calendar' => PLUGIN_CALENDARIMPORTER_DEFAULT, 'default_timezone' => PLUGIN_CALENDARIMPORTER_DEFAULT_TIMEZONE )