mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Fixes to unenrolling students, and unenrol_student() and remove_teacher()
now remove forum_subscriptions correctly
This commit is contained in:
parent
274f62e6d5
commit
45aa6d563c
@ -46,11 +46,7 @@
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
@ -30,9 +30,6 @@
|
||||
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) {
|
||||
|
@ -1045,9 +1045,16 @@ function remove_teacher($user, $course=0) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1070,9 +1077,17 @@ function unenrol_student($user, $course=0) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user