diff --git a/inc/caldav-REPORT.php b/inc/caldav-REPORT.php index b8618563..e77a2840 100644 --- a/inc/caldav-REPORT.php +++ b/inc/caldav-REPORT.php @@ -95,12 +95,7 @@ foreach( $request->xml_tags AS $k => $v ) { if ( $v['type'] == "close" ) { break; } - if ( $v['type'] == "complete" ) { - $filter_name = $xmltag; - } - else { - $filter_name = $v['attributes']['NAME']; - } + $filter_name = $v['attributes']['NAME']; dbg_log_array( "REPORT", "COMP-FILTER", $v, true ); if ( isset($filters) ) { dbg_error_log( "REPORT", "Adding filter '%s'", $filter_name ); @@ -333,6 +328,18 @@ for ( $i=0; $i <= $reportnum; $i++ ) { if ( isset( $report[$i]['end'] ) ) { $where .= "AND dtstart <= ".qpg($report[$i]['end'])."::timestamp with time zone "; } + if ( isset( $report[$i]['filters'] ) ) { + /** + * Only report on the filtered types that were specified + */ + $filters = ""; + foreach( $report[$i]['filters'] AS $k => $v ) { + $filters .= ($filters == "" ? "" : ", ") . " '$k'"; + } + if ( $filters != "" ) { + $where .= "AND caldav_data.caldav_type IN ( $filters ) "; + } + } break; case 'CALENDAR-MULTIGET':