summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2013-06-24 11:02:50 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2013-06-24 11:02:50 (GMT)
commit2880b3526afd15983b829c2d1e40a5b90d91b34d (patch)
tree9368ab99d95008feb2eb574f0b981f952848e5ea /plugins
parent8ea287e37f46f7ebd51c7dafdf6ad8693a0fd801 (diff)
downloadroundcubemail-plugins-kolab-2880b3526afd15983b829c2d1e40a5b90d91b34d.tar.gz
Revert "Save changes in a recurring event as exception to the master event"
This reverts commit 29a8a9ae4dd21fd84890ff0f9d2b445ea37a702a. Conflicts: plugins/calendar/drivers/kolab/kolab_calendar.php plugins/calendar/drivers/kolab/kolab_driver.php plugins/libkolab/lib/kolab_format_event.php
Diffstat (limited to 'plugins')
-rw-r--r--plugins/calendar/calendar.php3
-rw-r--r--plugins/calendar/drivers/calendar_driver.php1
-rw-r--r--plugins/calendar/drivers/kolab/kolab_calendar.php32
-rw-r--r--plugins/calendar/drivers/kolab/kolab_driver.php39
-rw-r--r--plugins/libkolab/lib/kolab_format_event.php91
-rw-r--r--plugins/libkolab/lib/kolab_format_xcal.php8
6 files changed, 27 insertions, 147 deletions
diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php
index d6cfbec..028b553 100644
--- a/plugins/calendar/calendar.php
+++ b/plugins/calendar/calendar.php
@@ -1091,7 +1091,6 @@ class calendar extends rcube_plugin
$event['recurrence_text'] = $this->_recurrence_text($event['recurrence']);
if ($event['recurrence']['UNTIL'])
$event['recurrence']['UNTIL'] = $this->lib->adjust_timezone($event['recurrence']['UNTIL'])->format('c');
- unset($event['recurrence']['EXCEPTIONS']);
}
foreach ((array)$event['attachments'] as $k => $attachment) {
@@ -1122,7 +1121,7 @@ class calendar extends rcube_plugin
'title' => strval($event['title']),
'description' => strval($event['description']),
'location' => strval($event['location']),
- 'className' => ($addcss ? 'fc-event-cal-'.asciiwords($event['calendar'], true).' ' : '') . 'fc-event-cat-' . asciiwords(strtolower(join('-', (array)$event['categories'])), true),
+ 'className' => ($addcss ? 'fc-event-cal-'.asciiwords($event['calendar'], true).' ' : '') . 'fc-event-cat-' . asciiwords(strtolower($event['categories']), true),
'allDay' => ($event['allday'] == 1),
) + $event;
}
diff --git a/plugins/calendar/drivers/calendar_driver.php b/plugins/calendar/drivers/calendar_driver.php
index a9402e1..ef3cdb1 100644
--- a/plugins/calendar/drivers/calendar_driver.php
+++ b/plugins/calendar/drivers/calendar_driver.php
@@ -46,7 +46,6 @@
* 'COUNT' => 1..n, // number of times
* // + more properties (see http://www.kanzaki.com/docs/ical/recur.html)
* 'EXDATE' => array(), // list of DateTime objects of exception Dates/Times
- * 'EXCEPTIONS' => array(<event>), list of event objects which denote exceptions in the recurrence chain
* ),
* 'recurrence_id' => 'ID of the recurrence group', // usually the ID of the starting event
* 'categories' => 'Event category',
diff --git a/plugins/calendar/drivers/kolab/kolab_calendar.php b/plugins/calendar/drivers/kolab/kolab_calendar.php
index da78a81..5b88b82 100644
--- a/plugins/calendar/drivers/kolab/kolab_calendar.php
+++ b/plugins/calendar/drivers/kolab/kolab_calendar.php
@@ -312,7 +312,7 @@ class kolab_calendar
* @return boolean True on success, False on error
*/
- public function update_event($event, $exception_id = null)
+ public function update_event($event)
{
$updated = false;
$old = $this->storage->get_object($event['id']);
@@ -333,11 +333,6 @@ class kolab_calendar
else {
$updated = true;
$this->events[$event['id']] = $this->_to_rcube_event($object);
-
- // refresh local cache with recurring instances
- if ($exception_id) {
- $this->_get_recurring_events($object, $event['start'], $event['end'], $exception_id);
- }
}
return $updated;
@@ -418,29 +413,6 @@ class kolab_calendar
$end->add(new DateInterval($intvl));
}
- // add recurrence exceptions to output
- $i = 0;
- $events = array();
- $exdates = array();
- if (is_array($event['recurrence']['EXCEPTIONS'])) {
- foreach ($event['recurrence']['EXCEPTIONS'] as $exception) {
- $rec_event = $this->_to_rcube_event($exception);
- $rec_event['id'] = $event['uid'] . '-' . ++$i;
- $rec_event['recurrence_id'] = $event['uid'];
- $rec_event['_instance'] = $i;
- $events[] = $rec_event;
-
- // found the specifically requested instance, exiting...
- if ($rec_event['id'] == $event_id) {
- $this->events[$rec_event['id']] = $rec_event;
- return $events;
- }
-
- // remember this exception's date
- $exdates[$rec_event['start']->format('Y-m-d')] = $rec_event['id'];
- }
- }
-
// use libkolab to compute recurring events
if (class_exists('kolabcalendaring')) {
$recurrence = new kolab_date_recurrence($object);
@@ -451,6 +423,8 @@ class kolab_calendar
$recurrence = new calendar_recurrence($this->cal, $event);
}
+ $i = 0;
+ $events = array();
while ($next_event = $recurrence->next_instance()) {
// skip if there's an exception at this date
if ($exdates[$next_event['start']->format('Y-m-d')])
diff --git a/plugins/calendar/drivers/kolab/kolab_driver.php b/plugins/calendar/drivers/kolab/kolab_driver.php
index 9b70018..fe9f25a 100644
--- a/plugins/calendar/drivers/kolab/kolab_driver.php
+++ b/plugins/calendar/drivers/kolab/kolab_driver.php
@@ -580,8 +580,6 @@ class kolab_driver extends calendar_driver
// keep saved exceptions (not submitted by the client)
if ($old['recurrence']['EXDATE'])
$event['recurrence']['EXDATE'] = $old['recurrence']['EXDATE'];
- if ($old['recurrence']['EXCEPTIONS'])
- $event['recurrence']['EXCEPTIONS'] = $old['recurrence']['EXCEPTIONS'];
switch ($savemode) {
case 'new':
@@ -599,11 +597,26 @@ class kolab_driver extends calendar_driver
break;
case 'current':
- // save as exception to master event
+ // modifying the first instance => just move to next occurence
+ if ($master['id'] == $event['id']) {
+ $recurring = reset($storage->_get_recurring_events($event, $event['start'], null, $event['id'].'-1'));
+ $master['start'] = $recurring['start'];
+ $master['end'] = $recurring['end'];
+ if ($master['recurrence']['COUNT'])
+ $master['recurrence']['COUNT']--;
+ }
+ else { // add exception to master event
+ $master['recurrence']['EXDATE'][] = $old['start'];
+ }
+
+ $storage->update_event($master);
+
+ // insert new event for this occurence
+ $event += $old;
$event['recurrence'] = array();
- $master['recurrence']['EXCEPTIONS'][] = $event;
-# $master['recurrence']['EXDATE'][] = $event['start'];
- $success = $storage->update_event($master);
+ unset($event['recurrence_id']);
+ $event['uid'] = $this->cal->generate_uid();
+ $success = $storage->insert_event($event);
break;
case 'future':
@@ -634,20 +647,6 @@ class kolab_driver extends calendar_driver
}
default: // 'all' is default
-
- // remove some internal properties which should not be saved
- unset($event['_savemode'], $event['_fromcalendar'], $event['_identity']);
-
- // save properties to a recurrence exception instance
- if ($old['recurrence_id']) {
- $i = $old['_instance'] - 1;
- if (!empty($master['recurrence']['EXCEPTIONS'][$i])) {
- $master['recurrence']['EXCEPTIONS'][$i] = $event;
- $success = $storage->update_event($master, $old['id']);
- break;
- }
- }
-
$event['id'] = $master['id'];
$event['uid'] = $master['uid'];
diff --git a/plugins/libkolab/lib/kolab_format_event.php b/plugins/libkolab/lib/kolab_format_event.php
index 933fbee..c9dc779 100644
--- a/plugins/libkolab/lib/kolab_format_event.php
+++ b/plugins/libkolab/lib/kolab_format_event.php
@@ -30,19 +30,6 @@ class kolab_format_event extends kolab_format_xcal
protected $read_func = 'readEvent';
protected $write_func = 'writeEvent';
- /**
- * Default constructor
- */
- function __construct($data = null, $version = 3.0)
- {
- parent::__construct(is_string($data) ? $data : null, $version);
-
- // got an Event object as argument
- if (is_object($data) && is_a($data, $this->objclass)) {
- $this->obj = $data;
- $this->loaded = true;
- }
- }
/**
* Clones into an instance of libcalendaring's extended EventCal class
@@ -108,18 +95,6 @@ class kolab_format_event extends kolab_format_xcal
$this->obj->setAttachments($vattach);
- // save recurrence exceptions
- if ($object['recurrence']['EXCEPTIONS']) {
- $vexceptions = new vectorevent;
- foreach((array)$object['recurrence']['EXCEPTIONS'] as $exception) {
- $exevent = new kolab_format_event;
- $exevent->set($this->compact_exception($exception, $object)); // only save differing values
- $exevent->obj->setRecurrenceID(self::get_datetime($exception['start'], null, true), false);
- $vexceptions->push($exevent->obj);
- }
- $this->obj->setExceptions($vexceptions);
- }
-
// cache this data
$this->data = $object;
unset($this->data['_formatobj']);
@@ -189,30 +164,6 @@ class kolab_format_event extends kolab_format_xcal
}
}
- // read exception event objects
- if ($exceptions = $this->obj->exceptions()) {
- for ($i=0; $i < $exceptions->size(); $i++) {
- if (($exobj = $exceptions->get($i))) {
- $exception = new kolab_format_event($exobj);
- if ($exception->is_valid()) {
- $object['recurrence']['EXCEPTIONS'][] = $this->expand_exception($exception->to_array(), $object);
- }
- }
- }
- }
-
- // merge with additional data, e.g. attachments from the message
- if ($data) {
- foreach ($data as $idx => $value) {
- if (is_array($value)) {
- $object[$idx] = array_merge((array)$object[$idx], $value);
- }
- else {
- $object[$idx] = $value;
- }
- }
- }
-
$this->data = $object;
return $this->data;
}
@@ -236,46 +187,4 @@ class kolab_format_event extends kolab_format_xcal
return $tags;
}
-
- /**
- * Reduce the exception container to attributes which differ from the master event
- */
- private function compact_exception($exception, $master)
- {
- static $mandatory = array('uid','created','start');
- static $forbidden = array('recurrence','attendees','sequence');
-
- $out = $exception;
- foreach ($exception as $prop => $val) {
- if (in_array($prop, $mandatory))
- continue;
-
- if (is_object($exception[$prop]) && is_a($exception[$prop], 'DateTime'))
- $equals = $exception[$prop] <> $master[$prop];
- else
- $equals = $exception[$prop] == $master[$prop];
-
- if ($equals || in_array($prop, $forbidden)) {
- unset($out[$prop]);
- }
- }
-
- return $exception;
- }
-
- /**
- * Copy attributes not specified by the exception from the master event
- */
- private function expand_exception($exception, $master)
- {
- static $forbidden = array('recurrence');
-
- foreach ($master as $prop => $value) {
- if (empty($exception[$prop]) && !in_array($prop, $forbidden))
- $exception[$prop] = $value;
- }
-
- return $exception;
- }
-
}
diff --git a/plugins/libkolab/lib/kolab_format_xcal.php b/plugins/libkolab/lib/kolab_format_xcal.php
index b37b727..e9a28e1 100644
--- a/plugins/libkolab/lib/kolab_format_xcal.php
+++ b/plugins/libkolab/lib/kolab_format_xcal.php
@@ -111,7 +111,7 @@ abstract class kolab_format_xcal extends kolab_format
);
// read organizer and attendees
- if (($organizer = $this->obj->organizer()) && ($organizer->email() || $organizer->name())) {
+ if ($organizer = $this->obj->organizer()) {
$object['organizer'] = array(
'email' => $organizer->email(),
'name' => $organizer->name(),
@@ -170,9 +170,9 @@ abstract class kolab_format_xcal extends kolab_format
$object['recurrence']['BYMONTH'] = join(',', self::vector2array($bymonth));
}
- if ($exdates = $this->obj->exceptionDates()) {
- for ($i=0; $i < $exdates->size(); $i++) {
- if ($exdate = self::php_datetime($exdates->get($i)))
+ if ($exceptions = $this->obj->exceptionDates()) {
+ for ($i=0; $i < $exceptions->size(); $i++) {
+ if ($exdate = self::php_datetime($exceptions->get($i)))
$object['recurrence']['EXDATE'][] = $exdate;
}
}