Branch 'roundcubemail-plugins-kolab-format2-horde5' - plugins/calendar

Thomas Brüderli bruederli at kolabsys.com
Mon Jul 22 19:48:49 CEST 2013


 plugins/calendar/calendar.php     |   11 ++++++++---
 plugins/calendar/calendar_base.js |    2 +-
 2 files changed, 9 insertions(+), 4 deletions(-)

New commits:
commit 542083f03d1749ec3dbedca2d697933a97b52af7
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Mon Jul 22 19:39:24 2013 +0200

    Avoid disabling RSVP button on event updates

diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php
index f02d4ea..90e5575 100644
--- a/plugins/calendar/calendar.php
+++ b/plugins/calendar/calendar.php
@@ -706,9 +706,13 @@ class calendar extends rcube_plugin
       case "rsvp-status":
         $action = 'rsvp';
         $status = $event['fallback'];
+        $latest = false;
         $html = html::div('rsvp-status', $status != 'CANCELLED' ? $this->gettext('acceptinvitation') : '');
+        if (is_numeric($event['changed']))
+          $event['changed'] = new DateTime('@'.$event['changed']);
         $this->load_driver();
         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();
           foreach ($existing['attendees'] as $i => $attendee) {
             if ($attendee['email'] && in_array(strtolower($attendee['email']), $emails)) {
@@ -738,10 +742,10 @@ class calendar extends rcube_plugin
         }
         else if (in_array($status, array('ACCEPTED','TENTATIVE','DECLINED'))) {
           $html = html::div('rsvp-status ' . strtolower($status), $this->gettext('youhave'.strtolower($status)));
-          if ($existing['sequence'] >= $event['sequence'] || (!$event['sequence']
+          if ($existing['sequence'] > $event['sequence'] || (!$event['sequence']
                 && $this->rc->config->get('calendar_itip_dtstampcheck', false)
-                && $existing['changed'] && $existing['changed'] >= $event['changed'])) {
-            $action = '';  // nothing to do here
+                && $existing['changed'] && $existing['changed'] > $event['changed'])) {
+            $action = '';  // nothing to do here, outdated invitation
          }
         }
         
@@ -750,6 +754,7 @@ class calendar extends rcube_plugin
           'uid' => $event['uid'],
           'id' => asciiwords($event['uid'], true),
           'saved' => $existing ? true : false,
+          'latest' => $latest,
           'status' => $status,
           'action' => $action,
           'html' => $html,
diff --git a/plugins/calendar/calendar_base.js b/plugins/calendar/calendar_base.js
index 38d3520..7bd24a7 100644
--- a/plugins/calendar/calendar_base.js
+++ b/plugins/calendar/calendar_base.js
@@ -144,7 +144,7 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
 
       // enable/disable rsvp buttons
       $('.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
       if (!p.select)




More information about the commits mailing list