diff --git a/inc/caldav-PROPFIND.php b/inc/caldav-PROPFIND.php index 4acd8d46..da89081d 100644 --- a/inc/caldav-PROPFIND.php +++ b/inc/caldav-PROPFIND.php @@ -185,12 +185,17 @@ function get_collection_contents( $depth, $collection, $parent_path = null ) { if ( $collection->HavePrivilegeTo('DAV::read', false) ) { dbg_error_log('PROPFIND','Getting collection items: Depth %d, Path: %s', $depth, $bound_from ); $privacy_clause = ' '; + $todo_clause = ' '; $time_limit_clause = ' '; if ( $collection->IsCalendar() ) { if ( ! $collection->HavePrivilegeTo('all', false) ) { $privacy_clause = " AND (calendar_item.class != 'PRIVATE' OR calendar_item.class IS NULL) "; } + if ( isset($c->hide_TODO) && ($c->hide_TODO === true || (is_string($c->hide_TODO) && preg_match($c->hide_TODO, $_SERVER['HTTP_USER_AGENT']))) && ! $collection->HavePrivilegeTo('all') ) { + $todo_clause = " AND caldav_data.caldav_type NOT IN ('VTODO') "; + } + if ( isset($c->hide_older_than) && intval($c->hide_older_than > 0) ) { $time_limit_clause = " AND (CASE WHEN caldav_data.caldav_type<>'VEVENT' OR calendar_item.dtstart IS NULL THEN true ELSE calendar_item.dtstart > (now() - interval '".intval($c->hide_older_than)." days') END) "; } @@ -202,7 +207,7 @@ function get_collection_contents( $depth, $collection, $parent_path = null ) { $sql .= 'summary AS dav_displayname '; $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 '.$time_limit_clause.' '.$privacy_clause; + $sql .= 'WHERE collection.dav_name = :collection_dav_name '.$time_limit_clause.' '.$todo_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' => $bound_from) ); if( $qry->Exec('PROPFIND',__LINE__,__FILE__) && $qry->rows() > 0 ) { diff --git a/inc/caldav-REPORT-calquery.php b/inc/caldav-REPORT-calquery.php index 03d80bea..365b8905 100644 --- a/inc/caldav-REPORT-calquery.php +++ b/inc/caldav-REPORT-calquery.php @@ -334,7 +334,7 @@ if ( $target_collection->Privileges() != privilege_to_bits('DAV::all') ) { $where .= " AND (calendar_item.class != 'PRIVATE' OR calendar_item.class IS NULL) "; } -if ( isset($c->hide_TODO) && $c->hide_TODO && ! $target_collection->HavePrivilegeTo('DAV::write-content') ) { +if ( isset($c->hide_TODO) && ($c->hide_TODO === true || (is_string($c->hide_TODO) && preg_match($c->hide_TODO, $_SERVER['HTTP_USER_AGENT']))) && ! $target_collection->HavePrivilegeTo('all') ) { $where .= " AND caldav_data.caldav_type NOT IN ('VTODO') "; } diff --git a/inc/caldav-REPORT-multiget.php b/inc/caldav-REPORT-multiget.php index bdb1151e..594b2422 100644 --- a/inc/caldav-REPORT-multiget.php +++ b/inc/caldav-REPORT-multiget.php @@ -88,9 +88,6 @@ if ( $mode == 'caldav' ) { if ( $collection->Privileges() != privilege_to_bits('DAV::all') ) { $where .= " AND (calendar_item.class != 'PRIVATE' OR calendar_item.class IS NULL) "; } - if ( isset($c->hide_TODO) && $c->hide_TODO && ! $collection->HavePrivilegeTo('all') ) { - $where .= " AND caldav_data.caldav_type NOT IN ('VTODO') "; - } } $sql = 'SELECT calendar_item.*, addressbook_resource.*, caldav_data.* FROM caldav_data LEFT JOIN calendar_item USING(dav_id, user_no, dav_name, collection_id) diff --git a/inc/caldav-REPORT-sync-collection.php b/inc/caldav-REPORT-sync-collection.php index b5a0c9bd..1a04087f 100644 --- a/inc/caldav-REPORT-sync-collection.php +++ b/inc/caldav-REPORT-sync-collection.php @@ -84,13 +84,17 @@ else { if ( isset($c->hide_older_than) && intval($c->hide_older_than) > 0 ) $hide_older = " AND (CASE WHEN caldav_data.caldav_type<>'VEVENT' OR calendar_item.dtstart IS NULL THEN true ELSE calendar_item.dtstart > (now() - interval '".intval($c->hide_older_than)." days') END)"; + $hide_todo = ''; + if ( isset($c->hide_TODO) && ($c->hide_TODO === true || (is_string($c->hide_TODO) && preg_match($c->hide_TODO, $_SERVER['HTTP_USER_AGENT']))) && ! $collection->HavePrivilegeTo('all') ) + $hide_todo = " AND caldav_data.caldav_type NOT IN ('VTODO') "; + 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 ) {