Changeset View
Changeset View
Standalone View
Standalone View
plugins/calendar/drivers/kolab/kolab_driver.php
Show First 20 Lines • Show All 1,966 Lines • ▼ Show 20 Lines | public static function to_rcube_event(&$record) | ||||
return $record; | return $record; | ||||
} | } | ||||
/** | /** | ||||
* | * | ||||
*/ | */ | ||||
public static function from_rcube_event($event, $old = array()) | public static function from_rcube_event($event, $old = array()) | ||||
{ | { | ||||
// in kolab_storage attachments are indexed by content-id | kolab_format::merge_attachments($event, $old); | ||||
if (is_array($event['attachments']) || !empty($event['deleted_attachments'])) { | |||||
$event['_attachments'] = array(); | |||||
foreach ($event['attachments'] as $attachment) { | |||||
$key = null; | |||||
// Roundcube ID has nothing to do with the storage ID, remove it | |||||
if ($attachment['content'] || $attachment['path']) { | |||||
unset($attachment['id']); | |||||
} | |||||
else { | |||||
foreach ((array)$old['_attachments'] as $cid => $oldatt) { | |||||
if ($attachment['id'] == $oldatt['id']) | |||||
$key = $cid; | |||||
} | |||||
} | |||||
// flagged for deletion => set to false | |||||
if ($attachment['_deleted'] || in_array($attachment['id'], (array)$event['deleted_attachments'])) { | |||||
$event['_attachments'][$key] = false; | |||||
} | |||||
// replace existing entry | |||||
else if ($key) { | |||||
$event['_attachments'][$key] = $attachment; | |||||
} | |||||
// append as new attachment | |||||
else { | |||||
$event['_attachments'][] = $attachment; | |||||
} | |||||
} | |||||
$event['_attachments'] = array_merge((array)$old['_attachments'], $event['_attachments']); | |||||
// attachments flagged for deletion => set to false | |||||
foreach ($event['_attachments'] as $key => $attachment) { | |||||
if ($attachment['_deleted'] || in_array($attachment['id'], (array)$event['deleted_attachments'])) { | |||||
$event['_attachments'][$key] = false; | |||||
} | |||||
} | |||||
} | |||||
return $event; | return $event; | ||||
} | } | ||||
/** | /** | ||||
* Set CSS class according to the event's attendde partstat | * Set CSS class according to the event's attendde partstat | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 524 Lines • Show Last 20 Lines |