Initial revision
[moodle.git] / course / log.php
1 <?PHP // $Id$
3 //  log.php - displays different views of the logs.
5     require("../config.php");
6     require("lib.php");
8     require_login($id);
10     if (! $course = get_record("course", "id", $id) ) {
11         error("That's an invalid course id");
12     }
14     if ( ! isteacher($course->id)) {
15         error("Only teachers can view logs");
16     }
19     if (isset($user) || isset($date)) {
21         $userinfo = "all users";
22         $dateinfo = "any day";
24         if ($user) {
25             if (!$u = get_record("user", "id", $user) ) {
26                 error("That's an invalid user!");
27             }
28             $userinfo = "$u->firstname $u->lastname";
29         }
30         if ($date) {
31             $dateinfo = date("l, j F Y", $date);
32         }
34         print_header("$course->shortname: Logs", "$course->shortname : Logs", 
35                      "<A HREF=\"view.php?id=$course->id\">$course->shortname</A> ->
36                       <A HREF=\"log.php?id=$course->id\">Logs</A> -> Logs for $userinfo, $dateinfo", "");
37         
38         print_heading("Logs for $userinfo, $dateinfo");
40         print_log_selector_form($course, $user, $date);
42         print_log($course, $user, $date, "ORDER BY l.time DESC");
45     } else {
46         print_header("$course->shortname: Logs", "$course->shortname : Logs", 
47                  "<A HREF=\"view.php?id=$course->id\">$course->shortname</A> -> Logs", "");
49         print_heading("Choose which logs you want to look at");
51         print_log_selector_form($course);
53         print_heading("Or see what is happening right now");
55         echo "<CENTER><H3>";
56         link_to_popup_window("/course/loglive.php?id=$course->id","livelog","Live logs", 500, 800);
57         echo "</H3></CENTER>";
59     }
61     print_footer($course);
63     exit;
65 ?>