diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-09-19 07:12:35 +0000 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-09-19 07:12:35 +0000 |
| commit | fa2e6a9438fcb1a8347ce68a8df66748e9f1a8c7 (patch) | |
| tree | c01bc52d79938b8a246920ff0cf70ad13ec718de /lib | |
| parent | 6fe2ff954192faedde1958dceae4458a90cc25f7 (diff) | |
fix deleting of course members and clean up, fixes #4605
Closes #4605
Merge request studip/studip!3417
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/models/Course.php | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/lib/models/Course.php b/lib/models/Course.php index b51db08..d736725 100644 --- a/lib/models/Course.php +++ b/lib/models/Course.php @@ -1215,10 +1215,7 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe */ public function deleteMember(User $user, bool $send_mail = false) : void { - $membership = CourseMember::findOneBySQL( - 'seminar_id = :course_id AND user_id = :user_id', - ['course_id' => $this->id, 'user_id' => $user->id] - ); + $membership = CourseMember::find([$this->id, $user->id]); if (!$membership) { //The user is not a member of the course. throw new \Studip\MembershipException( @@ -1262,9 +1259,6 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe ); } - $removed_from_parent = false; - $removed_from_children = false; - if ($this->parent_course) { //This course has a parent course. //Delete the user from the parent course if they are not part of @@ -1276,14 +1270,13 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe AND `seminar_id` <> :this_course_id', [ 'user_id' => $user->id, - 'parent_course_id' => $this->parent_course->id, + 'parent_course_id' => $this->parent->id, 'this_course_id' => $this->id ] ); if ($other_memberships === 0) { //No other memberships. We can delete the user from the parent course. - $this->parent_course->deleteMember($user, false); - $removed_from_parent = true; + $this->parent->deleteMember($user); } } @@ -1294,7 +1287,6 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe foreach ($this->children as $child) { $child->deleteMember($user); } - $removed_from_children = true; } if ($send_mail) { @@ -1344,7 +1336,7 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe AND `seminar_user`.`status` = 'dozent'", ['deleted_user_id' => $user->id] ); - if ($other_deputy_amount === 0 && $GLOBALS['user']->id != $deputy_duty->user_id) { + if ($other_deputy_amount === 0 && $GLOBALS['user']->id !== $deputy_duty->user_id) { Deputy::deleteBySQL( '`range_id` = :course_id AND `user_id` = :deputy_id', ['course_id' => $this->id, $deputy_duty->user_id] @@ -1370,8 +1362,6 @@ class Course extends SimpleORMap implements Range, PrivacyObject, StudipItem, Fe StudipLog::log('SEM_USER_DEL', $this->id, $user->id, 'Wurde aus der Veranstaltung entfernt'); $this->resetRelation('members'); - - //At this point, removal is complete. } /** |
