Fix attachment loading of recurring events

This commit is contained in:
Thomas Bruederli 2011-07-04 17:46:56 +02:00
parent 325bae250d
commit 8c6e9286c2
2 changed files with 8 additions and 7 deletions

View file

@ -116,7 +116,7 @@ function rcube_calendar_ui(settings)
var load_attachment = function(event, att) 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 // open attachment in frame if it's of a supported mimetype
if (id && att.mimetype && $.inArray(att.mimetype, rcmail.mimetypes)>=0) { if (id && att.mimetype && $.inArray(att.mimetype, rcmail.mimetypes)>=0) {

View file

@ -632,7 +632,7 @@ class database_driver extends calendar_driver
if (!empty($calendar_ids)) { if (!empty($calendar_ids)) {
$result = $this->rc->db->query(sprintf( $result = $this->rc->db->query(sprintf(
"SELECT e.*, COUNT(a.attachment_id) AS _attachments FROM " . $this->db_events . " AS e "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) WHERE e.calendar_id IN (%s)
AND e.start <= %s AND e.end >= %s AND e.start <= %s AND e.end >= %s
%s %s
@ -803,8 +803,9 @@ class database_driver extends calendar_driver
public function list_attachments($event) public function list_attachments($event)
{ {
$attachments = array(); $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( $result = $this->rc->db->query(
"SELECT attachment_id AS id, filename AS name, mimetype, size " . "SELECT attachment_id AS id, filename AS name, mimetype, size " .
" FROM " . $this->db_attachments . " FROM " . $this->db_attachments .
@ -812,7 +813,7 @@ class database_driver extends calendar_driver
" WHERE event_id=?" . " WHERE event_id=?" .
" AND calendar_id IN (" . $this->calendar_ids . "))". " AND calendar_id IN (" . $this->calendar_ids . "))".
" ORDER BY filename", " ORDER BY filename",
$event['id'] $event['recurrence_id'] ? $event['recurrence_id'] : $event['event_id']
); );
while ($result && ($arr = $this->rc->db->fetch_assoc($result))) { 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) public function get_attachment($id, $event)
{ {
if (!empty($this->rc->user->ID)) { if (!empty($this->calendar_ids)) {
$result = $this->rc->db->query( $result = $this->rc->db->query(
"SELECT attachment_id AS id, filename AS name, mimetype, size " . "SELECT attachment_id AS id, filename AS name, mimetype, size " .
" FROM " . $this->db_attachments . " FROM " . $this->db_attachments .
" WHERE attachment_id=?". " WHERE attachment_id=?".
" AND event_id=?", " AND event_id=?",
$id, $id,
$event['id'] $event['recurrence_id'] ? $event['recurrence_id'] : $event['id']
); );
if ($result && ($arr = $this->rc->db->fetch_assoc($result))) { 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) public function get_attachment_body($id, $event)
{ {
if (!empty($this->rc->user->ID)) { if (!empty($this->calendar_ids)) {
$result = $this->rc->db->query( $result = $this->rc->db->query(
"SELECT data " . "SELECT data " .
" FROM " . $this->db_attachments . " FROM " . $this->db_attachments .