57 $server->xml->elementMap[
'{DAV:}sync-collection'] =
'Sabre\\DAV\\Xml\\Request\\SyncCollectionReport';
61 $server->on(
'report',
function($reportName, $dom, $uri) use ($self) {
63 if ($reportName ===
'{DAV:}sync-collection') {
64 $this->server->transactionType =
'report-sync-collection';
65 $self->syncCollection($uri, $dom);
71 $server->on(
'propFind', [$this,
'propFind']);
72 $server->on(
'validateTokens', [$this,
'validateTokens']);
88 $node = $this->server->tree->getNodeForPath($uri);
91 '{DAV:}sync-collection',
110 $node = $this->server->tree->getNodeForPath($uri);
112 throw new DAV\Exception\ReportNotSupported(
'The {DAV:}sync-collection REPORT is not supported on this url.');
114 $token = $node->getSyncToken();
116 throw new DAV\Exception\ReportNotSupported(
'No sync information is available at this node');
119 $syncToken = $report->syncToken;
120 if (!is_null($syncToken)) {
122 if (substr($syncToken, 0, strlen(self::SYNCTOKEN_PREFIX)) !== self::SYNCTOKEN_PREFIX) {
123 throw new DAV\Exception\InvalidSyncToken(
'Invalid or unknown sync token');
126 $syncToken = substr($syncToken, strlen(self::SYNCTOKEN_PREFIX));
129 $changeInfo = $node->getChanges($syncToken, $report->syncLevel, $report->limit);
131 if (is_null($changeInfo)) {
133 throw new DAV\Exception\InvalidSyncToken(
'Invalid or unknown sync token');
139 $changeInfo[
'syncToken'],
141 $changeInfo[
'added'],
142 $changeInfo[
'modified'],
143 $changeInfo[
'deleted'],
160 protected function sendSyncCollectionResponse($syncToken, $collectionUrl, array $added, array $modified, array $deleted, array $properties) {
166 foreach (array_merge($added, $modified) as $item) {
167 $fullPath = $collectionUrl .
'/' . $item;
168 $fullPaths[] = $fullPath;
172 foreach ($this->server->getPropertiesForMultiplePaths($fullPaths, $properties) as $fullPath => $props) {
184 foreach ($deleted as $item) {
186 $fullPath = $collectionUrl .
'/' . $item;
192 $this->server->httpResponse->setStatus(207);
193 $this->server->httpResponse->setHeader(
'Content-Type',
'application/xml; charset=utf-8');
194 $this->server->httpResponse->setBody(
195 $this->server->xml->write(
'{DAV:}multistatus', $multiStatus, $this->server->getBaseUri())
210 $propFind->handle(
'{DAV:}sync-token',
function() use ($node) {
214 return self::SYNCTOKEN_PREFIX .
$token;
231 foreach ($conditions as $kk => $condition) {
233 foreach ($condition[
'tokens'] as
$ii =>
$token) {
236 if (substr(
$token[
'token'], 0, strlen(self::SYNCTOKEN_PREFIX)) !== self::SYNCTOKEN_PREFIX) {
241 $node = $this->server->tree->getNodeForPath($condition[
'uri']);
247 $conditions[$kk][
'tokens'][
$ii][
'validToken'] =
true;
271 'description' =>
'Adds support for WebDAV Collection Sync (rfc6578)',
272 'link' =>
'http://sabre.io/dav/sync/',
The RequestInterface represents a HTTP request.
WebDAV MultiStatus parser.
The baseclass for all server plugins.
foreach($paths as $path) $request
initialize(DAV\Server $server)
Initializes the plugin.
This plugin all WebDAV-sync capabilities to the Server.
getPluginInfo()
Returns a bunch of meta-data about the plugin.
This class holds all the information about a PROPFIND request.
propFind(DAV\PropFind $propFind, DAV\INode $node)
This method is triggered whenever properties are requested for a node.
SyncCollection request parser.
getSyncToken()
This method returns the current sync-token for this collection.
syncCollection($uri, SyncCollectionReport $report)
This method handles the {DAV:}sync-collection HTTP REPORT.
getSupportedReportSet($uri)
Returns a list of reports this plugin supports.
getPluginName()
Returns a plugin name.
If a class extends ISyncCollection, it supports WebDAV-sync.
sendSyncCollectionResponse($syncToken, $collectionUrl, array $added, array $modified, array $deleted, array $properties)
Sends the response to a sync-collection request.
The INode interface is the base interface, and the parent class of both ICollection and IFile...
WebDAV {DAV:}response parser.
validateTokens(RequestInterface $request, &$conditions)
The validateTokens event is triggered before every request.