diff --git a/rest/index.php b/rest/index.php index 1d8cce6b66e45ec73465897419ebf99d60fc6d2f..58577f8a47ba3f51bb78b127ffa334aff9fd035e 100755 --- a/rest/index.php +++ b/rest/index.php @@ -379,6 +379,7 @@ $app->get('/resources/{resId}/emailsInitialization', \Email\controllers\EmailCon $app->get('/resources/{resId}/fields/{fieldId}', \Resource\controllers\ResController::class . ':getField'); $app->delete('/resources/{resId}/linkedResources/{id}', \Resource\controllers\LinkController::class . ':unlinkResources'); $app->delete('/resources/{resId}/circuits/{type}', \Entity\controllers\ListInstanceController::class . ':deleteCircuit'); +$app->get('/resources/{resId}/fileInformation', \Resource\controllers\ResController::class . ':getResourceFileInformation'); $app->put('/res/resource/status', \Resource\controllers\ResController::class . ':updateStatus'); $app->post('/res/list', \Resource\controllers\ResController::class . ':getList'); diff --git a/src/app/resource/controllers/ResController.php b/src/app/resource/controllers/ResController.php index 46acc801f894aaa8841faaf4d66461e03634d203..d9f48f55b6bf75c988bc5033994d9385fb62276c 100755 --- a/src/app/resource/controllers/ResController.php +++ b/src/app/resource/controllers/ResController.php @@ -1232,4 +1232,23 @@ class ResController extends ResourceControlController return $response->withJson(['listEventData' => $listEventData]); } + + public function getResourceFileInformation(Request $request, Response $response, array $args) + { + if (!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' => ['format', 'fingerprint', 'filesize', 'fulltext_result'] + ]); + + $allowedFiles = StoreController::getAllowedFiles(); + $allowedFiles = array_column($allowedFiles, 'extension'); + + $resource['canConvert'] = in_array(strtoupper($resource['format']), $allowedFiles); + + return $response->withJson(['information' => $resource]); + } }