Avoid disabling RSVP button on event updates
This commit is contained in:
parent
64174f4fac
commit
f67c2bbcb7
2 changed files with 8 additions and 5 deletions
|
@ -778,9 +778,13 @@ class calendar extends rcube_plugin
|
||||||
case "rsvp-status":
|
case "rsvp-status":
|
||||||
$action = 'rsvp';
|
$action = 'rsvp';
|
||||||
$status = $event['fallback'];
|
$status = $event['fallback'];
|
||||||
|
$latest = false;
|
||||||
$html = html::div('rsvp-status', $status != 'CANCELLED' ? $this->gettext('acceptinvitation') : '');
|
$html = html::div('rsvp-status', $status != 'CANCELLED' ? $this->gettext('acceptinvitation') : '');
|
||||||
|
if (is_numeric($event['changed']))
|
||||||
|
$event['changed'] = new DateTime('@'.$event['changed']);
|
||||||
$this->load_driver();
|
$this->load_driver();
|
||||||
if ($existing = $this->driver->get_event($event, true, false, true)) {
|
if ($existing = $this->driver->get_event($event, true, false, true)) {
|
||||||
|
$latest = ($event['sequence'] && $existing['sequence'] == $event['sequence']) || (!$event['sequence'] && $existing['changed'] && $existing['changed'] >= $event['changed']);
|
||||||
$emails = $this->get_user_emails();
|
$emails = $this->get_user_emails();
|
||||||
foreach ($existing['attendees'] as $i => $attendee) {
|
foreach ($existing['attendees'] as $i => $attendee) {
|
||||||
if ($attendee['email'] && in_array(strtolower($attendee['email']), $emails)) {
|
if ($attendee['email'] && in_array(strtolower($attendee['email']), $emails)) {
|
||||||
|
@ -809,11 +813,9 @@ class calendar extends rcube_plugin
|
||||||
$action = 'import';
|
$action = 'import';
|
||||||
}
|
}
|
||||||
else if (in_array($status, array('ACCEPTED','TENTATIVE','DECLINED'))) {
|
else if (in_array($status, array('ACCEPTED','TENTATIVE','DECLINED'))) {
|
||||||
if (is_numeric($event['changed']))
|
|
||||||
$event['changed'] = new DateTime('@'.$event['changed']);
|
|
||||||
$html = html::div('rsvp-status ' . strtolower($status), $this->gettext('youhave'.strtolower($status)));
|
$html = html::div('rsvp-status ' . strtolower($status), $this->gettext('youhave'.strtolower($status)));
|
||||||
if ($existing['sequence'] >= $event['sequence'] || (!$event['sequence'] && $existing['changed'] && $existing['changed'] >= $event['changed'])) {
|
if ($existing['sequence'] > $event['sequence'] || (!$event['sequence'] && $existing['changed'] && $existing['changed'] > $event['changed'])) {
|
||||||
$action = ''; // nothing to do here
|
$action = ''; // nothing to do here, outdated invitation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -822,6 +824,7 @@ class calendar extends rcube_plugin
|
||||||
'uid' => $event['uid'],
|
'uid' => $event['uid'],
|
||||||
'id' => asciiwords($event['uid'], true),
|
'id' => asciiwords($event['uid'], true),
|
||||||
'saved' => $existing ? true : false,
|
'saved' => $existing ? true : false,
|
||||||
|
'latest' => $latest,
|
||||||
'status' => $status,
|
'status' => $status,
|
||||||
'action' => $action,
|
'action' => $action,
|
||||||
'html' => $html,
|
'html' => $html,
|
||||||
|
|
|
@ -144,7 +144,7 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
|
||||||
|
|
||||||
// enable/disable rsvp buttons
|
// enable/disable rsvp buttons
|
||||||
$('.rsvp-buttons input.button').prop('disabled', false)
|
$('.rsvp-buttons input.button').prop('disabled', false)
|
||||||
.filter('.'+String(p.status).toLowerCase()).prop('disabled', true);
|
.filter('.'+String(p.status).toLowerCase()).prop('disabled', p.latest);
|
||||||
|
|
||||||
// show rsvp/import buttons with or without calendar selector
|
// show rsvp/import buttons with or without calendar selector
|
||||||
if (!p.select)
|
if (!p.select)
|
||||||
|
|
Loading…
Add table
Reference in a new issue