]> git.mjollnir.org Git - moodle.git/commitdiff
Get longtimenosee students according to their course access (not site access)
authormoodler <moodler>
Mon, 27 Oct 2003 14:01:29 +0000 (14:01 +0000)
committermoodler <moodler>
Mon, 27 Oct 2003 14:01:29 +0000 (14:01 +0000)
admin/cron.php
lib/datalib.php

index 25981f7463f27387603fbe6c888ba807c0212bf0..9e41abc860c59521d955b21499d77d8a00cf3477 100644 (file)
 
         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";
                     }
                 }
             }
index 3e7512e4440b90839f05ee2d0d23a97207c4e14e..436a22b8c352f281bb61263a5f7fc5410595514b 100644 (file)
@@ -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' ");
 }