From b07019ed9630224279a7c42e6b7423ed84592990 Mon Sep 17 00:00:00 2001 From: Jamie McClymont Date: Wed, 27 Feb 2019 16:39:31 +1300 Subject: [PATCH] Make calquery expansion aware of the calendar default timezone This fixes cases where we emit floating times --- inc/RRule.php | 4 ++-- inc/caldav-REPORT-calquery.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/inc/RRule.php b/inc/RRule.php index 13cc98dc..0d8cfa42 100644 --- a/inc/RRule.php +++ b/inc/RRule.php @@ -1203,7 +1203,7 @@ function rrule_expand( $dtstart, $property, $component, $range_end, $is_date=nul * * @return vComponent The original vComponent, with the instances of the internal components expanded. */ -function expand_event_instances( vComponent $vResource, $range_start = null, $range_end = null, $return_floating_times=false ) { +function expand_event_instances( vComponent $vResource, $range_start = null, $range_end = null, $return_floating_times=false, $fallback_tzid=null ) { global $c; $components = $vResource->GetComponents(); @@ -1302,7 +1302,7 @@ function expand_event_instances( vComponent $vResource, $range_start = null, $ra } print "\n"; } - $instances += rrule_expand($dtstart, 'RRULE', $comp, $range_end, null, $return_floating_times); + $instances += rrule_expand($dtstart, 'RRULE', $comp, $range_end, null, $return_floating_times, $fallback_tzid); if ( DEBUG_RRULE ) { print( "After rrule_expand"); foreach( $instances AS $k => $v ) { diff --git a/inc/caldav-REPORT-calquery.php b/inc/caldav-REPORT-calquery.php index f7e311e2..58d212db 100644 --- a/inc/caldav-REPORT-calquery.php +++ b/inc/caldav-REPORT-calquery.php @@ -328,7 +328,7 @@ if ( isset($c->hide_older_than) && intval($c->hide_older_than > 0) ) { $where .= " AND (CASE WHEN caldav_data.caldav_type<>'VEVENT' OR calendar_item.dtstart IS NULL OR calendar_item.rrule IS NOT NULL THEN true ELSE calendar_item.dtstart > (now() - interval '".intval($c->hide_older_than)." days') END) "; } -$sql = 'SELECT '.$distinct.' caldav_data.*,calendar_item.* FROM collection INNER JOIN caldav_data USING(collection_id) INNER JOIN calendar_item USING(dav_id) '. $where; +$sql = 'SELECT '.$distinct.' caldav_data.*,calendar_item.*,collection.timezone AS collection_tzid FROM collection INNER JOIN caldav_data USING(collection_id) INNER JOIN calendar_item USING(dav_id) '. $where; if ( isset($c->strict_result_ordering) && $c->strict_result_ordering ) $sql .= " ORDER BY caldav_data.dav_id"; $qry = new AwlQuery( $sql, $params ); if ( $qry->Exec("calquery",__LINE__,__FILE__) && $qry->rows() > 0 ) { @@ -340,10 +340,10 @@ if ( $qry->Exec("calquery",__LINE__,__FILE__) && $qry->rows() > 0 ) { } if ( $need_expansion ) { $vResource = new vComponent($dav_object->caldav_data); - $expanded = getVCalendarRange($vResource); + $expanded = getVCalendarRange($vResource, $dav_object->collection_tzid); if ( !$expanded->overlaps($range_filter) ) continue; - $expanded = expand_event_instances($vResource, $expand_range_start, $expand_range_end, $expand_as_floating ); + $expanded = expand_event_instances($vResource, $expand_range_start, $expand_range_end, $expand_as_floating , $dav_object->collection_tzid); if ( $expanded->ComponentCount() == 0 ) continue; if ( $need_expansion ) $dav_object->caldav_data = $expanded->Render();