]> git.mjollnir.org Git - moodle.git/commitdiff
Fix to account for people not in course
authormartin <martin>
Sat, 27 Jul 2002 07:22:20 +0000 (07:22 +0000)
committermartin <martin>
Sat, 27 Jul 2002 07:22:20 +0000 (07:22 +0000)
mod/journal/lib.php

index 3cc7b8c1f1c2ec877755b55f4d8366355f94c24a..c1fa1fffde15d2dfea8b23817dbfb1c370d79cfe 100644 (file)
@@ -80,10 +80,10 @@ function journal_cron () {
 
     $cutofftime = time() - $CFG->maxeditingtime;
 
-    if ($entries = get_records_sql("SELECT e.*, j.course, j.name 
+    if ($entries = get_records_sql("SELECT e.*, j.course, j.name
                                      FROM   journal_entries e, journal j
-                                     WHERE  e.mailed = '0' AND 
-                                     e.timemarked < '$cutofftime' AND e.timemarked > 0
+                                     WHERE  e.mailed = '0' 
+                                     AND e.timemarked < '$cutofftime' AND e.timemarked > 0
                                      AND e.journal = j.id")) {
         $timenow = time();
 
@@ -96,16 +96,21 @@ function journal_cron () {
                 continue;
             }
 
-            if (! $teacher = get_record("user", "id", "$entry->teacher")) {
-                echo "Could not find teacher $entry->teacher\n";
+            if (! $course = get_record("course", "id", "$entry->course")) {
+                echo "Could not find course $entry->course\n";
                 continue;
             }
 
-            if (! $course = get_record("course", "id", "$entry->course")) {
-                echo "Could not find course $entry->course\n";
+            if (! isstudent($course->id, $user->id) and !isteacher($course->id, $user->id)) {
+                continue;  // Not an active participant
+            }
+
+            if (! $teacher = get_record("user", "id", "$entry->teacher")) {
+                echo "Could not find teacher $entry->teacher\n";
                 continue;
             }
 
+
             if (! $mod = get_coursemodule_from_instance("journal", $entry->journal, $course->id)) {
                 echo "Could not find course module for journal id $entry->journal\n";
                 continue;