3 // @@@ TO DO Need to write these functions because they are needed by parts of
4 // the current moodle code where courses are deleted etc.
7 * @param int $courseid If false, removes the user from all groups for all
10 function groups_remove_user_from_all_groups($userid, $courseid) {
14 function groups_remove_all_group_members($courseid, $showfeedback) {
18 function groups_remove_all_groups($courseid, $removemembers, $showfeedback) {
23 * Cleans up all the groups and groupings in a course (it does this best-effort
24 * i.e. if one deletion fails, it still attempts further deletions).
25 * IMPORTANT: Note that if the groups and groupings are used by other courses
26 * somehow, they will still be deleted - it doesn't protect against this.
27 * @param int $courseid The id of the course
28 * @return boolean True if the clean up was successful, false otherwise.
30 function groups_cleanup_groups($courseid) {
33 // Delete all the groupings
34 $groupings = groups_get_groupings($courseid);
35 if ($groupings != false) {
36 foreach($groupings as $groupingid) {
37 $groupingdeleted = groups_delete_grouping($groupingid);
38 if (!$groupingdeleted) {
44 // Delete all the groups
45 $groupids = groups_get_groups($courseid);
46 if ($groupids != false) {
47 foreach($groupids as $groupid) {
48 $groupdeleted = groups_delete_group($groupid);