javascript rework
This commit is contained in:
parent
e76893d82f
commit
67b6a332f2
@ -1,13 +1,11 @@
|
|||||||
<?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', true);
|
||||||
/** Disable the export feature for all clients */
|
|
||||||
define('PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE_EXPORT', false);
|
|
||||||
/** Disable the sync feature for all clients */
|
/** Disable the sync feature for all clients */
|
||||||
define('PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE_SYNC', true); // not yet implemented
|
define('PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE_SYNC', true); // not yet implemented
|
||||||
|
|
||||||
/** The default calendar to import to*/
|
/** The default calendar to import to*/
|
||||||
define('PLUGIN_CALENDARIMPORTER_DEFAULT', "calendar");
|
define('PLUGIN_CALENDARIMPORTER_DEFAULT', "Kalender");
|
||||||
define('PLUGIN_CALENDARIMPORTER_DEFAULT_TIMEZONE', "Europe/Vienna");
|
define('PLUGIN_CALENDARIMPORTER_DEFAULT_TIMEZONE', "Europe/Vienna");
|
||||||
|
|
||||||
/** Tempory path for uploaded files... */
|
/** Tempory path for uploaded files... */
|
||||||
|
65
js/data/Actions.js
Normal file
65
js/data/Actions.js
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
@ -38,13 +38,13 @@ Zarafa.plugins.calendarimporter.data.ResponseHandler = Ext.extend(Zarafa.core.da
|
|||||||
* @cfg {Function} successCallback The function which
|
* @cfg {Function} successCallback The function which
|
||||||
* will be called after success request.
|
* will be called after success request.
|
||||||
*/
|
*/
|
||||||
successCallback : null,
|
successCallback: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call the successCallback callback function.
|
* Call the successCallback callback function.
|
||||||
* @param {Object} response Object contained the response data.
|
* @param {Object} response Object contained the response data.
|
||||||
*/
|
*/
|
||||||
doExport : function(response) {
|
doExport: function (response) {
|
||||||
this.successCallback(response);
|
this.successCallback(response);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ Zarafa.plugins.calendarimporter.data.ResponseHandler = Ext.extend(Zarafa.core.da
|
|||||||
* Call the successCallback callback function.
|
* Call the successCallback callback function.
|
||||||
* @param {Object} response Object contained the response data.
|
* @param {Object} response Object contained the response data.
|
||||||
*/
|
*/
|
||||||
doList : function(response) {
|
doList: function (response) {
|
||||||
this.successCallback(response);
|
this.successCallback(response);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ Zarafa.plugins.calendarimporter.data.ResponseHandler = Ext.extend(Zarafa.core.da
|
|||||||
* Call the successCallback callback function.
|
* Call the successCallback callback function.
|
||||||
* @param {Object} response Object contained the response data.
|
* @param {Object} response Object contained the response data.
|
||||||
*/
|
*/
|
||||||
doImport : function(response) {
|
doImport: function (response) {
|
||||||
this.successCallback(response);
|
this.successCallback(response);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ Zarafa.plugins.calendarimporter.data.ResponseHandler = Ext.extend(Zarafa.core.da
|
|||||||
* Call the successCallback callback function.
|
* Call the successCallback callback function.
|
||||||
* @param {Object} response Object contained the response data.
|
* @param {Object} response Object contained the response data.
|
||||||
*/
|
*/
|
||||||
doAttachmentpath : function(response) {
|
doImportattachment: function (response) {
|
||||||
this.successCallback(response);
|
this.successCallback(response);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ Zarafa.plugins.calendarimporter.data.ResponseHandler = Ext.extend(Zarafa.core.da
|
|||||||
* exception response with the code of exception.
|
* exception response with the code of exception.
|
||||||
* @param {Object} response Object contained the response data.
|
* @param {Object} response Object contained the response data.
|
||||||
*/
|
*/
|
||||||
doError: function(response) {
|
doError: function (response) {
|
||||||
alert("error response code: " + response.error.info.code);
|
alert("error response code: " + response.error.info.code);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -372,7 +372,7 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
|||||||
name: "choosen_timezone",
|
name: "choosen_timezone",
|
||||||
value: Zarafa.plugins.calendarimporter.data.Timezones.unMap(container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/default_timezone")),
|
value: Zarafa.plugins.calendarimporter.data.Timezones.unMap(container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/default_timezone")),
|
||||||
width: 100,
|
width: 100,
|
||||||
fieldLabel: "Select a timezone (optional)",
|
fieldLabel: "Timezone",
|
||||||
store: Zarafa.plugins.calendarimporter.data.Timezones.store,
|
store: Zarafa.plugins.calendarimporter.data.Timezones.store,
|
||||||
labelSeperator: ":",
|
labelSeperator: ":",
|
||||||
mode: 'local',
|
mode: 'local',
|
||||||
@ -393,7 +393,7 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
|||||||
ref: 'dstcheck',
|
ref: 'dstcheck',
|
||||||
name: "dst_check",
|
name: "dst_check",
|
||||||
width: 100,
|
width: 100,
|
||||||
fieldLabel: "Ignore DST (optional)",
|
fieldLabel: "Ignore DST",
|
||||||
boxLabel: 'This will ignore "Daylight saving time" offsets.',
|
boxLabel: 'This will ignore "Daylight saving time" offsets.',
|
||||||
labelSeperator: ":",
|
labelSeperator: ":",
|
||||||
border: false,
|
border: false,
|
||||||
@ -529,14 +529,15 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
|||||||
|
|
||||||
parseCalendar: function (icsPath, timezone, ignoredst) {
|
parseCalendar: function (icsPath, timezone, ignoredst) {
|
||||||
this.loadMask.show();
|
this.loadMask.show();
|
||||||
// call export function here!
|
|
||||||
var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({
|
var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({
|
||||||
successCallback: this.handleParsingResult.createDelegate(this)
|
successCallback: this.handleParsingResult,
|
||||||
|
scope: this
|
||||||
});
|
});
|
||||||
|
|
||||||
container.getRequest().singleRequest(
|
container.getRequest().singleRequest(
|
||||||
'calendarmodule',
|
'calendarmodule',
|
||||||
'import',
|
'load',
|
||||||
{
|
{
|
||||||
ics_filepath: icsPath,
|
ics_filepath: icsPath,
|
||||||
timezone: timezone,
|
timezone: timezone,
|
||||||
@ -550,17 +551,17 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
|||||||
this.loadMask.hide();
|
this.loadMask.hide();
|
||||||
|
|
||||||
if(response["status"] == true) {
|
if(response["status"] == true) {
|
||||||
Ext.getCmp('submitButton').enable();
|
this.submitButton.enable();
|
||||||
Ext.getCmp('submitAllButton').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.timezone = response.parsed.calendar["X-WR-TIMEZONE"];
|
||||||
this.timezoneselector.setValue(Zarafa.plugins.calendarimporter.data.Timezones.unMap(this.timezone));
|
this.timezoneselector.setValue(Zarafa.plugins.calendarimporter.data.Timezones.unMap(this.timezone));
|
||||||
}
|
}
|
||||||
this.reloadGridStore(response.parsed);
|
this.reloadGridStore(response.parsed);
|
||||||
} else {
|
} else {
|
||||||
Ext.getCmp('submitButton').disable();
|
this.submitButton.disable();
|
||||||
Ext.getCmp('submitAllButton').disable();
|
this.submitAllButton.disable();
|
||||||
Zarafa.common.dialogs.MessageBox.show({
|
Zarafa.common.dialogs.MessageBox.show({
|
||||||
title : _('Parser Error'),
|
title : _('Parser Error'),
|
||||||
msg : _(response["message"]),
|
msg : _(response["message"]),
|
||||||
@ -575,54 +576,6 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
|||||||
this.dialog.close()
|
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 () {
|
importCheckedEvents: function () {
|
||||||
var newRecords = this.eventgrid.selModel.getSelections();
|
var newRecords = this.eventgrid.selModel.getSelections();
|
||||||
this.importEvents(newRecords);
|
this.importEvents(newRecords);
|
||||||
@ -635,295 +588,15 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
|||||||
this.importEvents(newRecords);
|
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
|
* This function stores all given events to the appointmentstore
|
||||||
* @param events
|
* @param events
|
||||||
*/
|
*/
|
||||||
importEvents: function (events) {
|
importEvents: function (events) {
|
||||||
//receive existing calendar store
|
//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({
|
Zarafa.common.dialogs.MessageBox.show({
|
||||||
title : _('Error'),
|
title : _('Error'),
|
||||||
msg : _('You have to choose a calendar!'),
|
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
|
buttons : Zarafa.common.dialogs.MessageBox.OK
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var calexist = true;
|
|
||||||
if(this.eventgrid.selModel.getCount() < 1) {
|
if(this.eventgrid.selModel.getCount() < 1) {
|
||||||
Zarafa.common.dialogs.MessageBox.show({
|
Zarafa.common.dialogs.MessageBox.show({
|
||||||
title : _('Error'),
|
title : _('Error'),
|
||||||
@ -940,53 +612,52 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
|||||||
buttons : Zarafa.common.dialogs.MessageBox.OK
|
buttons : Zarafa.common.dialogs.MessageBox.OK
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var calendarStore = new Zarafa.calendar.AppointmentStore();
|
var calendarFolder = this.getContactFolderByEntryid(folderValue);
|
||||||
var calendarFolder = container.getHierarchyStore().getDefaultFolder('calendar');
|
|
||||||
var pubStore = container.getHierarchyStore().getPublicStore();
|
|
||||||
var pubFolder = pubStore.getDefaultFolder("publicfolders");
|
|
||||||
var pubSubFolders = pubFolder.getChildren();
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
|
||||||
this.loadMask.show();
|
this.loadMask.show();
|
||||||
|
var uids = [];
|
||||||
|
|
||||||
//receive Records from grid rows
|
//receive Records from grid rows
|
||||||
Ext.each(events, function(newRecord) {
|
Ext.each(events, function(newRecord) {
|
||||||
var record = this.convertToAppointmentRecord(calendarFolder,newRecord.data);
|
uids.push(newRecord.data.record.internal_fields.event_uid);
|
||||||
calendarStore.add(record);
|
|
||||||
}, this);
|
}, this);
|
||||||
calendarStore.save();
|
|
||||||
|
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.loadMask.hide();
|
||||||
this.dialog.close();
|
this.dialog.close();
|
||||||
container.getNotifier().notify('info', 'Imported', 'Imported ' + events.length + ' events. Please reload your calendar!');
|
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 : _('Import failed: ') + response.message,
|
||||||
|
icon : Zarafa.common.dialogs.MessageBox.ERROR,
|
||||||
|
buttons: Zarafa.common.dialogs.MessageBox.OK
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -39,7 +39,7 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
* initialises insertion point for plugin
|
* initialises insertion point for plugin
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
initPlugin : function() {
|
initPlugin: function () {
|
||||||
Zarafa.plugins.calendarimporter.ImportPlugin.superclass.initPlugin.apply(this, arguments);
|
Zarafa.plugins.calendarimporter.ImportPlugin.superclass.initPlugin.apply(this, arguments);
|
||||||
|
|
||||||
/* our panel */
|
/* our panel */
|
||||||
@ -47,44 +47,69 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
|
|
||||||
/* directly import received icals */
|
/* directly import received icals */
|
||||||
this.registerInsertionPoint('common.contextmenu.attachment.actions', this.createAttachmentImportButton);
|
this.registerInsertionPoint('common.contextmenu.attachment.actions', this.createAttachmentImportButton);
|
||||||
/* add import button to south navigation */
|
|
||||||
this.registerInsertionPoint("navigation.south", this.createImportButton, this);
|
|
||||||
/* add settings widget */
|
/* add settings widget */
|
||||||
this.registerInsertionPoint('context.settings.category.calendar', this.createSettingsWidget);
|
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 */
|
/* ical sync stuff */
|
||||||
if(container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/enable_sync") === true) {
|
if (container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/enable_sync") === true) {
|
||||||
/* edit panel */
|
/* edit panel */
|
||||||
Zarafa.core.data.SharedComponentType.addProperty('plugins.calendarimporter.settings.dialogs.calsyncedit');
|
Zarafa.core.data.SharedComponentType.addProperty('plugins.calendarimporter.settings.dialogs.calsyncedit');
|
||||||
|
|
||||||
/* enable the settings widget */
|
/* enable the settings widget */
|
||||||
this.registerInsertionPoint('context.settings.category.calendar', this.createSettingsCalSyncWidget);
|
this.registerInsertionPoint('context.settings.category.calendar', this.createSettingsCalSyncWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the button
|
* This method hooks to the contact context menu and allows users to export users to vcf.
|
||||||
*
|
|
||||||
* @return {Object} Configuration object for a {@link Ext.Button button}
|
|
||||||
*
|
*
|
||||||
|
* @param include
|
||||||
|
* @param btn
|
||||||
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
createImportButton: function () {
|
createItemExportInsertionPoint: function (include, btn) {
|
||||||
var button = {
|
return {
|
||||||
xtype : 'button',
|
text : dgettext('plugin_files', 'Export Event'),
|
||||||
ref : "importbutton",
|
handler: this.exportToICS.createDelegate(this, [btn]),
|
||||||
id : "importbutton",
|
scope : this,
|
||||||
text : _('Import Calendar'),
|
iconCls: 'icon_calendarimporter_export'
|
||||||
iconCls : 'icon_calendarimporter_button',
|
|
||||||
navigationContext : container.getContextByName('calendar'),
|
|
||||||
handler : this.onImportButtonClick,
|
|
||||||
scope : this
|
|
||||||
};
|
};
|
||||||
|
},
|
||||||
|
|
||||||
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
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,7 +120,7 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
*/
|
*/
|
||||||
createSettingsWidget: function () {
|
createSettingsWidget: function () {
|
||||||
return [{
|
return [{
|
||||||
xtype : 'calendarimporter.settingswidget'
|
xtype: 'calendarimporter.settingswidget'
|
||||||
}];
|
}];
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -107,7 +132,7 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
*/
|
*/
|
||||||
createSettingsCalSyncWidget: function () {
|
createSettingsCalSyncWidget: function () {
|
||||||
return [{
|
return [{
|
||||||
xtype : 'calendarimporter.settingscalsyncwidget'
|
xtype: 'calendarimporter.settingscalsyncwidget'
|
||||||
}];
|
}];
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -116,19 +141,19 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
|
|
||||||
* @return {Object} Configuration object for a {@link Ext.Button button}
|
* @return {Object} Configuration object for a {@link Ext.Button button}
|
||||||
*/
|
*/
|
||||||
createAttachmentImportButton : function(include, btn) {
|
createAttachmentImportButton: function (include, btn) {
|
||||||
return {
|
return {
|
||||||
text : _('Import Calendar'),
|
text : _('Import to Calendar'),
|
||||||
handler : this.getAttachmentFileName.createDelegate(this, [btn, this.gotAttachmentFileName]),
|
handler : this.getAttachmentFileName.createDelegate(this, [btn]),
|
||||||
scope : this,
|
scope : this,
|
||||||
iconCls : 'icon_calendarimporter_button',
|
iconCls : 'icon_calendarimporter_button',
|
||||||
beforeShow : function(item, record) {
|
beforeShow: function (item, record) {
|
||||||
var extension = record.data.name.split('.').pop().toLowerCase();
|
var extension = record.data.name.split('.').pop().toLowerCase();
|
||||||
|
|
||||||
if(record.data.filetype == "text/calendar" || extension == "ics" || extension == "ifb" || extension == "ical" || extension == "ifbf") {
|
if (record.data.filetype == "text/calendar" || extension == "ics" || extension == "ifb" || extension == "ical" || extension == "ifbf") {
|
||||||
item.setDisabled(false);
|
item.setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
item.setDisabled(true);
|
item.setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -137,18 +162,15 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
/**
|
/**
|
||||||
* Callback for getAttachmentFileName
|
* Callback for getAttachmentFileName
|
||||||
*/
|
*/
|
||||||
gotAttachmentFileName: function(response) {
|
gotAttachmentFileName: function (response) {
|
||||||
if(response.status == true) {
|
if (response.status == true) {
|
||||||
Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents'], undefined, {
|
this.openImportDialog(response.tmpname);
|
||||||
manager : Ext.WindowMgr,
|
|
||||||
filename : response.tmpname
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
Zarafa.common.dialogs.MessageBox.show({
|
Zarafa.common.dialogs.MessageBox.show({
|
||||||
title : _('Error'),
|
title : _('Error'),
|
||||||
msg : _(response["message"]),
|
msg : _(response["message"]),
|
||||||
icon : Zarafa.common.dialogs.MessageBox.ERROR,
|
icon : Zarafa.common.dialogs.MessageBox.ERROR,
|
||||||
buttons : Zarafa.common.dialogs.MessageBox.OK
|
buttons: Zarafa.common.dialogs.MessageBox.OK
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -158,27 +180,27 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
*/
|
*/
|
||||||
getAttachmentFileName: function (btn, callback) {
|
getAttachmentFileName: function (btn, callback) {
|
||||||
Zarafa.common.dialogs.MessageBox.show({
|
Zarafa.common.dialogs.MessageBox.show({
|
||||||
title: 'Please wait',
|
title : 'Please wait',
|
||||||
msg: 'Loading attachment...',
|
msg : 'Loading attachment...',
|
||||||
progressText: 'Initializing...',
|
progressText: 'Initializing...',
|
||||||
width:300,
|
width : 300,
|
||||||
progress:true,
|
progress : true,
|
||||||
closable:false
|
closable : false
|
||||||
});
|
});
|
||||||
|
|
||||||
// progress bar... ;)
|
// progress bar... ;)
|
||||||
var f = function(v){
|
var f = function (v) {
|
||||||
return function(){
|
return function () {
|
||||||
if(v == 100){
|
if (v == 100) {
|
||||||
Zarafa.common.dialogs.MessageBox.hide();
|
Zarafa.common.dialogs.MessageBox.hide();
|
||||||
}else{
|
} else {
|
||||||
Zarafa.common.dialogs.MessageBox.updateProgress(v/100, Math.round(v)+'% loaded');
|
Zarafa.common.dialogs.MessageBox.updateProgress(v / 100, Math.round(v) + '% loaded');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
for(var i = 1; i < 101; i++){
|
for (var i = 1; i < 101; i++) {
|
||||||
setTimeout(f(i), 20*i);
|
setTimeout(f(i), 20 * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* store the attachment to a temporary folder and prepare it for uploading */
|
/* store the attachment to a temporary folder and prepare it for uploading */
|
||||||
@ -188,39 +210,46 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
var store = attachmentStore.getParentRecord().get('store_entryid');
|
var store = attachmentStore.getParentRecord().get('store_entryid');
|
||||||
var entryid = attachmentStore.getAttachmentParentRecordEntryId();
|
var entryid = attachmentStore.getAttachmentParentRecordEntryId();
|
||||||
var attachNum = new Array(1);
|
var attachNum = new Array(1);
|
||||||
if (attachmentRecord.get('attach_num') != -1)
|
if (attachmentRecord.get('attach_num') != -1) {
|
||||||
attachNum[0] = attachmentRecord.get('attach_num');
|
attachNum[0] = attachmentRecord.get('attach_num');
|
||||||
else
|
} else {
|
||||||
attachNum[0] = attachmentRecord.get('tmpname');
|
attachNum[0] = attachmentRecord.get('tmpname');
|
||||||
|
}
|
||||||
var dialog_attachments = attachmentStore.getId();
|
var dialog_attachments = attachmentStore.getId();
|
||||||
var filename = attachmentRecord.data.name;
|
var filename = attachmentRecord.data.name;
|
||||||
|
|
||||||
var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({
|
var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({
|
||||||
successCallback: callback
|
successCallback: this.gotAttachmentFileName,
|
||||||
|
scope : this
|
||||||
});
|
});
|
||||||
|
|
||||||
// request attachment preperation
|
// request attachment preperation
|
||||||
container.getRequest().singleRequest(
|
container.getRequest().singleRequest(
|
||||||
'calendarmodule',
|
'calendarmodule',
|
||||||
'attachmentpath',
|
'importattachment',
|
||||||
{
|
{
|
||||||
entryid : entryid,
|
entryid : entryid,
|
||||||
store: store,
|
store : store,
|
||||||
attachNum: attachNum,
|
attachNum : attachNum,
|
||||||
dialog_attachments: dialog_attachments,
|
dialog_attachments: dialog_attachments,
|
||||||
filename: filename
|
filename : filename
|
||||||
},
|
},
|
||||||
responseHandler
|
responseHandler
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clickhandler for the button
|
* Open the import dialog.
|
||||||
|
* @param {String} filename
|
||||||
*/
|
*/
|
||||||
onImportButtonClick: function () {
|
openImportDialog: function (filename) {
|
||||||
Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents'], undefined, {
|
var componentType = Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents'];
|
||||||
manager : Ext.WindowMgr
|
var config = {
|
||||||
});
|
filename: filename,
|
||||||
|
modal : true
|
||||||
|
};
|
||||||
|
|
||||||
|
Zarafa.core.data.UIFactory.openLayerComponent(componentType, undefined, config);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -231,15 +260,22 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
* @param {Ext.data.Record} record Optionally passed record.
|
* @param {Ext.data.Record} record Optionally passed record.
|
||||||
* @return {Number} The bid for the shared component
|
* @return {Number} The bid for the shared component
|
||||||
*/
|
*/
|
||||||
bidSharedComponent : function(type, record) {
|
bidSharedComponent: function (type, record) {
|
||||||
var bid = -1;
|
var bid = -1;
|
||||||
switch(type) {
|
switch (type) {
|
||||||
case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents']:
|
case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents']:
|
||||||
bid = 2;
|
bid = 2;
|
||||||
break;
|
break;
|
||||||
case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit']:
|
case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit']:
|
||||||
bid = 2;
|
bid = 2;
|
||||||
break;
|
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;
|
return bid;
|
||||||
},
|
},
|
||||||
@ -251,15 +287,18 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
* @param {Ext.data.Record} record Optionally passed record.
|
* @param {Ext.data.Record} record Optionally passed record.
|
||||||
* @return {Ext.Component} Component
|
* @return {Ext.Component} Component
|
||||||
*/
|
*/
|
||||||
getSharedComponent : function(type, record) {
|
getSharedComponent: function (type, record) {
|
||||||
var component;
|
var component;
|
||||||
switch(type) {
|
switch (type) {
|
||||||
case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents']:
|
case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents']:
|
||||||
component = Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel;
|
component = Zarafa.plugins.calendarimporter.dialogs.ImportContentPanel;
|
||||||
break;
|
break;
|
||||||
case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit']:
|
case Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit']:
|
||||||
component = Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel;
|
component = Zarafa.plugins.calendarimporter.settings.dialogs.CalSyncEditContentPanel;
|
||||||
break;
|
break;
|
||||||
|
case Zarafa.core.data.SharedComponentType['common.contextmenu']:
|
||||||
|
component = Zarafa.plugins.calendarimporter.ui.ContextMenu;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return component;
|
return component;
|
||||||
@ -270,11 +309,11 @@ Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
/*############################################################################################################################*
|
/*############################################################################################################################*
|
||||||
* STARTUP
|
* STARTUP
|
||||||
*############################################################################################################################*/
|
*############################################################################################################################*/
|
||||||
Zarafa.onReady(function() {
|
Zarafa.onReady(function () {
|
||||||
container.registerPlugin(new Zarafa.core.PluginMetaData({
|
container.registerPlugin(new Zarafa.core.PluginMetaData({
|
||||||
name : 'calendarimporter',
|
name : 'calendarimporter',
|
||||||
displayName : _('Calendarimporter Plugin'),
|
displayName : _('Calendarimporter Plugin'),
|
||||||
about : Zarafa.plugins.calendarimporter.ABOUT,
|
about : Zarafa.plugins.calendarimporter.ABOUT,
|
||||||
pluginConstructor : Zarafa.plugins.calendarimporter.ImportPlugin
|
pluginConstructor: Zarafa.plugins.calendarimporter.ImportPlugin
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
@ -24,13 +24,6 @@ Zarafa.plugins.calendarimporter.settings.SettingsWidget = Ext.extend(Zarafa.sett
|
|||||||
title : _('Calendar Import/Export plugin settings'),
|
title : _('Calendar Import/Export plugin settings'),
|
||||||
xtype : 'calendarimporter.settingswidget',
|
xtype : 'calendarimporter.settingswidget',
|
||||||
items : [
|
items : [
|
||||||
{
|
|
||||||
xtype : 'checkbox',
|
|
||||||
name : 'zarafa/v1/plugins/calendarimporter/enable_export',
|
|
||||||
ref : 'enableExport',
|
|
||||||
fieldLabel : 'Enable exporter',
|
|
||||||
lazyInit : false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
xtype : 'checkbox',
|
xtype : 'checkbox',
|
||||||
name : 'zarafa/v1/plugins/calendarimporter/enable_sync',
|
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
|
* @param {Zarafa.settings.SettingsModel} settingsModel The settings to load
|
||||||
*/
|
*/
|
||||||
update : function(settingsModel) {
|
update : function(settingsModel) {
|
||||||
this.enableExport.setValue(settingsModel.get(this.enableExport.name));
|
|
||||||
this.enableSync.setValue(settingsModel.get(this.enableSync.name));
|
this.enableSync.setValue(settingsModel.get(this.enableSync.name));
|
||||||
this.defaultCalendar.setValue(settingsModel.get(this.defaultCalendar.name));
|
this.defaultCalendar.setValue(settingsModel.get(this.defaultCalendar.name));
|
||||||
this.defaultTimezone.setValue(settingsModel.get(this.defaultTimezone.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
|
* @param {Zarafa.settings.SettingsModel} settingsModel The settings to update
|
||||||
*/
|
*/
|
||||||
updateSettings : function(settingsModel) {
|
updateSettings : function(settingsModel) {
|
||||||
settingsModel.set(this.enableExport.name, this.enableExport.getValue());
|
|
||||||
settingsModel.set(this.enableSync.name, this.enableSync.getValue());
|
settingsModel.set(this.enableSync.name, this.enableSync.getValue());
|
||||||
settingsModel.set(this.defaultCalendar.name, this.defaultCalendar.getValue());
|
settingsModel.set(this.defaultCalendar.name, this.defaultCalendar.getValue());
|
||||||
settingsModel.set(this.defaultTimezone.name, this.defaultTimezone.getValue());
|
settingsModel.set(this.defaultTimezone.name, this.defaultTimezone.getValue());
|
||||||
|
@ -95,7 +95,7 @@ Zarafa.plugins.calendarimporter.ui.ContextMenu = Ext.extend(Zarafa.hierarchy.ui.
|
|||||||
*/
|
*/
|
||||||
onContextItemExport: function () {
|
onContextItemExport: function () {
|
||||||
var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({
|
var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({
|
||||||
successCallback: this.downloadICS,
|
successCallback: Zarafa.plugins.calendarimporter.data.Actions.downloadICS,
|
||||||
scope : this
|
scope : this
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -116,42 +116,13 @@ Zarafa.plugins.calendarimporter.ui.ContextMenu = Ext.extend(Zarafa.hierarchy.ui.
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
onContextItemImport: function () {
|
onContextItemImport: function () {
|
||||||
var componentType = Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importcontacts'];
|
var componentType = Zarafa.core.data.SharedComponentType['plugins.calendarimporter.dialogs.importevents'];
|
||||||
var config = {
|
var config = {
|
||||||
modal : true,
|
modal : true,
|
||||||
folder: this.records.get("entryid")
|
folder: this.records.get("entryid")
|
||||||
};
|
};
|
||||||
|
|
||||||
Zarafa.core.data.UIFactory.openLayerComponent(componentType, undefined, config);
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -24,9 +24,10 @@
|
|||||||
<clientfile load="debug">js/calendarimporter-debug.js</clientfile>
|
<clientfile load="debug">js/calendarimporter-debug.js</clientfile>
|
||||||
|
|
||||||
<clientfile load="source">js/data/timezones.js</clientfile>
|
<clientfile load="source">js/data/timezones.js</clientfile>
|
||||||
<clientfile load="source">js/external/Ext.util.base64.js</clientfile>
|
<clientfile load="source">js/data/Actions.js</clientfile>
|
||||||
<clientfile load="source">js/plugin.calendarimporter.js</clientfile>
|
|
||||||
<clientfile load="source">js/data/ResponseHandler.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/ImportContentPanel.js</clientfile>
|
||||||
<clientfile load="source">js/dialogs/ImportPanel.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/SettingsWidget.js</clientfile>
|
||||||
@ -35,6 +36,7 @@
|
|||||||
<clientfile load="source">js/dialogs/settings/ui/CalSyncPanel.js</clientfile>
|
<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/CalSyncEditContentPanel.js</clientfile>
|
||||||
<clientfile load="source">js/dialogs/settings/dialogs/CalSyncEditPanel.js</clientfile>
|
<clientfile load="source">js/dialogs/settings/dialogs/CalSyncEditPanel.js</clientfile>
|
||||||
|
<clientfile load="source">js/plugin.calendarimporter.js</clientfile>
|
||||||
</client>
|
</client>
|
||||||
<resources>
|
<resources>
|
||||||
<resourcefile load="release">resources/css/calendarimporter-min.css</resourcefile>
|
<resourcefile load="release">resources/css/calendarimporter-min.css</resourcefile>
|
||||||
|
@ -63,7 +63,7 @@ class CalendarModule extends Module {
|
|||||||
case "import":
|
case "import":
|
||||||
$result = $this->importCalendar($actionType, $actionData);
|
$result = $this->importCalendar($actionType, $actionData);
|
||||||
break;
|
break;
|
||||||
case "attachmentpath":
|
case "importattachment":
|
||||||
$result = $this->getAttachmentPath($actionType, $actionData);
|
$result = $this->getAttachmentPath($actionType, $actionData);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -67,7 +67,6 @@ 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,
|
|
||||||
'enable_sync' => PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE_SYNC,
|
'enable_sync' => PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE_SYNC,
|
||||||
'default_calendar' => PLUGIN_CALENDARIMPORTER_DEFAULT,
|
'default_calendar' => PLUGIN_CALENDARIMPORTER_DEFAULT,
|
||||||
'default_timezone' => PLUGIN_CALENDARIMPORTER_DEFAULT_TIMEZONE
|
'default_timezone' => PLUGIN_CALENDARIMPORTER_DEFAULT_TIMEZONE
|
||||||
|
Loading…
Reference in New Issue
Block a user