summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2012-10-18 20:02:29 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2012-10-18 20:02:29 (GMT)
commit8ec81e2879a6592fdddfa11e081783e88eddd81f (patch)
treed04bed7701419b106183297cc38801215c0c0e3c
parent6e018d536c44525f58df68651fef6d36a51fbd58 (diff)
downloadroundcubemail-plugins-kolab-8ec81e2879a6592fdddfa11e081783e88eddd81f.tar.gz
Store event sequence numbers in database driver
-rw-r--r--plugins/calendar/drivers/database/database_driver.php10
-rw-r--r--plugins/calendar/drivers/database/sql/mysql.sql1
-rw-r--r--plugins/calendar/drivers/database/sql/postgresql.sql1
-rw-r--r--plugins/calendar/drivers/database/sql/sqlite.sql1
4 files changed, 10 insertions, 3 deletions
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,