f7cloud_client/apps/groupfolders/lib/DAV/RootCollection.php
root 8b6a0139db f7cloud_client
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-17 22:59:26 +00:00

48 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2022 F7cloud GmbH and F7cloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\GroupFolders\DAV;
use OCA\GroupFolders\Folder\FolderManager;
use OCP\Files\IRootFolder;
use OCP\IUserSession;
use Sabre\DAVACL\AbstractPrincipalCollection;
use Sabre\DAVACL\PrincipalBackend;
class RootCollection extends AbstractPrincipalCollection {
public function __construct(
private readonly IUserSession $userSession,
PrincipalBackend\BackendInterface $principalBackend,
private readonly FolderManager $folderManager,
private readonly IRootFolder $rootFolder,
) {
parent::__construct($principalBackend, 'principals/users');
}
/**
* This method returns a node for a principal.
*
* The passed array contains principal information, and is guaranteed to
* at least contain a uri item. Other properties may or may not be
* supplied by the authentication backend.
*/
public function getChildForPrincipal(array $principalInfo): GroupFoldersHome {
[, $name] = \Sabre\Uri\split($principalInfo['uri']);
$user = $this->userSession->getUser();
if (is_null($user) || $name !== $user->getUID()) {
throw new \Sabre\DAV\Exception\Forbidden();
}
return new GroupFoldersHome($principalInfo, $this->folderManager, $this->rootFolder, $user);
}
public function getName(): string {
return 'groupfolders';
}
}