Initial revision
[moodle.git] / user / index.php
CommitLineData
f9903ed0 1<?PHP // $Id$
2
3// Lists all the users within a given course
4
5 require("../config.php");
6 require("lib.php");
7
8 require_variable($id); //course
9
10 if (! $course = get_record("course", "id", $id)) {
11 error("Course ID is incorrect");
12 }
13
14 require_login($course->id);
15
16 add_to_log("View list of all profiles", $course->id);
17
18 if ($course->category) {
19 print_header("$course->shortname: Participants", "$course->fullname",
20 "<A HREF=../course/view.php?id=$course->id>$course->shortname</A> -> Participants", "");
21 } else {
22 print_header("$course->shortname: Participants", "$course->fullname", "Participants", "");
23 }
24
25
26 $teacherlinks = isteacher($course->id);
27
28 echo "<H2 align=center>".$course->teacher."s</H2>";
29
30 if ( $teachers = get_records_sql("SELECT u.* FROM user u, user_teachers t
31 WHERE t.course = '$course->id' AND t.user = u.id
32 ORDER BY t.authority")) {
33 foreach ($teachers as $teacher) {
34 print_user($teacher, $course, $teacherlinks);
35 }
36 } else {
37 notify("None yet");
38 }
39
40 echo "<H2 align=center>Students</H2>";
41 if ($students = get_records_sql("SELECT u.* FROM user u, user_students s
42 WHERE s.course = '$course->id' AND s.user = u.id
43 ORDER BY u.lastaccess DESC")) {
44 foreach ($students as $student) {
45 print_user($student, $course, $teacherlinks);
46 }
47 } else {
48 notify("None yet");
49 }
50
51 print_footer($course);
52
53
54/// FUNCTIONS //////////////////
55
56function print_user($user, $course, $teacherlinks) {
57
58 echo "<TABLE WIDTH=80% ALIGN=CENTER BORDER=0 CELLPADDING=1 CELLSPACING=1><TR><TD BGCOLOR=#888888>";
59 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR>";
60 echo "<TD WIDTH=100 BGCOLOR=#FFFFFF VALIGN=top>";
61 echo "<A HREF=\"view.php?id=$user->id&course=$course->id\">";
62 if ($user->picture) {
63 echo "<IMG BORDER=0 ALIGN=left WIDTH=100 SRC=\"pix.php/$user->id/f1.jpg\">";
64 } else {
65 echo "<IMG BORDER=0 ALIGN=left WIDTH=100 SRC=\"default/f1.jpg\">";
66 }
67 echo "</A>";
68 echo "</TD><TD WIDTH=100% BGCOLOR=#FFFFFF VALIGN=top>";
69 echo "<FONT SIZE=-1>";
70 echo "<FONT SIZE=3><B>$user->firstname $user->lastname</B></FONT>";
71 echo "<P>Email: <A HREF=\"mailto:$user->email\">$user->email</A><BR>";
72 echo "Last access: ".userdate($user->lastaccess);
73 echo "&nbsp (".format_time(time() - $user->lastaccess).")";
74 echo "</TD><TD VALIGN=bottom BGCOLOR=#FFFFFF NOWRAP>";
75
76 echo "<FONT SIZE=1>";
77 if ($teacherlinks) {
78 $tt = getdate(time());
79 $today = mktime (0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]);
80 echo "<A HREF=\"../course/user.php?id=$course->id&user=$user->id\">Contributions</A><BR><BR>";
81 echo "<A HREF=\"../course/log.php?id=$course->id&user=$user->id&date=$today\">Today's logs</A><BR>";
82 echo "<A HREF=\"../course/log.php?id=$course->id&user=$user->id\">All logs</A><BR><BR>";
83 if (isstudent($course->id, $user->id)) {
84 echo "<A HREF=\"../course/loginas.php?id=$course->id&user=$user->id\">Login as</A><BR><BR>";
85 }
86 }
87 echo "<A HREF=\"view.php?id=$user->id&course=$course->id\">Full profile...</A>";
88 echo "</FONT>";
89
90 echo "</TD></TR></TABLE></TD></TR></TABLE>";
91}
92
93?>