From 2a8a8f75f11de7bb47cd1512943c6307c96a6f15 Mon Sep 17 00:00:00 2001 From: Michael J Rubinsky Date: Wed, 31 Aug 2016 11:54:25 -0400 Subject: [PATCH] Allow returning a hash from import(). Needed since attachment addition/deletions are handled by the message objects in activesync, instead of by a folder command as the rest of addition/deletions are. Clients need to be able to map their clientId with the returned server UID. Will also allow us to return the syncstamp when the rest of the API is refactored to allow this. --- kronolith/lib/Api.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/kronolith/lib/Api.php b/kronolith/lib/Api.php index 1cc6e8e0bef..e1c455f9607 100644 --- a/kronolith/lib/Api.php +++ b/kronolith/lib/Api.php @@ -784,11 +784,14 @@ public function getHighestModSeq($id = null) * activesync * * @param string $calendar What calendar should the event be added to? + * @param boolean $hash If true, return a hash for EAS additions. + * @since 4.3.0 @todo Remove for 5.0 and make + * this the normal return. * * @return array The event's UID. * @throws Kronolith_Exception */ - public function import($content, $contentType, $calendar = null) + public function import($content, $contentType, $calendar = null, $hash = false) { if (!isset($calendar)) { $calendar = Kronolith::getDefaultCalendar(Horde_Perms::EDIT); @@ -818,7 +821,21 @@ public function import($content, $contentType, $calendar = null) $event = $kronolith_driver->getEvent(); $event->fromASAppointment($content); $event->save(); - return $event->uid; + // Handle attachment data after we commit changes since we + // are required to have a saved event to attach files. Also, + // we can only handle files if we are returning a hash since EAS + // needs the information returned to attach filereferences to + // the attachments. + if (!$hash) { + return $event->uid; + } + $atc_hash = $event->addEASFiles($content); + return array( + 'uid' => $event->uid, + 'atchash' => $atc_hash, + // See Bug #12567 + //'syncstamp' => $stamp + ); } throw new Kronolith_Exception(sprintf(_("Unsupported Content-Type: %s"), $contentType));