diff --git a/build.xml b/build.xml index 054084e..3b1b606 100644 --- a/build.xml +++ b/build.xml @@ -1,6 +1,6 @@ - + @@ -102,6 +102,7 @@ + diff --git a/changelog.txt b/changelog.txt index 868fb5d..cae79da 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +calendarimporter 2.0.5: + - added settings widget + - compatible with webapp 1.5 and 1.6 + calendarimporter 2.0.4: - added compatible with webapp 1.4 - added gui for sync - sync algorithms not jet implemented diff --git a/config.php b/config.php index f6c555b..34bd778 100644 --- a/config.php +++ b/config.php @@ -4,7 +4,7 @@ /** 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); + define('PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE_SYNC', true); // not yet implemented /** The default calendar to import to*/ define('PLUGIN_CALENDARIMPORTER_DEFAULT', "calendar"); diff --git a/js/plugin.calendarimporter.js b/js/plugin.calendarimporter.js index 4918426..34fe6ef 100644 --- a/js/plugin.calendarimporter.js +++ b/js/plugin.calendarimporter.js @@ -49,14 +49,17 @@ 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); + /* add settings widget */ + this.registerInsertionPoint('context.settings.category.calendar', this.createSettingsWidget); /* 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); + this.registerInsertionPoint('context.settings.category.calendar', this.createSettingsCalSyncWidget); } + }, /** @@ -91,6 +94,18 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, { * */ createSettingsWidget: function () { + return [{ + xtype : 'calendarimporter.settingswidget' + }]; + }, + + /** + * Creates the button + * + * @return {Object} Configuration object for a {@link Ext.Button button} + * + */ + createSettingsCalSyncWidget: function () { return [{ xtype : 'calendarimporter.settingscalsyncwidget' }]; @@ -256,13 +271,10 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, { * STARTUP *############################################################################################################################*/ Zarafa.onReady(function() { - if(container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/enable") === true) { - container.registerPlugin(new Zarafa.core.PluginMetaData({ - name : 'calendarimporter', - displayName : _('Calendarimporter Plugin'), - about : Zarafa.plugins.calendarimporter.ABOUT, - allowUserDisable : true, - pluginConstructor : Zarafa.plugins.calendarimporter.ImportPlugin - })); - } + container.registerPlugin(new Zarafa.core.PluginMetaData({ + name : 'calendarimporter', + displayName : _('Calendarimporter Plugin'), + about : Zarafa.plugins.calendarimporter.ABOUT, + pluginConstructor : Zarafa.plugins.calendarimporter.ImportPlugin + })); }); diff --git a/js/settings/SettingsWidget.js b/js/settings/SettingsWidget.js new file mode 100644 index 0000000..eb1b889 --- /dev/null +++ b/js/settings/SettingsWidget.js @@ -0,0 +1,146 @@ +Ext.namespace('Zarafa.plugins.calendarimporter.settings'); + +/** + * @class Zarafa.plugins.calendarimporter.settings.SettingsWidget + * @extends Zarafa.settings.ui.SettingsWidget + * @xtype calendarimporter.settingswidget + * + */ +Zarafa.plugins.calendarimporter.settings.SettingsWidget = Ext.extend(Zarafa.settings.ui.SettingsWidget, { + /** + * @cfg {Zarafa.settings.SettingsContext} settingsContext + */ + settingsContext : undefined, + + /** + * @constructor + * @param {Object} config Configuration object + */ + constructor : function(config) + { + config = config || {}; + + Ext.applyIf(config, { + title : _('Calendar Import/Export plugin settings'), + xtype : 'calendarimporter.settingswidget', + items : [ + { + xtype : 'checkbox', + name : 'zarafa/v1/plugins/calendarimporter/enable_export', + ref : 'enableExport', + fieldLabel : 'Enable exporter', + lazyInit : false + }, + { + xtype : 'checkbox', + name : 'zarafa/v1/plugins/calendarimporter/enable_sync', + ref : 'enableSync', + fieldLabel : 'Enable ical sync', + lazyInit : false + }, + this.createSelectBox(), + this.createTimezoneBox() + ] + }); + + Zarafa.plugins.calendarimporter.settings.SettingsWidget.superclass.constructor.call(this, config); + }, + + createSelectBox: function() { + var defaultFolder = container.getHierarchyStore().getDefaultFolder('calendar'); // @type: Zarafa.hierarchy.data.MAPIFolderRecord + var subFolders = defaultFolder.getChildren(); + var myStore = []; + + /* add all local calendar folders */ + var i = 0; + myStore.push(new Array(defaultFolder.getDefaultFolderKey(), defaultFolder.getDisplayName())); + for(i = 0; i < subFolders.length; i++) { + /* Store all subfolders */ + myStore.push(new Array(subFolders[i].getDisplayName(), subFolders[i].getDisplayName(), false)); // 3rd field = isPublicfolder + } + + /* add all shared calendar folders */ + var pubStore = container.getHierarchyStore().getPublicStore(); + + if(typeof pubStore !== "undefined") { + try { + var pubFolder = pubStore.getDefaultFolder("publicfolders"); + var pubSubFolders = pubFolder.getChildren(); + + for(i = 0; i < pubSubFolders.length; i++) { + if(pubSubFolders[i].isContainerClass("IPF.Appointment")){ + myStore.push(new Array(pubSubFolders[i].getDisplayName(), pubSubFolders[i].getDisplayName() + " [Shared]", true)); // 3rd field = isPublicfolder + } + } + } catch (e) { + console.log("Error opening the shared folder..."); + console.log(e); + } + } + + return { + xtype: "selectbox", + ref : 'defaultCalendar', + editable: false, + name: "zarafa/v1/plugins/calendarimporter/default_calendar", + value: container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/default_calendar"), + width: 100, + fieldLabel: "Default calender", + store: myStore, + mode: 'local', + labelSeperator: ":", + border: false, + anchor: "100%", + scope: this, + allowBlank: false + } + }, + + createTimezoneBox: function() { + return { + xtype: "selectbox", + ref : 'defaultTimezone', + editable: false, + name: "zarafa/v1/plugins/calendarimporter/default_timezone", + value: Zarafa.plugins.calendarimporter.data.Timezones.unMap(container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/default_timezone")), + width: 100, + fieldLabel: "Default timezone", + store: Zarafa.plugins.calendarimporter.data.Timezones.store, + labelSeperator: ":", + mode: 'local', + border: false, + anchor: "100%", + scope: this, + allowBlank: false + } + }, + + /** + * Called by the {@link Zarafa.settings.ui.SettingsCategory Category} when + * it has been called with {@link zarafa.settings.ui.SettingsCategory#update}. + * This is used to load the latest version of the settings from the + * {@link Zarafa.settings.SettingsModel} into the UI of this category. + * @param {Zarafa.settings.SettingsModel} settingsModel The settings to load + */ + update : function(settingsModel) { + this.enableExport.setValue(settingsModel.get(this.enableExport.name)); + this.enableSync.setValue(settingsModel.get(this.enableSync.name)); + this.defaultCalendar.setValue(settingsModel.get(this.defaultCalendar.name)); + this.defaultTimezone.setValue(settingsModel.get(this.defaultTimezone.name)); + }, + + /** + * Called by the {@link Zarafa.settings.ui.SettingsCategory Category} when + * it has been called with {@link zarafa.settings.ui.SettingsCategory#updateSettings}. + * This is used to update the settings from the UI into the {@link Zarafa.settings.SettingsModel settings model}. + * @param {Zarafa.settings.SettingsModel} settingsModel The settings to update + */ + updateSettings : function(settingsModel) { + settingsModel.set(this.enableExport.name, this.enableExport.getValue()); + settingsModel.set(this.enableSync.name, this.enableSync.getValue()); + settingsModel.set(this.defaultCalendar.name, this.defaultCalendar.getValue()); + settingsModel.set(this.defaultTimezone.name, this.defaultTimezone.getValue()); + } +}); + +Ext.reg('calendarimporter.settingswidget', Zarafa.plugins.calendarimporter.settings.SettingsWidget); diff --git a/manifest.xml b/manifest.xml index f293d7d..be53fe0 100644 --- a/manifest.xml +++ b/manifest.xml @@ -27,7 +27,8 @@ js/plugin.calendarimporter.js js/data/ResponseHandler.js js/dialogs/ImportContentPanel.js - js/dialogs/ImportPanel.js + js/dialogs/ImportPanel.js + js/dialogs/settings/SettingsWidget.js js/dialogs/settings/SettingsCalSyncWidget.js js/dialogs/settings/ui/CalSyncGrid.js js/dialogs/settings/ui/CalSyncPanel.js diff --git a/test.php b/test.php new file mode 100644 index 0000000..7ae9649 --- /dev/null +++ b/test.php @@ -0,0 +1,77 @@ +#!/usr/bin/php +getCode(); + return $e->getCode(); + } + break; + } + } +} + +// get settings +// first check if property exist and we can open that using mapi_openproperty +$storeProps = mapi_getprops($userstore, array(PR_EC_WEBACCESS_SETTINGS_JSON)); + +// Check if property exists, if it doesn not exist then we can continue with empty set of settings +if (isset($storeProps[PR_EC_WEBACCESS_SETTINGS_JSON]) || propIsError(PR_EC_WEBACCESS_SETTINGS_JSON, $storeProps) == MAPI_E_NOT_ENOUGH_MEMORY) { + // read the settings property + $stream = mapi_openproperty($userstore, PR_EC_WEBACCESS_SETTINGS_JSON, IID_IStream, 0, 0); + if ($stream == false) { + echo "Error opening settings property\n"; + } + + $settings_string = ""; + $stat = mapi_stream_stat($stream); + mapi_stream_seek($stream, 0, STREAM_SEEK_SET); + for ($i = 0; $i < $stat['cb']; $i += 1024) { + $settings_string .= mapi_stream_read($stream, 1024); + } + + if(empty($settings_string)) { + // property exists but without any content so ignore it and continue with + // empty set of settings + return; + } + + $settings = json_decode($settings_string, true); + if (empty($settings) || empty($settings['settings'])) { + echo "Error retrieving existing settings\n"; + } + + $calcontext = $settings["settings"]["zarafa"]["v1"]["contexts"]["calendar"]; + if(isset($calcontext["icssync"])) { + foreach($calcontext["icssync"] as $syncitem) { + echo $syncitem["icsurl"] . "
"; + } + } else { + echo "no sync items"; + } +} +?> \ No newline at end of file