diff --git a/rest/index.php b/rest/index.php index ebcd558ba15a5e3e5ec7feb77279ad7a7c0e850d..d3511c4f8250c503a159da8c3eb161bde46d5d12 100755 --- a/rest/index.php +++ b/rest/index.php @@ -384,6 +384,7 @@ $app->post('/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}/ch $app->post('/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}/checkExternalNoteBook', \Action\controllers\PreProcessActionController::class . ':checkExternalNoteBook'); $app->get('/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}/actions/{actionId}/getRedirect', \Action\controllers\PreProcessActionController::class . ':getRedirectInformations'); $app->post('/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}/actions/{actionId}/checkShippings', \Action\controllers\PreProcessActionController::class . ':checkShippings'); +$app->post('/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}/actions/{actionId}/checkSignatureBook', \Action\controllers\PreProcessActionController::class . ':checkSignatureBook'); //Search $app->get('/search', \Search\controllers\SearchController::class . ':get'); diff --git a/src/app/action/controllers/PreProcessActionController.php b/src/app/action/controllers/PreProcessActionController.php index cb182aa8207b6519ca7d5a71c3d34ec38910e8ec..ad1f880e5523e56ce496a05480a14d97d75b279d 100755 --- a/src/app/action/controllers/PreProcessActionController.php +++ b/src/app/action/controllers/PreProcessActionController.php @@ -798,6 +798,56 @@ class PreProcessActionController ]); } + public function checkSignatureBook(Request $request, Response $response, array $args) + { + $body = $request->getParsedBody(); + + if (!Validator::arrayType()->notEmpty()->validate($body['resources'])) { + return $response->withStatus(400)->withJson(['errors' => 'Body resources is empty or not an array']); + } + + $errors = ResourceListController::listControl(['groupId' => $args['groupId'], 'userId' => $args['userId'], 'basketId' => $args['basketId'], 'currentUserId' => $GLOBALS['id']]); + if (!empty($errors['errors'])) { + return $response->withStatus($errors['code'])->withJson(['errors' => $errors['errors']]); + } + + $body['resources'] = array_slice($body['resources'], 0, 500); + if (!ResController::hasRightByResId(['resId' => $body['resources'], 'userId' => $GLOBALS['id']])) { + return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); + } + + $signableAttachmentsTypes = []; + $attachmentsTypes = AttachmentModel::getAttachmentsTypesByXML(); + foreach ($attachmentsTypes as $key => $type) { + if ($type['sign']) { + $signableAttachmentsTypes[] = $key; + } + } + + $resourcesInformations = []; + foreach ($body['resources'] as $resId) { + $resource = ResModel::getById(['resId' => $resId, 'select' => ['alt_identifier']]); + if (empty($resource['alt_identifier'])) { + $resource['alt_identifier'] = _UNDEFINED; + } + + $attachments = AttachmentModel::get([ + 'select' => [1], + 'where' => ['res_id_master = ?', 'attachment_type in (?)', 'in_signature_book = ?', 'status not in (?)'], + 'data' => [$resId, $signableAttachmentsTypes, true, ['OBS', 'DEL', 'FRZ']], + 'groupBy' => ['res_id_master'] + ]); + + if (empty($attachments)) { + $resourcesInformations['noAttachment'][] = ['alt_identifier' => $resource['alt_identifier'], 'res_id' => $resId, 'reason' => 'noAttachmentInSignatoryBook']; + } else { + $resourcesInformations['attachments'][] = ['res_id' => $resId]; + } + } + + return $response->withJson(['resourcesInformations' => $resourcesInformations]); + } + public function isDestinationChanging(Request $request, Response $response, array $args) { if (!ResController::hasRightByResId(['resId' => [$args['resId']], 'userId' => $GLOBALS['id']])) { diff --git a/src/app/contentManagement/controllers/OnlyOfficeController.php b/src/app/contentManagement/controllers/OnlyOfficeController.php index 741073fee362eef0880e3554b3cecca4b53cd1c0..4b2e81fae89fe5bb19413a71487e889331461885 100644 --- a/src/app/contentManagement/controllers/OnlyOfficeController.php +++ b/src/app/contentManagement/controllers/OnlyOfficeController.php @@ -161,7 +161,10 @@ class OnlyOfficeController $checkUrl = str_replace('http://', '', $queryParams['url']); $checkUrl = str_replace('https://', '', $checkUrl); - if (strpos($checkUrl, (string)$loadedXml->onlyoffice->server_uri .'/cache/files/') !== 0) { + $uri = (string)$loadedXml->onlyoffice->server_uri; + $port = (string)$loadedXml->onlyoffice->server_port; + + if (strpos($checkUrl, "{$uri}:{$port}/cache/files/") !== 0) { return $response->withStatus(400)->withJson(['errors' => 'Query params url is not allowed']); } diff --git a/src/app/resource/controllers/ResController.php b/src/app/resource/controllers/ResController.php index 309838f9bcd9edbb1a838240c6017e1f635f3f93..eafd381c3787c1c384db0f84536e39a374c0ae4e 100755 --- a/src/app/resource/controllers/ResController.php +++ b/src/app/resource/controllers/ResController.php @@ -238,7 +238,7 @@ class ResController $formattedData['opinionCircuit'] = 0; $listInstanceItems = ListInstanceModel::get(['select' => ['count(1)', 'difflist_type'], 'where' => ['res_id = ?'], 'data' => [$args['resId']], 'groupBy' => ['difflist_type']]); foreach ($listInstanceItems as $item) { - $type = $item['difflist_type'] == 'entity_id' ? 'diffusionList' : ($item['difflist_type'] == 'visaCircuit' ? 'visaCircuitItems' : 'opinionCircuit'); + $type = $item['difflist_type'] == 'entity_id' ? 'diffusionList' : ($item['difflist_type'] == 'VISA_CIRCUIT' ? 'visaCircuit' : 'opinionCircuit'); $formattedData[$type] = $item['count']; }