From 937ae59c8eb44698d63bd283ffe8f5b0ac7abef9 Mon Sep 17 00:00:00 2001 From: moodler Date: Mon, 27 Oct 2003 14:01:29 +0000 Subject: [PATCH] Get longtimenosee students according to their course access (not site access) --- admin/cron.php | 8 ++++---- lib/datalib.php | 12 ++++-------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/admin/cron.php b/admin/cron.php index 25981f7463..9e41abc860 100644 --- a/admin/cron.php +++ b/admin/cron.php @@ -54,10 +54,10 @@ if ($CFG->longtimenosee) { // value in days $longtime = $timenow - ($CFG->longtimenosee * 3600 * 24); - if ($users = get_users_longtimenosee($longtime)) { - foreach ($users as $user) { - if (unenrol_student($user->id)) { - echo "Deleted student enrolment for $user->firstname $user->lastname ($user->id)\n"; + if ($students = get_users_longtimenosee($longtime)) { + foreach ($students as $student) { + if (unenrol_student($student->userid, $student->course)) { + echo "Deleted student enrolment for user $student->userid from course $student->course\n"; } } } diff --git a/lib/datalib.php b/lib/datalib.php index 3e7512e444..436a22b8c3 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -1364,14 +1364,10 @@ function get_users_unconfirmed($cutofftime=2000000000) { */ function get_users_longtimenosee($cutofftime) { global $CFG; - - $db->debug = true; - return get_records_sql("SELECT DISTINCT u.* - FROM {$CFG->prefix}user u, - {$CFG->prefix}user_students s - WHERE u.lastaccess > '0' - AND u.lastaccess < '$cutofftime' - AND u.id = s.userid "); + return get_records_sql("SELECT DISTINCT * + FROM {$CFG->prefix}user_students + WHERE timeaccess > '0' + AND timeaccess < '$cutofftime' "); } -- 2.39.5