Merge branch 'develop'
commit
f1a3de74b0
|
@ -90,6 +90,9 @@ class AuthKeysController extends AppController
|
||||||
if (!in_array($data['user_id'], array_keys($users))) {
|
if (!in_array($data['user_id'], array_keys($users))) {
|
||||||
throw new MethodNotAllowedException(__('You are not authorised to do that.'));
|
throw new MethodNotAllowedException(__('You are not authorised to do that.'));
|
||||||
}
|
}
|
||||||
|
if (empty($data['expiration'])) {
|
||||||
|
$data['expiration'] = 0;
|
||||||
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -29,7 +29,7 @@ class AuthKeysTable extends AppTable
|
||||||
public function beforeMarshal(EventInterface $event, ArrayObject $data, ArrayObject $options)
|
public function beforeMarshal(EventInterface $event, ArrayObject $data, ArrayObject $options)
|
||||||
{
|
{
|
||||||
$data['created'] = time();
|
$data['created'] = time();
|
||||||
if (!isset($data['expiration'])) {
|
if (!isset($data['expiration']) || empty($data['expiration'])) {
|
||||||
$data['expiration'] = 0;
|
$data['expiration'] = 0;
|
||||||
} else {
|
} else {
|
||||||
$data['expiration'] = strtotime($data['expiration']);
|
$data['expiration'] = strtotime($data['expiration']);
|
||||||
|
|
|
@ -125,17 +125,29 @@ class IndividualsTable extends AppTable
|
||||||
|
|
||||||
public function getValidIndividualsToEdit(object $currentUser): array
|
public function getValidIndividualsToEdit(object $currentUser): array
|
||||||
{
|
{
|
||||||
$validRoles = $this->Users->Roles->find('list')->select(['id'])->where(['perm_admin' => 0, 'perm_org_admin' => 0])->all()->toArray();
|
$isSiteAdmin = $currentUser['role']['perm_admin'];
|
||||||
$validIndividualIds = $this->Users->find()->select(['individual_id'])->where(
|
$isGroupAdmin = $currentUser['role']['perm_group_admin'];
|
||||||
[
|
$validRoles = $this->Users->Roles->find('list')->select(['id']);
|
||||||
'organisation_id' => $currentUser['organisation_id'],
|
if (!$isSiteAdmin) {
|
||||||
'disabled' => 0,
|
$validRoles->where(['perm_admin' => 0]);
|
||||||
'OR' => [
|
}
|
||||||
|
$validRoles = $validRoles->all()->toArray();
|
||||||
|
$conditions = [
|
||||||
|
'disabled' => 0
|
||||||
|
];
|
||||||
|
if (!$isSiteAdmin) {
|
||||||
|
$conditions['OR'] = [
|
||||||
['role_id IN' => array_keys($validRoles)],
|
['role_id IN' => array_keys($validRoles)],
|
||||||
['id' => $currentUser['id']],
|
['id' => $currentUser['id']]
|
||||||
]
|
];
|
||||||
]
|
if ($isGroupAdmin) {
|
||||||
)->all()->extract('individual_id')->toArray();
|
$OrgGroups = \Cake\ORM\TableRegistry::getTableLocator()->get('OrgGroups');
|
||||||
|
$conditions['organisation_id IN'] = $OrgGroups->getGroupOrgIdsForUser($currentUser);
|
||||||
|
} else {
|
||||||
|
$conditions['organisation_id'] = $currentUser['organisation_id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$validIndividualIds = $this->Users->find()->select(['individual_id'])->where($conditions)->all()->extract('individual_id')->toArray();
|
||||||
return $validIndividualIds;
|
return $validIndividualIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ echo $this->element('genericElements/Form/genericForm', [
|
||||||
'field' => 'expiration',
|
'field' => 'expiration',
|
||||||
'label' => __('Expiration'),
|
'label' => __('Expiration'),
|
||||||
'type' => 'datetime',
|
'type' => 'datetime',
|
||||||
|
'required' => false
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'submit' => [
|
'submit' => [
|
||||||
|
|
|
@ -40,6 +40,12 @@ echo $this->element(
|
||||||
'scope' => 'individuals'
|
'scope' => 'individuals'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'children' => []
|
'children' => [
|
||||||
|
[
|
||||||
|
'url' => '/EncryptionKeys/index?owner_id={{0}}&owner_model=individual',
|
||||||
|
'url_params' => ['id'],
|
||||||
|
'title' => __('Encryption keys')
|
||||||
|
]
|
||||||
|
]
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Cake\ORM\TableRegistry;
|
use Cake\ORM\TableRegistry;
|
||||||
|
use Cake\Routing\Router;
|
||||||
|
|
||||||
$bookmarks = !empty($loggedUser->user_settings_by_name['ui.bookmarks']['value']) ? json_decode($loggedUser->user_settings_by_name['ui.bookmarks']['value'], true) : [];
|
$bookmarks = !empty($loggedUser->user_settings_by_name['ui.bookmarks']['value']) ? json_decode($loggedUser->user_settings_by_name['ui.bookmarks']['value'], true) : [];
|
||||||
$this->userSettingsTable = TableRegistry::getTableLocator()->get('UserSettings');
|
$this->userSettingsTable = TableRegistry::getTableLocator()->get('UserSettings');
|
||||||
|
@ -49,9 +50,10 @@ $this->userSettingsTable = TableRegistry::getTableLocator()->get('UserSettings')
|
||||||
$modelForDisplay = $exploded[count($exploded) - 1];
|
$modelForDisplay = $exploded[count($exploded) - 1];
|
||||||
$panelTitle = $this->Html->link(
|
$panelTitle = $this->Html->link(
|
||||||
h($modelForDisplay),
|
h($modelForDisplay),
|
||||||
$this->Url->build([
|
Router::url([
|
||||||
'controller' => $modelForDisplay,
|
'controller' => $modelForDisplay,
|
||||||
'action' => 'index',
|
'action' => 'index',
|
||||||
|
'?' => ['sort' => 'modified', 'direction' => 'desc']
|
||||||
]),
|
]),
|
||||||
['class' => 'text-white text-decoration-none fw-light stretched-link']
|
['class' => 'text-white text-decoration-none fw-light stretched-link']
|
||||||
);
|
);
|
||||||
|
|
|
@ -63,6 +63,12 @@ echo $this->element(
|
||||||
'data' => $entity,
|
'data' => $entity,
|
||||||
'fields' => $fields,
|
'fields' => $fields,
|
||||||
'combinedFieldsView' => false,
|
'combinedFieldsView' => false,
|
||||||
'children' => []
|
'children' => [
|
||||||
|
[
|
||||||
|
'url' => '/EncryptionKeys/index?owner_id={{0}}&owner_model=organisation',
|
||||||
|
'url_params' => ['id'],
|
||||||
|
'title' => __('Encryption keys')
|
||||||
|
]
|
||||||
|
]
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue