From c4fb6b73b72bef4c77a3eb0caab6f72aba60a77e Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Thu, 10 Apr 2014 08:58:35 +0200 Subject: [PATCH] Allow to update a cancelled event (from iTip) in the personal calendar --- plugins/calendar/calendar.php | 10 ++++++++-- plugins/calendar/calendar_ui.js | 2 +- plugins/calendar/localization/en_US.inc | 1 + plugins/libcalendaring/lib/libcalendaring_itip.php | 4 +--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php index e4c3b291..70d58be1 100644 --- a/plugins/calendar/calendar.php +++ b/plugins/calendar/calendar.php @@ -2396,8 +2396,14 @@ class calendar extends rcube_plugin else if ($event['sequence'] >= $existing['sequence'] || $event['changed'] >= $existing['changed']) { $event['id'] = $existing['id']; $event['calendar'] = $existing['calendar']; - if ($status == 'declined' || $event['status'] == 'CANCELLED') // show me as free when declined (#1670) + + // set status=CANCELLED on CANCEL messages + if ($this->ical->method == 'CANCEL') + $event['status'] = 'CANCELLED'; + // show me as free when declined (#1670) + if ($status == 'declined' || $event['status'] == 'CANCELLED') $event['free_busy'] = 'free'; + $success = $this->driver->edit_event($event); } else if (!empty($status)) { @@ -2422,7 +2428,7 @@ class calendar extends rcube_plugin } if ($success) { - $message = $this->ical->method == 'REPLY' ? 'attendeupdateesuccess' : ($deleted ? 'successremoval' : 'importedsuccessfully'); + $message = $this->ical->method == 'REPLY' ? 'attendeupdateesuccess' : ($deleted ? 'successremoval' : ($existing ? 'updatedsuccessfully' : 'importedsuccessfully')); $this->rc->output->command('display_message', $this->gettext(array('name' => $message, 'vars' => array('calendar' => $calendar['name']))), 'confirmation'); $metadata['rsvp'] = intval($metadata['rsvp']); diff --git a/plugins/calendar/calendar_ui.js b/plugins/calendar/calendar_ui.js index 92a17653..04ec3923 100644 --- a/plugins/calendar/calendar_ui.js +++ b/plugins/calendar/calendar_ui.js @@ -407,7 +407,7 @@ function rcube_calendar_ui(settings) } } - $('#event-rsvp')[(rsvp && !is_organizer(event) ? 'show' : 'hide')](); + $('#event-rsvp')[(rsvp && !is_organizer(event) && event.status != 'CANCELLED' ? 'show' : 'hide')](); $('#event-rsvp .rsvp-buttons input').prop('disabled', false).filter('input[rel='+rsvp+']').prop('disabled', true); } diff --git a/plugins/calendar/localization/en_US.inc b/plugins/calendar/localization/en_US.inc index 3df791cd..9be8fc02 100644 --- a/plugins/calendar/localization/en_US.inc +++ b/plugins/calendar/localization/en_US.inc @@ -199,6 +199,7 @@ $labels['importwarningexists'] = 'A copy of this event already exists in your ca $labels['newerversionexists'] = 'A newer version of this event already exists! Aborted.'; $labels['nowritecalendarfound'] = 'No calendar found to save the event'; $labels['importedsuccessfully'] = 'The event was successfully added to \'$calendar\''; +$labels['updatedsuccessfully'] = 'The event was successfully updated in \'$calendar\''; $labels['attendeupdateesuccess'] = 'Successfully updated the participant\'s status'; $labels['itipsendsuccess'] = 'Invitation sent to participants.'; $labels['itipresponseerror'] = 'Failed to send the response to this event invitation'; diff --git a/plugins/libcalendaring/lib/libcalendaring_itip.php b/plugins/libcalendaring/lib/libcalendaring_itip.php index a703160f..b03900d2 100644 --- a/plugins/libcalendaring/lib/libcalendaring_itip.php +++ b/plugins/libcalendaring/lib/libcalendaring_itip.php @@ -451,14 +451,12 @@ class libcalendaring_itip )); // 2. update our copy with status=cancelled - /* TODO: implement CANCELLED status in calendar UI first $button_update = html::tag('input', array( 'type' => 'button', 'class' => 'button', - 'onclick' => "rcube_libcalendaring.add_from_itip_mail('" . JQ($mime_id) . "')", + 'onclick' => "rcube_libcalendaring.add_from_itip_mail('" . JQ($mime_id) . "', '$task')", 'value' => $this->gettext('updatemycopy'), )); - */ $buttons[] = html::div(array('id' => 'rsvp-'.$dom_id, 'style' => 'display:none'), $button_remove . $button_update);