Branch 'roundcubemail-plugins-kolab-3.0' - 2 commits - plugins/calendar plugins/libkolab

Thomas Brüderli bruederli at kolabsys.com
Mon Jul 22 20:01:35 CEST 2013


 plugins/calendar/calendar.php                         |    9 +++++++--
 plugins/calendar/calendar_base.js                     |    2 +-
 plugins/calendar/drivers/database/database_driver.php |    2 +-
 plugins/calendar/drivers/kolab/kolab_driver.php       |    8 ++++++--
 plugins/libkolab/lib/kolab_format_xcal.php            |    3 ++-
 5 files changed, 17 insertions(+), 7 deletions(-)

New commits:
commit 6e976234bdb63d86b30ce9be0097c6628f712443
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Mon Jul 22 19:42:41 2013 +0200

    Only increase sequence number of not supplied (keeps it for event imports)

diff --git a/plugins/calendar/drivers/database/database_driver.php b/plugins/calendar/drivers/database/database_driver.php
index 5f00b1d..079fcb0 100644
--- a/plugins/calendar/drivers/database/database_driver.php
+++ b/plugins/calendar/drivers/database/database_driver.php
@@ -302,7 +302,7 @@ class database_driver extends calendar_driver
       $old = $this->get_event($event);
       
       // increment sequence number
-      if ($old['sequence'])
+      if ($old['sequence'] && empty($event['sequence']))
         $event['sequence'] = max($event['sequence'], $old['sequence']+1);
       
       // modify a recurring event, check submitted savemode to do the right things
diff --git a/plugins/calendar/drivers/kolab/kolab_driver.php b/plugins/calendar/drivers/kolab/kolab_driver.php
index fe9f25a..19214b9 100644
--- a/plugins/calendar/drivers/kolab/kolab_driver.php
+++ b/plugins/calendar/drivers/kolab/kolab_driver.php
@@ -377,8 +377,10 @@ class kolab_driver extends calendar_driver
    */
   public function move_event($event)
   {
-    if (($storage = $this->calendars[$event['calendar']]) && ($ev = $storage->get_event($event['id'])))
+    if (($storage = $this->calendars[$event['calendar']]) && ($ev = $storage->get_event($event['id']))) {
+      unset($ev['sequence']);
       return $this->update_event($event + $ev);
+    }
 
     return false;
   }
@@ -391,8 +393,10 @@ class kolab_driver extends calendar_driver
    */
   public function resize_event($event)
   {
-    if (($storage = $this->calendars[$event['calendar']]) && ($ev = $storage->get_event($event['id'])))
+    if (($storage = $this->calendars[$event['calendar']]) && ($ev = $storage->get_event($event['id']))) {
+      unset($ev['sequence']);
       return $this->update_event($event + $ev);
+    }
 
     return false;
   }
diff --git a/plugins/libkolab/lib/kolab_format_xcal.php b/plugins/libkolab/lib/kolab_format_xcal.php
index db817ff..fc40aef 100644
--- a/plugins/libkolab/lib/kolab_format_xcal.php
+++ b/plugins/libkolab/lib/kolab_format_xcal.php
@@ -224,7 +224,8 @@ abstract class kolab_format_xcal extends kolab_format
         parent::set($object);
 
         // increment sequence on updates
-        $object['sequence'] = !$is_new ? $this->obj->sequence()+1 : 0;
+        if (empty($object['sequence']))
+            $object['sequence'] = !$is_new ? $this->obj->sequence()+1 : 0;
         $this->obj->setSequence($object['sequence']);
 
         $this->obj->setSummary($object['title']);


commit b6e935bcb46c5d03aa1a957204a8c161ec20fc11
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 905b4ff..bda393b 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,8 +742,8 @@ 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'] && $existing['changed'] && $existing['changed'] >= $event['changed'])) {
-            $action = '';  // nothing to do here
+          if ($existing['sequence'] > $event['sequence'] || (!$event['sequence'] && $existing['changed'] && $existing['changed'] > $event['changed'])) {
+            $action = '';  // nothing to do here, outdated invitation
          }
         }
 
@@ -748,6 +752,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 fb776c8..c60c89a 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