lastaccess < '$cutofftime' AND
u.id = s.user GROUP BY u.id")) {
foreach ($users as $user) {
- if (delete_records("user_students", "user", $user->id)) {
-
- // Delete other things ... this should be modular than it is right now:
- delete_records("forum_subscriptions", "user", $user->id);
-
+ if (unenrol_student($user->id)) {
echo "Deleted student enrolment for $user->firstname $user->lastname ($user->id)\n";
}
}
error("An error occurred while trying to unenrol you.");
}
- // remove some other things
- delete_records("forum_subscriptions", "user", $user->id);
-
add_to_log($course->id, "course", "unenrol", "view.php?id=$course->id", "$user->id");
if ($user->id == $USER->id) {
global $db;
if ($course) {
+ /// First delete any crucial stuff that might still send mail
+ if ($forums = get_records("forum", "course", $course)) {
+ foreach ($forums as $forum) {
+ $db->Execute("DELETE FROM forum_subscriptions WHERE forum = '$forum->id' AND user = '$user'");
+ }
+ }
return $db->Execute("DELETE FROM user_teachers WHERE user = '$user' AND course = '$course'");
} else {
- return $db->Execute("DELETE FROM user_teachers WHERE user = '$user'");
+ delete_records("forum_subscriptions", "user", $user);
+ return delete_records("user_teachers", "user", $user);
}
}
global $db;
if ($course) {
+ /// First delete any crucial stuff that might still send mail
+ if ($forums = get_records("forum", "course", $course)) {
+ foreach ($forums as $forum) {
+ $db->Execute("DELETE FROM forum_subscriptions WHERE forum = '$forum->id' AND user = '$user'");
+ }
+ }
return $db->Execute("DELETE FROM user_students WHERE user = '$user' AND course = '$course'");
+
} else {
- return $db->Execute("DELETE FROM user_students WHERE user = '$user'");
+ delete_records("forum_subscriptions", "user", $user);
+ return delete_records("user_students", "user", $user);
}
}