From affde58cb64829a881133e95fe53f1e5a8cdb3e4 Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Thu, 30 Jan 2020 18:50:34 +0100 Subject: [PATCH] FEAT #12346 TIME 0:15 fix control set in integration + change get integrations --- rest/index.php | 1 - .../resource/controllers/ResController.php | 19 ++----------------- .../controllers/ResourceListController.php | 3 ++- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/rest/index.php b/rest/index.php index a5a20e66c78..eee8e31a298 100755 --- a/rest/index.php +++ b/rest/index.php @@ -372,7 +372,6 @@ $app->get('/resources/{resId}/users/{userId}/isDestinationChanging', \Action\con $app->get('/resources/{resId}/users/{userId}/groups/{groupId}/baskets/{basketId}/processingData', \Resource\controllers\ResController::class . ':getProcessingData'); $app->post('/resources/exportData', \Resource\controllers\ResourceDataExportController::class . ':generateFile'); $app->put('/resources/{resId}/integrations', \Resource\controllers\ResController::class . ':setInIntegrations'); -$app->get('/resources/{resId}/integrations', \Resource\controllers\ResController::class . ':getInIntegrations'); //ResourcesList $app->get('/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}', \Resource\controllers\ResourceListController::class . ':get'); diff --git a/src/app/resource/controllers/ResController.php b/src/app/resource/controllers/ResController.php index 08055913610..64aa6bacc00 100755 --- a/src/app/resource/controllers/ResController.php +++ b/src/app/resource/controllers/ResController.php @@ -727,18 +727,15 @@ class ResController } $resource = ResModel::getById(['resId' => $args['resId'], 'select' => ['integrations']]); - if (empty($resource)) { - return $response->withStatus(400)->withJson(['errors' => 'Resource not found']); - } $integrations = json_decode($resource['integrations'], true); - if (!empty($body['integrations']['inSignatureBook']) && Validator::boolType()->validate($body['integrations']['inSignatureBook'])) { + if (Validator::boolType()->validate($body['integrations']['inSignatureBook'])) { $integrations['inSignatureBook'] = $body['integrations']['inSignatureBook']; } else { $integrations['inSignatureBook'] = $integrations['inSignatureBook'] ?? false; } - if (!empty($body['integrations']['inShipping']) && Validator::boolType()->validate($body['integrations']['inShipping'])) { + if (Validator::boolType()->validate($body['integrations']['inShipping'])) { $integrations['inShipping'] = $body['integrations']['inShipping']; } else { $integrations['inShipping'] = $integrations['inShipping'] ?? false; @@ -755,18 +752,6 @@ class ResController return $response->withStatus(204); } - public static function getInIntegrations(Request $request, Response $response, array $args) - { - if (!Validator::intVal()->validate($args['resId']) || !ResController::hasRightByResId(['resId' => [$args['resId']], 'userId' => $GLOBALS['id']])) { - return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); - } - - $resource = ResModel::getById(['resId' => $args['resId'], 'select' => ['integrations']]); - $integrations = json_decode($resource['integrations'], true); - - return $response->withJson(['integrations' => $integrations]); - } - public static function getEncodedDocument(array $aArgs) { ValidatorModel::notEmpty($aArgs, ['resId']); diff --git a/src/app/resource/controllers/ResourceListController.php b/src/app/resource/controllers/ResourceListController.php index c5189dd9be5..fca9109a599 100644 --- a/src/app/resource/controllers/ResourceListController.php +++ b/src/app/resource/controllers/ResourceListController.php @@ -107,7 +107,7 @@ class ResourceListController 'res_letterbox.res_id', 'res_letterbox.subject', 'res_letterbox.barcode', 'res_letterbox.alt_identifier', 'status.label_status AS "status.label_status"', 'status.img_filename AS "status.img_filename"', 'priorities.color AS "priorities.color"', 'res_letterbox.closing_date', 'res_letterbox.locker_user_id', 'res_letterbox.locker_time', 'res_letterbox.confidentiality', - 'res_letterbox.filename as res_filename' + 'res_letterbox.filename as res_filename', 'res_letterbox.integrations' ]; $tableFunction = ['status', 'priorities']; $leftJoinFunction = ['res_letterbox.status = status.id', 'res_letterbox.priority = priorities.id']; @@ -792,6 +792,7 @@ class ResourceListController $formattedResources[$key]['countAttachments'] = 0; $formattedResources[$key]['hasDocument'] = $resource['res_filename'] != null; $formattedResources[$key]['mailTracking'] = in_array($resource['res_id'], $args['trackedMails']); + $formattedResources[$key]['integrations'] = json_decode($resource['integrations'], true); foreach ($attachments as $attachment) { if ($attachment['res_id_master'] == $resource['res_id']) { $formattedResources[$key]['countAttachments'] = $attachment['count']; -- GitLab