[Unfinished] Migrating away from deprecated iCalendar class.

This is working, to a point...  Some regression tests are still failing
and I need to investigate why, but this is substantially finished. The
remaining fixes will need to be in AWL/vCalendar in any case.
This commit is contained in:
Andrew McMillan 2011-09-14 23:05:20 +12:00
parent 1a35a111e7
commit af3478cd25

View File

@ -1,5 +1,7 @@
<?php <?php
include_once('vCalendar.php');
$need_expansion = false; $need_expansion = false;
function check_for_expansion( $calendar_data_node ) { function check_for_expansion( $calendar_data_node ) {
global $need_expansion, $expand_range_start, $expand_range_end, $expand_as_floating; global $need_expansion, $expand_range_start, $expand_range_end, $expand_as_floating;
@ -54,23 +56,11 @@ while (list($idx, $qqq) = each($qry_content))
/** /**
* There can only be *one* FILTER element, and it must contain *one* COMP-FILTER * There can only be *one* FILTER element, and it must contain *one* COMP-FILTER
* element. In every case I can see this contained COMP-FILTER element will be a * element. In every case I can see this contained COMP-FILTER element will
* VCALENDAR, but perhaps there are others. In our case we strip it if that is * necessarily be a VCALENDAR, which then may contain other COMP-FILTER etc.
* the case and leave it alone otherwise.
*/ */
$qry_filters = $xmltree->GetPath('/urn:ietf:params:xml:ns:caldav:calendar-query/urn:ietf:params:xml:ns:caldav:filter/*'); $qry_filters = $xmltree->GetPath('/urn:ietf:params:xml:ns:caldav:calendar-query/urn:ietf:params:xml:ns:caldav:filter/*');
if ( count($qry_filters) == 1 ) { if ( count($qry_filters) != 1 ) $qry_filters = false;
$qry_filters = $qry_filters[0]; // There can only be one FILTER element
if ( $qry_filters->GetTag() == "urn:ietf:params:xml:ns:caldav:comp-filter" && $qry_filters->GetAttribute("name") == "VCALENDAR" )
$qry_filters = $qry_filters->GetContent(); // Everything is inside a VCALENDAR AFAICS
else {
dbg_error_log("calquery", "Got bizarre CALDAV:FILTER[%s=%s]] which does not contain comp-filter = VCALENDAR!!", $qry_filters->GetTag(), $qry_filters->GetAttribute("name") );
$qry_filters = false;
}
}
else {
$qry_filters = false;
}
/** /**
@ -88,8 +78,8 @@ function apply_filter( $filters, $item ) {
if ( count($filters) == 0 ) return true; if ( count($filters) == 0 ) return true;
dbg_error_log("calquery","Applying filter for item '%s'", $item->dav_name ); dbg_error_log("calquery","Applying filter for item '%s'", $item->dav_name );
$ical = new iCalendar( array( "icalendar" => $item->caldav_data) ); $ical = new vCalendar( $item->caldav_data );
return $ical->TestFilter($filters); return $ical->StartFilter($filters);
} }
@ -197,11 +187,11 @@ function SqlFilterFragment( $filter, $components, $property = null, $parameter =
case 'urn:ietf:params:xml:ns:caldav:comp-filter': case 'urn:ietf:params:xml:ns:caldav:comp-filter':
$comp_filter_name = $v->GetAttribute("name"); $comp_filter_name = $v->GetAttribute("name");
if ( count($components) == 0 ) { if ( $comp_filter_name != 'VCALENDAR' && count($components) == 0 ) {
$sql .= "AND caldav_data.caldav_type = :component_name_filter "; $sql .= "AND caldav_data.caldav_type = :component_name_filter ";
$params[':component_name_filter'] = $comp_filter_name; $params[':component_name_filter'] = $comp_filter_name;
$components[] = $comp_filter_name;
} }
$components[] = $comp_filter_name;
$subfilter = $v->GetContent(); $subfilter = $v->GetContent();
if ( is_array( $subfilter ) ) { if ( is_array( $subfilter ) ) {
$success = SqlFilterFragment( $subfilter, $components, $property, $parameter ); $success = SqlFilterFragment( $subfilter, $components, $property, $parameter );
@ -284,6 +274,11 @@ function SqlFilterFragment( $filter, $components, $property = null, $parameter =
*/ */
function BuildSqlFilter( $filter ) { function BuildSqlFilter( $filter ) {
$components = array(); $components = array();
if ( $filter->GetTag() == "urn:ietf:params:xml:ns:caldav:comp-filter" && $filter->GetAttribute("name") == "VCALENDAR" )
$filter = $filter->GetContent(); // Everything is inside a VCALENDAR AFAICS
else {
dbg_error_log("calquery", "Got bizarre CALDAV:FILTER[%s=%s]] which does not contain comp-filter = VCALENDAR!!", $filter->GetTag(), $filter->GetAttribute("name") );
}
return SqlFilterFragment( $filter, $components ); return SqlFilterFragment( $filter, $components );
} }