diff --git a/plugins/libcalendaring/composer.json b/plugins/libcalendaring/composer.json --- a/plugins/libcalendaring/composer.json +++ b/plugins/libcalendaring/composer.json @@ -24,8 +24,8 @@ } ], "require": { - "php": ">=5.4.0", + "php": ">=5.5", "roundcube/plugin-installer": ">=0.1.3", - "sabre/vobject": "~3.5.3" + "sabre/vobject": "~4.3.5" } } diff --git a/plugins/libcalendaring/lib/Horde_Date.php b/plugins/libcalendaring/lib/Horde_Date.php --- a/plugins/libcalendaring/lib/Horde_Date.php +++ b/plugins/libcalendaring/lib/Horde_Date.php @@ -1096,7 +1096,7 @@ protected function _initializeFromObject($date) { - if ($date instanceof DateTime) { + if ($date instanceof DateTime || $date instanceof DateTimeImmutable) { $this->_year = (int)$date->format('Y'); $this->_month = (int)$date->format('m'); $this->_mday = (int)$date->format('d'); diff --git a/plugins/libcalendaring/lib/Horde_Date_Recurrence.php b/plugins/libcalendaring/lib/Horde_Date_Recurrence.php --- a/plugins/libcalendaring/lib/Horde_Date_Recurrence.php +++ b/plugins/libcalendaring/lib/Horde_Date_Recurrence.php @@ -1565,7 +1565,7 @@ // Exceptions. if (isset($hash['exclusion'])) { foreach ($hash['exclusion'] as $exception) { - if ($exception instanceof DateTime) { + if ($exception instanceof DateTime || $exception instanceof DateTimeImmutable) { $this->exceptions[] = $exception->format('Ymd'); } } @@ -1573,7 +1573,7 @@ if (isset($hash['complete'])) { foreach ($hash['complete'] as $completion) { - if ($exception instanceof DateTime) { + if ($exception instanceof DateTime || $exception instanceof DateTimeImmutable) { $this->completions[] = $completion->format('Ymd'); } } diff --git a/plugins/libcalendaring/lib/libcalendaring_itip.php b/plugins/libcalendaring/lib/libcalendaring_itip.php --- a/plugins/libcalendaring/lib/libcalendaring_itip.php +++ b/plugins/libcalendaring/lib/libcalendaring_itip.php @@ -467,7 +467,7 @@ if ($key == 'allday') { $event[$key] = $event[$key] == 'true'; } - $value = $existing[$key] instanceof DateTime ? $existing[$key]->format('c') : $existing[$key]; + $value = ($existing[$key] instanceof DateTime || $existing[$key] instanceof DateTimeImmutable) ? $existing[$key]->format('c') : $existing[$key]; $num++; $got += intval($value == $event[$key]); } @@ -683,7 +683,7 @@ // For replies we need more metadata foreach (array('start', 'end', 'due', 'allday', 'recurrence', 'location') as $key) { if (isset($event[$key])) { - $metadata[$key] = $event[$key] instanceof DateTime ? $event[$key]->format('c') : $event[$key]; + $metadata[$key] = ($event[$key] instanceof DateTime || $event[$key] instanceof DateTimeImmutable) ? $event[$key]->format('c') : $event[$key]; } } } diff --git a/plugins/libcalendaring/lib/libcalendaring_recurrence.php b/plugins/libcalendaring/lib/libcalendaring_recurrence.php --- a/plugins/libcalendaring/lib/libcalendaring_recurrence.php +++ b/plugins/libcalendaring/lib/libcalendaring_recurrence.php @@ -127,14 +127,14 @@ public function end() { // recurrence end date is given - if ($this->recurrence['UNTIL'] instanceof DateTime) { + if ($this->recurrence['UNTIL'] instanceof DateTime || $this->recurrence['UNTIL'] instanceof DateTimeImmutable) { return $this->recurrence['UNTIL']; } // take the last RDATE entry if set if (is_array($this->recurrence['RDATE']) && !empty($this->recurrence['RDATE'])) { $last = end($this->recurrence['RDATE']); - if ($last instanceof DateTime) { + if ($last instanceof DateTime || $last instanceof DateTimeImmutable) { return $last; } } diff --git a/plugins/libcalendaring/libcalendaring.php b/plugins/libcalendaring/libcalendaring.php --- a/plugins/libcalendaring/libcalendaring.php +++ b/plugins/libcalendaring/libcalendaring.php @@ -194,7 +194,7 @@ $dt = rcube_utils::anytodatetime($dt); } - if ($dt instanceof DateTime && empty($dt->_dateonly) && !$dateonly) { + if (($dt instanceof DateTime || $dt instanceof DateTimeImmutable) && empty($dt->_dateonly) && !$dateonly) { $dt->setTimezone($this->timezone); } @@ -499,7 +499,7 @@ public static function to_client_alarms($valarms) { return array_map(function($alarm){ - if ($alarm['trigger'] instanceof DateTime) { + if ($alarm['trigger'] instanceof DateTime || $alarm['trigger'] instanceof DateTimeImmutable) { $alarm['trigger'] = '@' . $alarm['trigger']->format('U'); } else if ($trigger = libcalendaring::parse_alarm_value($alarm['trigger'])) { @@ -577,7 +577,7 @@ break; } - if ($trigger instanceof DateTime) { + if ($trigger instanceof DateTime || $trigger instanceof DateTimeImmutable) { $text .= ' ' . $rcube->gettext(array( 'name' => 'libcalendaring.alarmat', 'vars' => array('datetime' => $rcube->format_date($trigger)) @@ -657,7 +657,7 @@ foreach ($rec['valarms'] as $alarm) { $notify_time = null; - if ($alarm['trigger'] instanceof DateTime) { + if ($alarm['trigger'] instanceof DateTime || $alarm['trigger'] instanceof DateTimeImmutable) { $notify_time = $alarm['trigger']; } else if (is_string($alarm['trigger'])) { @@ -1183,7 +1183,7 @@ * @param string Message part ID and object index (e.g. '1.2:0') * @param string Object type filter (optional) * - * @return array Hash array with the parsed iCal + * @return array Hash array with the parsed iCal */ public function mail_get_itip_object($mbox, $uid, $mime_id, $type = null) { @@ -1309,7 +1309,7 @@ { $instance_date = !empty($event['recurrence_date']) ? $event['recurrence_date'] : $event['start']; - if ($instance_date instanceof DateTime) { + if ($instance_date instanceof DateTime || $instance_date instanceof DateTimeImmutable) { // According to RFC5545 (3.8.4.4) RECURRENCE-ID format should // be date/date-time depending on the main event type, not the exception if ($allday === null) { diff --git a/plugins/libcalendaring/libvcalendar.php b/plugins/libcalendaring/libvcalendar.php --- a/plugins/libcalendaring/libvcalendar.php +++ b/plugins/libcalendaring/libvcalendar.php @@ -149,7 +149,7 @@ } } - $vobject = VObject\Reader::read($vcal, VObject\Reader::OPTION_FORGIVING | VObject\Reader::OPTION_IGNORE_INVALID_LINES); + $vobject = Sabre\VObject\Reader::read($vcal, Sabre\VObject\Reader::OPTION_FORGIVING | Sabre\VObject\Reader::OPTION_IGNORE_INVALID_LINES); if ($vobject) return $this->import_from_vobject($vobject); } @@ -247,7 +247,7 @@ } catch (Exception $e) { if ($this->forward_exceptions) { - throw new VObject\ParseException($e->getMessage() . " in\n" . $buffer); + throw new Sabre\VObject\ParseException($e->getMessage() . " in\n" . $buffer); } else { // write the failing section to error log @@ -421,8 +421,8 @@ } // map other attributes to internal fields - foreach ($ve->children as $prop) { - if (!($prop instanceof VObject\Property)) + foreach ($ve->children() as $prop) { + if (!($prop instanceof Sabre\VObject\Property)) continue; $value = strval($prop); @@ -645,7 +645,7 @@ $trigger = null; $alarm = array(); - foreach ($valarm->children as $prop) { + foreach ($valarm->children() as $prop) { $value = strval($prop); switch ($prop->name) { @@ -713,14 +713,14 @@ } // assign current timezone to event start/end - if (!empty($event['start']) && $event['start'] instanceof DateTime) { + if (!empty($event['start']) && ($event['start'] instanceof DateTime || $event['start'] instanceof DateTimeImmutable)) { $this->_apply_timezone($event['start']); } else { unset($event['start']); } - if (!empty($event['end']) && $event['end'] instanceof DateTime) { + if (!empty($event['end']) && ($event['end'] instanceof DateTimeImmutable || $event['end'] instanceof DateTimeImmutable)) { $this->_apply_timezone($event['end']); } else { @@ -740,7 +740,7 @@ // minimal validation if (empty($event['uid']) || ($event['_type'] == 'event' && empty($event['start']) != empty($event['end']))) { - throw new VObject\ParseException('Object validation failed: missing mandatory object properties'); + throw new Sabre\VObject\ParseException('Object validation failed: missing mandatory object properties'); } return $event; @@ -775,8 +775,8 @@ $this->freebusy = array('_type' => 'freebusy', 'periods' => array()); $seen = array(); - foreach ($ve->children as $prop) { - if (!($prop instanceof VObject\Property)) + foreach ($ve->children() as $prop) { + if (!($prop instanceof Sabre\VObject\Property)) continue; $value = strval($prop); @@ -864,7 +864,7 @@ if (empty($prop)) { return $as_array ? array() : null; } - else if ($prop instanceof VObject\Property\iCalendar\DateTime) { + else if ($prop instanceof Sabre\VObject\Property\iCalendar\DateTime) { if (count($prop->getDateTimes()) > 1) { $dt = array(); $dateonly = !$prop->hasTime(); @@ -880,7 +880,7 @@ } } } - else if ($prop instanceof VObject\Property\iCalendar\Period) { + else if ($prop instanceof Sabre\VObject\Property\iCalendar\Period) { $dt = array(); foreach ($prop->getParts() as $val) { try { @@ -903,7 +903,7 @@ } } } - else if ($prop instanceof \DateTime) { + else if ($prop instanceof \DateTime || $prop instanceof \DateTimeImmutable) { $dt = $prop; } @@ -1000,7 +1000,7 @@ $this->method = $method; // encapsulate in VCALENDAR container - $vcal = new VObject\Component\VCalendar(); + $vcal = new Sabre\VObject\Component\VCalendar(); $vcal->VERSION = '2.0'; $vcal->PRODID = $this->prodid; $vcal->CALSCALE = 'GREGORIAN'; @@ -1056,7 +1056,7 @@ { $type = !empty($event['_type']) ? $event['_type'] : 'event'; - $cal = $vcal ?: new VObject\Component\VCalendar(); + $cal = $vcal ?: new Sabre\VObject\Component\VCalendar(); $ve = $cal->create($this->type_component_map[$type]); $ve->UID = $event['uid']; @@ -1087,7 +1087,7 @@ } // we're exporting a recurrence instance only - if (!$recurrence_id && !empty($event['recurrence_date']) && $event['recurrence_date'] instanceof DateTime) { + if (!$recurrence_id && !empty($event['recurrence_date']) && ($event['recurrence_date'] instanceof DateTime || $event['recurrence_date'] instanceof DateTimeImmutable)) { $recurrence_id = $this->datetime_prop($cal, 'RECURRENCE-ID', $event['recurrence_date'], false, !empty($event['allday'])); if (!empty($event['thisandfuture'])) { $recurrence_id->add('RANGE', 'THISANDFUTURE'); @@ -1129,7 +1129,7 @@ // add EXDATEs each one per line (for Thunderbird Lightning) if (is_array($exdates)) { foreach ($exdates as $exdate) { - if ($exdate instanceof DateTime) { + if ($exdate instanceof DateTime || $exdate instanceof DateTimeImmutable) { $ve->add($this->datetime_prop($cal, 'EXDATE', $exdate)); } } @@ -1194,7 +1194,7 @@ foreach ($event['valarms'] as $alarm) { $va = $cal->createComponent('VALARM'); $va->action = $alarm['action']; - if ($alarm['trigger'] instanceof DateTime) { + if ($alarm['trigger'] instanceof DateTime || $alarm['trigger'] instanceof DateTimeImmutable) { $va->add($this->datetime_prop($cal, 'TRIGGER', $alarm['trigger'], true, null, true)); } else { @@ -1236,7 +1236,7 @@ if (!empty($val[3])) { $va->add('TRIGGER', $val[3]); } - else if ($val[0] instanceof DateTime) { + else if ($val[0] instanceof DateTime || $val[0] instanceof DateTimeImmutable) { $va->add($this->datetime_prop($cal, 'TRIGGER', $val[0], true, null, true)); } $ve->add($va); @@ -1384,7 +1384,7 @@ if (!$from) $from = time(); if (!$to) $to = $from; - if (!$cal) $cal = new VObject\Component\VCalendar(); + if (!$cal) $cal = new Sabre\VObject\Component\VCalendar(); if (is_string($tzid)) { try { @@ -1512,7 +1512,7 @@ * Override Sabre\VObject\Property\Text that quotes commas in the location property * because Apple clients treat that property as list. */ -class vobject_location_property extends VObject\Property\Text +class vobject_location_property extends Sabre\VObject\Property\Text { /** * List of properties that are considered 'structured'.