From 21711d82e87c0b177cd2858c81f0fc6230940c17 Mon Sep 17 00:00:00 2001 From: Damien <damien.burel@maarch.org> Date: Thu, 21 Nov 2019 16:23:47 +0100 Subject: [PATCH] FEAT #11691 small adjustments --- .../controllers/AttachmentController.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/app/attachment/controllers/AttachmentController.php b/src/app/attachment/controllers/AttachmentController.php index e294e9bfe42..0db33a4bfb1 100755 --- a/src/app/attachment/controllers/AttachmentController.php +++ b/src/app/attachment/controllers/AttachmentController.php @@ -107,7 +107,12 @@ class AttachmentController return $response->withStatus(400)->withJson(['errors' => 'Attachment type out of perimeter']); } - $attachment['typist'] = UserModel::getLabelledUserById(['login' => $attachment['typist']]); + if ($attachment['modificationDate'] == $attachment['creationDate']) { + $attachment['modificationDate'] = null; + } + $typist = UserModel::getByLogin(['login' => $attachment['typist'], 'select' => ['id', 'firstname', 'lastname']]); + $attachment['typist'] = $typist['id']; + $attachment['typistLabel'] = $typist['firstname']. ' ' .$typist['lastname']; $attachment['modifiedBy'] = UserModel::getLabelledUserById(['id' => $attachment['modifiedBy']]); $attachmentsTypes = AttachmentModel::getAttachmentsTypesByXML(); @@ -231,7 +236,7 @@ class AttachmentController return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); } if ($GLOBALS['userId'] != $attachment['typist'] && !PrivilegeController::hasPrivilege(['privilegeId' => 'manage_attachments', 'userId' => $GLOBALS['id']])) { - return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); + return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); } if (empty($attachment['origin_id'])) { @@ -284,7 +289,12 @@ class AttachmentController $attachmentsTypes = AttachmentModel::getAttachmentsTypesByXML(); foreach ($attachments as $key => $attachment) { - $attachments[$key]['typist'] = UserModel::getLabelledUserById(['login' => $attachment['typist']]); + if ($attachment['modificationDate'] == $attachment['creationDate']) { + $attachments[$key]['modificationDate'] = null; + } + $typist = UserModel::getByLogin(['login' => $attachment['typist'], 'select' => ['id', 'firstname', 'lastname']]); + $attachments[$key]['typist'] = $typist['id']; + $attachments[$key]['typistLabel'] = $typist['firstname']. ' ' .$typist['lastname']; $attachments[$key]['modifiedBy'] = UserModel::getLabelledUserById(['id' => $attachment['modifiedBy']]); if (!empty($attachmentsTypes[$attachment['type']]['label'])) { -- GitLab