12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?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 {
- public function __construct(
- private ITrashManager $trashManager,
- PrincipalBackend\BackendInterface $principalBackend,
- IConfig $config,
- ) {
- parent::__construct($principalBackend, 'principals/users');
- $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';
- }
- }
|