]> git.mjollnir.org Git - moodle.git/commitdiff
Fixed 'remove_teacher' to remove the teacher from any groups.
authormchurch <mchurch>
Tue, 14 Sep 2004 23:54:23 +0000 (23:54 +0000)
committermchurch <mchurch>
Tue, 14 Sep 2004 23:54:23 +0000 (23:54 +0000)
lib/moodlelib.php

index 3949a2d6cd4a98ab9f17878ffc164085946b7852..513056a66c87d16777277630e1ef7b799c4540e6 100644 (file)
@@ -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