From 994001c4804f214a340922467a8ea96ec96a227e Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 11 Jul 2016 16:10:25 +0200 Subject: [PATCH] Dirty hack to disable dav plugins on public calendar urls --- .../lib/CalDAV/Publishing/PublishPlugin.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php b/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php index 1d45aef5a2..109e115855 100644 --- a/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php +++ b/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php @@ -91,6 +91,7 @@ class PublishPlugin extends ServerPlugin $this->server->on('method:POST', [$this, 'httpPost']); $this->server->on('propFind', [$this, 'propFind']); + $this->server->on('method:OPTIONS', [$this, 'httpOptions'], 5); } public function propFind(PropFind $propFind, INode $node) @@ -209,4 +210,23 @@ class PublishPlugin extends ServerPlugin } } + + public function httpOptions(RequestInterface $request, ResponseInterface $response) { + if ($request->getPath() == 'public-calendars') { + $methods = $this->server->getAllowedMethods($request->getPath()); + + $response->setHeader('Allow', strtoupper(implode(', ', $methods))); + $features = ['1', '3', 'extended-mkcol']; + + $response->setHeader('DAV', implode(', ', $features)); + $response->setHeader('MS-Author-Via', 'DAV'); + $response->setHeader('Accept-Ranges', 'bytes'); + $response->setHeader('Content-Length', '0'); + $response->setStatus(200); + + // Sending back false will interupt the event chain and tell the server + // we've handled this method. + return false; + } + } }