From 580c3f4ffe9608d2beb56d418c68b3b112420e76 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 10 Nov 2019 12:49:51 +0000 Subject: another bulk of composer updates (cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce) --- .../dav/lib/CalDAV/CalendarQueryValidator.php | 141 +++++++++------------ 1 file changed, 60 insertions(+), 81 deletions(-) (limited to 'vendor/sabre/dav/lib/CalDAV/CalendarQueryValidator.php') diff --git a/vendor/sabre/dav/lib/CalDAV/CalendarQueryValidator.php b/vendor/sabre/dav/lib/CalDAV/CalendarQueryValidator.php index df8008fe2..0e7f1307d 100644 --- a/vendor/sabre/dav/lib/CalDAV/CalendarQueryValidator.php +++ b/vendor/sabre/dav/lib/CalDAV/CalendarQueryValidator.php @@ -1,12 +1,14 @@ name !== $filters['name']) { @@ -40,8 +43,6 @@ class CalendarQueryValidator { return $this->validateCompFilters($vObject, $filters['comp-filters']) && $this->validatePropFilters($vObject, $filters['prop-filters']); - - } /** @@ -52,23 +53,21 @@ class CalendarQueryValidator { * itself. * * @param VObject\Component $parent - * @param array $filters + * @param array $filters + * * @return bool */ - protected function validateCompFilters(VObject\Component $parent, array $filters) { - + protected function validateCompFilters(VObject\Component $parent, array $filters) + { foreach ($filters as $filter) { - $isDefined = isset($parent->{$filter['name']}); if ($filter['is-not-defined']) { - if ($isDefined) { return false; } else { continue; } - } if (!$isDefined) { return false; @@ -80,6 +79,7 @@ class CalendarQueryValidator { continue 2; } } + return false; } @@ -90,27 +90,23 @@ class CalendarQueryValidator { // If there are sub-filters, we need to find at least one component // for which the subfilters hold true. foreach ($parent->{$filter['name']} as $subComponent) { - if ( $this->validateCompFilters($subComponent, $filter['comp-filters']) && $this->validatePropFilters($subComponent, $filter['prop-filters'])) { - // We had a match, so this comp-filter succeeds - continue 2; + // We had a match, so this comp-filter succeeds + continue 2; } - } // If we got here it means there were sub-comp-filters or // sub-prop-filters and there was no match. This means this filter // needs to return false. return false; - } // If we got here it means we got through all comp-filters alive so the // filters were all true. return true; - } /** @@ -121,23 +117,21 @@ class CalendarQueryValidator { * itself. * * @param VObject\Component $parent - * @param array $filters + * @param array $filters + * * @return bool */ - protected function validatePropFilters(VObject\Component $parent, array $filters) { - + protected function validatePropFilters(VObject\Component $parent, array $filters) + { foreach ($filters as $filter) { - $isDefined = isset($parent->{$filter['name']}); if ($filter['is-not-defined']) { - if ($isDefined) { return false; } else { continue; } - } if (!$isDefined) { return false; @@ -149,6 +143,7 @@ class CalendarQueryValidator { continue 2; } } + return false; } @@ -159,7 +154,6 @@ class CalendarQueryValidator { // If there are sub-filters, we need to find at least one property // for which the subfilters hold true. foreach ($parent->{$filter['name']} as $subComponent) { - if ( $this->validateParamFilters($subComponent, $filter['param-filters']) && (!$filter['text-match'] || $this->validateTextMatch($subComponent, $filter['text-match'])) @@ -167,20 +161,17 @@ class CalendarQueryValidator { // We had a match, so this prop-filter succeeds continue 2; } - } // If we got here it means there were sub-param-filters or // text-match filters and there was no match. This means the // filter needs to return false. return false; - } // If we got here it means we got through all prop-filters alive so the // filters were all true. return true; - } /** @@ -191,23 +182,21 @@ class CalendarQueryValidator { * itself. * * @param VObject\Property $parent - * @param array $filters + * @param array $filters + * * @return bool */ - protected function validateParamFilters(VObject\Property $parent, array $filters) { - + protected function validateParamFilters(VObject\Property $parent, array $filters) + { foreach ($filters as $filter) { - $isDefined = isset($parent[$filter['name']]); if ($filter['is-not-defined']) { - if ($isDefined) { return false; } else { continue; } - } if (!$isDefined) { return false; @@ -220,24 +209,20 @@ class CalendarQueryValidator { // If there are sub-filters, we need to find at least one parameter // for which the subfilters hold true. foreach ($parent[$filter['name']]->getParts() as $paramPart) { - if ($this->validateTextMatch($paramPart, $filter['text-match'])) { // We had a match, so this param-filter succeeds continue 2; } - } // If we got here it means there was a text-match filter and there // were no matches. This means the filter needs to return false. return false; - } // If we got here it means we got through all param-filters alive so the // filters were all true. return true; - } /** @@ -246,20 +231,20 @@ class CalendarQueryValidator { * A single text-match should be specified as well as the specific property * or parameter we need to validate. * - * @param VObject\Node|string $check Value to check against. - * @param array $textMatch + * @param VObject\Node|string $check value to check against + * @param array $textMatch + * * @return bool */ - protected function validateTextMatch($check, array $textMatch) { - + protected function validateTextMatch($check, array $textMatch) + { if ($check instanceof VObject\Node) { $check = $check->getValue(); } $isMatching = \Sabre\DAV\StringUtil::textMatch($check, $textMatch['value'], $textMatch['collation']); - return ($textMatch['negate-condition'] xor $isMatching); - + return $textMatch['negate-condition'] xor $isMatching; } /** @@ -269,12 +254,13 @@ class CalendarQueryValidator { * complex. * * @param VObject\Node $component - * @param DateTime $start - * @param DateTime $end + * @param DateTime $start + * @param DateTime $end + * * @return bool */ - protected function validateTimeRange(VObject\Node $component, $start, $end) { - + protected function validateTimeRange(VObject\Node $component, $start, $end) + { if (is_null($start)) { $start = new DateTime('1900-01-01'); } @@ -283,14 +269,13 @@ class CalendarQueryValidator { } switch ($component->name) { - - case 'VEVENT' : - case 'VTODO' : - case 'VJOURNAL' : + case 'VEVENT': + case 'VTODO': + case 'VJOURNAL': return $component->isInTimeRange($start, $end); - case 'VALARM' : + case 'VALARM': // If the valarm is wrapped in a recurring event, we need to // expand the recursions, and validate each. @@ -298,10 +283,9 @@ class CalendarQueryValidator { // Our datamodel doesn't easily allow us to do this straight // in the VALARM component code, so this is a hack, and an // expensive one too. - if ($component->parent->name === 'VEVENT' && $component->parent->RRULE) { - + if ('VEVENT' === $component->parent->name && $component->parent->RRULE) { // Fire up the iterator! - $it = new VObject\Recur\EventIterator($component->parent->parent, (string)$component->parent->UID); + $it = new VObject\Recur\EventIterator($component->parent->parent, (string) $component->parent->UID); while ($it->valid()) { $expandedEvent = $it->getEventObject(); @@ -309,15 +293,14 @@ class CalendarQueryValidator { // one is the first to trigger. Based on this, we can // determine if we can 'give up' expanding events. $firstAlarm = null; - if ($expandedEvent->VALARM !== null) { + if (null !== $expandedEvent->VALARM) { foreach ($expandedEvent->VALARM as $expandedAlarm) { - $effectiveTrigger = $expandedAlarm->getEffectiveTriggerTime(); if ($expandedAlarm->isInTimeRange($start, $end)) { return true; } - if ((string)$expandedAlarm->TRIGGER['VALUE'] === 'DATE-TIME') { + if ('DATE-TIME' === (string) $expandedAlarm->TRIGGER['VALUE']) { // This is an alarm with a non-relative trigger // time, likely created by a buggy client. The // implication is that every alarm in this @@ -346,30 +329,26 @@ class CalendarQueryValidator { } $it->next(); } + return false; } else { return $component->isInTimeRange($start, $end); } - case 'VFREEBUSY' : - throw new \Sabre\DAV\Exception\NotImplemented('time-range filters are currently not supported on ' . $component->name . ' components'); - - case 'COMPLETED' : - case 'CREATED' : - case 'DTEND' : - case 'DTSTAMP' : - case 'DTSTART' : - case 'DUE' : - case 'LAST-MODIFIED' : - return ($start <= $component->getDateTime() && $end >= $component->getDateTime()); - - - - default : - throw new \Sabre\DAV\Exception\BadRequest('You cannot create a time-range filter on a ' . $component->name . ' component'); - + // no break + case 'VFREEBUSY': + throw new \Sabre\DAV\Exception\NotImplemented('time-range filters are currently not supported on '.$component->name.' components'); + case 'COMPLETED': + case 'CREATED': + case 'DTEND': + case 'DTSTAMP': + case 'DTSTART': + case 'DUE': + case 'LAST-MODIFIED': + return $start <= $component->getDateTime() && $end >= $component->getDateTime(); + + default: + throw new \Sabre\DAV\Exception\BadRequest('You cannot create a time-range filter on a '.$component->name.' component'); } - } - } -- cgit v1.2.3