From: martin Date: Mon, 5 Aug 2002 08:57:37 +0000 (+0000) Subject: Needed to delete forum_subscriptions as well. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=d0daec361aa80fa909c29a64352be5679e21087c;p=moodle.git Needed to delete forum_subscriptions as well. --- diff --git a/admin/cron.php b/admin/cron.php index 20c138a178..0b39cef0db 100644 --- a/admin/cron.php +++ b/admin/cron.php @@ -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"; } } }