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

FEAT #9685 Redirect informations entity tree 3

parent c35c427c
No related branches found
No related tags found
No related merge requests found
......@@ -240,6 +240,7 @@ class ActionMethodController
public static function getRedirectInformations(Request $request, Response $response, array $args)
{
$currentUser = UserModel::getByLogin(['login' => $GLOBALS['userId'], 'select' => ['id']]);
$primaryEntity = UserModel::getPrimaryEntityByUserId(['userId' => $GLOBALS['userId']]);
$errors = ResourceListController::listControl(['groupId' => $args['groupId'], 'userId' => $args['userId'], 'basketId' => $args['basketId'], 'currentUserId' => $currentUser['id']]);
if (!empty($errors['errors'])) {
......@@ -307,6 +308,9 @@ class ActionMethodController
if (in_array($value['entity_id'], $allowedEntities)) {
$allEntities[$key]['allowed'] = true;
$allEntities[$key]['state']['opened'] = true;
if ($primaryEntity['entity_id'] == $value['entity_id']) {
$allEntities[$key]['state']['selected'] = true;
}
} else {
$allEntities[$key]['allowed'] = false;
$allEntities[$key]['state']['disabled'] = true;
......@@ -346,7 +350,10 @@ class ActionMethodController
$allowedEntities = array_unique($allowedEntities);
$users = UserEntityModel::getUsersByEntities(['select' => ['DISTINCT id', 'users.user_id', 'firstname', 'lastname'], 'entities' => $allowedEntities]);
$users = [];
if (!empty($allowedEntities)) {
$users = UserEntityModel::getUsersByEntities(['select' => ['DISTINCT id', 'users.user_id', 'firstname', 'lastname'], 'entities' => $allowedEntities]);
}
return $response->withJson(['entities' => $allEntities, 'users' => $users]);
}
......
......@@ -268,10 +268,10 @@ class ListTemplateController
foreach ($listTemplates as $key => $value) {
if ($value['item_type'] == 'entity_id') {
$listTemplates[$key]['idToDisplay'] = entitymodel::getByEntityId(['entityId' => $value['item_id'], 'select' => ['entity_label']])['entity_label'];
$listTemplates[$key]['labelToDisplay'] = entitymodel::getByEntityId(['entityId' => $value['item_id'], 'select' => ['entity_label']])['entity_label'];
$listTemplates[$key]['descriptionToDisplay'] = '';
} else {
$listTemplates[$key]['idToDisplay'] = UserModel::getLabelledUserById(['login' => $value['item_id']]);
$listTemplates[$key]['labelToDisplay'] = UserModel::getLabelledUserById(['login' => $value['item_id']]);
$listTemplates[$key]['descriptionToDisplay'] = UserModel::getPrimaryEntityByUserId(['userId' => $value['item_id']])['entity_label'];
}
}
......@@ -310,10 +310,6 @@ class ListTemplateController
public function getTypeRoles(Request $request, Response $response, array $aArgs)
{
if (!ServiceModel::hasService(['id' => 'manage_entities', 'userId' => $GLOBALS['userId'], 'location' => 'entities', 'type' => 'admin'])) {
return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
}
$unneededRoles = [];
if ($aArgs['typeId'] == 'entity_id') {
$unneededRoles = ['visa', 'sign'];
......
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