From acc49b51fff21dadee9201e4899d2b39d61a48d8 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Tue, 4 Apr 2017 12:17:17 +0200 Subject: [PATCH] Fix misleading warning when editing/deleting a shared event (T1357) and properly notify attendees of such a change. Conflicts: plugins/libcalendaring/libvcalendar.php --- plugins/calendar/calendar_ui.js | 21 ++++++++----------- .../lib/libcalendaring_itip.php | 15 +++++++++++++ plugins/libcalendaring/libvcalendar.php | 20 +++++++++++++++--- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/plugins/calendar/calendar_ui.js b/plugins/calendar/calendar_ui.js index ea494c36..d23d1b91 100644 --- a/plugins/calendar/calendar_ui.js +++ b/plugins/calendar/calendar_ui.js @@ -2558,7 +2558,15 @@ function rcube_calendar_ui(settings) if (_has_attendees) { var checked = (settings.itip_notify & 1 ? ' checked="checked"' : ''); - if (_is_organizer) { + if (action == 'remove' && cal.group == 'personal' && is_attendee(event)) { + decline = true; + checked = event.status != 'CANCELLED' ? checked : ''; + html += '
' + + '
'; + } + else { notify = true; if (settings.itip_notify & 2) { html += '
' + @@ -2570,17 +2578,6 @@ function rcube_calendar_ui(settings) data._notify = settings.itip_notify; } } - else if (action == 'remove' && is_attendee(event)) { - decline = true; - checked = event.status != 'CANCELLED' ? checked : ''; - html += '
' + - '
'; - } - else { - html += '
' + rcmail.gettext('localchangeswarning', 'calendar') + '
'; - } } // recurring event: user needs to select the savemode diff --git a/plugins/libcalendaring/lib/libcalendaring_itip.php b/plugins/libcalendaring/lib/libcalendaring_itip.php index 886a3ed7..6add2b22 100644 --- a/plugins/libcalendaring/lib/libcalendaring_itip.php +++ b/plugins/libcalendaring/lib/libcalendaring_itip.php @@ -261,6 +261,21 @@ class libcalendaring_itip } } + // Set SENT-BY property if the sender is not the organizer + if ($method == 'CANCEL' || $method == 'REQUEST') { + foreach ((array)$event['attendees'] as $idx => $attendee) { + if ($attendee['role'] == 'ORGANIZER' + && $attendee['email'] + && strcasecmp($attendee['email'], $from) != 0 + && strcasecmp($attendee['email'], $from_utf) != 0 + ) { + $attendee['sent-by'] = 'mailto:' . $from_utf; + $event['organizer'] = $event['attendees'][$idx] = $attendee; + break; + } + } + } + // compose multipart message using PEAR:Mail_Mime $message = new Mail_mime("\r\n"); $message->setParam('text_encoding', 'quoted-printable'); diff --git a/plugins/libcalendaring/libvcalendar.php b/plugins/libcalendaring/libvcalendar.php index b63cffb4..60fb1ef5 100644 --- a/plugins/libcalendaring/libvcalendar.php +++ b/plugins/libcalendaring/libvcalendar.php @@ -43,8 +43,22 @@ class libvcalendar implements Iterator private $attach_uri = null; private $prodid = '-//Roundcube libcalendaring//Sabre//Sabre VObject//EN'; private $type_component_map = array('event' => 'VEVENT', 'task' => 'VTODO'); - private $attendee_keymap = array('name' => 'CN', 'status' => 'PARTSTAT', 'role' => 'ROLE', - 'cutype' => 'CUTYPE', 'rsvp' => 'RSVP', 'delegated-from' => 'DELEGATED-FROM', 'delegated-to' => 'DELEGATED-TO'); + private $attendee_keymap = array( + 'name' => 'CN', + 'status' => 'PARTSTAT', + 'role' => 'ROLE', + 'cutype' => 'CUTYPE', + 'rsvp' => 'RSVP', + 'delegated-from' => 'DELEGATED-FROM', + 'delegated-to' => 'DELEGATED-TO', + 'schedule-status' => 'SCHEDULE-STATUS', + 'sent-by' => 'SENT-BY', + ); + private $organizer_keymap = array( + 'name' => 'CN', + 'schedule-status' => 'SCHEDULE-STATUS', + 'sent-by' => 'SENT-BY', + ); private $iteratorkey = 0; private $charset; private $forward_exceptions; @@ -1139,7 +1153,7 @@ class libvcalendar implements Iterator if ($event['organizer']) { $ve->add('ORGANIZER', 'mailto:' . $event['organizer']['email'], - array_filter(self::map_keys($event['organizer'], array('name' => 'CN')))); + array_filter(self::map_keys($event['organizer'], $this->organizer_keymap))); } foreach ((array)$event['url'] as $url) {