From 946e0719efec3ad4282f459fd94511eef23270b3 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Thu, 22 Mar 2012 13:47:11 +1300 Subject: [PATCH] Changes to Depth handling. --- inc/CalDAVRequest.php | 8 ++++++-- inc/caldav-REPORT-freebusy.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/inc/CalDAVRequest.php b/inc/CalDAVRequest.php index d95b4f6e..8daeca43 100644 --- a/inc/CalDAVRequest.php +++ b/inc/CalDAVRequest.php @@ -230,8 +230,11 @@ class CalDAVRequest $this->depth = 'infinity'; break; - case 'PROPFIND': case 'REPORT': + $this->depth = 0; + break; + + case 'PROPFIND': default: $this->depth = 0; } @@ -740,8 +743,9 @@ EOSQL; * Returns the tail of a Regex appropriate for this Depth, when appended to * */ - function DepthRegexTail() { + function DepthRegexTail( $for_collection_report = false) { if ( $this->IsInfiniteDepth() ) return ''; + if ( $this->depth == 0 && $for_collection_report ) return '[^/]+$'; if ( $this->depth == 0 ) return '$'; return '[^/]*/?$'; } diff --git a/inc/caldav-REPORT-freebusy.php b/inc/caldav-REPORT-freebusy.php index b4c8acef..c77a504b 100644 --- a/inc/caldav-REPORT-freebusy.php +++ b/inc/caldav-REPORT-freebusy.php @@ -15,7 +15,7 @@ $range_end = new RepeatRuleDateTime($fbq_end); /** We use the same code for the REPORT, the POST and the freebusy GET... */ -$freebusy = get_freebusy( '^'.$request->path.$request->DepthRegexTail(), $range_start, $range_end ); +$freebusy = get_freebusy( '^' . $request->path . $request->DepthRegexTail(true), $range_start, $range_end ); $result = new iCalComponent(); $result->VCalendar();