123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- declare(strict_types=1);
- namespace OCA\Files_Trashbin\Sabre;
- use OCA\Files_Trashbin\Trash\ITrashManager;
- use OCP\IConfig;
- use Sabre\DAV\INode;
- use Sabre\DAVACL\AbstractPrincipalCollection;
- use Sabre\DAVACL\PrincipalBackend;
- class RootCollection extends AbstractPrincipalCollection {
-
- private $trashManager;
- public function __construct(
- ITrashManager $trashManager,
- PrincipalBackend\BackendInterface $principalBackend,
- IConfig $config
- ) {
- parent::__construct($principalBackend, 'principals/users');
- $this->trashManager = $trashManager;
- $this->disableListing = !$config->getSystemValue('debug', false);
- }
-
- public function getChildForPrincipal(array $principalInfo): TrashHome {
- [, $name] = \Sabre\Uri\split($principalInfo['uri']);
- $user = \OC::$server->getUserSession()->getUser();
- if (is_null($user) || $name !== $user->getUID()) {
- throw new \Sabre\DAV\Exception\Forbidden();
- }
- return new TrashHome($principalInfo, $this->trashManager, $user);
- }
- public function getName(): string {
- return 'trashbin';
- }
- }
|