Changeset View
Changeset View
Standalone View
Standalone View
plugins/libkolab/lib/kolab_storage_cache_event.php
Show All 29 Lines | class kolab_storage_cache_event extends kolab_storage_cache | ||||
* Helper method to convert the given Kolab object into a dataset to be written to cache | * Helper method to convert the given Kolab object into a dataset to be written to cache | ||||
* | * | ||||
* @override | * @override | ||||
*/ | */ | ||||
protected function _serialize($object) | protected function _serialize($object) | ||||
{ | { | ||||
$sql_data = parent::_serialize($object); | $sql_data = parent::_serialize($object); | ||||
$sql_data['dtstart'] = $this->_convert_datetime($object['start']); | $sql_data['dtstart'] = $this->_convert_datetime($object['start'] ?? null); | ||||
$sql_data['dtend'] = $this->_convert_datetime($object['end']); | $sql_data['dtend'] = $this->_convert_datetime($object['end'] ?? null); | ||||
// extend date range for recurring events | // extend date range for recurring events | ||||
if ($object['recurrence']) { | if ($object['recurrence'] ?? null) { | ||||
$recurrence = new kolab_date_recurrence($object['_formatobj']); | $recurrence = new kolab_date_recurrence($object['_formatobj']); | ||||
$dtend = $recurrence->end() ?: new DateTime('now +100 years'); | $dtend = $recurrence->end() ?: new DateTime('now +100 years'); | ||||
$sql_data['dtend'] = $this->_convert_datetime($dtend); | $sql_data['dtend'] = $this->_convert_datetime($dtend); | ||||
} | } | ||||
// extend start/end dates to spawn all exceptions | // extend start/end dates to spawn all exceptions | ||||
if (is_array($object['exceptions'])) { | if (is_array($object['exceptions'] ?? null)) { | ||||
foreach ($object['exceptions'] as $exception) { | foreach ($object['exceptions'] as $exception) { | ||||
if ($exception['start'] instanceof DateTimeInterface) { | if (($exception['start'] ?? null) instanceof DateTimeInterface) { | ||||
$exstart = $this->_convert_datetime($exception['start']); | $exstart = $this->_convert_datetime($exception['start']); | ||||
if ($exstart < $sql_data['dtstart']) { | if ($exstart < $sql_data['dtstart']) { | ||||
$sql_data['dtstart'] = $exstart; | $sql_data['dtstart'] = $exstart; | ||||
} | } | ||||
} | } | ||||
if ($exception['end'] instanceof DateTimeInterface) { | if (($exception['end'] ?? null) instanceof DateTimeInterface) { | ||||
$exend = $this->_convert_datetime($exception['end']); | $exend = $this->_convert_datetime($exception['end']); | ||||
if ($exend > $sql_data['dtend']) { | if ($exend > $sql_data['dtend']) { | ||||
$sql_data['dtend'] = $exend; | $sql_data['dtend'] = $exend; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
return $sql_data; | return $sql_data; | ||||
} | } | ||||
} | } |