From d564e23aa345ce67c7c8cabca1a324628a94fcba Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Sun, 15 Feb 2015 17:10:22 +0100 Subject: [PATCH] Use the right list of properties relevenat for scheduling (follow-up of commit 12591358). Static vars don't work here as intended --- .../calendar/drivers/kolab/kolab_driver.php | 3 ++- plugins/libkolab/lib/kolab_format_event.php | 12 +++--------- plugins/libkolab/lib/kolab_format_task.php | 19 ++++++++++--------- plugins/libkolab/lib/kolab_format_xcal.php | 14 +++++++++----- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/plugins/calendar/drivers/kolab/kolab_driver.php b/plugins/calendar/drivers/kolab/kolab_driver.php index 815f51ee..d4a3436a 100644 --- a/plugins/calendar/drivers/kolab/kolab_driver.php +++ b/plugins/calendar/drivers/kolab/kolab_driver.php @@ -1041,7 +1041,8 @@ class kolab_driver extends calendar_driver } // iterate through the list of properties considered 'significant' for scheduling - $reschedule = kolab_format_event::check_rescheduling($event, $old); + $kolab_event = $old['_formatobj'] ?: new kolab_format_event(); + $reschedule = $kolab_event->check_rescheduling($event, $old); // reset all attendee status to needs-action (#4360) if ($update && $reschedule && is_array($event['attendees'])) { diff --git a/plugins/libkolab/lib/kolab_format_event.php b/plugins/libkolab/lib/kolab_format_event.php index f3c52df8..fe10f9d6 100644 --- a/plugins/libkolab/lib/kolab_format_event.php +++ b/plugins/libkolab/lib/kolab_format_event.php @@ -44,6 +44,9 @@ class kolab_format_event extends kolab_format_xcal $this->obj = $data; $this->loaded = true; } + + // copy static property overriden by this class + $this->_scheduling_properties = self::$scheduling_properties; } /** @@ -275,13 +278,4 @@ 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 2c0cda5e..d3ddfe93 100644 --- a/plugins/libkolab/lib/kolab_format_task.php +++ b/plugins/libkolab/lib/kolab_format_task.php @@ -32,6 +32,16 @@ class kolab_format_task extends kolab_format_xcal protected $read_func = 'readTodo'; protected $write_func = 'writeTodo'; + /** + * Default constructor + */ + function __construct($data = null, $version = 3.0) + { + parent::__construct(is_string($data) ? $data : null, $version); + + // copy static property overriden by this class + $this->_scheduling_properties = self::$scheduling_properties; + } /** * Set properties to the kolabformat object @@ -127,13 +137,4 @@ 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 8d751a6a..6d49ad18 100644 --- a/plugins/libkolab/lib/kolab_format_xcal.php +++ b/plugins/libkolab/lib/kolab_format_xcal.php @@ -32,6 +32,8 @@ abstract class kolab_format_xcal extends kolab_format public static $scheduling_properties = array('start', 'end', 'location'); + protected $_scheduling_properties = null; + protected $sensitivity_map = array( 'public' => kolabformat::ClassPublic, 'private' => kolabformat::ClassPrivate, @@ -317,11 +319,10 @@ abstract class kolab_format_xcal extends kolab_format } else { $object['sequence'] = $old_sequence; - $old = $this->data['uid'] ? $this->data : $this->to_array(); // 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." - if (self::check_rescheduling($object, $old)) { + if ($this->check_rescheduling($object)) { $object['sequence']++; } } @@ -634,15 +635,18 @@ abstract class kolab_format_xcal extends kolab_format * * @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) + public function check_rescheduling($object, $old = null) { $reschedule = false; - foreach ($checks ?: self::$scheduling_properties as $prop) { + if (!is_array($old)) { + $old = $this->data['uid'] ? $this->data : $this->to_array(); + } + + foreach ($this->_scheduling_properties ?: self::$scheduling_properties as $prop) { $a = $old[$prop]; $b = $object[$prop]; if ($object['allday'] && ($prop == 'start' || $prop == 'end') && $a instanceof DateTime && $b instanceof DateTime) {