fix: [sharingGroup] Various fixes for sharing groups
- Renamed sharingGroupsOrgs table to follow cake4's recommendation - Fix case if logged user doesn't have an organisation - Provide all orgs if user is admin - Fix issue with model associated with sharingGroupOrgs - Fix addOrg missing entity for genericForm helperpull/34/head
parent
62d9a73673
commit
54c513613e
|
@ -8,6 +8,8 @@ DROP TABLE IF EXISTS encryption_keys;
|
||||||
DROP TABLE IF EXISTS organisation_encryption_keys;
|
DROP TABLE IF EXISTS organisation_encryption_keys;
|
||||||
DROP TABLE IF EXISTS organisations;
|
DROP TABLE IF EXISTS organisations;
|
||||||
DROP TABLE IF EXISTS roles;
|
DROP TABLE IF EXISTS roles;
|
||||||
|
DROP TABLE IF EXISTS sharing_groups;
|
||||||
|
DROP TABLE IF EXISTS organisations_sharing_groups;
|
||||||
DROP TABLE IF EXISTS tags;
|
DROP TABLE IF EXISTS tags;
|
||||||
DROP TABLE IF EXISTS user_keys;
|
DROP TABLE IF EXISTS user_keys;
|
||||||
DROP TABLE IF EXISTS users;
|
DROP TABLE IF EXISTS users;
|
||||||
|
|
|
@ -309,7 +309,7 @@ CREATE TABLE `sharing_groups` (
|
||||||
KEY `name` (`name`)
|
KEY `name` (`name`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|
||||||
CREATE TABLE `sharing_group_orgs` (
|
CREATE TABLE `organisations_sharing_groups` (
|
||||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`sharing_group_id` int(10) unsigned NOT NULL,
|
`sharing_group_id` int(10) unsigned NOT NULL,
|
||||||
`organisation_id` int(10) unsigned NOT NULL,
|
`organisation_id` int(10) unsigned NOT NULL,
|
||||||
|
|
|
@ -29,12 +29,7 @@ class SharingGroupsController extends AppController
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
$dropdownData = [
|
$dropdownData = [
|
||||||
'organisation' => $this->SharingGroups->Organisations->find('list', [
|
'organisation' => $this->getAvailableOrgForSg($this->ACL->getUser())
|
||||||
'sort' => ['name' => 'asc'],
|
|
||||||
'conditions' => [
|
|
||||||
'id IN' => array_values(\Cake\Utility\Hash::extract($this->ACL->getUser(), 'individual.organisations.{n}.id'))
|
|
||||||
]
|
|
||||||
])
|
|
||||||
];
|
];
|
||||||
if ($this->ParamHandler->isRest()) {
|
if ($this->ParamHandler->isRest()) {
|
||||||
return $this->restResponsePayload;
|
return $this->restResponsePayload;
|
||||||
|
@ -61,12 +56,7 @@ class SharingGroupsController extends AppController
|
||||||
return $this->restResponsePayload;
|
return $this->restResponsePayload;
|
||||||
}
|
}
|
||||||
$dropdownData = [
|
$dropdownData = [
|
||||||
'organisation' => $this->SharingGroups->Organisations->find('list', [
|
'organisation' => $this->getAvailableOrgForSg($this->ACL->getUser())
|
||||||
'sort' => ['name' => 'asc'],
|
|
||||||
'conditions' => [
|
|
||||||
'id IN' => array_values(\Cake\Utility\Hash::extract($this->ACL->getUser(), 'individual.organisations.{n}.id'))
|
|
||||||
]
|
|
||||||
])
|
|
||||||
];
|
];
|
||||||
$this->set(compact('dropdownData'));
|
$this->set(compact('dropdownData'));
|
||||||
$this->set('metaGroup', 'Trust Circles');
|
$this->set('metaGroup', 'Trust Circles');
|
||||||
|
@ -160,4 +150,20 @@ class SharingGroupsController extends AppController
|
||||||
$this->set('sharing_group_id', $id);
|
$this->set('sharing_group_id', $id);
|
||||||
$this->set('sharing_group_orgs', $sharingGroup['sharing_group_orgs']);
|
$this->set('sharing_group_orgs', $sharingGroup['sharing_group_orgs']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getAvailableOrgForSg($user)
|
||||||
|
{
|
||||||
|
$organisations = [];
|
||||||
|
if (!empty($user['role']['perm_admin'])) {
|
||||||
|
$organisations = $this->SharingGroups->Organisations->find('list')->order(['name' => 'ASC'])->toArray();
|
||||||
|
} else if (!empty($user['individual']['organisations'])) {
|
||||||
|
$organisations = $this->SharingGroups->Organisations->find('list', [
|
||||||
|
'sort' => ['name' => 'asc'],
|
||||||
|
'conditions' => [
|
||||||
|
'id IN' => array_values(\Cake\Utility\Hash::extract($user, 'individual.organisations.{n}.id'))
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return $organisations;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ class SharingGroupsTable extends AppTable
|
||||||
'SharingGroupOrgs',
|
'SharingGroupOrgs',
|
||||||
[
|
[
|
||||||
'className' => 'Organisations',
|
'className' => 'Organisations',
|
||||||
'joinTable' => 'sgo',
|
|
||||||
'foreignKey' => 'sharing_group_id',
|
'foreignKey' => 'sharing_group_id',
|
||||||
'targetForeignKey' => 'organisation_id'
|
'targetForeignKey' => 'organisation_id'
|
||||||
]
|
]
|
||||||
|
|
|
@ -12,8 +12,9 @@
|
||||||
],
|
],
|
||||||
'submit' => [
|
'submit' => [
|
||||||
'action' => $this->request->getParam('action')
|
'action' => $this->request->getParam('action')
|
||||||
]
|
],
|
||||||
]
|
],
|
||||||
|
'entity' => null,
|
||||||
]);
|
]);
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue