diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php index 547be1e3..f84d07a0 100644 --- a/plugins/calendar/calendar.php +++ b/plugins/calendar/calendar.php @@ -1636,6 +1636,15 @@ class calendar extends rcube_plugin $event['attachments'][$k]['classname'] = rcube_utils::file2class($attachment['mimetype'], $attachment['name']); } + // convert link URIs references into structs + if (array_key_exists('links', $event)) { + foreach ((array)$event['links'] as $i => $link) { + if (strpos($link, 'imap://') === 0 && ($msgref = $this->driver->get_message_reference($link))) { + $event['links'][$i] = $msgref; + } + } + } + // check for organizer in attendees list $organizer = null; foreach ((array)$event['attendees'] as $i => $attendee) { @@ -1824,6 +1833,13 @@ class calendar extends rcube_plugin $event['attachments'] = $attachments; + // convert link references into simple URIs + if (array_key_exists('links', $event)) { + $event['links'] = array_map(function($link) { + return is_array($link) ? $link['uri'] : strval($link); + }, (array)$event['links']); + } + // check for organizer in attendees if ($action == 'new' || $action == 'edit') { if (!$event['attendees']) @@ -2932,9 +2948,15 @@ class calendar extends rcube_plugin if ($message->headers) { $event['title'] = trim($message->subject); $event['description'] = trim($message->first_text_part()); - + + $this->load_driver(); + + // add a reference to the email message + if ($msgref = $this->driver->get_message_reference($message->headers, $mbox)) { + $event['links'] = array($msgref); + } // copy mail attachments to event - if ($message->attachments) { + else if ($message->attachments) { $eventid = 'cal:'; if (!is_array($_SESSION[self::SESSION_KEY]) || $_SESSION[self::SESSION_KEY]['id'] != $eventid) { $_SESSION[self::SESSION_KEY] = array(); diff --git a/plugins/calendar/calendar_ui.js b/plugins/calendar/calendar_ui.js index a2dc39c4..45a537f4 100644 --- a/plugins/calendar/calendar_ui.js +++ b/plugins/calendar/calendar_ui.js @@ -187,6 +187,7 @@ function rcube_calendar_ui(settings) var fromunixtime = this.fromunixtime; var parseISO8601 = this.parseISO8601; var date2servertime = this.date2ISO8601; + var render_message_links = this.render_message_links; /*** private methods ***/ @@ -471,6 +472,13 @@ function rcube_calendar_ui(settings) // fetch attachments, some drivers doesn't set 'attachments' prop of the event? } + // build attachments list + $('#event-links').hide(); + if ($.isArray(event.links) && event.links.length) { + render_message_links(event.links || [], $('#event-links').children('.event-text'), false, 'calendar'); + $('#event-links').show(); + } + // list event attendees if (calendar.attendees && event.attendees) { // sort resources to the end @@ -546,20 +554,30 @@ function rcube_calendar_ui(settings) $('#event-rsvp .itip-reply-comment textarea').hide().val(''); } - var buttons = {}; + var buttons = []; if (!temp && calendar.editable && event.editable !== false) { - buttons[rcmail.gettext('edit', 'calendar')] = function() { - event_edit_dialog('edit', event); - }; - buttons[rcmail.gettext('delete', 'calendar')] = function() { - me.delete_event(event); - $dialog.dialog('close'); - }; + buttons.push({ + text: rcmail.gettext('edit', 'calendar'), + click: function() { + event_edit_dialog('edit', event); + } + }); + buttons.push({ + text: rcmail.gettext('delete', 'calendar'), + 'class': 'delete', + click: function() { + me.delete_event(event); + $dialog.dialog('close'); + } + }); } else { - buttons[rcmail.gettext('close', 'calendar')] = function(){ - $dialog.dialog('close'); - }; + buttons.push({ + text: rcmail.gettext('close', 'calendar'), + click: function(){ + $dialog.dialog('close'); + } + }); } // open jquery UI dialog @@ -712,6 +730,14 @@ function rcube_calendar_ui(settings) $('