Changeset View
Changeset View
Standalone View
Standalone View
plugins/libkolab/lib/kolab_format_event.php
Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | public function set(&$object) | ||||
// do the hard work of setting object values | // do the hard work of setting object values | ||||
$this->obj->setStart(self::get_datetime($object['start'], null, $object['allday'])); | $this->obj->setStart(self::get_datetime($object['start'], null, $object['allday'])); | ||||
$this->obj->setEnd(self::get_datetime($object['end'], null, $object['allday'])); | $this->obj->setEnd(self::get_datetime($object['end'], null, $object['allday'])); | ||||
$this->obj->setTransparency($object['free_busy'] == 'free'); | $this->obj->setTransparency($object['free_busy'] == 'free'); | ||||
$status = kolabformat::StatusUndefined; | $status = kolabformat::StatusUndefined; | ||||
if ($object['free_busy'] == 'tentative') | if ($object['free_busy'] == 'tentative') | ||||
$status = kolabformat::StatusTentative; | $status = kolabformat::StatusTentative; | ||||
if ($object['cancelled']) | if ($object['cancelled'] ?? false) | ||||
$status = kolabformat::StatusCancelled; | $status = kolabformat::StatusCancelled; | ||||
else if ($object['status'] && array_key_exists($object['status'], $this->status_map)) | else if ($object['status'] && array_key_exists($object['status'], $this->status_map)) | ||||
$status = $this->status_map[$object['status']]; | $status = $this->status_map[$object['status']]; | ||||
$this->obj->setStatus($status); | $this->obj->setStatus($status); | ||||
// save (recurrence) exceptions | // save (recurrence) exceptions | ||||
if (is_array($object['recurrence']) && is_array($object['recurrence']['EXCEPTIONS']) && !isset($object['exceptions'])) { | if (is_array($object['recurrence'] ?? null) && is_array($object['recurrence']['EXCEPTIONS'] ?? null) && !isset($object['exceptions'])) { | ||||
$object['exceptions'] = $object['recurrence']['EXCEPTIONS']; | $object['exceptions'] = $object['recurrence']['EXCEPTIONS']; | ||||
} | } | ||||
if (is_array($object['exceptions'])) { | if (is_array($object['exceptions'] ?? null)) { | ||||
$recurrence_id_format = libkolab::recurrence_id_format($object); | $recurrence_id_format = libkolab::recurrence_id_format($object); | ||||
$vexceptions = new vectorevent; | $vexceptions = new vectorevent; | ||||
foreach ($object['exceptions'] as $i => $exception) { | foreach ($object['exceptions'] as $i => $exception) { | ||||
$exevent = new kolab_format_event; | $exevent = new kolab_format_event; | ||||
$exevent->set($compacted = $this->compact_exception($exception, $object)); // only save differing values | $exevent->set($compacted = $this->compact_exception($exception, $object)); // only save differing values | ||||
// get value for recurrence-id | // get value for recurrence-id | ||||
$recurrence_id = null; | $recurrence_id = null; | ||||
Show All 12 Lines | public function set(&$object) | ||||
// write cleaned-up exception data back to memory/cache | // write cleaned-up exception data back to memory/cache | ||||
$object['exceptions'][$i] = $this->expand_exception($exevent->data, $object); | $object['exceptions'][$i] = $this->expand_exception($exevent->data, $object); | ||||
$object['exceptions'][$i]['_instance'] = $compacted['_instance']; | $object['exceptions'][$i]['_instance'] = $compacted['_instance']; | ||||
} | } | ||||
$this->obj->setExceptions($vexceptions); | $this->obj->setExceptions($vexceptions); | ||||
// link with recurrence.EXCEPTIONS for compatibility | // link with recurrence.EXCEPTIONS for compatibility | ||||
if (is_array($object['recurrence'])) { | if (is_array($object['recurrence'] ?? null)) { | ||||
$object['recurrence']['EXCEPTIONS'] = &$object['exceptions']; | $object['recurrence']['EXCEPTIONS'] = &$object['exceptions']; | ||||
} | } | ||||
} | } | ||||
if ($object['recurrence_date'] && $object['recurrence_date'] instanceof DateTimeInterface) { | if (($object['recurrence_date'] ?? false) && $object['recurrence_date'] instanceof DateTimeInterface) { | ||||
if ($object['recurrence']) { | if ($object['recurrence'] ?? false) { | ||||
// unset recurrence_date for master events with rrule | // unset recurrence_date for master events with rrule | ||||
$object['recurrence_date'] = null; | $object['recurrence_date'] = null; | ||||
} | } | ||||
$this->obj->setRecurrenceID(self::get_datetime($object['recurrence_date'], null, $object['allday']), (bool)$object['thisandfuture']); | $this->obj->setRecurrenceID(self::get_datetime($object['recurrence_date'], null, $object['allday']), (bool)$object['thisandfuture']); | ||||
} | } | ||||
// cache this data | // cache this data | ||||
$this->data = $object; | $this->data = $object; | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | public function to_array($data = array()) | ||||
$exdata['_instance'] = $recurrence_id->format($recurrence_id_format); | $exdata['_instance'] = $recurrence_id->format($recurrence_id_format); | ||||
$recurrence_exceptions[] = $this->expand_exception($exdata, $object); | $recurrence_exceptions[] = $this->expand_exception($exdata, $object); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
$object['exceptions'] = $recurrence_exceptions; | $object['exceptions'] = $recurrence_exceptions; | ||||
// also link with recurrence.EXCEPTIONS for compatibility | // also link with recurrence.EXCEPTIONS for compatibility | ||||
if (is_array($object['recurrence'])) { | if (is_array($object['recurrence'] ?? null)) { | ||||
$object['recurrence']['EXCEPTIONS'] = &$object['exceptions']; | $object['recurrence']['EXCEPTIONS'] = &$object['exceptions']; | ||||
} | } | ||||
} | } | ||||
return $this->data = $object; | return $this->data = $object; | ||||
} | } | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines |