2 commits - plugins/calendar

Thomas Brüderli bruederli at kolabsys.com
Thu Oct 18 22:02:41 CEST 2012


 plugins/calendar/calendar.php                         |    2 +-
 plugins/calendar/drivers/database/database_driver.php |   10 +++++++---
 plugins/calendar/drivers/database/sql/mysql.sql       |    1 +
 plugins/calendar/drivers/database/sql/postgresql.sql  |    1 +
 plugins/calendar/drivers/database/sql/sqlite.sql      |    1 +
 5 files changed, 11 insertions(+), 4 deletions(-)

New commits:
commit 8ec81e2879a6592fdddfa11e081783e88eddd81f
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Thu Oct 18 22:02:29 2012 +0200

    Store event sequence numbers in database driver

diff --git a/plugins/calendar/drivers/database/database_driver.php b/plugins/calendar/drivers/database/database_driver.php
index e3d9d51..f136b00 100644
--- a/plugins/calendar/drivers/database/database_driver.php
+++ b/plugins/calendar/drivers/database/database_driver.php
@@ -277,6 +277,10 @@ class database_driver extends calendar_driver
       $update_recurring = true;
       $old = $this->get_event($event);
       
+      // increment sequence number
+      if ($old['sequence'])
+        $event['sequence'] = max($event['sequence'], $old['sequence']+1);
+      
       // modify a recurring event, check submitted savemode to do the right things
       if ($old['recurrence'] || $old['recurrence_id']) {
         $master = $old['recurrence_id'] ? $this->get_event(array('id' => $old['recurrence_id'])) : $old;
@@ -431,7 +435,7 @@ class database_driver extends calendar_driver
   {
     $event = $this->_save_preprocess($event);
     $sql_set = array();
-    $set_cols = array('start', 'end', 'all_day', 'recurrence_id', 'title', 'description', 'location', 'categories', 'free_busy', 'priority', 'sensitivity', 'attendees', 'alarms', 'notifyat');
+    $set_cols = array('start', 'end', 'all_day', 'recurrence_id', 'sequence', 'title', 'description', 'location', 'categories', 'free_busy', 'priority', 'sensitivity', 'attendees', 'alarms', 'notifyat');
     foreach ($set_cols as $col) {
       if (is_object($event[$col]) && is_a($event[$col], 'DateTime'))
         $sql_set[] = $this->rc->db->quote_identifier($col) . '=' . $this->rc->db->quote($event[$col]->format(self::DB_DATE_FORMAT));
@@ -650,8 +654,8 @@ class database_driver extends calendar_driver
   public function get_event($event, $writeable = null)
   {
     $id = is_array($event) ? ($event['id'] ? $event['id'] : $event['uid']) : $event;
-    $col = $event['id'] && is_numeric($event['id']) ? 'event_id' : 'uid';
-    
+    $col = is_array($event) && is_numeric($id) ? 'event_id' : 'uid';
+
     if ($this->cache[$id])
       return $this->cache[$id];
     
diff --git a/plugins/calendar/drivers/database/sql/mysql.sql b/plugins/calendar/drivers/database/sql/mysql.sql
index d7887a9..e39acf4 100644
--- a/plugins/calendar/drivers/database/sql/mysql.sql
+++ b/plugins/calendar/drivers/database/sql/mysql.sql
@@ -31,6 +31,7 @@ CREATE TABLE `events` (
   `uid` varchar(255) NOT NULL DEFAULT '',
   `created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
   `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
+  `sequence` int(1) UNSIGNED NOT NULL DEFAULT '0',
   `start` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
   `end` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
   `recurrence` varchar(255) DEFAULT NULL,
diff --git a/plugins/calendar/drivers/database/sql/postgresql.sql b/plugins/calendar/drivers/database/sql/postgresql.sql
index c8f385e..cff741b 100644
--- a/plugins/calendar/drivers/database/sql/postgresql.sql
+++ b/plugins/calendar/drivers/database/sql/postgresql.sql
@@ -47,6 +47,7 @@ CREATE TABLE events (
     uid varchar(255) NOT NULL DEFAULT '',
     created timestamp without time zone DEFAULT now() NOT NULL,
     changed timestamp without time zone DEFAULT now(),
+    sequence integer NOT NULL DEFAULT 0,
     "start" timestamp without time zone DEFAULT now() NOT NULL,
     "end" timestamp without time zone DEFAULT now() NOT NULL,
     recurrence varchar(255) DEFAULT NULL,
diff --git a/plugins/calendar/drivers/database/sql/sqlite.sql b/plugins/calendar/drivers/database/sql/sqlite.sql
index c89de5e..1debe54 100644
--- a/plugins/calendar/drivers/database/sql/sqlite.sql
+++ b/plugins/calendar/drivers/database/sql/sqlite.sql
@@ -30,6 +30,7 @@ CREATE TABLE events (
   uid varchar(255) NOT NULL default '',
   created datetime NOT NULL default '1000-01-01 00:00:00',
   changed datetime NOT NULL default '1000-01-01 00:00:00',
+  sequence integer NOT NULL default '0',
   start datetime NOT NULL default '1000-01-01 00:00:00',
   end datetime NOT NULL default '1000-01-01 00:00:00',
   recurrence varchar(255) default NULL,


commit 6e018d536c44525f58df68651fef6d36a51fbd58
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Thu Oct 18 22:02:04 2012 +0200

    Fix check for updated events

diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php
index d82971b..24ab592 100644
--- a/plugins/calendar/calendar.php
+++ b/plugins/calendar/calendar.php
@@ -735,7 +735,7 @@ 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'])) {
+          if ($existing['sequence'] >= $event['sequence'] || (!$event['sequence'] && $existing['changed'] && $existing['changed'] >= $event['changed'])) {
             $action = '';  // nothing to do here
          }
         }





More information about the commits mailing list