From b90e3f291c55ac08fbba571386080e0ca3d0c6bb Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Sun, 8 Jul 2012 11:55:46 +1200 Subject: [PATCH] Add method to return list of changes since a previous token. --- inc/WritableCollection.php | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/inc/WritableCollection.php b/inc/WritableCollection.php index 6d2bb91e..68c78a3a 100644 --- a/inc/WritableCollection.php +++ b/inc/WritableCollection.php @@ -442,4 +442,46 @@ EOSQL; } + + /** + * + * @param unknown_type $some_old_token + */ + public function whatChangedSince( $some_old_token ) { + $params = array( ':collection_id' => $this->collection_id() ); + if ( $some_old_token == 0 || empty($some_old_token) ) { + $sql = <<= (SELECT modification_time FROM sync_tokens WHERE sync_token = :sync_token) + ORDER BY sync_changes.collection_id, sync_changes.dav_id, sync_changes.sync_time +EOSQL; + + } + $qry = new AwlQuery($sql, $params ); + + $changes = array(); + if ( $qry->Exec() && $qry->rows() ) { + while( $change = $qry->Fetch() ) { + $changes[$change->uid] = $change; + } + } + + return $changes; + } }