Improve iTip handling when decline events (#1670)

- Remove events from calendar when declined (user's choice)
- Set busy status to free when decling but keep the event in calendar
- Update RSVP status display in email view after change
This commit is contained in:
Thomas Bruederli 2013-07-18 16:37:00 +02:00
parent a21fc44ed4
commit 17354a88e3
5 changed files with 45 additions and 7 deletions

View file

@ -821,6 +821,7 @@ class calendar extends rcube_plugin
$this->rc->output->command('plugin.update_event_rsvp_status', array(
'uid' => $event['uid'],
'id' => asciiwords($event['uid'], true),
'saved' => $existing ? true : false,
'status' => $status,
'action' => $action,
'html' => $html,
@ -1831,7 +1832,7 @@ class calendar extends rcube_plugin
foreach (array('accepted','tentative','declined') as $method) {
$rsvp_buttons .= html::tag('input', array(
'type' => 'button',
'class' => 'button',
'class' => "button $method",
'onclick' => "rcube_calendar.add_event_from_mail('" . JQ($mime_id.':'.$idx) . "', '$method')",
'value' => $this->gettext('itip' . $method),
));
@ -1905,7 +1906,7 @@ class calendar extends rcube_plugin
if ($html) {
$this->ui->init();
$p['content'] = $html . $p['content'];
$this->rc->output->add_label('calendar.savingdata','calendar.deleteventconfirm');
$this->rc->output->add_label('calendar.savingdata','calendar.deleteventconfirm','calendar.declinedeleteconfirm');
}
return $p;
@ -1921,6 +1922,7 @@ class calendar extends rcube_plugin
$mbox = get_input_value('_mbox', RCUBE_INPUT_POST);
$mime_id = get_input_value('_part', RCUBE_INPUT_POST);
$status = get_input_value('_status', RCUBE_INPUT_POST);
$delete = intval(get_input_value('_del', RCUBE_INPUT_POST));
$charset = RCMAIL_CHARSET;
// establish imap connection
@ -2005,14 +2007,23 @@ class calendar extends rcube_plugin
$error_msg = $this->gettext('newerversionexists');
}
}
// delete the event when declined (#1670)
else if ($status == 'declined' && $delete) {
$deleted = $this->driver->remove_event($existing, true);
$success = true;
}
// import the (newer) event
else if ($event['sequence'] >= $existing['sequence'] || $event['changed'] >= $existing['changed']) {
$event['id'] = $existing['id'];
$event['calendar'] = $existing['calendar'];
if ($status == 'declined') // show me as free when declined (#1670)
$event['free_busy'] = 'free';
$success = $this->driver->edit_event($event);
}
else if (!empty($status)) {
$existing['attendees'] = $event['attendees'];
if ($status == 'declined') // show me as free when declined (#1670)
$existing['free_busy'] = 'free';
$success = $this->driver->edit_event($existing);
}
else
@ -2031,8 +2042,9 @@ class calendar extends rcube_plugin
}
if ($success) {
$message = $this->ical->method == 'REPLY' ? 'attendeupdateesuccess' : 'importedsuccessfully';
$message = $this->ical->method == 'REPLY' ? 'attendeupdateesuccess' : ($deleted ? 'successremoval' : 'importedsuccessfully');
$this->rc->output->command('display_message', $this->gettext(array('name' => $message, 'vars' => array('calendar' => $calendar['name']))), 'confirmation');
$this->rc->output->command('plugin.fetch_event_rsvp_status', array('uid' => $event['uid'], 'changed' => $event['changed']->format('U'), 'sequence' => intval($event['sequence']), 'fallback' => strtoupper($status)));
$error_msg = null;
}
else if ($error_msg)

View file

@ -81,14 +81,22 @@ function rcube_calendar(settings)
// static methods
rcube_calendar.add_event_from_mail = function(mime_id, status)
{
// ask user to delete the declined event from the local calendar (#1670)
var del = false;
if (rcmail.env.rsvp_saved && status == 'declined') {
del = confirm(rcmail.gettext('calendar.declinedeleteconfirm'));
}
var lock = rcmail.set_busy(true, 'calendar.savingdata');
rcmail.http_post('calendar/mailimportevent', {
'_uid': rcmail.env.uid,
'_mbox': rcmail.env.mailbox,
'_part': mime_id,
'_calendar': $('#calendar-saveto').val(),
'_status': status
'_status': status,
'_del': del?1:0
}, lock);
return false;
};
@ -123,13 +131,28 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
var cal = new rcube_calendar($.extend(rcmail.env.calendar_settings, rcmail.env.libcal_settings));
rcmail.addEventListener('plugin.update_event_rsvp_status', function(p){
if (p.html)
rcmail.env.rsvp_saved = p.saved;
if (p.html) {
// append/replace rsvp status display
$('#loading-'+p.id).next('.rsvp-status').remove();
$('#loading-'+p.id).hide().after(p.html);
else
}
else {
$('#loading-'+p.id).hide();
}
// enable/disable rsvp buttons
$('.rsvp-buttons input.button').prop('disabled', false)
.filter('.'+String(p.status).toLowerCase()).prop('disabled', true);
// show rsvp/import buttons with or without calendar selector
if (!p.select)
$('#rsvp-'+p.id+' .calendar-select').remove();
$('#'+p.action+'-'+p.id).show().append(p.select);
});
rcmail.addEventListener('plugin.fetch_event_rsvp_status', rcube_calendar.fetch_event_rsvp_status);
// register create-from-mail command to message_commands array
if (rcmail.env.task == 'mail') {

View file

@ -145,6 +145,7 @@ $labels['itipmailbodyaccepted'] = "\$sender hat die Einladung zum folgenden Term
$labels['itipmailbodytentative'] = "\$sender hat die Einladung mit Vorbehalt zum folgenden Termin angenommen:\n\n*\$title*\n\nWann: \$date\n\nTeilnehmer: \$attendees";
$labels['itipmailbodydeclined'] = "\$sender hat die Einladung zum folgenden Termin abgelehnt:\n\n*\$title*\n\nWann: \$date\n\nTeilnehmer: \$attendees";
$labels['itipdeclineevent'] = 'Möchten Sie die Einladung zu diesem Termin ablehnen?';
$labels['declinedeleteconfirm'] = 'Möchten Sie den abgelehnten Termin ebenfalls aus Ihrem Kalender löschen?';
$labels['importtocalendar'] = 'In Kalender übernehmen';
$labels['removefromcalendar'] = 'Aus meinem Kalender löschen';
$labels['updateattendeestatus'] = 'Teilnehmerstatus aktualisieren';

View file

@ -145,6 +145,7 @@ $labels['itipmailbodyaccepted'] = "\$sender hat die Einladung zum folgenden Term
$labels['itipmailbodytentative'] = "\$sender hat die Einladung mit Vorbehalt zum folgenden Termin angenommen:\n\n*\$title*\n\nWann: \$date\n\nTeilnehmer: \$attendees";
$labels['itipmailbodydeclined'] = "\$sender hat die Einladung zum folgenden Termin abgelehnt:\n\n*\$title*\n\nWann: \$date\n\nTeilnehmer: \$attendees";
$labels['itipdeclineevent'] = 'Möchten Sie die Einladung zu diesem Termin ablehnen?';
$labels['declinedeleteconfirm'] = 'Möchten Sie den abgelehnten Termin ebenfalls aus Ihrem Kalender löschen?';
$labels['importtocalendar'] = 'In Kalender übernehmen';
$labels['removefromcalendar'] = 'Aus meinem Kalender löschen';
$labels['updateattendeestatus'] = 'Teilnehmerstatus aktualisieren';

View file

@ -150,6 +150,7 @@ $labels['itipmailbodyaccepted'] = "\$sender has accepted the invitation to the f
$labels['itipmailbodytentative'] = "\$sender has tentatively accepted the invitation to the following event:\n\n*\$title*\n\nWhen: \$date\n\nInvitees: \$attendees";
$labels['itipmailbodydeclined'] = "\$sender has declined the invitation to the following event:\n\n*\$title*\n\nWhen: \$date\n\nInvitees: \$attendees";
$labels['itipdeclineevent'] = 'Do you want to decline your invitation to this event?';
$labels['declinedeleteconfirm'] = 'Do you also want to delete this declined event from your calendar?';
$labels['importtocalendar'] = 'Save to my calendar';
$labels['removefromcalendar'] = 'Remove from my calendar';
$labels['updateattendeestatus'] = 'Update the participant\'s status';