Skip to content
Snippets Groups Projects
Commit f480395f authored by Guillaume Heurtier's avatar Guillaume Heurtier
Browse files

FEAT #11454 TIME 0:40 get folders returns whether a folder is pinned or not

parent 16ac35c3
No related branches found
No related tags found
No related merge requests found
......@@ -64,6 +64,14 @@ class FolderController
if (isset($key[0])) {
$count = $foldersWithResources[$key[0]]['count'];
}
$isPinned = !empty(
UserPinnedFolderModel::get([
'where' => ['folder_id = ?', 'user_id = ?'],
'data' => [$folder['id'], $GLOBALS['id']]
])
);
$insert = [
'name' => $folder['label'],
'id' => $folder['id'],
......@@ -72,7 +80,8 @@ class FolderController
'user_id' => $folder['user_id'],
'parent_id' => $folder['parent_id'],
'level' => $folder['level'],
'countResources' => $count
'countResources' => $count,
'pinned' => $isPinned
];
if ($folder['level'] == 0) {
array_splice($tree, 0, 0, [$insert]);
......@@ -120,6 +129,13 @@ class FolderController
}
}
$folder['pinned'] = !empty(
UserPinnedFolderModel::get([
'where' => ['folder_id = ?', 'user_id = ?'],
'data' => [$folder['id'], $GLOBALS['id']]
])
);
return $response->withJson(['folder' => $folder]);
}
......@@ -690,8 +706,7 @@ class FolderController
return $response->withStatus(400)->withJson(['errors' => 'Route id not found or is not an integer']);
}
$folder = FolderController::getScopeFolders(['login' => $GLOBALS['userId'], 'folderId' => $args['id']]);
if (empty($folder[0])) {
if (!FolderController::hasFolders(['folders' => [$args['id']], 'userId' => $GLOBALS['id']])) {
return $response->withStatus(400)->withJson(['errors' => 'Folder not found or out of your perimeter']);
}
......@@ -753,8 +768,7 @@ class FolderController
return $response->withStatus(400)->withJson(['errors' => 'Route id not found or is not an integer']);
}
$folder = FolderController::getScopeFolders(['login' => $GLOBALS['userId'], 'folderId' => $args['id']]);
if (empty($folder[0])) {
if (!FolderController::hasFolders(['folders' => [$args['id']], 'userId' => $GLOBALS['id']])) {
return $response->withStatus(400)->withJson(['errors' => 'Folder not found or out of your perimeter']);
}
......
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