Skip to content
Snippets Groups Projects
Commit 4a5beb6e authored by Florian Azizian's avatar Florian Azizian
Browse files

FEAT #11643 TIME 1 add ownerDisplayName and entity label sharing folder

parent 965a7ff3
No related branches found
No related tags found
No related merge requests found
......@@ -107,12 +107,14 @@ class FolderController
}
$folder = $folder[0];
$ownerInfo = UserModel::getById(['select' => ['firstname', 'lastname'], 'id' => $folder['user_id']]);
$folder['ownerDisplayName'] = $ownerInfo['firstname'] . ' ' . $ownerInfo['lastname'];
$folder['sharing']['entities'] = [];
if ($folder['public']) {
$entitiesFolder = EntityFolderModel::getByFolderId(['folder_id' => $args['id']]);
$entitiesFolder = EntityFolderModel::getByFolderId(['folder_id' => $args['id'], 'select' => ['entities_folders.entity_id', 'entities_folders.edition', 'entities.entity_label']]);
foreach ($entitiesFolder as $value) {
$folder['sharing']['entities'][] = ['entity_id' => $value['entity_id'], 'edition' => $value['edition']];
$folder['sharing']['entities'][] = ['entity_id' => $value['entity_id'], 'edition' => $value['edition'], 'label' => $value['entity_label']];
}
}
......@@ -193,7 +195,7 @@ class FolderController
return $response->withStatus(400)->withJson(['errors' => 'Parent_id and id can not be the same']);
}
if (!empty($data['parent_id']) && FolderController::isParentFolder(['parent_id' => $data['parent_id'], 'id' => $aArgs['id']])) {
return $response->withStatus(400)->withJson(['errors' => 'Id is a parent of parent_id']);
return $response->withStatus(400)->withJson(['errors' => 'parent_id does not exist or Id is a parent of parent_id']);
}
$folder = FolderController::getScopeFolders(['login' => $GLOBALS['userId'], 'folderId' => $aArgs['id'], 'edition' => true]);
......
......@@ -23,7 +23,8 @@ class EntityFolderModelAbstract
$entitiesFolder = DatabaseModel::select([
'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
'table' => ['entities_folders'],
'table' => ['entities_folders', 'entities'],
'left_join' => ['entities_folders.entity_id = entities.id'],
'where' => ['folder_id = ?'],
'data' => [$aArgs['folder_id']]
]);
......
......@@ -86,7 +86,7 @@ class FolderControllerTest extends TestCase
$response = $folderController->update($fullRequest, new \Slim\Http\Response(), ['id' => self::$id]);
$responseBody = json_decode((string)$response->getBody());
$this->assertSame('Parent Folder not found or out of your perimeter', $responseBody->errors);
$this->assertSame('parent_id does not exist or Id is a parent of parent_id', $responseBody->errors);
}
public function testGetById()
......@@ -106,6 +106,8 @@ class FolderControllerTest extends TestCase
$this->assertSame(0, $responseBody->folder->level);
$this->assertInternalType('array', $responseBody->folder->sharing->entities);
$this->assertInternalType('integer', $responseBody->folder->user_id);
$this->assertNotEmpty($responseBody->folder->user_id);
$this->assertNotEmpty($responseBody->folder->ownerDisplayName);
// ERROR
$response = $folderController->getById($request, new \Slim\Http\Response(), ['id' => '123456789']);
......
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