calendarimporter 2.0.5:

- added settings widget
 - compatible with webapp 1.5 and 1.6
This commit is contained in:
Christoph Haas 2014-05-01 13:28:51 +00:00
parent baa184dcd9
commit 38855391f0
7 changed files with 254 additions and 13 deletions

View File

@ -1,6 +1,6 @@
<project default="all">
<!--############# CONFIGURE ALL PROPERTIES FOR THE REPLACER HERE ################-->
<property name="plugin_version" value="2.0.4"/>
<property name="plugin_version" value="2.0.5"/>
<!-- EOC -->
<property name="root-folder" value="${basedir}/../"/>
@ -102,6 +102,7 @@
<fileset file="js/data/ResponseHandler.js" />
<fileset file="js/dialogs/ImportContentPanel.js" />
<fileset file="js/dialogs/ImportPanel.js" />
<fileset file="js/settings/SettingsWidget.js" />
<fileset file="js/settings/SettingsCalSyncWidget.js" />
<fileset file="js/settings/ui/CalSyncPanel.js" />
<fileset file="js/settings/ui/CalSyncGrid.js" />

View File

@ -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

View File

@ -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");

View File

@ -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
}));
}
});

View File

@ -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);

View File

@ -28,6 +28,7 @@
<clientfile load="source">js/data/ResponseHandler.js</clientfile>
<clientfile load="source">js/dialogs/ImportContentPanel.js</clientfile>
<clientfile load="source">js/dialogs/ImportPanel.js</clientfile>
<clientfile load="source">js/dialogs/settings/SettingsWidget.js</clientfile>
<clientfile load="source">js/dialogs/settings/SettingsCalSyncWidget.js</clientfile>
<clientfile load="source">js/dialogs/settings/ui/CalSyncGrid.js</clientfile>
<clientfile load="source">js/dialogs/settings/ui/CalSyncPanel.js</clientfile>

77
test.php Normal file
View File

@ -0,0 +1,77 @@
#!/usr/bin/php
<?php
include('/usr/share/php/mapi/mapi.util.php');
include('/usr/share/php/mapi/mapidefs.php');
include('/usr/share/php/mapi/mapicode.php');
include('/usr/share/php/mapi/mapitags.php');
include('/usr/share/php/mapi/mapiguid.php');
// $serverlocation is optional, default http://localhost:236/zarafa
$session = mapi_logon_zarafa("SYSTEM", "", "file:///var/run/zarafa");
if($session === FALSE) {
echo "Logon failed with error " .mapi_last_hresult() . "\n";
}
// load the default store
$userstore = null;
$stores = mapi_getmsgstorestable($session);
if($stores === FALSE) {
echo "Stores not opened with error " .mapi_last_hresult() . "\n";
}
$storeslist = mapi_table_queryallrows($stores, array(PR_ENTRYID, PR_DEFAULT_STORE));
foreach($storeslist as $row) {
if($row[PR_ENTRYID]){
if(isset($row[PR_DEFAULT_STORE]) && $row[PR_DEFAULT_STORE] == true) {
try {
$masterstore = mapi_openmsgstore($session, $row[PR_ENTRYID]);
$id = mapi_msgstore_createentryid($masterstore, "christoph");
$userstore = mapi_openmsgstore($session, $id);
} catch (MAPIException $e) {
echo "OpenMsgStore failed: " . $e->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"] . "<br/>";
}
} else {
echo "no sync items";
}
}
?>