From 246549f53be8dd89c63a2fe1510373f05fb3f688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Lehrke?= Date: Sun, 12 Sep 2010 20:35:05 +0000 Subject: [PATCH] New ctag implementation for CalDAV --- calendar/inc/class.calendar_groupdav.inc.php | 35 ++++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/calendar/inc/class.calendar_groupdav.inc.php b/calendar/inc/class.calendar_groupdav.inc.php index e4da86a4ff..f063b69da1 100644 --- a/calendar/inc/class.calendar_groupdav.inc.php +++ b/calendar/inc/class.calendar_groupdav.inc.php @@ -107,8 +107,8 @@ class calendar_groupdav extends groupdav_handler // ToDo: add parameter to only return id & etag $filter = array( 'users' => $user, - 'start' => time()-100*24*3600, // default one month back -30 breaks all sync recurrences - 'end' => time()+365*24*3600, // default one year into the future +365 + 'start' => $this->bo->now - 100*24*3600, // default one month back -30 breaks all sync recurrences + 'end' => $this->bo->now + 365*24*3600, // default one year into the future +365 'enum_recuring' => false, 'daywise' => false, 'date_format' => 'server', @@ -756,7 +756,36 @@ error_log(__METHOD__."($path,,".array2string($start).") filter=".array2string($f */ public function getctag($path,$user) { - $ctag = $GLOBALS['egw']->contenthistory->getLastChange('calendar'); + $filter = array( + 'users' => $user, + 'start' => $this->bo->now - 100*24*3600, // default one month back -30 breaks all sync recurrences + 'end' => $this->bo->now + 365*24*3600, // default one year into the future +365 + 'enum_recuring' => false, + 'daywise' => false, + 'date_format' => 'server', + 'cols' => array('egw_cal.cal_id', 'cal_start', 'cal_modified'), + ); + + if ($path == '/calendar/') + { + $filter['filter'] = 'owner'; + } + else + { + $filter['filter'] = 'default'; // not rejected + } + + $ctag = 0; + + if (($events =& $this->bo->search($filter))) + { + foreach ($events as $event) + { + $modified = max($this->bo->so->max_user_modified($event['cal_id']), $event['cal_modified']); + if ($ctag < $modified) $ctag = $modified; + break; + } + } if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag");