From 557ea6b6da4db3e4eac50cf724c33a96f190a691 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Sat, 25 Jun 2016 15:17:19 +0200 Subject: [PATCH] basic import working --- js/dialogs/ImportPanel.js | 6 +++--- php/module.calendar.php | 27 +++++++++++++++++++-------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/js/dialogs/ImportPanel.js b/js/dialogs/ImportPanel.js index 7271717..a4f6684 100644 --- a/js/dialogs/ImportPanel.js +++ b/js/dialogs/ImportPanel.js @@ -285,13 +285,13 @@ Zarafa.plugins.calendarimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, { parsedData[i] = [ eventdata.events[i]["subject"], new Date(parseInt(eventdata.events[i]["startdate"]) * 1000), - new Date(parseInt(eventdata.events[i]["enddate"]) * 1000), + new Date(parseInt(eventdata.events[i]["duedate"]) * 1000), 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]["busystatus"], + eventdata.events[i]["private"], eventdata.events[i]["organizer"], eventdata.events[i]["alarms"], eventdata.events[i]["timezone"], diff --git a/php/module.calendar.php b/php/module.calendar.php index bb7fcac..2e72cff 100644 --- a/php/module.calendar.php +++ b/php/module.calendar.php @@ -406,14 +406,18 @@ class CalendarModule extends Module $propValuesMAPI = array(); $properties = $GLOBALS['properties']->getAppointmentProperties(); + error_log("properties: " . print_r($properties, true)); $count = 0; // iterate through all events and import them :) foreach ($events as $event) { if (isset($event["startdate"]) && ($importall || in_array($event["internal_fields"]["event_uid"], $uids))) { + + error_log("Importing: " . print_r($event, true)); + // parse the arraykeys // TODO: this is very slow... - foreach ($events as $key => $value) { + foreach ($event as $key => $value) { if ($key !== "internal_fields") { if(isset($properties[$key])) { $propValuesMAPI[$properties[$key]] = $value; @@ -421,6 +425,11 @@ class CalendarModule extends Module } } + error_log("MAPI: " . print_r($propValuesMAPI, true)); + + $propValuesMAPI[$properties["commonstart"]] = $propValuesMAPI[$properties["startdate"]]; + $propValuesMAPI[$properties["commonend"]] = $propValuesMAPI[$properties["duedate"]]; + $propValuesMAPI[$properties["message_class"]] = "IPM.Appointment"; $propValuesMAPI[$properties["icon_index"]] = "1024"; $message = mapi_folder_createmessage($folder); @@ -429,7 +438,7 @@ class CalendarModule extends Module mapi_setprops($message, $propValuesMAPI); mapi_savechanges($message); if ($this->DEBUG) { - error_log("New event added: \"" . $propValuesMAPI[$properties["startdate"]] . "\".\n"); + error_log("New event added: \"" . $event["startdate"] . "\".\n"); } $count++; } @@ -663,21 +672,23 @@ class CalendarModule extends Module $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["duedate"] = (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["busystatus"] = array_search((string)$vEvent->{'X-MICROSOFT-CDO-INTENDEDSTATUS'}, $this->busystates); // 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; + $properties["private"] = ((string)$vEvent->CLASS) == "PRIVATE" ? true : false; + if(!empty((string)$vEvent->{'X-ZARAFA-LABEL'})) { + $properties["label"] = array_search((string)$vEvent->{'X-ZARAFA-LABEL'}, $this->labels); + } + $properties["last_modification_time"] = (string)$vEvent->{'LAST-MODIFIED'}->getDateTime()->getTimestamp(); + $properties["creation_time"] = (string)$vEvent->CREATED->getDateTime()->getTimestamp(); $properties["rrule"] = (string)$vEvent->RRULE; // Attendees