Use the right list of properties relevenat for scheduling (follow-up of commit 12591358). Static vars don't work here as intended

This commit is contained in:
Thomas Bruederli 2015-02-15 17:10:22 +01:00
parent 12591358e6
commit d564e23aa3
4 changed files with 24 additions and 24 deletions

View file

@ -1041,7 +1041,8 @@ class kolab_driver extends calendar_driver
} }
// iterate through the list of properties considered 'significant' for scheduling // 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) // reset all attendee status to needs-action (#4360)
if ($update && $reschedule && is_array($event['attendees'])) { if ($update && $reschedule && is_array($event['attendees'])) {

View file

@ -44,6 +44,9 @@ class kolab_format_event extends kolab_format_xcal
$this->obj = $data; $this->obj = $data;
$this->loaded = true; $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; 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);
}
} }

View file

@ -32,6 +32,16 @@ class kolab_format_task extends kolab_format_xcal
protected $read_func = 'readTodo'; protected $read_func = 'readTodo';
protected $write_func = 'writeTodo'; 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 * Set properties to the kolabformat object
@ -127,13 +137,4 @@ class kolab_format_task extends kolab_format_xcal
return $tags; 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);
}
} }

View file

@ -32,6 +32,8 @@ abstract class kolab_format_xcal extends kolab_format
public static $scheduling_properties = array('start', 'end', 'location'); public static $scheduling_properties = array('start', 'end', 'location');
protected $_scheduling_properties = null;
protected $sensitivity_map = array( protected $sensitivity_map = array(
'public' => kolabformat::ClassPublic, 'public' => kolabformat::ClassPublic,
'private' => kolabformat::ClassPrivate, 'private' => kolabformat::ClassPrivate,
@ -317,11 +319,10 @@ abstract class kolab_format_xcal extends kolab_format
} }
else { else {
$object['sequence'] = $old_sequence; $object['sequence'] = $old_sequence;
$old = $this->data['uid'] ? $this->data : $this->to_array();
// increment sequence when updating properties relevant for scheduling. // 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." // 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']++; $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 NEW object properties
* @param array Hash array with OLD 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 * @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; $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]; $a = $old[$prop];
$b = $object[$prop]; $b = $object[$prop];
if ($object['allday'] && ($prop == 'start' || $prop == 'end') && $a instanceof DateTime && $b instanceof DateTime) { if ($object['allday'] && ($prop == 'start' || $prop == 'end') && $a instanceof DateTime && $b instanceof DateTime) {