summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2013-07-18 14:37:00 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2013-07-18 14:43:06 (GMT)
commitb10b81c92702543f17b9ef424717223f1d297a7f (patch)
treee0625ed446e1a72a6c665ce598babfb869ae356c
parentd00d3da92492cfade722ea040d4752871dcdc2bc (diff)
downloadroundcubemail-plugins-kolab-b10b81c92702543f17b9ef424717223f1d297a7f.tar.gz
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
-rw-r--r--plugins/calendar/calendar.php18
-rw-r--r--plugins/calendar/calendar_base.js31
-rw-r--r--plugins/calendar/localization/de_CH.inc1
-rw-r--r--plugins/calendar/localization/de_DE.inc1
-rw-r--r--plugins/calendar/localization/en_US.inc1
5 files changed, 45 insertions, 7 deletions
diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php
index 2379c90..905b4ff 100644
--- a/plugins/calendar/calendar.php
+++ b/plugins/calendar/calendar.php
@@ -747,6 +747,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,
@@ -1747,7 +1748,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),
));
@@ -1821,7 +1822,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;
@@ -1837,6 +1838,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
@@ -1921,14 +1923,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
@@ -1947,8 +1958,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)
diff --git a/plugins/calendar/calendar_base.js b/plugins/calendar/calendar_base.js
index 234bad4..fb776c8 100644
--- a/plugins/calendar/calendar_base.js
+++ b/plugins/calendar/calendar_base.js
@@ -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') {
diff --git a/plugins/calendar/localization/de_CH.inc b/plugins/calendar/localization/de_CH.inc
index 20311a2..d8364bc 100644
--- a/plugins/calendar/localization/de_CH.inc
+++ b/plugins/calendar/localization/de_CH.inc
@@ -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';
diff --git a/plugins/calendar/localization/de_DE.inc b/plugins/calendar/localization/de_DE.inc
index a3b0058..b8623c7 100644
--- a/plugins/calendar/localization/de_DE.inc
+++ b/plugins/calendar/localization/de_DE.inc
@@ -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';
diff --git a/plugins/calendar/localization/en_US.inc b/plugins/calendar/localization/en_US.inc
index 4164d89..aa598be 100644
--- a/plugins/calendar/localization/en_US.inc
+++ b/plugins/calendar/localization/en_US.inc
@@ -145,6 +145,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';