Skip to content

Commit

Permalink
Allow returning a hash from import().
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mrubinsk committed Aug 31, 2016
1 parent 862156f commit 2a8a8f7
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions kronolith/lib/Api.php
Expand Up @@ -784,11 +784,14 @@ public function getHighestModSeq($id = null)
* activesync
* </pre>
* @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);
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 2a8a8f7

Please sign in to comment.