Skip to content

Commit

Permalink
add param to only list applicable folders for admins
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Apr 18, 2023
1 parent db69302 commit 5453916
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,6 @@ The following REST API's are supported:
- `mountpoint`: The new name for the folder

For all `POST` calls the required parameters are listed.

Non admins can access the `GET` requests to retrieve info about group folders they have access to.
Admins can add `applicable=1` as a parameter to the group folder list request to get the same filtered results of only folders they have access to.
7 changes: 4 additions & 3 deletions lib/Controller/FolderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,16 @@ private function filterNonAdminFolder(array $folder): ?array {
/**
* @NoAdminRequired
*/
public function getFolders(): DataResponse {
public function getFolders(bool $applicable = false): DataResponse {
$folders = $this->manager->getAllFoldersWithSize($this->getRootFolderStorageId());
if ($this->delegationService->isAdminNextcloud() || $this->delegationService->isDelegatedAdmin()) {
$isAdmin = $this->delegationService->isAdminNextcloud() || $this->delegationService->isDelegatedAdmin();
if ($isAdmin && !$applicable) {
return new DataResponse($folders);
}
if ($this->delegationService->hasOnlyApiAccess()) {
$folders = $this->foldersFilter->getForApiUser($folders);
}
if (!$this->delegationService->hasApiAccess()) {
if ($applicable || !$this->delegationService->hasApiAccess()) {
$folders = array_map([$this, 'filterNonAdminFolder'], $folders);
$folders = array_filter($folders);
}
Expand Down

0 comments on commit 5453916

Please sign in to comment.