javascript rework

This commit is contained in:
Christoph Haas 2016-06-20 15:48:24 +02:00
parent e76893d82f
commit 67b6a332f2
10 changed files with 304 additions and 568 deletions

View File

@ -1,13 +1,11 @@
<?php
/** Disable the import plugin for all clients */
define('PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE', false);
/** Disable the export feature for all clients */
define('PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE_EXPORT', false);
define('PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE', true);
/** Disable the sync feature for all clients */
define('PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE_SYNC', true); // not yet implemented
/** The default calendar to import to*/
define('PLUGIN_CALENDARIMPORTER_DEFAULT', "calendar");
define('PLUGIN_CALENDARIMPORTER_DEFAULT', "Kalender");
define('PLUGIN_CALENDARIMPORTER_DEFAULT_TIMEZONE', "Europe/Vienna");
/** Tempory path for uploaded files... */

65
js/data/Actions.js Normal file
View File

@ -0,0 +1,65 @@
/**
* Actions.js zarafa calender to ics im/exporter
*
* Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 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
*
*/
/**
* ResponseHandler
*
* This class handles all responses from the php backend
*/
Ext.namespace('Zarafa.plugins.calendarimporter.data');
/**
* @class Zarafa.plugins.calendarimporter.data.Actions
* Common actions which can be used within {@link Ext.Button buttons}
* or other {@link Ext.Component components} with action handlers.
* @singleton
*/
Zarafa.plugins.calendarimporter.data.Actions = {
/**
* Callback for the export request.
* @param {Object} response
*/
downloadICS: function (response) {
if (response.status == false) {
Zarafa.common.dialogs.MessageBox.show({
title : dgettext('plugin_files', 'Warning'),
msg : dgettext('plugin_files', response.message),
icon : Zarafa.common.dialogs.MessageBox.WARNING,
buttons: Zarafa.common.dialogs.MessageBox.OK
});
} else {
var downloadFrame = Ext.getBody().createChild({
tag: 'iframe',
cls: 'x-hidden'
});
var url = document.URL;
var link = url.substring(0, url.lastIndexOf('/') + 1);
link += "index.php?sessionid=" + container.getUser().getSessionId() + "&load=custom&name=download_ics";
link = Ext.urlAppend(link, "token=" + encodeURIComponent(response.download_token));
link = Ext.urlAppend(link, "filename=" + encodeURIComponent(response.filename));
downloadFrame.dom.contentWindow.location = link;
}
}
};

View File

