diff --git a/appinfo/routes.php b/appinfo/routes.php deleted file mode 100644 index 88009e7f4..000000000 --- a/appinfo/routes.php +++ /dev/null @@ -1,92 +0,0 @@ - [ - [ - 'name' => 'Folder#getFolders', - 'url' => '/folders', - 'verb' => 'GET' - ], - [ - 'name' => 'Folder#getFolder', - 'url' => '/folders/{id}', - 'verb' => 'GET' - ], - [ - 'name' => 'Folder#addFolder', - 'url' => '/folders', - 'verb' => 'POST' - ], - [ - 'name' => 'Folder#removeFolder', - 'url' => '/folders/{id}', - 'verb' => 'DELETE' - ], - [ - 'name' => 'Folder#setMountPoint', - 'url' => '/folders/{id}', - 'verb' => 'PUT' - ], - [ - 'name' => 'Folder#addGroup', - 'url' => '/folders/{id}/groups', - 'verb' => 'POST' - ], - [ - 'name' => 'Folder#removeGroup', - 'url' => '/folders/{id}/groups/{group}', - 'verb' => 'DELETE', - 'requirements' => ['group' => '.+'] - ], - [ - 'name' => 'Folder#setPermissions', - 'url' => '/folders/{id}/groups/{group}', - 'verb' => 'POST', - 'requirements' => ['group' => '.+'] - ], - [ - 'name' => 'Folder#setManageACL', - 'url' => '/folders/{id}/manageACL', - 'verb' => 'POST' - ], - [ - 'name' => 'Folder#setQuota', - 'url' => '/folders/{id}/quota', - 'verb' => 'POST' - ], - - [ - 'name' => 'Folder#setACL', - 'url' => '/folders/{id}/acl', - 'verb' => 'POST' - ], - [ - 'name' => 'Folder#renameFolder', - 'url' => '/folders/{id}/mountpoint', - 'verb' => 'POST' - ], - [ - 'name' => 'Folder#aclMappingSearch', - 'url' => '/folders/{id}/search', - 'verb' => 'GET' - ], - [ - 'name' => 'Delegation#getAllGroups', - 'url' => 'delegation/groups', - 'verb' => 'GET' - ], - [ - 'name' => 'Delegation#getAllCircles', - 'url' => 'delegation/circles', - 'verb' => 'GET' - ], - [ - 'name' => 'Delegation#getAuthorizedGroups', - 'url' => '/delegation/authorized-groups', - 'verb' => 'GET', - ], -]]; diff --git a/lib/Controller/DelegationController.php b/lib/Controller/DelegationController.php index f245f93fd..309f3b56d 100644 --- a/lib/Controller/DelegationController.php +++ b/lib/Controller/DelegationController.php @@ -11,6 +11,8 @@ use OCA\GroupFolders\Service\DelegationService; use OCA\Settings\Service\AuthorizedGroupService; use OCP\App\IAppManager; +use OCP\AppFramework\Http\Attribute\ApiRoute; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCSController; use OCP\IConfig; @@ -37,9 +39,10 @@ public function __construct( /** * Returns the list of all groups * - * @NoAdminRequired * @RequireGroupFolderAdmin */ + #[NoAdminRequired] + #[ApiRoute(verb: 'GET', url: '/delegation/groups')] public function getAllGroups(): DataResponse { // Get all groups $groups = $this->groupManager->search(''); @@ -59,9 +62,10 @@ public function getAllGroups(): DataResponse { /** * Returns the list of all visible circles * - * @NoAdminRequired * @RequireGroupFolderAdmin */ + #[NoAdminRequired] + #[ApiRoute(verb: 'GET', url: '/delegation/circles')] public function getAllCircles(): DataResponse { $circlesEnabled = $this->appManager->isEnabledForUser('circles'); if (!$circlesEnabled) { @@ -98,9 +102,10 @@ public function getAllCircles(): DataResponse { * - OCA\GroupFolders\Settings\Admin : It's reference to fields in Admin Priveleges. * - OCA\GroupFolders\Controller\DelegationController : It's just to specific the subadmins. * They can only manage groupfolders in which they are added in the Advanced Permissions (groups only) - * @NoAdminRequired * @RequireGroupFolderAdmin */ + #[NoAdminRequired] + #[ApiRoute(verb: 'GET', url: '/delegation/authorized-groups')] public function getAuthorizedGroups(string $classname = ""): DataResponse { $data = []; $authorizedGroups = $this->authorizedGroupService->findExistingGroupsForClass($classname); diff --git a/lib/Controller/FolderController.php b/lib/Controller/FolderController.php index 8ea5ebe35..c869f2f7d 100644 --- a/lib/Controller/FolderController.php +++ b/lib/Controller/FolderController.php @@ -13,6 +13,8 @@ use OCA\GroupFolders\Service\DelegationService; use OCA\GroupFolders\Service\FoldersFilter; use OCP\AppFramework\Http; +use OCP\AppFramework\Http\Attribute\ApiRoute; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCS\OCSNotFoundException; use OCP\AppFramework\OCSController; @@ -87,9 +89,8 @@ private function formatFolder(array $folder): array { return $folder; } - /** - * @NoAdminRequired - */ + #[NoAdminRequired] + #[ApiRoute(verb: 'GET', url: '/folders')] public function getFolders(bool $applicable = false): DataResponse { $folders = $this->manager->getAllFoldersWithSize($this->getRootFolderStorageId()); $folders = array_map([$this, 'formatFolder'], $folders); @@ -107,9 +108,8 @@ public function getFolders(bool $applicable = false): DataResponse { return new DataResponse($folders); } - /** - * @NoAdminRequired - */ + #[NoAdminRequired] + #[ApiRoute(verb: 'GET', url: '/folders/{id}')] public function getFolder(int $id): DataResponse { $response = $this->checkFolderExists($id); if ($response) { @@ -145,9 +145,10 @@ private function getRootFolderStorageId(): ?int { /** * @RequireGroupFolderAdmin - * @NoAdminRequired * @throws OCSNotFoundException */ + #[NoAdminRequired] + #[ApiRoute(verb: 'POST', url: '/folders')] public function addFolder(string $mountpoint): DataResponse { $id = $this->manager->createFolder(trim($mountpoint)); $folder = $this->manager->getFolder($id, $this->rootFolder->getMountPoint()->getNumericStorageId()); @@ -158,9 +159,10 @@ public function addFolder(string $mountpoint): DataResponse { } /** - * @NoAdminRequired * @RequireGroupFolderAdmin */ + #[NoAdminRequired] + #[ApiRoute(verb: 'DELETE', url: '/folders/{id}')] public function removeFolder(int $id): DataResponse { $response = $this->checkFolderExists($id); if ($response) { @@ -173,18 +175,20 @@ public function removeFolder(int $id): DataResponse { } /** - * @NoAdminRequired * @RequireGroupFolderAdmin */ + #[NoAdminRequired] + #[ApiRoute(verb: 'PUT', url: '/folders/{id}')] public function setMountPoint(int $id, string $mountPoint): DataResponse { $this->manager->renameFolder($id, trim($mountPoint)); return new DataResponse(['success' => true]); } /** - * @NoAdminRequired * @RequireGroupFolderAdmin */ + #[NoAdminRequired] + #[ApiRoute(verb: 'POST', url: '/folders/{id}/groups')] public function addGroup(int $id, string $group): DataResponse { $response = $this->checkFolderExists($id); if ($response) { @@ -195,9 +199,10 @@ public function addGroup(int $id, string $group): DataResponse { } /** - * @NoAdminRequired * @RequireGroupFolderAdmin */ + #[NoAdminRequired] + #[ApiRoute(verb: 'DELETE', url: '/folders/{id}/groups/{group}', requirements: ['group' => '.+'])] public function removeGroup(int $id, string $group): DataResponse { $response = $this->checkFolderExists($id); if ($response) { @@ -208,9 +213,10 @@ public function removeGroup(int $id, string $group): DataResponse { } /** - * @NoAdminRequired * @RequireGroupFolderAdmin */ + #[NoAdminRequired] + #[ApiRoute(verb: 'POST', url: '/folders/{id}/groups/{group}', requirements: ['group' => '.+'])] public function setPermissions(int $id, string $group, int $permissions): DataResponse { $response = $this->checkFolderExists($id); if ($response) { @@ -221,10 +227,11 @@ public function setPermissions(int $id, string $group, int $permissions): DataRe } /** - * @NoAdminRequired * @RequireGroupFolderAdmin * @throws \OCP\DB\Exception */ + #[NoAdminRequired] + #[ApiRoute(verb: 'POST', url: '/folders/{id}/manageACL')] public function setManageACL(int $id, string $mappingType, string $mappingId, bool $manageAcl): DataResponse { $response = $this->checkFolderExists($id); if ($response) { @@ -235,9 +242,10 @@ public function setManageACL(int $id, string $mappingType, string $mappingId, bo } /** - * @NoAdminRequired * @RequireGroupFolderAdmin */ + #[NoAdminRequired] + #[ApiRoute(verb: 'POST', url: '/folders/{id}/quota')] public function setQuota(int $id, int $quota): DataResponse { $response = $this->checkFolderExists($id); if ($response) { @@ -248,9 +256,10 @@ public function setQuota(int $id, int $quota): DataResponse { } /** - * @NoAdminRequired * @RequireGroupFolderAdmin */ + #[NoAdminRequired] + #[ApiRoute(verb: 'POST', url: '/folders/{id}/acl')] public function setACL(int $id, bool $acl): DataResponse { $response = $this->checkFolderExists($id); if ($response) { @@ -261,9 +270,10 @@ public function setACL(int $id, bool $acl): DataResponse { } /** - * @NoAdminRequired * @RequireGroupFolderAdmin */ + #[NoAdminRequired] + #[ApiRoute(verb: 'POST', url: '/folders/{id}/mountpoint')] public function renameFolder(int $id, string $mountpoint): DataResponse { $response = $this->checkFolderExists($id); if ($response) { @@ -310,9 +320,8 @@ private function folderDataForXML(array $data): array { return $data; } - /** - * @NoAdminRequired - */ + #[NoAdminRequired] + #[ApiRoute(verb: 'GET', url: '/folders/{id}/search')] public function aclMappingSearch(int $id, ?int $fileId, string $search = ''): DataResponse { $users = []; $groups = []; diff --git a/src/components/SharingSidebarView.vue b/src/components/SharingSidebarView.vue index bbdba1fe4..f31c0a087 100644 --- a/src/components/SharingSidebarView.vue +++ b/src/components/SharingSidebarView.vue @@ -157,7 +157,7 @@