Skip to content
Snippets Groups Projects
Verified Commit ebbc506d authored by Damien's avatar Damien
Browse files

FIX #12070 TIME 0:15 Destination and initiator are integer in webservice

parent 7b7db495
No related branches found
No related tags found
No related merge requests found
...@@ -781,7 +781,7 @@ class ResController ...@@ -781,7 +781,7 @@ class ResController
if (!empty($body['initiator'])) { if (!empty($body['initiator'])) {
$userEntities = UserModel::getEntitiesByLogin(['login' => $GLOBALS['userId']]); $userEntities = UserModel::getEntitiesByLogin(['login' => $GLOBALS['userId']]);
$userEntities = array_column($userEntities, 'entity_id'); $userEntities = array_column($userEntities, 'id');
if (!in_array($body['initiator'], $userEntities)) { if (!in_array($body['initiator'], $userEntities)) {
return ['errors' => "Body initiator does not belong to your entities"]; return ['errors' => "Body initiator does not belong to your entities"];
} }
...@@ -1011,16 +1011,15 @@ class ResController ...@@ -1011,16 +1011,15 @@ class ResController
$allowedEntities = array_unique($allowedEntities); $allowedEntities = array_unique($allowedEntities);
} }
$preparedClause = '';
if (!empty($clauseToProcess)) { if (!empty($clauseToProcess)) {
$preparedClause = PreparedClauseController::getPreparedClause(['clause' => $clauseToProcess, 'login' => $GLOBALS['userId']]); $preparedClause = PreparedClauseController::getPreparedClause(['clause' => $clauseToProcess, 'login' => $GLOBALS['userId']]);
} $preparedEntities = EntityModel::get(['select' => ['id'], 'where' => ['enabled = ?', "entity_id in {$preparedClause}"], 'data' => ['Y']]);
if (!empty($allowedEntities)) { $preparedEntities = array_column($preparedEntities, 'id');
$preparedEntities = EntityModel::get(['select' => ['entity_id'], 'where' => ['enabled = ?', 'id in (?)'], 'data' => ['Y', $allowedEntities]]); $allowedEntities = array_merge($allowedEntities, $preparedEntities);
$allowedEntities = array_column($preparedEntities, 'entity_id'); $allowedEntities = array_unique($allowedEntities);
} }
if (!in_array($body['destination'], $allowedEntities) && strpos($preparedClause, $body['destination']) === false) { if (!in_array($body['destination'], $allowedEntities)) {
return ['errors' => "Body destination is out of your indexing parameters"]; return ['errors' => "Body destination is out of your indexing parameters"];
} }
} }
......
...@@ -17,6 +17,7 @@ namespace Resource\controllers; ...@@ -17,6 +17,7 @@ namespace Resource\controllers;
use Attachment\models\AttachmentModel; use Attachment\models\AttachmentModel;
use Docserver\controllers\DocserverController; use Docserver\controllers\DocserverController;
use Entity\models\EntityModel;
use IndexingModel\models\IndexingModelModel; use IndexingModel\models\IndexingModelModel;
use Resource\models\ChronoModel; use Resource\models\ChronoModel;
use SrcCore\models\DatabaseModel; use SrcCore\models\DatabaseModel;
...@@ -125,6 +126,15 @@ class StoreController ...@@ -125,6 +126,15 @@ class StoreController
$chrono = ChronoModel::getChrono(['id' => $indexingModel['category'], 'entityId' => $args['destination'], 'typeId' => $args['doctype'], 'resId' => $args['resId']]); $chrono = ChronoModel::getChrono(['id' => $indexingModel['category'], 'entityId' => $args['destination'], 'typeId' => $args['doctype'], 'resId' => $args['resId']]);
} }
if (!empty($args['initiator'])) {
$entity = EntityModel::getById(['id' => $args['initiator'], 'select' => ['entity_id']]);
$args['initiator'] = $entity['entity_id'];
}
if (!empty($args['destination'])) {
$entity = EntityModel::getById(['id' => $args['destination'], 'select' => ['entity_id']]);
$args['destination'] = $entity['entity_id'];
}
if (!empty($args['processLimitDate']) && !empty($args['priority'])) { if (!empty($args['processLimitDate']) && !empty($args['priority'])) {
$args['priority'] = IndexingController::calculatePriorityWithProcessLimitDate(['processLimitDate' => $args['processLimitDate']]); $args['priority'] = IndexingController::calculatePriorityWithProcessLimitDate(['processLimitDate' => $args['processLimitDate']]);
} }
......
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