Skip to content
Snippets Groups Projects
Commit fdccd644 authored by Guillaume Heurtier's avatar Guillaume Heurtier
Browse files

FEAT #12091 TIME 1:300 create private template

parent c83b0377
No related branches found
No related tags found
No related merge requests found
......@@ -97,12 +97,26 @@ class ListTemplateController
{
$body = $request->getParsedBody();
if (!PrivilegeController::hasPrivilege(['privilegeId' => 'manage_entities', 'userId' => $GLOBALS['id']]) && !empty($body['entityId'])) {
return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
}
if (empty($body['private'])) {
if (!PrivilegeController::hasPrivilege(['privilegeId' => 'manage_entities', 'userId' => $GLOBALS['id']]) && !empty($body['entityId'])) {
return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
}
if (!PrivilegeController::hasPrivilege(['privilegeId' => 'admin_listmodels', 'userId' => $GLOBALS['id']]) && empty($body['entityId'])) {
return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
if (!PrivilegeController::hasPrivilege(['privilegeId' => 'admin_listmodels', 'userId' => $GLOBALS['id']]) && empty($body['entityId'])) {
return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
}
$owner = null;
} else {
if (!empty($body['entityId'])) {
return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
}
if ($body['type'] == 'visaCircuit'
&& !PrivilegeController::hasPrivilege(['privilegeId' => 'config_visa_workflow', 'userId' => $GLOBALS['id']])) {
return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
}
$owner = $GLOBALS['id'];
}
$allowedTypes = ['diffusionList', 'visaCircuit', 'opinionCircuit'];
......@@ -135,7 +149,8 @@ class ListTemplateController
'title' => $body['title'] ?? $body['description'],
'description' => $body['description'] ?? null,
'type' => $body['type'],
'entity_id' => $body['entityId'] ?? null
'entity_id' => $body['entityId'] ?? null,
'owner' => $owner
]);
foreach ($body['items'] as $key => $item) {
......
......@@ -65,11 +65,12 @@ class ListTemplateModel
DatabaseModel::insert([
'table' => 'list_templates',
'columnsValues' => [
'id' => $nextSequenceId,
'title' => $args['title'],
'description' => $args['description'] ?? null,
'type' => $args['type'],
'entity_id' => $args['entity_id'] ?? null
'id' => $nextSequenceId,
'title' => $args['title'],
'description' => $args['description'] ?? null,
'type' => $args['type'],
'entity_id' => $args['entity_id'] ?? null,
'owner' => $args['owner']
]
]);
......
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