diff options
Diffstat (limited to 'apps/dav/lib/Connector/Sabre/FakeLockerPlugin.php')
-rw-r--r-- | apps/dav/lib/Connector/Sabre/FakeLockerPlugin.php | 50 |
1 files changed, 17 insertions, 33 deletions
diff --git a/apps/dav/lib/Connector/Sabre/FakeLockerPlugin.php b/apps/dav/lib/Connector/Sabre/FakeLockerPlugin.php index d05cd6d2e6d..b0c5a079ce1 100644 --- a/apps/dav/lib/Connector/Sabre/FakeLockerPlugin.php +++ b/apps/dav/lib/Connector/Sabre/FakeLockerPlugin.php @@ -1,33 +1,17 @@ <?php + /** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Joas Schilling <coding@schilljs.com> - * @author Lukas Reschke <lukas@statuscode.ch> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ namespace OCA\DAV\Connector\Sabre; +use OCP\AppFramework\Http; use Sabre\DAV\INode; use Sabre\DAV\Locks\LockInfo; use Sabre\DAV\PropFind; +use Sabre\DAV\Server; use Sabre\DAV\ServerPlugin; use Sabre\DAV\Xml\Property\LockDiscovery; use Sabre\DAV\Xml\Property\SupportedLock; @@ -47,11 +31,11 @@ use Sabre\HTTP\ResponseInterface; * @package OCA\DAV\Connector\Sabre */ class FakeLockerPlugin extends ServerPlugin { - /** @var \Sabre\DAV\Server */ + /** @var Server */ private $server; /** {@inheritDoc} */ - public function initialize(\Sabre\DAV\Server $server) { + public function initialize(Server $server) { $this->server = $server; $this->server->on('method:LOCK', [$this, 'fakeLockProvider'], 1); $this->server->on('method:UNLOCK', [$this, 'fakeUnlockProvider'], 1); @@ -90,7 +74,7 @@ class FakeLockerPlugin extends ServerPlugin { */ public function propFind(PropFind $propFind, INode $node) { $propFind->handle('{DAV:}supportedlock', function () { - return new SupportedLock(true); + return new SupportedLock(); }); $propFind->handle('{DAV:}lockdiscovery', function () use ($propFind) { return new LockDiscovery([]); @@ -108,7 +92,7 @@ class FakeLockerPlugin extends ServerPlugin { if (isset($fileCondition['tokens'])) { foreach ($fileCondition['tokens'] as &$token) { if (isset($token['token'])) { - if (substr($token['token'], 0, 16) === 'opaquelocktoken:') { + if (str_starts_with($token['token'], 'opaquelocktoken:')) { $token['validToken'] = true; } } @@ -125,19 +109,19 @@ class FakeLockerPlugin extends ServerPlugin { * @return bool */ public function fakeLockProvider(RequestInterface $request, - ResponseInterface $response) { + ResponseInterface $response) { $lockInfo = new LockInfo(); $lockInfo->token = md5($request->getPath()); $lockInfo->uri = $request->getPath(); - $lockInfo->depth = \Sabre\DAV\Server::DEPTH_INFINITY; + $lockInfo->depth = Server::DEPTH_INFINITY; $lockInfo->timeout = 1800; $body = $this->server->xml->write('{DAV:}prop', [ - '{DAV:}lockdiscovery' => - new LockDiscovery([$lockInfo]) + '{DAV:}lockdiscovery' + => new LockDiscovery([$lockInfo]) ]); - $response->setStatus(200); + $response->setStatus(Http::STATUS_OK); $response->setBody($body); return false; @@ -151,8 +135,8 @@ class FakeLockerPlugin extends ServerPlugin { * @return bool */ public function fakeUnlockProvider(RequestInterface $request, - ResponseInterface $response) { - $response->setStatus(204); + ResponseInterface $response) { + $response->setStatus(Http::STATUS_NO_CONTENT); $response->setHeader('Content-Length', '0'); return false; } |