summaryrefslogtreecommitdiff
path: root/plugins/libkolab
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2015-02-15 15:33:39 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2015-02-15 15:33:39 (GMT)
commit12591358e600dd3b0ad91a8f29345354e34000ac (patch)
tree198cbc1f991cb359f6aae482c82101295eb7c0aa /plugins/libkolab
parentf09948eefe6b7b1d275bc6d5465c02e8c0dbe9c2 (diff)
downloadroundcubemail-plugins-kolab-12591358e600dd3b0ad91a8f29345354e34000ac.tar.gz
Consider a change in recurrence rule significant for rescheduling (#4366)
Diffstat (limited to 'plugins/libkolab')
-rw-r--r--plugins/libkolab/config.inc.php.dist2
-rw-r--r--plugins/libkolab/lib/kolab_format_event.php12
-rw-r--r--plugins/libkolab/lib/kolab_format_task.php10
-rw-r--r--plugins/libkolab/lib/kolab_format_xcal.php48
4 files changed, 59 insertions, 13 deletions
diff --git a/plugins/libkolab/config.inc.php.dist b/plugins/libkolab/config.inc.php.dist
index 6e4b613..3a8476c 100644
--- a/plugins/libkolab/config.inc.php.dist
+++ b/plugins/libkolab/config.inc.php.dist
@@ -41,7 +41,7 @@ $config['kolab_messages_cache_bypass'] = 0;
// These event properties contribute to a significant revision to the calendar component
// and if changed will increment the sequence number relevant for scheduling according to RFC 5545
-$config['kolab_event_scheduling_properties'] = array('start', 'end', 'allday', 'location', 'status', 'cancelled');
+$config['kolab_event_scheduling_properties'] = array('start', 'end', 'allday', 'recurrence', 'location', 'status', 'cancelled');
// These task properties contribute to a significant revision to the calendar component
// and if changed will increment the sequence number relevant for scheduling according to RFC 5545
diff --git a/plugins/libkolab/lib/kolab_format_event.php b/plugins/libkolab/lib/kolab_format_event.php
index bf17149..f3c52df 100644
--- a/plugins/libkolab/lib/kolab_format_event.php
+++ b/plugins/libkolab/lib/kolab_format_event.php
@@ -26,7 +26,7 @@ class kolab_format_event extends kolab_format_xcal
{
public $CTYPEv2 = 'application/x-vnd.kolab.event';
- public static $scheduling_properties = array('start', 'end', 'allday', 'location', 'status', 'cancelled');
+ public static $scheduling_properties = array('start', 'end', 'allday', 'recurrence', 'location', 'status', 'cancelled');
protected $objclass = 'Event';
protected $read_func = 'readEvent';
@@ -100,6 +100,7 @@ class kolab_format_event extends kolab_format_xcal
foreach((array)$object['recurrence']['EXCEPTIONS'] as $i => $exception) {
$exevent = new kolab_format_event;
$exevent->set(($compacted = $this->compact_exception($exception, $object))); // only save differing values
+ console('COMPACTED', $compacted);
// get value for recurrence-id
if (!empty($exception['recurrence_date']) && is_a($exception['recurrence_date'], 'DateTime')) {
@@ -274,4 +275,13 @@ class kolab_format_event extends kolab_format_xcal
return $exception;
}
+ /**
+ * Identify changes considered relevant for scheduling
+ *
+ * @see kolab_format_xcal::check_rescheduling()
+ */
+ public static function check_rescheduling($object, $old, $checks = null)
+ {
+ return parent::check_rescheduling($object, $old, $checks ?: self::$scheduling_properties);
+ }
}
diff --git a/plugins/libkolab/lib/kolab_format_task.php b/plugins/libkolab/lib/kolab_format_task.php
index ee0ca6a..2c0cda5 100644
--- a/plugins/libkolab/lib/kolab_format_task.php
+++ b/plugins/libkolab/lib/kolab_format_task.php
@@ -126,4 +126,14 @@ class kolab_format_task extends kolab_format_xcal
return $tags;
}
+
+ /**
+ * Identify changes considered relevant for scheduling
+ *
+ * @see kolab_format_xcal::check_rescheduling()
+ */
+ public static function check_rescheduling($object, $old, $checks = null)
+ {
+ return parent::check_rescheduling($object, $old, $checks ?: self::$scheduling_properties);
+ }
}
diff --git a/plugins/libkolab/lib/kolab_format_xcal.php b/plugins/libkolab/lib/kolab_format_xcal.php
index d0f89b6..8d751a6 100644
--- a/plugins/libkolab/lib/kolab_format_xcal.php
+++ b/plugins/libkolab/lib/kolab_format_xcal.php
@@ -321,17 +321,8 @@ abstract class kolab_format_xcal extends kolab_format
// increment sequence when updating properties relevant for scheduling.
// RFC 5545: "It is incremented [...] each time the Organizer makes a significant revision to the calendar component."
- foreach (self::$scheduling_properties as $prop) {
- $a = $old[$prop];
- $b = $object[$prop];
- if ($object['allday'] && ($prop == 'start' || $prop == 'end') && $a instanceof DateTime && $b instanceof DateTime) {
- $a = $a->format('Y-m-d');
- $b = $b->format('Y-m-d');
- }
- if ($a != $b) {
- $object['sequence']++;
- break;
- }
+ if (self::check_rescheduling($object, $old)) {
+ $object['sequence']++;
}
}
}
@@ -637,4 +628,39 @@ abstract class kolab_format_xcal extends kolab_format
return $tags;
}
+
+ /**
+ * Identify changes considered relevant for scheduling
+ *
+ * @param array Hash array with NEW object properties
+ * @param array Hash array with OLD object properties
+ * @param array List of object properties to check for changes
+ *
+ * @return boolean True if changes affect scheduling, False otherwise
+ */
+ public static function check_rescheduling($object, $old, $checks = null)
+ {
+ $reschedule = false;
+
+ foreach ($checks ?: self::$scheduling_properties as $prop) {
+ $a = $old[$prop];
+ $b = $object[$prop];
+ if ($object['allday'] && ($prop == 'start' || $prop == 'end') && $a instanceof DateTime && $b instanceof DateTime) {
+ $a = $a->format('Y-m-d');
+ $b = $b->format('Y-m-d');
+ }
+ if ($prop == 'recurrence') {
+ unset($a['EXCEPTIONS']);
+ unset($b['EXCEPTIONS']);
+ $a = array_filter($a);
+ $b = array_filter($b);
+ }
+ if ($a != $b) {
+ $reschedule = true;
+ break;
+ }
+ }
+
+ return $reschedule;
+ }
} \ No newline at end of file