Skip to content
Snippets Groups Projects
Commit 467c801e authored by Jean-Laurent DUZANT's avatar Jean-Laurent DUZANT
Browse files

FIX #19541 TIME 0:10 check if doctype was changed, if it's not allowed

parent 2c836249
No related branches found
No related tags found
No related merge requests found
......@@ -128,7 +128,7 @@ class ResourceControlController
return ['errors' => 'Body is not set or empty'];
}
$resource = ResModel::getById(['resId' => $args['resId'], 'select' => ['status', 'model_id', 'format', 'initiator', 'external_id->>\'signatureBookId\' as signaturebookid', 'filename']]);
$resource = ResModel::getById(['resId' => $args['resId'], 'select' => ['type_id', 'status', 'model_id', 'format', 'initiator', 'external_id->>\'signatureBookId\' as signaturebookid', 'filename']]);
if (empty($resource['status'])) {
return ['errors' => 'Resource status is empty. It can not be modified'];
}
......@@ -188,7 +188,7 @@ class ResourceControlController
if (empty($body['modelId'])) {
$body['modelId'] = $resource['model_id'];
}
$control = ResourceControlController::controlIndexingModelFields(['body' => $body, 'isUpdating' => true]);
$control = ResourceControlController::controlIndexingModelFields(['body' => $body, 'oldDoctypeId' => $resource['type_id'], 'isUpdating' => true]);
if (!empty($control['errors'])) {
return ['errors' => $control['errors']];
}
......@@ -425,6 +425,9 @@ class ResourceControlController
} elseif ($customField['type'] == 'date' && !Validator::date()->notEmpty()->validate($body['customFields'][$customFieldId])) {
return ['errors' => "Body customFields[{$customFieldId}] is not a date"];
} elseif (!empty($indexingModelField['allowed_values']) && !in_array($body['customFields'][$customFieldId], $indexingModelField['allowed_values'])) {
if(!empty($args['oldDoctypeId']) && $body['customFields'][$customFieldId] == $args['oldDoctypeId']) {
continue;
}
return ['errors' => "Body {$indexingModelField['identifier']} is not one of the allowed values"];
}
}
......@@ -433,6 +436,9 @@ class ResourceControlController
} elseif ($indexingModelField['mandatory'] && !isset($body[$indexingModelField['identifier']])) {
return ['errors' => "Body {$indexingModelField['identifier']} is not set"];
} elseif (!empty($indexingModelField['allowed_values']) && !in_array($body[$indexingModelField['identifier']], $indexingModelField['allowed_values'])) {
if(!empty($args['oldDoctypeId']) && $body[$indexingModelField['identifier']] == $args['oldDoctypeId']) {
continue;
}
return ['errors' => "Body {$indexingModelField['identifier']} is not one of the allowed values"];
}
}
......
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