diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-04-17 22:22:41 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-04-25 20:25:10 +0200 |
commit | d5937e0fd6098b90cdfc6ea826d2ba7f1f37ad97 (patch) | |
tree | 772e579897b0d1dc7267a8020350c03b4a0af107 /apps/files_trashbin/lib/Sabre/PropfindPlugin.php | |
parent | cb617c4949f9b8570f65bf972c29d4cd78bc9b6e (diff) | |
download | nextcloud-server-d5937e0fd6098b90cdfc6ea826d2ba7f1f37ad97.tar.gz nextcloud-server-d5937e0fd6098b90cdfc6ea826d2ba7f1f37ad97.zip |
Add propfind properties to trashbin
* get original filename (without the weird timestamp)
* get original location
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/files_trashbin/lib/Sabre/PropfindPlugin.php')
-rw-r--r-- | apps/files_trashbin/lib/Sabre/PropfindPlugin.php | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/apps/files_trashbin/lib/Sabre/PropfindPlugin.php b/apps/files_trashbin/lib/Sabre/PropfindPlugin.php new file mode 100644 index 00000000000..11cfabe141a --- /dev/null +++ b/apps/files_trashbin/lib/Sabre/PropfindPlugin.php @@ -0,0 +1,63 @@ +<?php +/** + * @copyright 2018, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\Files_Trashbin\Sabre; + +use Sabre\DAV\INode; +use Sabre\DAV\PropFind; +use Sabre\DAV\Server; +use Sabre\DAV\ServerPlugin; + +class PropfindPlugin extends ServerPlugin { + + const TRASHBIN_FILENAME = '{http://nextcloud.org/ns}trashbin-filename'; + const TRASHBIN_ORIGINAL_LOCATION = '{http://nextcloud.org/ns}trashbin-original-location'; + + /** @var Server */ + private $server; + + public function __construct() { + } + + public function initialize(Server $server) { + $this->server = $server; + + $this->server->on('propFind', [$this, 'propFind']); + } + + + public function propFind(PropFind $propFind, INode $node) { + if (!($node instanceof ITrash)) { + return; + } + + $propFind->handle(self::TRASHBIN_FILENAME, function() use ($node) { + return $node->getFilename(); + }); + + $propFind->handle(self::TRASHBIN_ORIGINAL_LOCATION, function() use ($node) { + return $node->getOriginalLocation(); + }); + } + +} |