mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
Needed to delete forum_subscriptions as well.
This commit is contained in:
parent
3d7a585834
commit
d0daec361a
@ -37,34 +37,37 @@
|
||||
}
|
||||
|
||||
|
||||
// Any system-wide Moodle cron jobs should be run here
|
||||
|
||||
// Unsubscribe users who haven't logged in for $CFG->longtimenosee
|
||||
// Unenrol users who haven't logged in for $CFG->longtimenosee
|
||||
|
||||
if ($CFG->longtimenosee) { // value in days
|
||||
$cutofftime = time() - ($CFG->longtimenosee * 3600 * 24);
|
||||
$cutofftime = $timenow - ($CFG->longtimenosee * 3600 * 24);
|
||||
if ($users = get_records_sql("SELECT u.* FROM user u, user_students s
|
||||
WHERE lastaccess > '0' AND
|
||||
lastaccess < '$cutofftime'
|
||||
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);
|
||||
|
||||
echo "Deleted student enrolment for $user->firstname $user->lastname ($user->id)\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delete users who haven't confirmed within seven days
|
||||
|
||||
$cutofftime = time() - (7 * 24 * 3600);
|
||||
// Delete users who haven't confirmed within seven days
|
||||
|
||||
$cutofftime = $timenow - (7 * 24 * 3600);
|
||||
if ($users = get_records_sql("SELECT * FROM user
|
||||
WHERE confirmed = '0' AND
|
||||
firstaccess > '0' AND
|
||||
firstaccess < '$cutofftime'")) {
|
||||
foreach ($users as $user) {
|
||||
if (delete_records("user", "id", $user->id)) {
|
||||
echo "Deleted unconfirmed user for $user->firsname $user->lastname ($user->id)\n";
|
||||
echo "Deleted unconfirmed user for $user->firstname $user->lastname ($user->id)\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user