2012-11-12 23:57:50 +01:00
|
|
|
Ext.namespace("Zarafa.plugins.calendarimporter.dialogs");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @class Zarafa.plugins.calendarimporter.dialogs.ImportPanel
|
|
|
|
* @extends Ext.form.FormPanel
|
|
|
|
*/
|
2012-12-08 01:53:21 +01:00
|
|
|
Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
2012-11-12 23:57:50 +01:00
|
|
|
|
2012-11-13 21:25:52 +01:00
|
|
|
/* store the imported timezone here... */
|
|
|
|
timezone: null,
|
2012-11-17 12:42:48 +01:00
|
|
|
|
2012-11-12 23:57:50 +01:00
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
* @param {object} config
|
|
|
|
*/
|
2012-12-05 22:31:10 +01:00
|
|
|
constructor : function (config)
|
2012-11-12 23:57:50 +01:00
|
|
|
{
|
|
|
|
config = config || {};
|
|
|
|
var self = this;
|
|
|
|
Ext.apply(config, {
|
|
|
|
xtype : 'calendarimporter.importpanel',
|
|
|
|
layout : {
|
|
|
|
type : 'form',
|
|
|
|
align : 'stretch'
|
|
|
|
},
|
|
|
|
anchor : '100%',
|
|
|
|
bodyStyle : 'background-color: inherit;',
|
|
|
|
defaults : {
|
|
|
|
border : true,
|
|
|
|
bodyStyle : 'background-color: inherit; padding: 3px 0px 3px 0px; border-style: none none solid none;'
|
|
|
|
},
|
|
|
|
items : [
|
|
|
|
this.createSelectBox(),
|
|
|
|
this.initForm()
|
|
|
|
],
|
|
|
|
buttons: [
|
2012-12-05 22:31:10 +01:00
|
|
|
this.createExportAllButton(),
|
2012-11-17 12:42:48 +01:00
|
|
|
this.createSubmitAllButton(),
|
|
|
|
this.createSubmitButton(),
|
2012-11-12 23:57:50 +01:00
|
|
|
this.createCancelButton()
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
Zarafa.plugins.calendarimporter.dialogs.ImportPanel.superclass.constructor.call(this, config);
|
|
|
|
},
|
2012-11-17 12:42:48 +01:00
|
|
|
|
2012-11-12 23:57:50 +01:00
|
|
|
/**
|
|
|
|
* Init embedded form, this is the form that is
|
|
|
|
* posted and contains the attachments
|
|
|
|
* @private
|
|
|
|
*/
|
2012-12-05 22:31:10 +01:00
|
|
|
initForm : function ()
|
2012-11-12 23:57:50 +01:00
|
|
|
{
|
|
|
|
return {
|
|
|
|
xtype: 'form',
|
|
|
|
ref: 'addFormPanel',
|
|
|
|
layout : 'column',
|
|
|
|
fileUpload: true,
|
|
|
|
autoWidth: true,
|
|
|
|
autoHeight: true,
|
|
|
|
border: false,
|
|
|
|
bodyStyle: 'padding: 5px;',
|
|
|
|
defaults: {
|
|
|
|
anchor: '95%',
|
|
|
|
border: false,
|
|
|
|
bodyStyle: 'padding: 5px;'
|
|
|
|
},
|
|
|
|
items: [this.createUploadField()]
|
|
|
|
};
|
|
|
|
},
|
2012-11-17 12:42:48 +01:00
|
|
|
|
2012-11-12 23:57:50 +01:00
|
|
|
/**
|
|
|
|
* Init embedded form, this is the form that is
|
|
|
|
* posted and contains the attachments
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
createGrid : function(eventdata) {
|
2012-11-17 12:42:48 +01:00
|
|
|
|
2012-12-05 22:31:10 +01:00
|
|
|
var parsedData = [];
|
|
|
|
if(eventdata !== null) {
|
2012-11-12 23:57:50 +01:00
|
|
|
var parsedData = new Array(eventdata.events.length);
|
|
|
|
|
|
|
|
for(var i=0; i < eventdata.events.length; i++) {
|
2012-11-17 12:42:48 +01:00
|
|
|
parsedData[i] = new Array(eventdata.events[i]["SUMMARY"], new Date(parseInt(eventdata.events[i]["DTSTART"])), new Date(parseInt(eventdata.events[i]["DTEND"])), eventdata.events[i]["LOCATION"], eventdata.events[i]["DESCRIPTION"]);
|
2012-11-12 23:57:50 +01:00
|
|
|
}
|
|
|
|
}
|
2012-11-17 12:42:48 +01:00
|
|
|
|
2012-11-12 23:57:50 +01:00
|
|
|
// create the data store
|
|
|
|
var store = new Ext.data.ArrayStore({
|
|
|
|
fields: [
|
|
|
|
{name: 'title'},
|
|
|
|
{name: 'start'},
|
|
|
|
{name: 'end'},
|
|
|
|
{name: 'location'},
|
|
|
|
{name: 'description'}
|
|
|
|
],
|
|
|
|
data: parsedData
|
|
|
|
});
|
2012-11-17 12:42:48 +01:00
|
|
|
|
|
|
|
return {
|
2012-11-12 23:57:50 +01:00
|
|
|
xtype: 'grid',
|
|
|
|
ref: 'eventgrid',
|
|
|
|
id: 'eventgrid',
|
|
|
|
columnWidth: 1.0,
|
|
|
|
store: store,
|
|
|
|
width: '100%',
|
|
|
|
height: 300,
|
|
|
|
title: 'Select events to import',
|
|
|
|
frame: true,
|
|
|
|
colModel: new Ext.grid.ColumnModel({
|
|
|
|
defaults: {
|
|
|
|
width: 300,
|
|
|
|
sortable: true
|
|
|
|
},
|
|
|
|
columns: [
|
2012-11-13 21:25:52 +01:00
|
|
|
{id: 'Summary', header: 'Title', width: 300, sortable: true, dataIndex: 'title'},
|
|
|
|
{header: 'Start', width: 150, sortable: true, dataIndex: 'start'},
|
|
|
|
{header: 'End', width: 150, sortable: true, dataIndex: 'end'},
|
|
|
|
{header: 'Location', width: 150, sortable: true, dataIndex: 'location'},
|
|
|
|
{header: 'Description', width: 150, sortable: true, dataIndex: 'description'}
|
2012-11-12 23:57:50 +01:00
|
|
|
]
|
|
|
|
}),
|
|
|
|
sm: new Ext.grid.RowSelectionModel({multiSelect:true})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
createSelectBox: function() {
|
|
|
|
ctx = container.getContextByName('calendar');
|
2012-11-17 12:42:48 +01:00
|
|
|
model = ctx.getModel();
|
|
|
|
defaultFolder = model.getDefaultFolder(); // @type: Zarafa.hierarchy.data.MAPIFolderRecord
|
|
|
|
subFolders = defaultFolder.getChildren();
|
2012-11-12 23:57:50 +01:00
|
|
|
|
2012-11-17 12:42:48 +01:00
|
|
|
var myStore = new Ext.data.ArrayStore({
|
|
|
|
fields: ['calendar_id', 'calendar_displayname'],
|
|
|
|
idIndex: 0 // id for each record will be the first element
|
|
|
|
});
|
|
|
|
|
|
|
|
/* Calendar Record holds the name and real name of the calender */
|
2012-11-12 23:57:50 +01:00
|
|
|
var CalendarRecord = Ext.data.Record.create([
|
|
|
|
{name: 'realname', type: "string"},
|
|
|
|
{name: 'displayname', type: "string"}
|
|
|
|
]);
|
|
|
|
|
|
|
|
/* Store the default folder */
|
|
|
|
var myNewRecord = new CalendarRecord({
|
|
|
|
realname: defaultFolder.getDefaultFolderKey(),
|
2012-11-17 12:42:48 +01:00
|
|
|
displayname: defaultFolder.getDisplayName()
|
2012-11-12 23:57:50 +01:00
|
|
|
});
|
|
|
|
myStore.add(myNewRecord);
|
2012-11-17 12:42:48 +01:00
|
|
|
|
|
|
|
for(i=0;i<subFolders.length;i++) {
|
2012-11-12 23:57:50 +01:00
|
|
|
/* Store all subfolders */
|
|
|
|
myNewRecord = new CalendarRecord({
|
|
|
|
realname: subFolders[i].getDisplayName(), // TODO: get the real path...
|
|
|
|
displayname: subFolders[i].getDisplayName()
|
|
|
|
});
|
|
|
|
myStore.add(myNewRecord);
|
2012-11-17 12:42:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* commit the changes to the store */
|
|
|
|
myStore.commitChanges();
|
|
|
|
|
2012-11-12 23:57:50 +01:00
|
|
|
return {
|
2012-11-17 12:42:48 +01:00
|
|
|
xtype: "selectbox",
|
|
|
|
ref: 'calendarselector',
|
|
|
|
id: 'calendarselector',
|
|
|
|
editable: false,
|
|
|
|
name: "choosen_calendar",
|
|
|
|
width: 100,
|
|
|
|
fieldLabel: "Select a calender",
|
|
|
|
store: myStore,
|
|
|
|
valueField: 'realname',
|
|
|
|
displayField: 'displayname',
|
|
|
|
labelSeperator: ":",
|
|
|
|
border: false,
|
|
|
|
anchor: "100%",
|
|
|
|
scope: this,
|
|
|
|
allowBlank: false
|
|
|
|
}
|
2012-11-12 23:57:50 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
createUploadField: function() {
|
|
|
|
return {
|
2012-11-17 12:42:48 +01:00
|
|
|
xtype: "fileuploadfield",
|
2012-11-12 23:57:50 +01:00
|
|
|
ref: 'fileuploadfield',
|
|
|
|
columnWidth: 1.0,
|
|
|
|
id: 'form-file',
|
|
|
|
name: 'icsdata',
|
2012-11-17 12:42:48 +01:00
|
|
|
emptyText: 'Select an .ics calendar',
|
|
|
|
border: false,
|
|
|
|
anchor: "100%",
|
|
|
|
scope: this,
|
|
|
|
allowBlank: false,
|
2012-11-12 23:57:50 +01:00
|
|
|
listeners: {
|
|
|
|
'fileselected': this.onFileSelected,
|
|
|
|
scope: this
|
|
|
|
}
|
2012-11-17 12:42:48 +01:00
|
|
|
}
|
2012-11-12 23:57:50 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
createSubmitButton: function() {
|
|
|
|
return {
|
2012-11-17 12:42:48 +01:00
|
|
|
xtype: "button",
|
2012-11-12 23:57:50 +01:00
|
|
|
ref: "submitButton",
|
|
|
|
id: "submitButton",
|
|
|
|
disabled: true,
|
2012-11-17 12:42:48 +01:00
|
|
|
width: 100,
|
|
|
|
border: false,
|
|
|
|
text: _("Import"),
|
|
|
|
anchor: "100%",
|
|
|
|
handler: this.importCheckedEvents,
|
|
|
|
scope: this,
|
|
|
|
allowBlank: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
createSubmitAllButton: function() {
|
|
|
|
return {
|
|
|
|
xtype: "button",
|
|
|
|
ref: "submitAllButton",
|
|
|
|
id: "submitAllButton",
|
|
|
|
disabled: true,
|
|
|
|
width: 100,
|
|
|
|
border: false,
|
|
|
|
text: _("Import All"),
|
|
|
|
anchor: "100%",
|
|
|
|
handler: this.importAllEvents,
|
|
|
|
scope: this,
|
|
|
|
allowBlank: false
|
|
|
|
}
|
2012-11-12 23:57:50 +01:00
|
|
|
},
|
|
|
|
|
2012-12-05 22:31:10 +01:00
|
|
|
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
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-11-12 23:57:50 +01:00
|
|
|
createCancelButton: function() {
|
|
|
|
return {
|
2012-11-17 12:42:48 +01:00
|
|
|
xtype: "button",
|
|
|
|
width: 100,
|
|
|
|
border: false,
|
|
|
|
text: _("Cancel"),
|
|
|
|
anchor: "100%",
|
|
|
|
handler: this.close,
|
|
|
|
scope: this,
|
|
|
|
allowBlank: false
|
|
|
|
}
|
2012-11-12 23:57:50 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is called when a file has been seleceted in the file dialog
|
|
|
|
* in the {@link Ext.ux.form.FileUploadField} and the dialog is closed
|
|
|
|
* @param {Ext.ux.form.FileUploadField} uploadField being added a file to
|
|
|
|
*/
|
2012-11-17 12:42:48 +01:00
|
|
|
onFileSelected : function(uploadField) {
|
2012-11-12 23:57:50 +01:00
|
|
|
var form = this.addFormPanel.getForm();
|
|
|
|
|
|
|
|
if (form.isValid()) {
|
|
|
|
form.submit({
|
|
|
|
waitMsg: 'Uploading and parsing calendar...',
|
|
|
|
url: 'plugins/calendarimporter/php/upload.php',
|
|
|
|
failure: function(file, action) {
|
2012-11-17 12:42:48 +01:00
|
|
|
Ext.getCmp('submitButton').disable();
|
|
|
|
Ext.getCmp('submitAllButton').disable();
|
2012-11-12 23:57:50 +01:00
|
|
|
Ext.MessageBox.show({
|
|
|
|
title : _('Error'),
|
|
|
|
msg : _(action.result.errors[action.result.errors.type]),
|
|
|
|
icon : Ext.MessageBox.ERROR,
|
|
|
|
buttons : Ext.MessageBox.OK
|
|
|
|
});
|
|
|
|
},
|
|
|
|
success: function(file, action){
|
|
|
|
uploadField.reset();
|
|
|
|
Ext.getCmp('submitButton').enable();
|
2012-11-17 12:42:48 +01:00
|
|
|
Ext.getCmp('submitAllButton').enable();
|
2012-11-13 21:25:52 +01:00
|
|
|
this.timezone = action.result.response.calendar["X-WR-TIMEZONE"];
|
2012-11-12 23:57:50 +01:00
|
|
|
this.insert(this.items.length,this.createGrid(action.result.response));
|
|
|
|
this.doLayout();
|
|
|
|
},
|
|
|
|
scope : this
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2012-11-17 12:42:48 +01:00
|
|
|
|
2012-11-12 23:57:50 +01:00
|
|
|
close: function () {
|
|
|
|
this.addFormPanel.getForm().reset();
|
|
|
|
this.dialog.close()
|
|
|
|
},
|
2012-11-17 12:42:48 +01:00
|
|
|
|
2012-11-12 23:57:50 +01:00
|
|
|
convertToAppointmentRecord: function (calendarFolder,entry) {
|
|
|
|
var newRecord = Zarafa.core.data.RecordFactory.createRecordObjectByMessageClass('IPM.Appointment', {
|
|
|
|
startdate: new Date(entry.start),
|
|
|
|
duedate: (entry.end) ?
|
|
|
|
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) ?
|
|
|
|
new Date(entry.end) :
|
|
|
|
new Date(entry.start).add(Date.HOUR, 1),
|
2012-11-13 21:25:52 +01:00
|
|
|
timezone: this.timezone,
|
2012-11-12 23:57:50 +01:00
|
|
|
parent_entryid: calendarFolder.get('entryid'),
|
|
|
|
store_entryid: calendarFolder.get('store_entryid')
|
|
|
|
});
|
|
|
|
return newRecord;
|
|
|
|
},
|
2012-11-17 12:42:48 +01:00
|
|
|
|
|
|
|
importAllEvents: function () {
|
2012-11-12 23:57:50 +01:00
|
|
|
//receive existing calendar store
|
2012-11-17 12:42:48 +01:00
|
|
|
var selIndex = this.calendarselector.selectedIndex;
|
|
|
|
var calValue = this.calendarselector.value;
|
|
|
|
|
|
|
|
if(selIndex == -1) { // 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 calendarStore = new Zarafa.calendar.AppointmentStore();
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//receive Records from grid rows
|
|
|
|
this.eventgrid.selModel.selectAll(); // select all entries
|
|
|
|
var newRecords = this.eventgrid.selModel.getSelections();
|
|
|
|
Ext.each(newRecords, function(newRecord) {
|
|
|
|
var record = this.convertToAppointmentRecord(calendarFolder,newRecord.data);
|
|
|
|
calendarStore.add(record);
|
|
|
|
}, this);
|
|
|
|
calendarStore.save();
|
|
|
|
this.dialog.close();
|
|
|
|
}
|
|
|
|
},
|
2012-12-05 22:31:10 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
});
|
2012-12-08 01:53:21 +01:00
|
|
|
} else {
|
2012-12-05 22:31:10 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-12-08 01:53:21 +01:00
|
|
|
|
|
|
|
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();
|
2012-12-05 22:31:10 +01:00
|
|
|
|
|
|
|
// call export function here!
|
|
|
|
var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({
|
|
|
|
successCallback: this.exportDone.createDelegate(this)
|
|
|
|
});
|
|
|
|
|
|
|
|
container.getRequest().singleRequest(
|
2012-12-07 00:10:23 +01:00
|
|
|
'appointmentlistmodule',
|
|
|
|
'list',
|
2012-12-05 22:31:10 +01:00
|
|
|
{
|
2012-12-07 00:10:23 +01:00
|
|
|
groupDir: "ASC",
|
|
|
|
restriction: {
|
|
|
|
startdate: 0,
|
|
|
|
duedate: 2145826800 // 2037... highest unix timestamp
|
|
|
|
},
|
|
|
|
sort: [{
|
|
|
|
"field": "startdate",
|
|
|
|
"direction": "DESC"
|
|
|
|
}],
|
2012-12-05 22:31:10 +01:00
|
|
|
store_entryid : calendarFolder.data.store_entryid,
|
|
|
|
entryid : calendarFolder.data.entryid
|
|
|
|
},
|
|
|
|
responseHandler
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Export done =)
|
|
|
|
* @param {Object} response
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
exportDone : function(response)
|
|
|
|
{
|
2012-12-07 00:10:23 +01:00
|
|
|
if(response.item.length > 0) {
|
|
|
|
// call export function here!
|
|
|
|
var responseHandler = new Zarafa.plugins.calendarimporter.data.ResponseHandler({
|
|
|
|
successCallback: this.downLoadICS.createDelegate(this)
|
|
|
|
});
|
|
|
|
|
|
|
|
container.getRequest().singleRequest(
|
|
|
|
'calendarexportermodule',
|
|
|
|
'export',
|
|
|
|
{
|
|
|
|
data: response,
|
|
|
|
calendar: this.calendarselector.value
|
|
|
|
},
|
|
|
|
responseHandler
|
|
|
|
);
|
2012-12-08 01:53:21 +01:00
|
|
|
container.getNotifier().notify('info', 'Exported', 'Found ' + response.item.length + ' entries to export.');
|
2012-12-05 22:31:10 +01:00
|
|
|
} else {
|
2012-12-07 00:10:23 +01:00
|
|
|
container.getNotifier().notify('info', 'Export Failed', 'There were no items to export!');
|
2012-12-08 01:53:21 +01:00
|
|
|
Zarafa.common.dialogs.MessageBox.hide();
|
2012-12-05 22:31:10 +01:00
|
|
|
}
|
|
|
|
this.dialog.close();
|
|
|
|
},
|
2012-12-07 00:10:23 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* download ics file =)
|
|
|
|
* @param {Object} response
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
downLoadICS : function(response)
|
|
|
|
{
|
2012-12-08 01:53:21 +01:00
|
|
|
Zarafa.common.dialogs.MessageBox.hide();
|
|
|
|
if(response.status === true) {
|
|
|
|
// needs to be window.open, document.location.href kills the extjs response handler...
|
|
|
|
window.open('plugins/calendarimporter/php/download.php?fileid='+response.fileid+'&basedir='+response.basedir+'&secid='+response.secid+'&realname='+response.realname,"Download");
|
2012-12-07 00:10:23 +01:00
|
|
|
} else {
|
|
|
|
container.getNotifier().notify('error', 'Export Failed', 'ICal File creation failed!');
|
2012-12-08 01:53:21 +01:00
|
|
|
}
|
2012-12-07 00:10:23 +01:00
|
|
|
},
|
2012-11-17 12:42:48 +01:00
|
|
|
|
|
|
|
importCheckedEvents: function () {
|
|
|
|
//receive existing calendar store
|
|
|
|
var selIndex = this.calendarselector.selectedIndex;
|
|
|
|
var calValue = this.calendarselector.value;
|
|
|
|
|
|
|
|
if(selIndex == -1) { // no calendar choosen
|
|
|
|
Ext.MessageBox.show({
|
|
|
|
title : _('Error'),
|
|
|
|
msg : _('You have to choose a calendar!'),
|
|
|
|
icon : Ext.MessageBox.ERROR,
|
|
|
|
buttons : Ext.MessageBox.OK
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
if(this.eventgrid.selModel.getCount() < 1) {
|
|
|
|
Ext.MessageBox.show({
|
|
|
|
title : _('Error'),
|
|
|
|
msg : _('You have to choose at least one event to import!'),
|
|
|
|
icon : Ext.MessageBox.ERROR,
|
|
|
|
buttons : Ext.MessageBox.OK
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
var calendarStore = new Zarafa.calendar.AppointmentStore();
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//receive Records from grid rows
|
|
|
|
var newRecords = this.eventgrid.selModel.getSelections();
|
|
|
|
Ext.each(newRecords, function(newRecord) {
|
|
|
|
var record = this.convertToAppointmentRecord(calendarFolder,newRecord.data);
|
|
|
|
calendarStore.add(record);
|
|
|
|
}, this);
|
|
|
|
calendarStore.save();
|
|
|
|
this.dialog.close();
|
|
|
|
}
|
|
|
|
}
|
2012-11-12 23:57:50 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Ext.reg('calendarimporter.importpanel', Zarafa.plugins.calendarimporter.dialogs.ImportPanel);
|