DAViCal
Loading...
Searching...
No Matches
caldav-REPORT-freebusy.php
1<?php
5include_once("freebusy-functions.php");
6
7$fbq_content = $xmltree->GetContent('urn:ietf:params:xml:ns:caldav:free-busy-query');
8$fbq_start = $fbq_content[0]->GetAttribute('start');
9$fbq_end = $fbq_content[0]->GetAttribute('end');
10if ( ! ( isset($fbq_start) || isset($fbq_end) ) ) {
11 $request->DoResponse( 400, 'All valid freebusy requests MUST contain a time-range filter' );
12}
13
14if ( isset($fbq_start) ) {
15 $range_start = new RepeatRuleDateTime($fbq_start);
16} else {
17 # RFC 4791 Section 9.9 says that if start isn't set, then -infinity
18 # should be used. We can't specify that in PHP, and
19 # expand_event_instances has '-6 weeks' as the default.
20 # That's a bit short, go for one year prior to end, if defined,
21 # otherwise 1 year prior to now now.
22 if ( isset($fbq_end) ) {
23 $range_start = new RepeatRuleDateTime($fbq_end);
24 } else {
25 $range_start = new RepeatRuleDateTime;
26 }
27
28 $range_start->modify('-365 days');
29}
30
31if ( isset($fbq_end) ) {
32 $range_end = new RepeatRuleDateTime($fbq_end);
33} else {
34 # RFC 4791 Section 9.9 says that if end isn't set, then +infinity
35 # should be used. We can't specify that in PHP, and
36 # expand_event_instances has '+ 6 weeks' as the default. That's a
37 # bit short, go for two years from the start.
38 $range_end = clone($range_start);
39 $range_end->modify('+730 days');
40}
41
43$freebusy = get_freebusy( '^' . $request->path . $request->DepthRegexTail(true), $range_start, $range_end );
44
45$result = new iCalComponent();
46$result->VCalendar();
47$result->AddComponent($freebusy);
48
49$request->DoResponse( 200, $result->Render(), 'text/calendar' );
50// Won't return from that
51