From a96c609cb46dfa87f4fdb5ac4b5ac20b56148df9 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Sat, 17 Mar 2012 21:33:41 +1300 Subject: [PATCH] We should respond with sync-token if PROPFIND asks too. --- inc/DAVResource.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/inc/DAVResource.php b/inc/DAVResource.php index dada1b98..7580f8e2 100644 --- a/inc/DAVResource.php +++ b/inc/DAVResource.php @@ -1259,6 +1259,22 @@ EOQRY; } + /** + * Returns the current sync_token for this collection, or the containing collection + */ + function sync_token() { + if ( !isset($this->sync_token) ) { + $sql = 'SELECT sync_token FROM sync_tokens WHERE collection_id = :collection_id ORDER BY sync_token DESC LIMIT 1'; + $params = array( ':collection_id' => $this->collection_id()); + $qry = new AwlQuery($sql, $params ); + if ( !$qry->Exec() || !$row = $qry->Fetch() ) { + if ( !$qry->QDo('SELECT new_sync_token( 0, :collection_id) AS sync_token', $params) ) throw new Exception('Problem with database query'); + } + $this->sync_token = 'data:,'.$row->sync_token; + } + return $this->sync_token; + } + /** * Checks whether the target collection is publicly_readable */ @@ -1608,6 +1624,11 @@ EOQRY; $reply->NSElement($prop, $tag, $this->unique_tag() ); break; + case 'DAV::sync-token': + if ( ! $this->_is_collection ) return false; + $reply->NSElement($prop, $tag, $this->sync_token() ); + break; + case 'http://calendarserver.org/ns/:calendar-proxy-read-for': $proxy_type = 'read'; case 'http://calendarserver.org/ns/:calendar-proxy-write-for':