Skip to content
Snippets Groups Projects
Commit ceece56e authored by nicolas lebozec's avatar nicolas lebozec
Browse files

FIX #19031 TIME 0:05 Change the position of the

parent 8d414d8a
No related branches found
No related tags found
No related merge requests found
...@@ -132,6 +132,11 @@ class DocumentController ...@@ -132,6 +132,11 @@ class DocumentController
public function getById(Request $request, Response $response, array $args) public function getById(Request $request, Response $response, array $args)
{ {
$canManageDocuments = PrivilegeController::hasPrivilege(['userId' => $GLOBALS['id'], 'privilege' => 'manage_documents']);
if (!$canManageDocuments && !DocumentController::hasRightById(['id' => $args['id'], 'userId' => $GLOBALS['id'], 'readOnly' => true])) {
return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']);
}
if (!DocumentController::hasRightById(['id' => $args['id'], 'userId' => $GLOBALS['id'], 'readOnly' => true]) && !PrivilegeController::hasPrivilege(['userId' => $GLOBALS['id'], 'privilege' => 'manage_documents'])) { if (!DocumentController::hasRightById(['id' => $args['id'], 'userId' => $GLOBALS['id'], 'readOnly' => true]) && !PrivilegeController::hasPrivilege(['userId' => $GLOBALS['id'], 'privilege' => 'manage_documents'])) {
return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']);
} }
...@@ -225,12 +230,7 @@ class DocumentController ...@@ -225,12 +230,7 @@ class DocumentController
$currentId = $value['user_id']; $currentId = $value['user_id'];
} }
} }
$canManageDocuments = PrivilegeController::hasPrivilege(['userId' => $GLOBALS['id'], 'privilege' => 'manage_documents']);
if (!$canManageDocuments && !DocumentController::hasRightById(['id' => $args['id'], 'userId' => $GLOBALS['id'], 'readOnly' => true])) {
return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']);
}
$formattedDocument['readOnly'] = !$canManageDocuments; $formattedDocument['readOnly'] = !$canManageDocuments;
if ($formattedDocument['readOnly'] && !empty($currentId)) { if ($formattedDocument['readOnly'] && !empty($currentId)) {
if ($currentId == $GLOBALS['id']) { if ($currentId == $GLOBALS['id']) {
......
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