Store event sequence numbers in database driver
This commit is contained in:
parent
6e018d536c
commit
8ec81e2879
4 changed files with 10 additions and 3 deletions
|
@ -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];
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue