Permalink
Browse files

Cron tidy-ups

  • Loading branch information...
1 parent 1f7227e commit f282e6314ca5a00efaee0e8b0a0abc172c4a3f14 martin committed Aug 5, 2002
Showing with 14 additions and 9 deletions.
  1. +14 −7 admin/cron.php
  2. +0 −2 mod/journal/lib.php
View
@@ -41,23 +41,30 @@
// Unsubscribe users who haven't logged in for $CFG->longtimenosee
- if ($CFG->longtimenosee) {
+ if ($CFG->longtimenosee) { // value in days
$cutofftime = time() - ($CFG->longtimenosee * 3600 * 24);
- if ($users = get_records_sql("SELECT * FROM user WHERE lastaccess > 0 AND lastaccess < '$cutofftime'")) {
+ if ($users = get_records_sql("SELECT * FROM user
+ WHERE lastaccess > '0' AND
+ lastaccess < '$cutofftime'")) {
foreach ($users as $user) {
- delete_records("user_students", "user", $user->id);
- echo "Deleted student enrolment for $user->firsname $user->lastname ($user->id)\n";
+ if (delete_records("user_students", "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);
- if ($users = get_records_sql("SELECT * FROM user WHERE confirmed = 0 AND firstaccess > 0 AND firstaccess < '$cutofftime'")) {
+ if ($users = get_records_sql("SELECT * FROM user
+ WHERE confirmed = '0' AND
+ firstaccess > '0' AND
+ firstaccess < '$cutofftime'")) {
foreach ($users as $user) {
- delete_records("user", "id", $user->id);
- echo "Deleted unconfirmed user for $user->firsname $user->lastname ($user->id)\n";
+ if (delete_records("user", "id", $user->id)) {
+ echo "Deleted unconfirmed user for $user->firsname $user->lastname ($user->id)\n";
+ }
}
}
View
@@ -53,8 +53,6 @@ function journal_cron () {
global $CFG;
- echo "Processing journals...\n";
-
$cutofftime = time() - $CFG->maxeditingtime;
if ($entries = get_records_sql("SELECT e.*, j.course, j.name

0 comments on commit f282e63

Please sign in to comment.