diff --git a/inc/caldav-PROPFIND.php b/inc/caldav-PROPFIND.php index c7d2af73..4bf64da3 100644 --- a/inc/caldav-PROPFIND.php +++ b/inc/caldav-PROPFIND.php @@ -156,6 +156,11 @@ function get_collection_contents( $depth, $user_no, $collection ) { $privacy_clause = " AND (calendar_item.class != 'PRIVATE' OR calendar_item.class IS NULL) "; } + $time_limit_clause = ' '; + if ( isset($c->hide_older_than) && intval($c->hide_older_than > 0) ) { + $time_limit_clause = " AND calendar_item.dtstart > (now() - interval '".intval($c->hide_older_than)." days') "; + } + $sql = 'SELECT collection.*, principal.*, caldav_data.*, caldav_data, '; $sql .= "to_char(coalesce(calendar_item.created, caldav_data.created) at time zone 'GMT',$date_format) AS created, "; $sql .= "to_char(last_modified at time zone 'GMT',$date_format) AS modified, "; @@ -163,7 +168,7 @@ function get_collection_contents( $depth, $user_no, $collection ) { $sql .= 'calendar_item.* '; $sql .= 'FROM caldav_data LEFT JOIN calendar_item USING( dav_id, user_no, dav_name, collection_id) '; $sql .= 'LEFT JOIN collection USING(collection_id,user_no) LEFT JOIN principal USING(user_no) '; - $sql .= 'WHERE collection.dav_name = :collection_dav_name '. $privacy_clause; + $sql .= 'WHERE collection.dav_name = :collection_dav_name '.$time_limit_clause.' '.$privacy_clause; if ( isset($c->strict_result_ordering) && $c->strict_result_ordering ) $sql .= " ORDER BY caldav_data.dav_id"; $qry = new AwlQuery( $sql, array( ':collection_dav_name' => $collection->dav_name()) ); if( $qry->Exec('PROPFIND',__LINE__,__FILE__) && $qry->rows() > 0 ) { diff --git a/inc/caldav-REPORT-calquery.php b/inc/caldav-REPORT-calquery.php index 6252b7d6..675efdcf 100644 --- a/inc/caldav-REPORT-calquery.php +++ b/inc/caldav-REPORT-calquery.php @@ -250,6 +250,10 @@ if ( isset($c->hide_TODO) && $c->hide_TODO && ! $request->AllowedTo('all') ) { $where .= "AND caldav_data.caldav_type NOT IN ('VTODO') "; } +if ( isset($c->hide_older_than) && intval($c->hide_older_than > 0) ) { + $where .= " AND calendar_item.dtstart > (now() - interval '".intval($c->hide_older_than)." days') "; +} + $sql = "SELECT * FROM caldav_data INNER JOIN calendar_item USING(dav_id,user_no,dav_name)". $where; if ( isset($c->strict_result_ordering) && $c->strict_result_ordering ) $sql .= " ORDER BY dav_id"; $qry = new PgQuery( $sql );