From 649be5b4524e9815eb37fd7d71fb790c72cda2e3 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Mon, 28 May 2012 07:37:41 +1200 Subject: [PATCH] Add support for $c->hide_older_than to this report. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on a suggestion from Ján Máté. --- inc/caldav-REPORT-sync-collection.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/inc/caldav-REPORT-sync-collection.php b/inc/caldav-REPORT-sync-collection.php index b2e10be9..9a6d323e 100644 --- a/inc/caldav-REPORT-sync-collection.php +++ b/inc/caldav-REPORT-sync-collection.php @@ -80,13 +80,17 @@ if ( $sync_token == $new_token ) { $responses[] = new XMLElement( 'sync-token', 'data:,'.$new_token ); } else { + $hide_older = ''; + if ( isset($c->hide_older_than) && intval($c->hide_older_than > 0) ) + $hide_older = " AND (CASE WHEN caldav_data.caldav_type<>'VEVENT' THEN true ELSE calendar_item.dtstart > (now() - interval '".intval($c->hide_older_than)." days') END)"; + if ( $sync_token == 0 ) { $sql = <<= (SELECT modification_time FROM sync_tokens WHERE sync_token = :sync_token) EOSQL; if ( isset($c->strict_result_ordering) && $c->strict_result_ordering ) {