diff --git a/plugins/calendar/calendar_ui.js b/plugins/calendar/calendar_ui.js index 6a42c7c6..889df966 100644 --- a/plugins/calendar/calendar_ui.js +++ b/plugins/calendar/calendar_ui.js @@ -116,7 +116,7 @@ function rcube_calendar_ui(settings) var load_attachment = function(event, att) { - var qstring = '_id='+urlencode(att.id)+'&_event='+urlencode(event.id)+'&_cal='+urlencode(event.calendar); + var qstring = '_id='+urlencode(att.id)+'&_event='+urlencode(event.recurrence_id||event.id)+'&_cal='+urlencode(event.calendar); // open attachment in frame if it's of a supported mimetype if (id && att.mimetype && $.inArray(att.mimetype, rcmail.mimetypes)>=0) { diff --git a/plugins/calendar/drivers/database/database_driver.php b/plugins/calendar/drivers/database/database_driver.php index 52bbbdec..9c759471 100644 --- a/plugins/calendar/drivers/database/database_driver.php +++ b/plugins/calendar/drivers/database/database_driver.php @@ -632,7 +632,7 @@ class database_driver extends calendar_driver if (!empty($calendar_ids)) { $result = $this->rc->db->query(sprintf( "SELECT e.*, COUNT(a.attachment_id) AS _attachments FROM " . $this->db_events . " AS e - LEFT JOIN " . $this->db_attachments . " AS a ON (a.event_id = e.event_id) + LEFT JOIN " . $this->db_attachments . " AS a ON (a.event_id = e.event_id OR a.event_id = e.recurrence_id) WHERE e.calendar_id IN (%s) AND e.start <= %s AND e.end >= %s %s @@ -803,8 +803,9 @@ class database_driver extends calendar_driver public function list_attachments($event) { $attachments = array(); + $event_id = $event['recurrence_id'] ? $event['recurrence_id'] : $event['event_id']; - if (!empty($this->rc->user->ID)) { + if (!empty($this->calendar_ids)) { $result = $this->rc->db->query( "SELECT attachment_id AS id, filename AS name, mimetype, size " . " FROM " . $this->db_attachments . @@ -812,7 +813,7 @@ class database_driver extends calendar_driver " WHERE event_id=?" . " AND calendar_id IN (" . $this->calendar_ids . "))". " ORDER BY filename", - $event['id'] + $event['recurrence_id'] ? $event['recurrence_id'] : $event['event_id'] ); while ($result && ($arr = $this->rc->db->fetch_assoc($result))) { @@ -828,14 +829,14 @@ class database_driver extends calendar_driver */ public function get_attachment($id, $event) { - if (!empty($this->rc->user->ID)) { + if (!empty($this->calendar_ids)) { $result = $this->rc->db->query( "SELECT attachment_id AS id, filename AS name, mimetype, size " . " FROM " . $this->db_attachments . " WHERE attachment_id=?". " AND event_id=?", $id, - $event['id'] + $event['recurrence_id'] ? $event['recurrence_id'] : $event['id'] ); if ($result && ($arr = $this->rc->db->fetch_assoc($result))) { @@ -851,7 +852,7 @@ class database_driver extends calendar_driver */ public function get_attachment_body($id, $event) { - if (!empty($this->rc->user->ID)) { + if (!empty($this->calendar_ids)) { $result = $this->rc->db->query( "SELECT data " . " FROM " . $this->db_attachments .