calendarimporter: added exportfeature - not finished yet
TODO: ical creater backend, download
This commit is contained in:
parent
e64d8415bc
commit
76c2f9192a
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/** Disable the import plugin for all clients */
|
/** Disable the import plugin for all clients */
|
||||||
define('PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE', false);
|
define('PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE', false);
|
||||||
|
/** Disable the export feature for all clients */
|
||||||
|
define('PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE_EXPORT', false);
|
||||||
|
|
||||||
/** The default calendar to import to*/
|
/** The default calendar to import to*/
|
||||||
define('PLUGIN_CALENDARIMPORTER_DEFAULT', "Default");
|
define('PLUGIN_CALENDARIMPORTER_DEFAULT', "Default");
|
||||||
|
36
js/data/ResponseHandler.js
Normal file
36
js/data/ResponseHandler.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
Ext.namespace('Zarafa.plugins.calendarimporter.data');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class Zarafa.plugins.calendarimporter.data.ResponseHandler
|
||||||
|
* @extends Zarafa.plugins.calendarimporter.data.AbstractResponseHandler
|
||||||
|
*
|
||||||
|
* Export specific response handler.
|
||||||
|
*/
|
||||||
|
Zarafa.plugins.calendarimporter.data.ResponseHandler = Ext.extend(Zarafa.core.data.AbstractResponseHandler, {
|
||||||
|
/**
|
||||||
|
* @cfg {Function} successCallback The function which
|
||||||
|
* will be called after success request.
|
||||||
|
*/
|
||||||
|
successCallback : null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call the successCallback callback function.
|
||||||
|
* @param {Object} response Object contained the response data.
|
||||||
|
*/
|
||||||
|
doExport : function(response)
|
||||||
|
{
|
||||||
|
this.successCallback(response);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In case exception happened on server, server will return
|
||||||
|
* exception response with the code of exception.
|
||||||
|
* @param {Object} response Object contained the response data.
|
||||||
|
*/
|
||||||
|
doError: function(response)
|
||||||
|
{
|
||||||
|
alert("error response code: " + response.error.info.code);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Ext.reg('calendarimporter.calendarexporterresponsehandler', Zarafa.plugins.calendarimporter.data.ResponseHandler);
|
@ -17,9 +17,14 @@ Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel = Ext.extend(Zarafa.c
|
|||||||
{
|
{
|
||||||
config = config || {};
|
config = config || {};
|
||||||
|
|
||||||
|
var title = _('Import Calendar File');
|
||||||
|
if(container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/enable_export")){
|
||||||
|
title = _('Import/Export Calendar File');
|
||||||
|
}
|
||||||
|
|
||||||
Ext.applyIf(config, {
|
Ext.applyIf(config, {
|
||||||
layout : 'fit',
|
layout : 'fit',
|
||||||
title : _('Import Calendar File'),
|
title : title,
|
||||||
closeOnSave : true,
|
closeOnSave : true,
|
||||||
width : 400,
|
width : 400,
|
||||||
height : 300,
|
height : 300,
|
||||||
|
@ -34,6 +34,7 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.form.FormPa
|
|||||||
this.initForm()
|
this.initForm()
|
||||||
],
|
],
|
||||||
buttons: [
|
buttons: [
|
||||||
|
this.createExportAllButton(),
|
||||||
this.createSubmitAllButton(),
|
this.createSubmitAllButton(),
|
||||||
this.createSubmitButton(),
|
this.createSubmitButton(),
|
||||||
this.createCancelButton()
|
this.createCancelButton()
|
||||||
@ -75,10 +76,8 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.form.FormPa
|
|||||||
*/
|
*/
|
||||||
createGrid : function(eventdata) {
|
createGrid : function(eventdata) {
|
||||||
|
|
||||||
if(eventdata == null) {
|
var parsedData = [];
|
||||||
var parsedData = [
|
if(eventdata !== null) {
|
||||||
];
|
|
||||||
} else {
|
|
||||||
var parsedData = new Array(eventdata.events.length);
|
var parsedData = new Array(eventdata.events.length);
|
||||||
|
|
||||||
for(var i=0; i < eventdata.events.length; i++) {
|
for(var i=0; i < eventdata.events.length; i++) {
|
||||||
@ -231,6 +230,22 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.form.FormPa
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
createExportAllButton: function() {
|
||||||
|
return {
|
||||||
|
xtype: "button",
|
||||||
|
ref: "exportAllButton",
|
||||||
|
id: "exportAllButton",
|
||||||
|
hidden: !container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/enable_export"),
|
||||||
|
width: 100,
|
||||||
|
border: false,
|
||||||
|
text: _("Export All"),
|
||||||
|
anchor: "100%",
|
||||||
|
handler: this.exportAllEvents,
|
||||||
|
scope: this,
|
||||||
|
allowBlank: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
createCancelButton: function() {
|
createCancelButton: function() {
|
||||||
return {
|
return {
|
||||||
xtype: "button",
|
xtype: "button",
|
||||||
@ -346,6 +361,68 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.form.FormPa
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
exportAllEvents: function () {
|
||||||
|
//receive existing calendar store
|
||||||
|
var selIndex = this.calendarselector.selectedIndex;
|
||||||
|
var calValue = this.calendarselector.value;
|
||||||
|
|
||||||
|
if(selIndex == -1 || calValue == "") { // no calendar choosen
|
||||||
|
Ext.MessageBox.show({
|
||||||
|
title : _('Error'),
|
||||||
|
msg : _('You have to choose a calendar!'),
|
||||||
|
icon : Ext.MessageBox.ERROR,
|
||||||
|
buttons : Ext.MessageBox.OK
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
|
||||||
|
var calendarFolder = container.getHierarchyStore().getDefaultFolder('calendar');
|
||||||
|
if(calValue != "calendar") {
|
||||||
|
var subFolders = calendarFolder.getChildren();
|
||||||
|
|
||||||
|
for(i=0;i<subFolders.length;i++) {
|
||||||
|
// loo up right folder
|
||||||
|
// TODO: improve!!
|
||||||
|
if(subFolders[i].getDisplayName() == calValue) {
|
||||||
|
calendarFolder = subFolders[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// call export function here!
|
||||||
|
var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({
|
||||||
|
successCallback: this.exportDone.createDelegate(this)
|
||||||
|
});
|
||||||
|
|
||||||
|
container.getRequest().singleRequest(
|
||||||
|
'calendarexportermodule',
|
||||||
|
'export',
|
||||||
|
{
|
||||||
|
calFolder : calValue,
|
||||||
|
calIndex : selIndex,
|
||||||
|
store_entryid : calendarFolder.data.store_entryid,
|
||||||
|
entryid : calendarFolder.data.entryid
|
||||||
|
},
|
||||||
|
responseHandler
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Export done =)
|
||||||
|
* @param {Object} response
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
exportDone : function(response)
|
||||||
|
{
|
||||||
|
if(response.status === true) {
|
||||||
|
container.getNotifier().notify('info', 'Exported', 'Exported ' + response.entries + ' entries');
|
||||||
|
} else {
|
||||||
|
container.getNotifier().notify('error', 'Export Failed', 'Failed to export your calendar');
|
||||||
|
}
|
||||||
|
this.dialog.close();
|
||||||
|
},
|
||||||
|
|
||||||
importCheckedEvents: function () {
|
importCheckedEvents: function () {
|
||||||
//receive existing calendar store
|
//receive existing calendar store
|
||||||
var selIndex = this.calendarselector.selectedIndex;
|
var selIndex = this.calendarselector.selectedIndex;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
Ext.namespace("Zarafa.plugins.calendarimporter"); // Assign the right namespace
|
Ext.namespace("Zarafa.plugins.calendarimporter"); // Assign the right namespace
|
||||||
|
|
||||||
Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, { // create new import plugin
|
Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, { // create new import plugin
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {Object} config Configuration object
|
* @param {Object} config Configuration object
|
||||||
@ -10,8 +11,6 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
config = config || {};
|
config = config || {};
|
||||||
|
|
||||||
Zarafa.plugins.calendarimporter.ImportPlugin.superclass.constructor.call(this, config);
|
Zarafa.plugins.calendarimporter.ImportPlugin.superclass.constructor.call(this, config);
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,7 +40,12 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
navigationContext : container.getContextByName('calendar'),
|
navigationContext : container.getContextByName('calendar'),
|
||||||
handler : this.onImportButtonClick,
|
handler : this.onImportButtonClick,
|
||||||
scope : this
|
scope : this
|
||||||
|
};
|
||||||
|
|
||||||
|
if(container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/enable_export")) {
|
||||||
|
button.text = _('Import/Export Calendar');
|
||||||
}
|
}
|
||||||
|
|
||||||
return button;
|
return button;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -101,6 +105,6 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
*############################################################################################################################*/
|
*############################################################################################################################*/
|
||||||
Zarafa.onReady(function() {
|
Zarafa.onReady(function() {
|
||||||
if(container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/enable") === true) {
|
if(container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/enable") === true) {
|
||||||
container.registerPlugin(new Zarafa.plugins.calendarimporter.ImportPlugin)
|
container.registerPlugin(new Zarafa.plugins.calendarimporter.ImportPlugin);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
<!DOCTYPE plugin SYSTEM "manifest.dtd">
|
<!DOCTYPE plugin SYSTEM "manifest.dtd">
|
||||||
<plugin version="2">
|
<plugin version="2">
|
||||||
<info>
|
<info>
|
||||||
<version>1.0</version>
|
<version>1.1</version>
|
||||||
<name>calendarimporter</name>
|
<name>calendarimporter</name>
|
||||||
<title>ICS Calendar Importer</title>
|
<title>ICS Calendar Importer/Exporter</title>
|
||||||
<author>Christoph Haas</author>
|
<author>Christoph Haas</author>
|
||||||
<authorURL>http://www.sprinternet.at</authorURL>
|
<authorURL>http://www.sprinternet.at</authorURL>
|
||||||
<description>Import a ICS file to the zarafa calendar</description>
|
<description>Import a ICS file to the zarafa calendar</description>
|
||||||
@ -17,19 +17,21 @@
|
|||||||
<files>
|
<files>
|
||||||
<server>
|
<server>
|
||||||
<serverfile>php/plugin.calendarimporter.php</serverfile>
|
<serverfile>php/plugin.calendarimporter.php</serverfile>
|
||||||
|
<serverfile type="module" module="calendarexportermodule">php/module.calendarexporter.php</serverfile>
|
||||||
</server>
|
</server>
|
||||||
<client>
|
<client>
|
||||||
<clientfile load="release">js/plugin.calendarimporter.js</clientfile>
|
<clientfile load="release">js/plugin.calendarimporter.js</clientfile>
|
||||||
|
<clientfile load="release">js/data/ResponseHandler.js</clientfile>
|
||||||
<clientfile load="release">js/dialogs/ImportContentPanel.js</clientfile>
|
<clientfile load="release">js/dialogs/ImportContentPanel.js</clientfile>
|
||||||
<clientfile load="release">js/dialogs/ImportPanel.js</clientfile>
|
<clientfile load="release">js/dialogs/ImportPanel.js</clientfile>
|
||||||
|
|
||||||
<clientfile load="debug">js/plugin.calendarimporter.js</clientfile>
|
<clientfile load="debug">js/plugin.calendarimporter.js</clientfile>
|
||||||
|
<clientfile load="debug">js/data/ResponseHandler.js</clientfile>
|
||||||
<clientfile load="debug">js/dialogs/ImportContentPanel.js</clientfile>
|
<clientfile load="debug">js/dialogs/ImportContentPanel.js</clientfile>
|
||||||
<clientfile load="debug">js/dialogs/ImportPanel.js</clientfile>
|
<clientfile load="debug">js/dialogs/ImportPanel.js</clientfile>
|
||||||
</client>
|
</client>
|
||||||
<resources>
|
<resources>
|
||||||
<resourcefile load="release">resources/css/calendarimporter.css</resourcefile>
|
<resourcefile load="release">resources/css/calendarimporter.css</resourcefile>
|
||||||
|
|
||||||
<resourcefile load="debug">resources/css/calendarimporter.css</resourcefile>
|
<resourcefile load="debug">resources/css/calendarimporter.css</resourcefile>
|
||||||
</resources>
|
</resources>
|
||||||
</files>
|
</files>
|
||||||
|
94
php/module.calendarexporter.php
Normal file
94
php/module.calendarexporter.php
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* class.calendarexporter.php, zarafa calender to ics exporter
|
||||||
|
*
|
||||||
|
* Author: Christoph Haas <christoph.h@sprinternet.at>
|
||||||
|
* Copyright (C) 2012 Christoph Haas
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This module integrates Owncloud into attachment part of emails
|
||||||
|
* @class OwncloudModule
|
||||||
|
* @extends Module
|
||||||
|
*/
|
||||||
|
class CalendarexporterModule extends Module {
|
||||||
|
|
||||||
|
private $DEBUG = true; // enable error_log debugging
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @param $id
|
||||||
|
* @param $data
|
||||||
|
*/
|
||||||
|
public function __construct($id, $data) {
|
||||||
|
parent::Module($id, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes all the actions in the $data variable.
|
||||||
|
* Exception part is used for authentication errors also
|
||||||
|
* @return boolean true on success or false on failure.
|
||||||
|
*/
|
||||||
|
public function execute() {
|
||||||
|
$result = false;
|
||||||
|
|
||||||
|
foreach($this->data as $actionType => $actionData) {
|
||||||
|
if(isset($actionType)) {
|
||||||
|
try {
|
||||||
|
if($this->DEBUG) {
|
||||||
|
error_log("exec: " . $actionType);
|
||||||
|
}
|
||||||
|
switch($actionType) {
|
||||||
|
case "export":
|
||||||
|
$result = $this->exportCalendar($actionType, $actionData);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->handleUnknownActionType($actionType);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (MAPIException $e) {
|
||||||
|
if($this->DEBUG) {
|
||||||
|
error_log("mapi exception: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
if($this->DEBUG) {
|
||||||
|
error_log("exception: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function exportCalendar($actionType, $actionData) {
|
||||||
|
/* look up functionality in class.appointmentlistmodule.php (webapp/server/modules)*/
|
||||||
|
|
||||||
|
$response['status'] = true;
|
||||||
|
$response['entries'] = "1002"; // number of entries that will be exported
|
||||||
|
$this->addActionData($actionType, $response);
|
||||||
|
$GLOBALS["bus"]->addData($this->getResponseData());
|
||||||
|
|
||||||
|
if($this->DEBUG) {
|
||||||
|
error_log("export done, bus data written!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
?>
|
@ -47,6 +47,7 @@ class Plugincalendarimporter extends Plugin {
|
|||||||
'plugins' => Array(
|
'plugins' => Array(
|
||||||
'calendarimporter' => Array(
|
'calendarimporter' => Array(
|
||||||
'enable' => PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE,
|
'enable' => PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE,
|
||||||
|
'enable_export' => PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE_EXPORT,
|
||||||
'default_calendar' => PLUGIN_CALENDARIMPORTER_DEFAULT // currently not used, maybe in next release
|
'default_calendar' => PLUGIN_CALENDARIMPORTER_DEFAULT // currently not used, maybe in next release
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user