mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-08-08 14:56:05 +00:00
Add an option to restrict visible contents to a limited date range.
This patch adds ability to hide old events from Caldav clients. New configuration option $c->hide_older_than accepts an integer number of days. For example, setting $c->hide_older_than=90 hides all events with "end date" older than 90 days. The main purpose of this patch is allowing to use Sunbird with more than 500 Caldav events without removing these events from calendar. Without this patch the Sunbird slows down and load calendars extremely slowly (up to 10 min. for 1800 events).
This commit is contained in:
parent
0492cb38bb
commit
9460803f71
@ -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 ) {
|
||||
|
||||
@ -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 );
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user