f9903ed0 |
1 | <? // $Id$ |
2 | |
3 | $MAXNEWSDISPLAY = 4; |
4 | |
5 | $FORMATS = array ( |
4567fb71 |
6 | "1" => "Weekly layout", |
7 | "2" => "Social layout" |
f9903ed0 |
8 | ); |
9 | |
10 | |
11 | function logdate($date) { |
12 | return date("l, j F Y, g:i A", $date); |
13 | } |
14 | |
15 | function print_log_selector_form($course, $selecteduser=0, $selecteddate="today") { |
16 | |
17 | // Get all the possible users |
18 | $users = array(); |
19 | if ($students = get_records_sql("SELECT u.* FROM user u, user_students s |
20 | WHERE s.course = '$course->id' AND s.user = u.id |
21 | ORDER BY u.lastaccess DESC")) { |
22 | foreach ($students as $student) { |
23 | $users["$student->id"] = "$student->firstname $student->lastname"; |
24 | } |
25 | } |
26 | if ($teachers = get_records_sql("SELECT u.* FROM user u, user_teachers t |
27 | WHERE t.course = '$course->id' AND t.user = u.id |
28 | ORDER BY u.lastaccess DESC")) { |
29 | foreach ($teachers as $teacher) { |
30 | $users["$teacher->id"] = "$teacher->firstname $teacher->lastname"; |
31 | } |
32 | } |
33 | |
34 | asort($users); |
35 | |
36 | // Get all the possible dates |
37 | $tt = getdate(time()); |
38 | $timemidnight = $today = mktime (0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]); |
39 | $dates = array("$today" => "Today, ".date("j F Y", $today) ); |
40 | |
41 | while ($timemidnight > $course->startdate) { |
42 | $timemidnight = $timemidnight - 86400; |
43 | $dates["$timemidnight"] = date("l, j F Y", $timemidnight); |
44 | } |
45 | |
46 | if ($selecteddate == "today") { |
47 | $selecteddate = $today; |
48 | } |
49 | |
50 | echo "<CENTER>"; |
51 | echo "<FORM ACTION=log.php METHOD=get>"; |
52 | echo "<INPUT TYPE=hidden NAME=id VALUE=\"$course->id\">"; |
53 | choose_from_menu ($users, "user", $selecteduser, "All participants"); |
54 | choose_from_menu ($dates, "date", $selecteddate, "Any day"); |
55 | echo "<INPUT TYPE=submit VALUE=\"Show these logs\">"; |
56 | echo "</FORM>"; |
57 | echo "</CENTER>"; |
58 | } |
59 | |
60 | function print_log($course, $user=0, $date=0, $order="ORDER BY l.time ASC") { |
61 | |
62 | $selector = "WHERE l.course='$course->id' AND l.user = u.id"; |
63 | |
64 | if ($user) { |
65 | $selector .= " AND l.user = '$user'"; |
66 | } |
67 | |
68 | if ($date) { |
69 | $enddate = $date + 86400; |
70 | $selector .= " AND l.time > '$date' AND l.time < '$enddate'"; |
71 | } |
72 | |
73 | if (!$logs = get_records_sql("SELECT l.*, u.firstname, u.lastname, u.picture |
74 | FROM logs l, user u $selector $order")){ |
75 | notify("No logs found!"); |
76 | print_footer($course); |
77 | exit; |
78 | } |
79 | |
80 | $count=0; |
81 | $tt = getdate(time()); |
82 | $today = mktime (0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]); |
83 | echo "<P ALIGN=CENTER>Displaying ".count($logs)." records</P>"; |
84 | echo "<TABLE BORDER=0 ALIGN=center CELLPADDING=3 CELLSPACING=3>"; |
85 | foreach ($logs as $log) { |
86 | $count++; |
87 | |
88 | echo "<TR>"; |
89 | echo "<TD ALIGN=right><FONT SIZE=2>".date("l", $log->time)."</TD>"; |
90 | echo "<TD><FONT SIZE=2>".date("j M Y, h:i A", $log->time)."</TD>"; |
91 | echo "<TD><FONT SIZE=2><B>$log->firstname $log->lastname</B></TD>"; |
92 | echo "<TD><FONT SIZE=2>"; |
93 | $log->message = addslashes($log->message); |
94 | link_to_popup_window("$log->url","popup","$log->message", 400, 600); |
95 | echo "</TD>"; |
96 | echo "</TR>"; |
97 | } |
98 | echo "</TABLE>"; |
99 | } |
100 | |
101 | |
102 | function print_course($course) { |
103 | |
104 | if (! $site = get_record("course", "category", "0") ) { |
105 | error("Could not find a site!"); |
106 | } |
107 | |
108 | print_simple_box_start("CENTER", "80%"); |
109 | |
110 | echo "<TABLE WIDTH=100%>"; |
111 | echo "<TR VALIGN=top><TD VALIGN=top WIDTH=50%>"; |
112 | echo "<P><FONT SIZE=3><B><A HREF=\"view.php?id=$course->id\">$course->fullname</A></B></FONT></P>"; |
113 | if ($teachers = get_records_sql("SELECT u.* FROM user u, user_teachers t |
114 | WHERE u.id = t.user AND t.course = '$course->id' |
f51ab26b |
115 | ORDER BY t.authority ASC")) { |
f9903ed0 |
116 | |
117 | echo "<P><FONT SIZE=1>\n"; |
118 | foreach ($teachers as $teacher) { |
119 | echo "$course->teacher: <A HREF=\"../user/view.php?id=$teacher->id&course=$site->id\">$teacher->firstname $teacher->lastname</A><BR>"; |
120 | } |
121 | echo "</FONT></P>"; |
122 | } |
123 | echo "</TD><TD VALIGN=top WIDTH=50%>"; |
124 | echo "<P><FONT SIZE=2>".text_to_html($course->summary)."</FONT></P>"; |
125 | echo "</TD></TR>"; |
126 | echo "</TABLE>"; |
127 | |
128 | print_simple_box_end(); |
129 | } |
130 | |
131 | ?> |