@ -68,7 +68,7 @@ Zarafa.plugins.calendarimporter.data.ResponseHandler = Ext.extend(Zarafa.core.da
* Call the successCallback callback function.
* @param {Object} response Object contained the response data.
*/
doAttachmentpath : function(response) {
doImportattachment: function (response) {
this.successCallback(response);
},

View File

@ -372,7 +372,7 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
name: "choosen_timezone",
value: Zarafa.plugins.calendarimporter.data.Timezones.unMap(container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/default_timezone")),
width: 100,
fieldLabel: "Select a timezone (optional)",
fieldLabel: "Timezone",
store: Zarafa.plugins.calendarimporter.data.Timezones.store,
labelSeperator: ":",
mode: 'local',
@ -393,7 +393,7 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
ref: 'dstcheck',
name: "dst_check",
width: 100,
fieldLabel: "Ignore DST (optional)",
fieldLabel: "Ignore DST",
boxLabel: 'This will ignore "Daylight saving time" offsets.',
labelSeperator: ":",
border: false,
@ -529,14 +529,15 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
parseCalendar: function (icsPath, timezone, ignoredst) {
this.loadMask.show();
// call export function here!
var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({
successCallback: this.handleParsingResult.createDelegate(this)
successCallback: this.handleParsingResult,
scope: this
});
container.getRequest().singleRequest(
'calendarmodule',
'import',
'load',
{
ics_filepath: icsPath,
timezone: timezone,
@ -550,17 +551,17 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
this.loadMask.hide();
if(response["status"] == true) {
Ext.getCmp('submitButton').enable();
Ext.getCmp('submitAllButton').enable();
this.submitButton.enable();
this.submitAllButton.enable();
if(typeof response.parsed.calendar["X-WR-TIMEZONE"] !== "undefined") {;
if(typeof response.parsed.calendar["X-WR-TIMEZONE"] !== "undefined") {
this.timezone = response.parsed.calendar["X-WR-TIMEZONE"];
this.timezoneselector.setValue(Zarafa.plugins.calendarimporter.data.Timezones.unMap(this.timezone));
}
this.reloadGridStore(response.parsed);
} else {
Ext.getCmp('submitButton').disable();
Ext.getCmp('submitAllButton').disable();
this.submitButton.disable();
this.submitAllButton.disable();
Zarafa.common.dialogs.MessageBox.show({
title : _('Parser Error'),
msg : _(response["message"]),
@ -575,54 +576,6 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
this.dialog.close()
},
convertToAppointmentRecord: function (calendarFolder,entry) {
var newRecord = Zarafa.core.data.RecordFactory.createRecordObjectByMessageClass('IPM.Appointment', {
startdate: new Date(entry.start),
duedate: (entry.end != null) ?
new Date(entry.end) :
new Date(entry.start).add(Date.HOUR, 1),
location: entry.location,
subject: entry.title,
body: entry.description,
commonstart: new Date(entry.start),
commonend: (entry.end != null) ?
new Date(entry.end) :
new Date(entry.start).add(Date.HOUR, 1),
timezone: this.timezone,
parent_entryid: calendarFolder.get('entryid'),
store_entryid: calendarFolder.get('store_entryid')
});
var busystate = new Array("FREE", "TENTATIVE", "BUSY", "OOF");
var zlabel = new Array("NONE", "IMPORTANT", "WORK", "PERSONAL", "HOLIDAY", "REQUIRED", "TRAVEL REQUIRED", "PREPARATION REQUIERED", "BIRTHDAY", "SPECIAL DATE", "PHONE INTERVIEW");
/* optional fields */
if(entry.priority !== "") {
newRecord.data.importance = entry.priority;
}
if(entry.label !== "") {
newRecord.data.label = zlabel.indexOf(entry.label);
}
if(entry.busy !== "") {
newRecord.data.busystatus = busystate.indexOf(entry.busy);
}
if(entry.privatestate !== "") {
newRecord.data["private"] = entry.privatestate == "PUBLIC" ? false : true;
}
if(entry.organizer !== "") {
newRecord.data.sent_representing_email_address = entry.organizer;
}
if(entry.trigger != null) {
newRecord.data.reminder = true;
newRecord.data.reminder_minutes = new Date((entry.start - entry.trigger)/60);
newRecord.data.reminder_time = new Date(entry.trigger);
} else {
newRecord.data.reminder = false;
}
return newRecord;
},
importCheckedEvents: function () {
var newRecords = this.eventgrid.selModel.getSelections();
this.importEvents(newRecords);
@ -635,295 +588,15 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
this.importEvents(newRecords);
},
exportAllEvents: function () {
//receive existing calendar store
var calValue = this.calendarselector.value;
if(calValue == undefined) { // no calendar choosen
Zarafa.common.dialogs.MessageBox.show({
title : _('Error'),
msg : _('You have to choose a calendar!'),
icon : Zarafa.common.dialogs.MessageBox.ERROR,
buttons : Zarafa.common.dialogs.MessageBox.OK
});
} else {
var calexist = true;
var calendarFolder = container.getHierarchyStore().getDefaultFolder('calendar');
var pubStore = container.getHierarchyStore().getPublicStore();
var pubSubFolders = [];
var pubFolder;
if(typeof pubStore !== "undefined") {
try {
pubFolder = pubStore.getDefaultFolder("publicfolders");
pubSubFolders = pubFolder.getChildren();
} catch (e) {
console.log("Error opening the shared folder...");
console.log(e);
}
}
if(calValue != "calendar") {
var subFolders = calendarFolder.getChildren();
var i = 0;
/* add public folders if any exist */
for(i = 0; i < pubSubFolders.length; i++) {
if(pubSubFolders[i].isContainerClass("IPF.Appointment")){
subFolders.push(pubSubFolders[i]);
}
}
for(i=0;i<subFolders.length;i++) {
// loo up right folder
// TODO: improve!!
if(subFolders[i].getDisplayName() == calValue) {
calendarFolder = subFolders[i];
break;
}
}
if(calendarFolder.isDefaultFolder()) {
Zarafa.common.dialogs.MessageBox.show({
title : _('Error'),
msg : _('Selected calendar does not exist!'),
icon : Zarafa.common.dialogs.MessageBox.ERROR,
buttons : Zarafa.common.dialogs.MessageBox.OK
});
calexist = false;
}
}
if(calexist) {
Zarafa.common.dialogs.MessageBox.show({
title: 'Please wait',
msg: 'Generating ical file...',
progressText: 'Exporting...',
width:300,
progress:true,
closable:false
});
// progress bar... ;)
var updateProgressBar = function(v){
return function(){
if(v == 100){
if(Zarafa.common.dialogs.MessageBox.isVisible()) {
updateTimer();
}
}else{
Zarafa.common.dialogs.MessageBox.updateProgress(v/100, 'Exporting...');
}
};
};
var updateTimer = function() {
for(var i = 1; i < 101; i++){
setTimeout(updateProgressBar(i), 20*i);
}
};
updateTimer();
// call export function here!
var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({
successCallback: this.exportPagedEvents.createDelegate(this)
});
container.getRequest().singleRequest(
'appointmentlistmodule',
'list',
{
groupDir: "ASC",
restriction: {
//start: 0,
//limit: 500, // limit to 500 events.... not working because of hardcoded limit in listmodule
//startdate: 0,
//duedate: 2145826800 // 2037... nearly highest unix timestamp
},
sort: [{
"field": "startdate",
"direction": "DESC"
}],
store_entryid : calendarFolder.data.store_entryid,
entryid : calendarFolder.data.entryid
},
responseHandler
);
}
}
},
/**
* Calculate needed Requests for all events
* Needed because the listmodule has hardcoded pageing setting -.-
* @param {Object} response
*/
exportPagedEvents:function(response) {
if(response.page.start = 0 && response.item.length <= 0) {
container.getNotifier().notify('info', 'Export Failed', 'There were no items to export!');
Zarafa.common.dialogs.MessageBox.hide();
} else {
this.exportResponse = response.item;
}
if(this.totalExportCount == null) {
this.totalExportCount = response.page.totalrowcount;
}
var requests = Math.ceil(response.page.totalrowcount / response.page.rowcount);
this.runningRequests = requests;
var i = 0;
//receive existing calendar store
var calValue = this.calendarselector.value;
var calendarFolder = container.getHierarchyStore().getDefaultFolder('calendar');
var pubStore = container.getHierarchyStore().getPublicStore();
var pubSubFolders = [];
var pubFolder;
if(typeof pubStore !== "undefined") {
try {
pubFolder = pubStore.getDefaultFolder("publicfolders");
pubSubFolders = pubFolder.getChildren();
} catch (e) {
console.log("Error opening the shared folder...");
console.log(e);
}
}
if(calValue != "calendar") {
var subFolders = calendarFolder.getChildren();
i = 0;
/* add public folders if any exist */
for(i = 0; i < pubSubFolders.length; i++) {
if(pubSubFolders[i].isContainerClass("IPF.Appointment")){
subFolders.push(pubSubFolders[i]);
}
}
for(i=0;i<subFolders.length;i++) {
// loo up right folder
// TODO: improve!!
if(subFolders[i].getDisplayName() == calValue) {
calendarFolder = subFolders[i];
break;
}
}
if(calendarFolder.isDefaultFolder()) {
Zarafa.common.dialogs.MessageBox.show({
title : _('Error'),
msg : _('Selected calendar does not exist!'),
icon : Zarafa.common.dialogs.MessageBox.ERROR,
buttons : Zarafa.common.dialogs.MessageBox.OK
});
}
}
for(i = 0; i < requests; i++) {
var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({
successCallback: this.storeResult.createDelegate(this)
});
this.requestNext(calendarFolder, responseHandler, response.page.rowcount *(i+1), response.page.rowcount);
}
},
/**
* Responsehandler for the single requests... will merge all events into one array
* @param {Object} response
*/
storeResult: function(response) {
var tmp = this.exportResponse;
this.exportResponse = tmp.concat(response.item);
if(this.runningRequests <= 1) {
// final request =)
var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({
successCallback: this.downLoadICS.createDelegate(this)
});
container.getRequest().singleRequest(
'calendarmodule',
'export',
{
data: this.exportResponse,
calendar: this.calendarselector.value
},
responseHandler
);
container.getNotifier().notify('info', 'Exported', 'Found ' + this.exportResponse.length + ' entries to export. Preparing download...');
this.dialog.close();
}
this.runningRequests--;
},
/**
* build a new event request for the listmodule
* @param {Object} calendarFolder the calendarFolder to export
* @param {Object} responseHandler (should be storeResult)
* @param {int} start
* @param {int} limit
*/
requestNext: function(calendarFolder, responseHandler, start, limit) {
container.getRequest().singleRequest(
'appointmentlistmodule',
'list',
{
groupDir: "ASC",
restriction: {
start: start,
limit: limit
//startdate: 0,
//duedate: 2145826800 // 2037... nearly highest unix timestamp
},
sort: [{
"field": "startdate",
"direction": "DESC"
}],
store_entryid : calendarFolder.data.store_entryid,
entryid : calendarFolder.data.entryid
},
responseHandler
);
},
/**
* download ics file =)
* @param {Object} response
* @private
*/
downLoadICS : function(response) {
Zarafa.common.dialogs.MessageBox.hide();
if(response.status === true) {
if(!this.downloadFrame){
this.downloadFrame = Ext.getBody().createChild({
tag: 'iframe',
cls: 'x-hidden'
});
}
var url = 'plugins/calendarimporter/php/download.php?fileid='+response.fileid+'&basedir='+response.basedir+'&secid='+response.secid+'&realname='+response.realname;
this.downloadFrame.dom.contentWindow.location = url;
} else {
container.getNotifier().notify('error', 'Export Failed', 'ICal File creation failed!');
}
},
/**
* This function stores all given events to the appointmentstore
* @param events
*/
importEvents: function (events) {
//receive existing calendar store
var calValue = this.calendarselector.value;
var calValue = this.calendarselector.getValue();
if(calValue == undefined) { // no calendar choosen
if(Ext.isEmpty(calValue)) { // no calendar choosen
Zarafa.common.dialogs.MessageBox.show({
title : _('Error'),
msg : _('You have to choose a calendar!'),
@ -931,7 +604,6 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
buttons : Zarafa.common.dialogs.MessageBox.OK
});
} else {
var calexist = true;
if(this.eventgrid.selModel.getCount() < 1) {
Zarafa.common.dialogs.MessageBox.show({
title : _('Error'),
@ -940,53 +612,52 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
buttons : Zarafa.common.dialogs.MessageBox.OK
});
} else {
var calendarStore = new Zarafa.calendar.AppointmentStore();
var calendarFolder = container.getHierarchyStore().getDefaultFolder('calendar');
var pubStore = container.getHierarchyStore().getPublicStore();
var pubFolder = pubStore.getDefaultFolder("publicfolders");
var pubSubFolders = pubFolder.getChildren();
var calendarFolder = this.getContactFolderByEntryid(folderValue);
if(calValue != "calendar") {
var subFolders = calendarFolder.getChildren();
var i = 0;
for(i = 0; i < pubSubFolders.length; i++) {
if(pubSubFolders[i].isContainerClass("IPF.Appointment")){
subFolders.push(pubSubFolders[i]);
}
}
for(i=0;i<subFolders.length;i++) {
// look up right folder
// TODO: improve!!
if(subFolders[i].getDisplayName() == calValue) {
calendarFolder = subFolders[i];
break;
}
}
this.loadMask.show();
var uids = [];
if(calendarFolder.isDefaultFolder()) {
//receive Records from grid rows
Ext.each(events, function(newRecord) {
uids.push(newRecord.data.record.internal_fields.event_uid);
}, this);
var responseHandler = new Zarafa.plugins.contactimporter.data.ResponseHandler({
successCallback: this.importEventsDone,
scope: this
});
container.getRequest().singleRequest(
'calendarmodule',
'import',
{
storeid : contactFolder.store_entryid,
folderid : contactFolder.entryid,
uids : uids,
vcf_filepath: this.vcffile
},
responseHandler
);
}
}
},
/**
* Callback for the import request.
* @param {Object} response
*/
importEventsDone: function (response) {
this.loadMask.hide();
this.dialog.close();
if (response.status == true) {
container.getNotifier().notify('info', 'Imported', 'Imported ' + response.count + ' events. Please reload your calendar!');
} else {
Zarafa.common.dialogs.MessageBox.show({
title : _('Error'),
msg : _('Selected calendar does not exist!'),
msg : _('Import failed: ') + response.message,
icon : Zarafa.common.dialogs.MessageBox.ERROR,
buttons: Zarafa.common.dialogs.MessageBox.OK
});
calexist = false;
}
}
if(calexist) {
this.loadMask.show();
//receive Records from grid rows
Ext.each(events, function(newRecord) {
var record = this.convertToAppointmentRecord(calendarFolder,newRecord.data);
calendarStore.add(record);
}, this);
calendarStore.save();
this.loadMask.hide();
this.dialog.close();
container.getNotifier().notify('info', 'Imported', 'Imported ' + events.length + ' events. Please reload your calendar!');
}
}
}
}
});

View File

@ -47,44 +47,69 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
/* directly import received icals */
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);
/* export a calendar entry via rightclick */
this.registerInsertionPoint('context.calendar.contextmenu.actions', this.createItemExportInsertionPoint, 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.createSettingsCalSyncWidget);
}
},
/**
* Creates the button
*
* @return {Object} Configuration object for a {@link Ext.Button button}
* This method hooks to the contact context menu and allows users to export users to vcf.
*
* @param include
* @param btn
* @returns {Object}
*/
createImportButton: function () {
var button = {
xtype : 'button',
ref : "importbutton",
id : "importbutton",
text : _('Import Calendar'),
iconCls : 'icon_calendarimporter_button',
navigationContext : container.getContextByName('calendar'),
handler : this.onImportButtonClick,
scope : this
createItemExportInsertionPoint: function (include, btn) {
return {
text : dgettext('plugin_files', 'Export Event'),
handler: this.exportToICS.createDelegate(this, [btn]),
scope : this,
iconCls: 'icon_calendarimporter_export'
};
},
if(container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/enable_export")) {
button.text = _('Import/Export Calendar');
/**
* Generates a request to download the selected records as vCard.
* @param {Ext.Button} btn
*/
exportToICS: function (btn) {
if (btn.records.length == 0) {
return; // skip if no records where given!
}
return button;
var recordIds = [];
for (var i = 0; i < btn.records.length; i++) {
recordIds.push(btn.records[i].get("entryid"));
}
var responseHandler = new Zarafa.plugins.contactimporter.data.ResponseHandler({
successCallback: Zarafa.plugins.calendarimporter.data.Actions.downloadICS,
scope : this
});
// request attachment preperation
container.getRequest().singleRequest(
'calendarmodule',
'export',
{
storeid: btn.records[0].get("store_entryid"),
records: recordIds
},
responseHandler
);
},
/**
@ -118,17 +143,17 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
*/
createAttachmentImportButton: function (include, btn) {
return {
text : _('Import Calendar'),
handler : this.getAttachmentFileName.createDelegate(this, [btn, this.gotAttachmentFileName]),
text : _('Import to Calendar'),
handler : this.getAttachmentFileName.createDelegate(this, [btn]),
scope : this,
iconCls : 'icon_calendarimporter_button',
beforeShow: function (item, record) {
var extension = record.data.name.split('.').pop().toLowerCase();
if (record.data.filetype == "text/calendar" || extension == "ics" || extension == "ifb" || extension == "ical" || extension == "ifbf") {
item.setDisabled(false);
item.setVisible(true);
} else {
item.setDisabled(true);
item.setVisible(false);
}
}
};
@ -139,10 +164,7 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
*/
gotAttachmentFileName: function (response) {
if (response.status == true) {
Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents'], undefined, {
manager : Ext.WindowMgr,
filename : response.tmpname
});
this.openImportDialog(response.tmpname);
} else {
Zarafa.common.dialogs.MessageBox.show({
title : _('Error'),
@ -188,21 +210,23 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
var store = attachmentStore.getParentRecord().get('store_entryid');
var entryid = attachmentStore.getAttachmentParentRecordEntryId();
var attachNum = new Array(1);
if (attachmentRecord.get('attach_num') != -1)
if (attachmentRecord.get('attach_num') != -1) {
attachNum[0] = attachmentRecord.get('attach_num');
else
} else {
attachNum[0] = attachmentRecord.get('tmpname');
}
var dialog_attachments = attachmentStore.getId();
var filename = attachmentRecord.data.name;
var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({
successCallback: callback
successCallback: this.gotAttachmentFileName,
scope : this
});
// request attachment preperation
container.getRequest().singleRequest(
'calendarmodule',
'attachmentpath',
'importattachment',
{
entryid : entryid,
store : store,
@ -215,12 +239,17 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
},
/**
* Clickhandler for the button
* Open the import dialog.
* @param {String} filename
*/
onImportButtonClick: function () {
Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents'], undefined, {
manager : Ext.WindowMgr
});
openImportDialog: function (filename) {
var componentType = Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents'];
var config = {
filename: filename,
modal : true
};
Zarafa.core.data.UIFactory.openLayerComponent(componentType, undefined, config);
},
/**
@ -240,6 +269,13 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit']:
bid = 2;
break;
case Zarafa.core.data.SharedComponentType['common.contextmenu']:
if (record instanceof Zarafa.core.data.MAPIRecord) {
if (record.get('object_type') == Zarafa.core.mapi.ObjectType.MAPI_FOLDER && record.get('container_class') == "IPF.Appointment") {
bid = 2;
}
}
break;
}
return bid;
},
@ -260,6 +296,9 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit']:
component = Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel;
break;
case Zarafa.core.data.SharedComponentType['common.contextmenu']:
component = Zarafa.plugins.calendarimporter.ui.ContextMenu;
break;
}
return component;

View File

@ -24,13 +24,6 @@ Zarafa.plugins.calendarimporter.settings.SettingsWidget = Ext.extend(Zarafa.sett
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',
@ -123,7 +116,6 @@ Zarafa.plugins.calendarimporter.settings.SettingsWidget = Ext.extend(Zarafa.sett
* @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));
@ -136,7 +128,6 @@ Zarafa.plugins.calendarimporter.settings.SettingsWidget = Ext.extend(Zarafa.sett
* @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());

View File

@ -95,7 +95,7 @@ Zarafa.plugins.calendarimporter.ui.ContextMenu = Ext.extend(Zarafa.hierarchy.ui.
*/
onContextItemExport: function () {
var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({
successCallback: this.downloadICS,
successCallback: Zarafa.plugins.calendarimporter.data.Actions.downloadICS,
scope : this
});
@ -116,42 +116,13 @@ Zarafa.plugins.calendarimporter.ui.ContextMenu = Ext.extend(Zarafa.hierarchy.ui.
* @private
*/
onContextItemImport: function () {
var componentType = Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importcontacts'];
var componentType = Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents'];
var config = {
modal : true,
folder: this.records.get("entryid")
};
Zarafa.core.data.UIFactory.openLayerComponent(componentType, undefined, config);
},
/**
* Callback for the export request.
* @param {Object} response
*/
downloadICS: function (response) {
if (response.status == false) {
Zarafa.common.dialogs.MessageBox.show({
title : dgettext('plugin_files', 'Warning'),
msg : dgettext('plugin_files', response.message),
icon : Zarafa.common.dialogs.MessageBox.WARNING,
buttons: Zarafa.common.dialogs.MessageBox.OK
});
} else {
var downloadFrame = Ext.getBody().createChild({
tag: 'iframe',
cls: 'x-hidden'
});
var url = document.URL;
var link = url.substring(0, url.lastIndexOf('/') + 1);
link += "index.php?sessionid=" + container.getUser().getSessionId() + "&load=custom&name=download_ics";
link = Ext.urlAppend(link, "token=" + encodeURIComponent(response.download_token));
link = Ext.urlAppend(link, "filename=" + encodeURIComponent(response.filename));
downloadFrame.dom.contentWindow.location = link;
}
}
});

View File

@ -24,9 +24,10 @@
<clientfile load="debug">js/calendarimporter-debug.js</clientfile>
<clientfile load="source">js/data/timezones.js</clientfile>
<clientfile load="source">js/external/Ext.util.base64.js</clientfile>
<clientfile load="source">js/plugin.calendarimporter.js</clientfile>
<clientfile load="source">js/data/Actions.js</clientfile>
<clientfile load="source">js/data/ResponseHandler.js</clientfile>
<clientfile load="source">js/external/Ext.util.base64.js</clientfile>
<clientfile load="source">js/ui/ContextMenu.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>
@ -35,6 +36,7 @@
<clientfile load="source">js/dialogs/settings/ui/CalSyncPanel.js</clientfile>
<clientfile load="source">js/dialogs/settings/dialogs/CalSyncEditContentPanel.js</clientfile>
<clientfile load="source">js/dialogs/settings/dialogs/CalSyncEditPanel.js</clientfile>
<clientfile load="source">js/plugin.calendarimporter.js</clientfile>
</client>
<resources>
<resourcefile load="release">resources/css/calendarimporter-min.css</resourcefile>

View File

@ -63,7 +63,7 @@ class CalendarModule extends Module {
case "import":
$result = $this->importCalendar($actionType, $actionData);
break;
case "attachmentpath":
case "importattachment":
$result = $this->getAttachmentPath($actionType, $actionData);
break;
default:

View File

@ -67,7 +67,6 @@ class Plugincalendarimporter extends Plugin {
'plugins' => Array(
'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