2020-06-19 00:42:10 +02:00
|
|
|
<?php
|
2022-12-09 11:53:20 +01:00
|
|
|
|
|
|
|
use Cake\Core\Configure;
|
2020-06-19 00:42:10 +02:00
|
|
|
echo $this->element('genericElements/IndexTable/index_table', [
|
|
|
|
'data' => [
|
|
|
|
'data' => $data,
|
|
|
|
'top_bar' => [
|
|
|
|
'children' => [
|
2020-06-21 21:27:11 +02:00
|
|
|
[
|
|
|
|
'type' => 'simple',
|
|
|
|
'children' => [
|
|
|
|
'data' => [
|
|
|
|
'type' => 'simple',
|
|
|
|
'text' => __('Add User'),
|
|
|
|
'class' => 'btn btn-primary',
|
|
|
|
'popover_url' => '/users/add'
|
|
|
|
]
|
|
|
|
]
|
|
|
|
],
|
2020-06-19 00:42:10 +02:00
|
|
|
[
|
|
|
|
'type' => 'search',
|
2021-11-10 15:31:09 +01:00
|
|
|
'button' => __('Search'),
|
2020-06-19 00:42:10 +02:00
|
|
|
'placeholder' => __('Enter value to search'),
|
|
|
|
'data' => '',
|
|
|
|
'searchKey' => 'value'
|
2022-11-13 11:23:23 +01:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'type' => 'table_action',
|
2020-06-19 00:42:10 +02:00
|
|
|
]
|
|
|
|
]
|
|
|
|
],
|
|
|
|
'fields' => [
|
|
|
|
[
|
|
|
|
'name' => '#',
|
|
|
|
'sort' => 'id',
|
|
|
|
'data_path' => 'id',
|
|
|
|
],
|
2021-01-11 12:48:58 +01:00
|
|
|
[
|
|
|
|
'name' => __('Disabled'),
|
|
|
|
'sort' => 'disabled',
|
|
|
|
'data_path' => 'disabled',
|
|
|
|
'element' => 'toggle',
|
|
|
|
'url' => '/users/toggle/{{0}}',
|
|
|
|
'url_params_vars' => ['id'],
|
|
|
|
'toggle_data' => [
|
|
|
|
'editRequirement' => [
|
|
|
|
'function' => function($row, $options) {
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'skip_full_reload' => true
|
|
|
|
]
|
|
|
|
],
|
2020-06-21 21:27:11 +02:00
|
|
|
[
|
|
|
|
'name' => __('Username'),
|
|
|
|
'sort' => 'username',
|
|
|
|
'data_path' => 'username',
|
|
|
|
],
|
2021-11-24 01:25:57 +01:00
|
|
|
[
|
|
|
|
'name' => __('Organisation'),
|
|
|
|
'sort' => 'organisation.name',
|
|
|
|
'data_path' => 'organisation.name',
|
|
|
|
'url' => '/organisations/view/{{0}}',
|
|
|
|
'url_vars' => ['organisation.id']
|
|
|
|
],
|
2023-09-12 09:26:07 +02:00
|
|
|
[
|
|
|
|
'name' => __('Administered Groups'),
|
|
|
|
'data_path' => 'org_groups',
|
|
|
|
'data_id_sub_path' => 'id',
|
|
|
|
'data_value_sub_path' => 'name',
|
|
|
|
'element' => 'link_list',
|
|
|
|
'url_pattern' => '/orgGroups/view/{{data_id}}'
|
|
|
|
],
|
2020-06-19 00:42:10 +02:00
|
|
|
[
|
|
|
|
'name' => __('Email'),
|
|
|
|
'sort' => 'individual.email',
|
|
|
|
'data_path' => 'individual.email',
|
|
|
|
'url' => '/individuals/view/{{0}}',
|
|
|
|
'url_vars' => ['individual.id']
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'name' => __('First Name'),
|
|
|
|
'sort' => 'individual.first_name',
|
|
|
|
'data_path' => 'individual.first_name',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'name' => __('Last Name'),
|
|
|
|
'sort' => 'individual.last_name',
|
|
|
|
'data_path' => 'individual.last_name'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'name' => __('Role'),
|
|
|
|
'sort' => 'role.name',
|
|
|
|
'data_path' => 'role.name',
|
|
|
|
'url' => '/roles/view/{{0}}',
|
|
|
|
'url_vars' => ['role.id']
|
|
|
|
],
|
2023-05-25 16:22:49 +02:00
|
|
|
[
|
|
|
|
'name' => __('Country'),
|
|
|
|
'sort' => 'organisation.nationality',
|
|
|
|
'data_path' => 'organisation.nationality'
|
|
|
|
],
|
2021-10-08 10:27:40 +02:00
|
|
|
[
|
|
|
|
'name' => __('# User Settings'),
|
|
|
|
'element' => 'count_summary',
|
|
|
|
'data_path' => 'user_settings',
|
|
|
|
'url' => '/user-settings/index?Users.id={{url_data}}',
|
|
|
|
'url_data_path' => 'id'
|
|
|
|
],
|
2022-12-09 12:19:29 +01:00
|
|
|
// [ // We might want to uncomment this at some point
|
2022-12-09 11:53:20 +01:00
|
|
|
// 'name' => __('Keycloak status'),
|
|
|
|
// 'element' => 'keycloak_status',
|
|
|
|
// 'data_path' => 'keycloak_status',
|
|
|
|
// 'requirements' => Configure::read('keycloak.enabled', false),
|
|
|
|
// ],
|
2020-06-19 00:42:10 +02:00
|
|
|
],
|
|
|
|
'title' => __('User index'),
|
|
|
|
'description' => __('The list of enrolled users in this Cerebrate instance. All of the users have or at one point had access to the system.'),
|
2023-09-06 09:18:40 +02:00
|
|
|
'includeAllPagination' => true,
|
2020-06-19 00:42:10 +02:00
|
|
|
'actions' => [
|
|
|
|
[
|
|
|
|
'url' => '/users/view',
|
|
|
|
'url_params_data_paths' => ['id'],
|
|
|
|
'icon' => 'eye'
|
|
|
|
],
|
|
|
|
[
|
2021-01-11 16:28:07 +01:00
|
|
|
'open_modal' => '/users/edit/[onclick_params_data_path]',
|
|
|
|
'modal_params_data_path' => 'id',
|
2022-01-25 11:34:22 +01:00
|
|
|
'icon' => 'edit',
|
|
|
|
'complex_requirement' => [
|
|
|
|
'options' => [
|
|
|
|
'datapath' => [
|
|
|
|
'role_id' => 'role_id'
|
|
|
|
]
|
|
|
|
],
|
|
|
|
'function' => function ($row, $options) use ($loggedUser, $validRoles) {
|
|
|
|
if (empty($loggedUser['role']['perm_admin'])) {
|
2023-09-07 16:11:47 +02:00
|
|
|
if ($row['id'] == $loggedUser['id']) {
|
|
|
|
return true;
|
|
|
|
}
|
2022-01-25 11:34:22 +01:00
|
|
|
if (empty($loggedUser['role']['perm_org_admin'])) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!isset($validRoles[$options['datapath']['role_id']])) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
]
|
2020-06-19 00:42:10 +02:00
|
|
|
],
|
|
|
|
[
|
2021-01-11 16:28:07 +01:00
|
|
|
'open_modal' => '/users/delete/[onclick_params_data_path]',
|
|
|
|
'modal_params_data_path' => 'id',
|
2022-01-25 11:34:22 +01:00
|
|
|
'icon' => 'trash',
|
|
|
|
'complex_requirement' => [
|
|
|
|
'options' => [
|
|
|
|
'datapath' => [
|
|
|
|
'role_id' => 'role_id'
|
|
|
|
]
|
|
|
|
],
|
|
|
|
'function' => function ($row, $options) use ($loggedUser, $validRoles) {
|
2023-02-16 15:07:06 +01:00
|
|
|
if (empty(Configure::read('user.allow-user-deletion'))) {
|
|
|
|
return false;
|
|
|
|
}
|
2023-02-16 14:59:52 +01:00
|
|
|
if ($row['id'] == $loggedUser['id']) {
|
|
|
|
return false;
|
|
|
|
}
|
2022-01-25 11:34:22 +01:00
|
|
|
if (empty($loggedUser['role']['perm_admin'])) {
|
|
|
|
if (empty($loggedUser['role']['perm_org_admin'])) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!isset($validRoles[$options['datapath']['role_id']])) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
]
|
2021-01-11 16:28:07 +01:00
|
|
|
],
|
2020-06-19 00:42:10 +02:00
|
|
|
]
|
|
|
|
]
|
|
|
|
]);
|
|
|
|
echo '</div>';
|
|
|
|
?>
|