From fccf3d7b160c32756da8888f67221d0e17f513f4 Mon Sep 17 00:00:00 2001 From: Rasmus Fuhse <fuhse@data-quest.de> Date: Tue, 8 Feb 2022 13:43:53 +0000 Subject: [PATCH] =?UTF-8?q?Resolve=20"L=C3=B6schen=20von=20InstituteMember?= =?UTF-8?q?=20schl=C3=A4gt=20fehl"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/models/InstituteMember.class.php | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/lib/models/InstituteMember.class.php b/lib/models/InstituteMember.class.php index 602d1cb0d3c..fe1b19d8359 100644 --- a/lib/models/InstituteMember.class.php +++ b/lib/models/InstituteMember.class.php @@ -74,6 +74,15 @@ class InstituteMember extends SimpleORMap implements PrivacyObject $config['additional_fields']['institute_name'] = []; + $config['registered_callbacks']['after_delete'][] = function ($member) { + $institute = $member->institute; + $user_id = $member->user_id; + + if ($institute) { + $institute->status_groups->removeUser($user_id, true); + } + }; + parent::configure($config); } @@ -170,24 +179,6 @@ class InstituteMember extends SimpleORMap implements PrivacyObject return true; } - /** - * Removes a user from an institute. Removes the user from all - * statusgroups as well. - * - * @return int number of deleted institute member records - */ - public function delete() - { - $institute = $this->institute; - $user_id = $this->user_id; - - if ($result = parent::delete()) { - $institute->status_groups->removeUser($user_id, true); - } - - return $result; - } - /** * Export available data of a given user into a storage object * (an instance of the StoredUserData class) for that user. -- GitLab