5include_once(
"freebusy-functions.php");
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' );
14if ( isset($fbq_start) ) {
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) ) {
28 $range_start->modify(
'-365 days');
31if ( isset($fbq_end) ) {
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');
43$freebusy = get_freebusy(
'^' . $request->path . $request->DepthRegexTail(
true), $range_start, $range_end );
45$result =
new iCalComponent();
47$result->AddComponent($freebusy);
49$request->DoResponse( 200, $result->Render(),
'text/calendar' );