/** * This method handles the {DAV:}sync-collection HTTP REPORT. * * @param string $uri * @param \DOMDocument $report * @return void */ function syncCollection($uri, \DOMDocument $report) { // Getting the sync token of the data requested /** * @var $node Tinebase_WebDav_Container_Abstract */ $node = $this->server->tree->getNodeForPath($uri); if (!$node instanceof Tinebase_WebDav_Container_Abstract || !$node->supportsSyncToken()) { throw new Sabre\DAV\Exception\ReportNotSupported('The {DAV:}sync-collection REPORT is not supported on this url.'); } $token = $node->getSyncToken(); if (!$token) { throw new Sabre\DAV\Exception\ReportNotSupported('No sync information is available at this node'); } // getting the sync token send with the request $syncToken = ''; $syncTokenList = $report->getElementsByTagNameNS('urn:DAV', 'sync-token'); if ($syncTokenList->length == 1) { $syncToken = $syncTokenList->item(0)->textContent; //?!? //nodeValue; } if (strlen($syncToken) > 0) { // Sync-token must start with our prefix if (substr($syncToken, 0, strlen(self::SYNCTOKEN_PREFIX)) !== self::SYNCTOKEN_PREFIX || strlen($syncToken) <= strlen(self::SYNCTOKEN_PREFIX)) { throw new Sabre\DAV\Exception\BadRequest('Invalid or unknown sync token'); } $syncToken = substr($syncToken, strlen(self::SYNCTOKEN_PREFIX)); } else { $syncToken = 0; } // get the list of properties the client requested $properties = array_keys(Sabre\DAV\XMLUtil::parseProperties($report->documentElement)); // get changes since client sync token $changeInfo = $node->getChanges($syncToken); if (is_null($changeInfo)) { throw new Sabre\DAV\Exception\BadRequest('Invalid or unknown sync token'); } // Encoding the response $this->sendSyncCollectionResponse($changeInfo['syncToken'], $uri, $changeInfo[Tinebase_Model_ContainerContent::ACTION_CREATE], $changeInfo[Tinebase_Model_ContainerContent::ACTION_UPDATE], $changeInfo[Tinebase_Model_ContainerContent::ACTION_DELETE], $properties); }