From: mchurch Date: Tue, 14 Sep 2004 23:54:23 +0000 (+0000) Subject: Fixed 'remove_teacher' to remove the teacher from any groups. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=b02193e605bd37badea60e7c0c8021a5651677c4;p=moodle.git Fixed 'remove_teacher' to remove the teacher from any groups. --- diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 3949a2d6cd..513056a66c 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -973,6 +973,17 @@ function remove_teacher($userid, $courseid=0) { delete_records("forum_subscriptions", "forum", $forum->id, "userid", $userid); } } + + /// Next if the teacher is not registered as a student, but is + /// a member of a group, remove them from the group. + if (!isstudent($courseid, $userid)) { + if ($groups = get_groups($courseid, $userid)) { + foreach ($groups as $group) { + delete_records("groups_members", "groupid", $group->id, "userid", $userid); + } + } + } + return delete_records("user_teachers", "userid", $userid, "course", $courseid); } else { delete_records("forum_subscriptions", "userid", $userid); @@ -3070,4 +3081,4 @@ function getremoteaddr() { } // vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140: -?> +?> \ No newline at end of file