Browse files

Needed to delete forum_subscriptions as well.

  • Loading branch information...
1 parent 3d7a585 commit d0daec361aa80fa909c29a64352be5679e21087c martin committed Aug 5, 2002
Showing with 10 additions and 7 deletions.
  1. +10 −7 admin/cron.php
View
17 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";
}
}
}

0 comments on commit d0daec3

Please sign in to comment.