summaryrefslogtreecommitdiff
path: root/plugins/calendar
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2015-02-24 11:49:05 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2015-02-24 13:17:53 (GMT)
commita837feb76e3458eb58c04545ad4711a0a5d77ef5 (patch)
treec08bc9a2b5dd1a1b15e40fbe8e190e9216636fe6 /plugins/calendar
parent055c5aff1327e503e8c82663ded21ea1666c72b4 (diff)
downloadroundcubemail-plugins-kolab-a837feb76e3458eb58c04545ad4711a0a5d77ef5.tar.gz
Fix loading attachments for events listed in virtual calendars (#4400)
Diffstat (limited to 'plugins/calendar')
-rw-r--r--plugins/calendar/drivers/kolab/kolab_calendar.php8
-rw-r--r--plugins/calendar/drivers/kolab/kolab_driver.php11
-rw-r--r--plugins/calendar/drivers/kolab/kolab_invitation_calendar.php27
-rw-r--r--plugins/calendar/drivers/kolab/kolab_user_calendar.php16
4 files changed, 52 insertions, 10 deletions
diff --git a/plugins/calendar/drivers/kolab/kolab_calendar.php b/plugins/calendar/drivers/kolab/kolab_calendar.php
index 64bb082..4bf064f 100644
--- a/plugins/calendar/drivers/kolab/kolab_calendar.php
+++ b/plugins/calendar/drivers/kolab/kolab_calendar.php
@@ -207,6 +207,14 @@ class kolab_calendar extends kolab_storage_folder_api
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)
diff --git a/plugins/calendar/drivers/kolab/kolab_driver.php b/plugins/calendar/drivers/kolab/kolab_driver.php
index 848f0f9..6549381 100644
--- a/plugins/calendar/drivers/kolab/kolab_driver.php
+++ b/plugins/calendar/drivers/kolab/kolab_driver.php
@@ -583,15 +583,6 @@ class kolab_driver extends calendar_driver
$cid = $event['calendar'] ? $event['calendar'] : reset(array_keys($this->calendars));
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);
if ($success && $this->freebusy_trigger) {
@@ -1614,7 +1605,7 @@ class kolab_driver extends calendar_driver
if (!($cal = $this->get_calendar($event['calendar'])))
return false;
- return $cal->storage->get_attachment($event['id'], $id);
+ return $cal->get_attachment_body($id, $event);
}
/**
diff --git a/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php b/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php
index a78c5a8..0ffdee5 100644
--- a/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php
+++ b/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php
@@ -188,6 +188,33 @@ class kolab_invitation_calendar
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)
diff --git a/plugins/calendar/drivers/kolab/kolab_user_calendar.php b/plugins/calendar/drivers/kolab/kolab_user_calendar.php
index 7241dd1..3d53206 100644
--- a/plugins/calendar/drivers/kolab/kolab_user_calendar.php
+++ b/plugins/calendar/drivers/kolab/kolab_user_calendar.php
@@ -174,6 +174,22 @@ class kolab_user_calendar extends kolab_calendar
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)