switched to sabre / vobject library
This commit is contained in:
parent
2c18071de4
commit
2606bf75b1
@ -52,7 +52,7 @@ Zarafa.plugins.calendarimporter.data.ResponseHandler = Ext.extend(Zarafa.core.da
|
||||
* Call the successCallback callback function.
|
||||
* @param {Object} response Object contained the response data.
|
||||
*/
|
||||
doList: function (response) {
|
||||
doLoad: function (response) {
|
||||
this.successCallback(response);
|
||||
},
|
||||
|
||||
|
@ -77,17 +77,19 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
||||
// create the data store
|
||||
this.store = new Ext.data.ArrayStore({
|
||||
fields: [
|
||||
{name: 'title'},
|
||||
{name: 'start'},
|
||||
{name: 'end'},
|
||||
{name: 'subject'},
|
||||
{name: 'startdate'},
|
||||
{name: 'enddate'},
|
||||
{name: 'location'},
|
||||
{name: 'description'},
|
||||
{name: 'body'},
|
||||
{name: 'priority'},
|
||||
{name: 'label'},
|
||||
{name: 'busy'},
|
||||
{name: 'privatestate'},
|
||||
{name: 'class'},
|
||||
{name: 'organizer'},
|
||||
{name: 'trigger'}
|
||||
{name: 'alarms'},
|
||||
{name: 'timezone'},
|
||||
{name: 'record'}
|
||||
]
|
||||
});
|
||||
|
||||
@ -285,13 +287,21 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
||||
parsedData = new Array(eventdata.events.length);
|
||||
var i = 0;
|
||||
for(i = 0; i < eventdata.events.length; i++) {
|
||||
var trigger = null;
|
||||
|
||||
if(eventdata.events[i]["VALARM"]) {
|
||||
trigger = eventdata.events[i]["VALARM"]["TRIGGER"];
|
||||
trigger = new Date(parseInt(trigger) + local_tz_offset);
|
||||
}
|
||||
parsedData[i] = new Array(eventdata.events[i]["SUMMARY"], new Date(parseInt(eventdata.events[i]["DTSTART"]) + local_tz_offset), new Date(parseInt(eventdata.events[i]["DTEND"]) + local_tz_offset), eventdata.events[i]["LOCATION"], eventdata.events[i]["DESCRIPTION"],eventdata.events[i]["PRIORITY"],eventdata.events[i]["X-ZARAFA-LABEL"],eventdata.events[i]["X-MICROSOFT-CDO-BUSYSTATUS"],eventdata.events[i]["CLASS"],eventdata.events[i]["ORGANIZER"],trigger);
|
||||
parsedData[i] = [
|
||||
eventdata.events[i]["subject"],
|
||||
new Date(parseInt(eventdata.events[i]["startdate"]) * 1000 + local_tz_offset),
|
||||
new Date(parseInt(eventdata.events[i]["enddate"]) * 1000 + local_tz_offset),
|
||||
eventdata.events[i]["location"],
|
||||
eventdata.events[i]["body"],
|
||||
eventdata.events[i]["priority"],
|
||||
eventdata.events[i]["label"],
|
||||
eventdata.events[i]["busy"],
|
||||
eventdata.events[i]["class"],
|
||||
eventdata.events[i]["organizer"],
|
||||
eventdata.events[i]["alarms"],
|
||||
eventdata.events[i]["timezone"],
|
||||
eventdata.events[i]
|
||||
];
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
@ -325,17 +335,18 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
||||
sortable: true
|
||||
},
|
||||
columns: [
|
||||
{id: 'Summary', header: 'Title', width: 200, sortable: true, dataIndex: 'title'},
|
||||
{header: 'Start', width: 200, sortable: true, dataIndex: 'start', renderer : Zarafa.common.ui.grid.Renderers.datetime},
|
||||
{header: 'End', width: 200, sortable: true, dataIndex: 'end', renderer : Zarafa.common.ui.grid.Renderers.datetime},
|
||||
{id: 'Summary', header: 'Title', width: 200, sortable: true, dataIndex: 'subject'},
|
||||
{header: 'Start', width: 200, sortable: true, dataIndex: 'startdate', renderer : Zarafa.common.ui.grid.Renderers.datetime},
|
||||
{header: 'End', width: 200, sortable: true, dataIndex: 'enddate', renderer : Zarafa.common.ui.grid.Renderers.datetime},
|
||||
{header: 'Location', width: 150, sortable: true, dataIndex: 'location'},
|
||||
{header: 'Description', sortable: true, dataIndex: 'description'},
|
||||
{header: 'Description', sortable: true, dataIndex: 'body'},
|
||||
{header: "Priority", dataIndex: 'priority', hidden: true},
|
||||
{header: "Label", dataIndex: 'label', hidden: true},
|
||||
{header: "Busystatus", dataIndex: 'busy', hidden: true},
|
||||
{header: "Privacystatus", dataIndex: 'privatestate', hidden: true},
|
||||
{header: "Privacystatus", dataIndex: 'class', hidden: true},
|
||||
{header: "Organizer", dataIndex: 'organizer', hidden: true},
|
||||
{header: "Alarm", dataIndex: 'trigger', hidden: true, renderer : Zarafa.common.ui.grid.Renderers.datetime}
|
||||
{header: "Alarm", dataIndex: 'alarms', hidden: true, renderer : Zarafa.common.ui.grid.Renderers.datetime},
|
||||
{header: "Timezone", dataIndex: 'timezone', hidden: true}
|
||||
]
|
||||
}),
|
||||
sm: new Ext.grid.RowSelectionModel({multiSelect:true})
|
||||
@ -430,7 +441,7 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
||||
createSubmitButton: function() {
|
||||
return {
|
||||
xtype: "button",
|
||||
ref: "submitButton",
|
||||
ref: "../submitButton",
|
||||
disabled: true,
|
||||
width: 100,
|
||||
border: false,
|
||||
@ -444,7 +455,7 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
||||
createSubmitAllButton: function() {
|
||||
return {
|
||||
xtype: "button",
|
||||
ref: "submitAllButton",
|
||||
ref: "../submitAllButton",
|
||||
disabled: true,
|
||||
width: 100,
|
||||
border: false,
|
||||
@ -548,20 +559,22 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
||||
},
|
||||
|
||||
handleParsingResult: function(response) {
|
||||
this.loadMask.hide();
|
||||
var self = this.scope;
|
||||
|
||||
self.loadMask.hide();
|
||||
|
||||
if(response["status"] == true) {
|
||||
this.submitButton.enable();
|
||||
this.submitAllButton.enable();
|
||||
self.submitButton.enable();
|
||||
self.submitAllButton.enable();
|
||||
|
||||
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));
|
||||
self.timezone = response.parsed.calendar["X-WR-TIMEZONE"];
|
||||
self.timezoneselector.setValue(Zarafa.plugins.calendarimporter.data.Timezones.unMap(this.timezone));
|
||||
}
|
||||
this.reloadGridStore(response.parsed);
|
||||
self.reloadGridStore(response.parsed);
|
||||
} else {
|
||||
this.submitButton.disable();
|
||||
this.submitAllButton.disable();
|
||||
self.submitButton.disable();
|
||||
self.submitAllButton.disable();
|
||||
Zarafa.common.dialogs.MessageBox.show({
|
||||
title : _('Parser Error'),
|
||||
msg : _(response["message"]),
|
||||
|
@ -20,7 +20,7 @@
|
||||
<serverfile type="module" module="calendarmodule">php/module.calendar.php</serverfile>
|
||||
</server>
|
||||
<client>
|
||||
<clientfile load="release">js/calendarimporter.js</clientfile>
|
||||
<clientfile load="release">js/calendarimporter-debug.js</clientfile>
|
||||
<clientfile load="debug">js/calendarimporter-debug.js</clientfile>
|
||||
|
||||
<clientfile load="source">js/data/timezones.js</clientfile>
|
||||
@ -39,7 +39,7 @@
|
||||
<clientfile load="source">js/plugin.calendarimporter.js</clientfile>
|
||||
</client>
|
||||
<resources>
|
||||
<resourcefile load="release">resources/css/calendarimporter-min.css</resourcefile>
|
||||
<resourcefile load="release">resources/css/calendarimporter.css</resourcefile>
|
||||
<resourcefile load="debug">resources/css/calendarimporter.css</resourcefile>
|
||||
<resourcefile load="source">resources/css/calendarimporter-main.css</resourcefile>
|
||||
</resources>
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"require": {
|
||||
"kigkonsult/icalcreator": "dev-master"
|
||||
"sabre/vobject": "4.1"
|
||||
}
|
||||
}
|
@ -23,6 +23,8 @@
|
||||
|
||||
include_once('vendor/autoload.php');
|
||||
|
||||
use Sabre\VObject;
|
||||
|
||||
class CalendarModule extends Module
|
||||
{
|
||||
|
||||
@ -585,13 +587,10 @@ class CalendarModule extends Module
|
||||
$parser = null;
|
||||
|
||||
try {
|
||||
$parser = new vcalendar([
|
||||
"unique_id" => md5($actionData["ics_filepath"]),
|
||||
"directory" => dirname($actionData["ics_filepath"]),
|
||||
"filename" => basename($actionData["ics_filepath"])
|
||||
]);
|
||||
$parser->parse();
|
||||
error_log(print_r($parser, true));
|
||||
$parser = VObject\Reader::read(
|
||||
fopen($actionData["ics_filepath"],'r')
|
||||
);
|
||||
error_log(print_r($parser->VTIMEZONE, true));
|
||||
} catch (Exception $e) {
|
||||
$error = true;
|
||||
$error_msg = $e->getMessage();
|
||||
@ -600,14 +599,16 @@ class CalendarModule extends Module
|
||||
$response['status'] = false;
|
||||
$response['message'] = $error_msg;
|
||||
} else {
|
||||
if (count($parser->components) == 0) {
|
||||
if (count($parser->VEVENT) == 0) {
|
||||
$response['status'] = false;
|
||||
$response['message'] = "No event in ics file";
|
||||
} else {
|
||||
$response['status'] = true;
|
||||
$response['parsed_file'] = $actionData["ics_filepath"];
|
||||
$response['parsed'] = array(
|
||||
'contacts' => $this->parseCalendarToArray($parser)
|
||||
'events' => $this->parseCalendarToArray($parser),
|
||||
'timezone' => $parser->VTIMEZONE->TZID,
|
||||
'calendar' => $parser
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -627,13 +628,42 @@ class CalendarModule extends Module
|
||||
/**
|
||||
* Create a array with contacts
|
||||
*
|
||||
* @param calendar ics parser object
|
||||
* @param {VObject} $calendar ics parser object
|
||||
* @return array parsed events
|
||||
* @private
|
||||
*/
|
||||
private function parseCalendarToArray($calendar)
|
||||
{
|
||||
return false;
|
||||
$events = array();
|
||||
foreach ($calendar->VEVENT as $Index => $vEvent) {
|
||||
// Sabre\VObject\Parser\XML\Element\VEvent
|
||||
$properties = array();
|
||||
|
||||
//uid - used for front/backend communication
|
||||
$properties["internal_fields"] = array();
|
||||
$properties["internal_fields"]["event_uid"] = base64_encode($Index . $vEvent->UID);
|
||||
|
||||
$properties["startdate"] = (string)$vEvent->DTSTART->getDateTime()->getTimestamp();
|
||||
$properties["enddate"] = (string)$vEvent->DTEND->getDateTime()->getTimestamp();
|
||||
$properties["location"] = (string)$vEvent->LOCATION;
|
||||
$properties["subject"] = (string)$vEvent->SUMMARY;
|
||||
$properties["body"] = (string)$vEvent->DESCRIPTION;
|
||||
$properties["comment"] = (string)$vEvent->COMMENT;
|
||||
$properties["timezone"] = (string)$vEvent->DTSTART["TZID"];
|
||||
$properties["organizer"] = (string)$vEvent->ORGANIZER;
|
||||
$properties["busy"] = (string)$vEvent->{'X-MICROSOFT-CDO-INTENDEDSTATUS'}; // X-MICROSOFT-CDO-BUSYSTATUS
|
||||
$properties["transp"] = (string)$vEvent->TRANSP;
|
||||
//$properties["trigger"] = (string)$vEvent->COMMENT;
|
||||
$properties["priority"] = (string)$vEvent->PRIORITY;
|
||||
$properties["class"] = (string)$vEvent->CLASS;
|
||||
$properties["label"] = (string)$vEvent->COMMENT;
|
||||
$properties["lastmodified"] = (string)$vEvent->{'LAST-MODIFIED'};
|
||||
$properties["created"] = (string)$vEvent->CREATED;
|
||||
|
||||
array_push($events, $properties);
|
||||
}
|
||||
|
||||
return $events;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,5 +2,29 @@
|
||||
background: url(../images/import_icon.png) no-repeat !important;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-size: 18px!important;
|
||||
}
|
||||
|
||||
.icon_calendarimporter_export {
|
||||
background: url(../images/download.png) no-repeat;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
}
|
||||
|
||||
.icon_calendarimporter_import {
|
||||
background: url(../images/upload.png) no-repeat;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
}
|
||||
|
||||
.zarafa-caiplg-container {
|
||||
width: 100%;
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
.zarafa-caiplg-button .x-btn-small {
|
||||
width: 80%;
|
||||
height: 30px;
|
||||
margin-left: 10%;
|
||||
margin-right: 10%;
|
||||
margin-top: 10px;
|
||||
}
|
BIN
resources/images/download.png
Executable file
BIN
resources/images/download.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 224 B |
BIN
resources/images/download.xcf
Executable file
BIN
resources/images/download.xcf
Executable file
Binary file not shown.
BIN
resources/images/upload.png
Normal file
BIN
resources/images/upload.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 213 B |
BIN
resources/images/upload.xcf
Executable file
BIN
resources/images/upload.xcf
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user