new: [individuals] add individual auto-saves an alignment

- if a non community admin enrolls an individual, set the alignment by default
  - this will prevent them from becoming uneditable
develop
iglocska 2024-08-28 15:38:53 +02:00
parent bb47046670
commit ccd4a8c624
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 10 additions and 1 deletions

View File

@ -62,7 +62,16 @@ class IndividualsController extends AppController
public function add() public function add()
{ {
$this->CRUD->add(); $currentUser = $this->ACL->getUser();
$params = [
'afterSave' => function($data) use ($currentUser) {
if (empty($currentUser['role']['perm_community_admin'])) {
$this->Individuals->Alignments->setAlignment($currentUser['organisation_id'], $data->id, 'Member');
}
return $data;
}
];
$this->CRUD->add($params);
$responsePayload = $this->CRUD->getResponsePayload(); $responsePayload = $this->CRUD->getResponsePayload();
if (!empty($responsePayload)) { if (!empty($responsePayload)) {
return $responsePayload; return $responsePayload;