]> git.mxchange.org Git - friendica-addons.git/blobdiff - dav/SabreDAV/lib/Sabre/CalDAV/CalendarQueryValidator.php
Merge branch '3.6-rc'
[friendica-addons.git] / dav / SabreDAV / lib / Sabre / CalDAV / CalendarQueryValidator.php
index 4bcd32cdf885c55af54ee023acc232506bd79143..53e86fc509f16d24e11b14737fb15e92c4328c57 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Sabre\VObject;
+
 /**
  * CalendarQuery Validator
  *
@@ -22,11 +24,11 @@ class Sabre_CalDAV_CalendarQueryValidator {
      *
      * The list of filters must be formatted as parsed by Sabre_CalDAV_CalendarQueryParser
      *
-     * @param Sabre_VObject_Component $vObject
+     * @param VObject\Component $vObject
      * @param array $filters
      * @return bool
      */
-    public function validate(Sabre_VObject_Component $vObject,array $filters) {
+    public function validate(VObject\Component $vObject,array $filters) {
 
         // The top level object is always a component filter.
         // We'll parse it manually, as it's pretty simple.
@@ -48,11 +50,11 @@ class Sabre_CalDAV_CalendarQueryValidator {
      * component we're checking should be specified, not the component to check
      * itself.
      *
-     * @param Sabre_VObject_Component $parent
+     * @param VObject\Component $parent
      * @param array $filters
      * @return bool
      */
-    protected function validateCompFilters(Sabre_VObject_Component $parent, array $filters) {
+    protected function validateCompFilters(VObject\Component $parent, array $filters) {
 
         foreach($filters as $filter) {
 
@@ -117,11 +119,11 @@ class Sabre_CalDAV_CalendarQueryValidator {
      * property we're checking should be specified, not the property to check
      * itself.
      *
-     * @param Sabre_VObject_Component $parent
+     * @param VObject\Component $parent
      * @param array $filters
      * @return bool
      */
-    protected function validatePropFilters(Sabre_VObject_Component $parent, array $filters) {
+    protected function validatePropFilters(VObject\Component $parent, array $filters) {
 
         foreach($filters as $filter) {
 
@@ -187,11 +189,11 @@ class Sabre_CalDAV_CalendarQueryValidator {
      * parameter we're checking should be specified, not the parameter to check
      * itself.
      *
-     * @param Sabre_VObject_Property $parent
+     * @param VObject\Property $parent
      * @param array $filters
      * @return bool
      */
-    protected function validateParamFilters(Sabre_VObject_Property $parent, array $filters) {
+    protected function validateParamFilters(VObject\Property $parent, array $filters) {
 
         foreach($filters as $filter) {
 
@@ -243,11 +245,11 @@ class Sabre_CalDAV_CalendarQueryValidator {
      * A single text-match should be specified as well as the specific property
      * or parameter we need to validate.
      *
-     * @param Sabre_VObject_Node $parent
+     * @param VObject\Node $parent
      * @param array $textMatch
      * @return bool
      */
-    protected function validateTextMatch(Sabre_VObject_Node $parent, array $textMatch) {
+    protected function validateTextMatch(VObject\Node $parent, array $textMatch) {
 
         $value = (string)$parent;
 
@@ -263,12 +265,12 @@ class Sabre_CalDAV_CalendarQueryValidator {
      * This is all based on the rules specified in rfc4791, which are quite
      * complex.
      *
-     * @param Sabre_VObject_Node $component
+     * @param VObject\Node $component
      * @param DateTime $start
      * @param DateTime $end
      * @return bool
      */
-    protected function validateTimeRange(Sabre_VObject_Node $component, $start, $end) {
+    protected function validateTimeRange(VObject\Node $component, $start, $end) {
 
         if (is_null($start)) {
             $start = new DateTime('1900-01-01');
@@ -296,7 +298,7 @@ class Sabre_CalDAV_CalendarQueryValidator {
                 if ($component->parent->name === 'VEVENT' && $component->parent->RRULE) {
 
                     // Fire up the iterator!
-                    $it = new Sabre_VObject_RecurrenceIterator($component->parent->parent, (string)$component->parent->UID);
+                    $it = new VObject\RecurrenceIterator($component->parent->parent, (string)$component->parent->UID);
                     while($it->valid()) {
                         $expandedEvent = $it->getEventObject();
 
@@ -304,28 +306,29 @@ class Sabre_CalDAV_CalendarQueryValidator {
                         // one is the first to trigger. Based on this, we can
                         // determine if we can 'give up' expanding events.
                         $firstAlarm = null;
-                        foreach($expandedEvent->VALARM as $expandedAlarm) {
+                        if ($expandedEvent->VALARM !== null) {
+                            foreach($expandedEvent->VALARM as $expandedAlarm) {
 
-                            $effectiveTrigger = $expandedAlarm->getEffectiveTriggerTime();
-                            if ($expandedAlarm->isInTimeRange($start, $end)) {
-                                return true;
-                            }
+                                $effectiveTrigger = $expandedAlarm->getEffectiveTriggerTime();
+                                if ($expandedAlarm->isInTimeRange($start, $end)) {
+                                    return true;
+                                }
 
-                            if ((string)$expandedAlarm->TRIGGER['VALUE'] === 'DATE-TIME') {
-                                // This is an alarm with a non-relative trigger
-                                // time, likely created by a buggy client. The
-                                // implication is that every alarm in this
-                                // recurring event trigger at the exact same
-                                // time. It doesn't make sense to traverse
-                                // further.
-                            } else {
-                                // We store the first alarm as a means to
-                                // figure out when we can stop traversing.
-                                if (!$firstAlarm || $effectiveTrigger < $firstAlarm) {
-                                    $firstAlarm = $effectiveTrigger;
+                                if ((string)$expandedAlarm->TRIGGER['VALUE'] === 'DATE-TIME') {
+                                    // This is an alarm with a non-relative trigger
+                                    // time, likely created by a buggy client. The
+                                    // implication is that every alarm in this
+                                    // recurring event trigger at the exact same
+                                    // time. It doesn't make sense to traverse
+                                    // further.
+                                } else {
+                                    // We store the first alarm as a means to
+                                    // figure out when we can stop traversing.
+                                    if (!$firstAlarm || $effectiveTrigger < $firstAlarm) {
+                                        $firstAlarm = $effectiveTrigger;
+                                    }
                                 }
                             }
-
                         }
                         if (is_null($firstAlarm)) {
                             // No alarm was found.