Improvements to logs for admin user (can view any course)
[moodle.git] / course / log.php
index bae4f7c..580d4f6 100644 (file)
@@ -5,18 +5,29 @@
     require("../config.php");
     require("lib.php");
 
+    require_variable($id);    // Course ID
+    optional_variable($user); // User to display
+    optional_variable($date); // Date to display
+
     require_login($id);
 
     if (! $course = get_record("course", "id", $id) ) {
         error("That's an invalid course id");
     }
 
-    if ( ! isteacher($course->id) && ! isadmin()) {
+    if (! isteacher($course->id)) {
         error("Only teachers can view logs");
     }
 
+    if (! $course->category) {
+        if (!isadmin()) {
+            error("Only administrators can look at the site logs");
+        }
+        $user = "";
+    }
+
 
-    if (isset($user) || isset($date)) {
+    if ($user || $date) {
 
         $userinfo = "all users";
         $dateinfo = "any day";
             $userinfo = "$u->firstname $u->lastname";
         }
         if ($date) {
-            $dateinfo = date("l, j F Y", $date);
+            $dateinfo = userdate($date, "l, j F Y");
         }
 
-        print_header("$course->shortname: Logs", "$course->shortname : Logs", 
+        print_header("$course->shortname: Logs", "$course->fullname", 
                      "<A HREF=\"view.php?id=$course->id\">$course->shortname</A> ->
                       <A HREF=\"log.php?id=$course->id\">Logs</A> -> Logs for $userinfo, $dateinfo", "");
         
-        print_heading("Logs for $userinfo, $dateinfo");
+        print_heading("$course->fullname: $userinfo, $dateinfo (".usertimezone().")");
 
         print_log_selector_form($course, $user, $date);
 
@@ -43,7 +54,7 @@
 
 
     } else {
-        print_header("$course->shortname: Logs", "$course->shortname : Logs", 
+        print_header("$course->shortname: Logs", "$course->fullname", 
                  "<A HREF=\"view.php?id=$course->id\">$course->shortname</A> -> Logs", "");
 
         print_heading("Choose which logs you want to look at");