Fix loading attachments for events listed in virtual calendars (#4400)
This commit is contained in:
parent
055c5aff13
commit
a837feb76e
4 changed files with 52 additions and 10 deletions
|
@ -207,6 +207,14 @@ class kolab_calendar extends kolab_storage_folder_api
|
||||||
return $this->events[$id];
|
return $this->events[$id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get attachment body
|
||||||
|
* @see calendar_driver::get_attachment_body()
|
||||||
|
*/
|
||||||
|
public function get_attachment_body($id, $event)
|
||||||
|
{
|
||||||
|
return $this->ready ? $this->storage->get_attachment($event['id'], $id): false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param integer Event's new start (unix timestamp)
|
* @param integer Event's new start (unix timestamp)
|
||||||
|
|
|
@ -583,15 +583,6 @@ class kolab_driver extends calendar_driver
|
||||||
|
|
||||||
$cid = $event['calendar'] ? $event['calendar'] : reset(array_keys($this->calendars));
|
$cid = $event['calendar'] ? $event['calendar'] : reset(array_keys($this->calendars));
|
||||||
if ($storage = $this->get_calendar($cid)) {
|
if ($storage = $this->get_calendar($cid)) {
|
||||||
// handle attachments to add
|
|
||||||
if (!empty($event['attachments'])) {
|
|
||||||
foreach ($event['attachments'] as $idx => $attachment) {
|
|
||||||
// we'll read file contacts into memory, Horde/Kolab classes does the same
|
|
||||||
// So we cannot save memory, rcube_imap class can do this better
|
|
||||||
$event['attachments'][$idx]['content'] = $attachment['data'] ? $attachment['data'] : file_get_contents($attachment['path']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$success = $storage->insert_event($event);
|
$success = $storage->insert_event($event);
|
||||||
|
|
||||||
if ($success && $this->freebusy_trigger) {
|
if ($success && $this->freebusy_trigger) {
|
||||||
|
@ -1614,7 +1605,7 @@ class kolab_driver extends calendar_driver
|
||||||
if (!($cal = $this->get_calendar($event['calendar'])))
|
if (!($cal = $this->get_calendar($event['calendar'])))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return $cal->storage->get_attachment($event['id'], $id);
|
return $cal->get_attachment_body($id, $event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -188,6 +188,33 @@ class kolab_invitation_calendar
|
||||||
return $event;
|
return $event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get attachment body
|
||||||
|
* @see calendar_driver::get_attachment_body()
|
||||||
|
*/
|
||||||
|
public function get_attachment_body($id, $event)
|
||||||
|
{
|
||||||
|
// find the actual folder this event resides in
|
||||||
|
if (!empty($event['_folder_id'])) {
|
||||||
|
$cal = $this->cal->get_calendar($event['_folder_id']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$cal = null;
|
||||||
|
foreach (kolab_storage::list_folders('', '*', 'event', null) as $foldername) {
|
||||||
|
$cal = new kolab_calendar($foldername, $this->cal);
|
||||||
|
if ($cal->ready && $cal->storage && $cal->get_event($event['id'])) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($cal && $cal->storage) {
|
||||||
|
return $cal->get_attachment_body($id, $event);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param integer Event's new start (unix timestamp)
|
* @param integer Event's new start (unix timestamp)
|
||||||
|
|
|
@ -174,6 +174,22 @@ class kolab_user_calendar extends kolab_calendar
|
||||||
return $this->events[$id];
|
return $this->events[$id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get attachment body
|
||||||
|
* @see calendar_driver::get_attachment_body()
|
||||||
|
*/
|
||||||
|
public function get_attachment_body($id, $event)
|
||||||
|
{
|
||||||
|
if (!$event['calendar'] && ($ev = $this->get_event($event['id']))) {
|
||||||
|
$event['calendar'] = $ev['calendar'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($event['calendar'] && ($cal = $this->cal->get_calendar($event['calendar']))) {
|
||||||
|
return $cal->get_attachment_body($id, $event);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param integer Event's new start (unix timestamp)
|
* @param integer Event's new start (unix timestamp)
|
||||||
|
|
Loading…
Add table
Reference in a new issue