]> git.mjollnir.org Git - moodle.git/commitdiff
add_to_log now updates lastaccess if used on site. See bug 1821
authorgustav_delius <gustav_delius>
Sun, 29 Aug 2004 11:41:55 +0000 (11:41 +0000)
committergustav_delius <gustav_delius>
Sun, 29 Aug 2004 11:41:55 +0000 (11:41 +0000)
lib/datalib.php

index 2c530787a8e68ad7514c04a687d8fb68ec085272..9beec5446d784a847d201bbbe8f96620eb12aa88 100644 (file)
@@ -2278,13 +2278,14 @@ function add_to_log($courseid, $module, $action, $url="", $info="", $cm=0, $user
     if (!$result and ($CFG->debug > 7)) {
         echo "<P>Error: Could not insert a new entry to the Moodle log</P>";  // Don't throw an error
     }    
-    if (!$user) {
-        if (isstudent($courseid)) {
+    if (!$user and isset($USER->id)) {
+        $site = get_site();
+        if ($courseid == $site->id) {
+            update_user_in_db();
+        } else if (isstudent($courseid)) {
             $db->Execute("UPDATE {$CFG->prefix}user_students SET timeaccess = '$timenow' ".
                          "WHERE course = '$courseid' AND userid = '$userid'");
-        }
-
-        if (isteacher($courseid, false, false)) {
+        } else if (isteacher($courseid, false, false)) {
             $db->Execute("UPDATE {$CFG->prefix}user_teachers SET timeaccess = '$timenow' ".
                          "WHERE course = '$courseid' AND userid = '$userid'");
         }