Skip to content
Snippets Groups Projects
Commit f2dd56af authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by David Siegfried
Browse files

fixes #4277

Closes #4277

Merge request studip/studip!3116
parent 0850b4ce
No related branches found
No related tags found
No related merge requests found
......@@ -19,20 +19,31 @@ class SubfoldersIndex extends JsonApiController
*/
public function __invoke(Request $request, Response $response, $args)
{
if (!$folder = \FileManager::getTypedFolder($args['id'])) {
$folder = \FileManager::getTypedFolder($args['id']);
if (!$folder) {
throw new RecordNotFoundException();
}
if (!Authority::canShowFolder($this->getUser($request), $folder)) {
$user = $this->getUser($request);
if (!Authority::canShowFolder($user, $folder)) {
throw new AuthorizationFailedException();
}
$subfolders = array_map(
function ($subfolder) {
return $subfolder->getTypedFolder();
$subfolders = array_reduce(
$folder->subfolders->getArrayCopy(),
function ($result, $subfolder) use ($user) {
$folder = $subfolder->getTypedFolder();
if (Authority::canShowFolder($user, $folder)) {
$result[] = $folder;
}
return $result;
},
$folder->subfolders->getArrayCopy()
[]
);
list($offset, $limit) = $this->getOffsetAndLimit();
return $this->getPaginatedContentResponse(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment