Not needed any more ... use the "News" forum instead.
[moodle.git] / user / view.php
CommitLineData
f9903ed0 1<?PHP // $Id$
2
3// Display profile for a particular user
4
5 require("../config.php");
6 require("lib.php");
7
8 require_variable($id);
9 require_variable($course);
10
11
12 if (! $user = get_record("user", "id", $id) ) {
13 error("No such user in this course");
14 }
15
16 if (! $course = get_record("course", "id", $course) ) {
17 error("No such course id");
18 }
19
20 if ($course->category) {
21 require_login($course->id);
22 }
23
24 $fullname = "$user->firstname $user->lastname";
25
da3a08d7 26 add_to_log($course->id, "user", "view", "view.php?id=$user->id&course=$course->id", "$user->id");
f9903ed0 27
28 if ($course->category) {
29 print_header("Personal profile: $fullname", "Personal profile: $fullname",
30 "<A HREF=\"../course/view.php?id=$course->id\">$course->shortname</A> ->
31 <A HREF=\"index.php?id=$course->id\">Participants</A> -> $fullname", "");
32 } else {
33 print_header("Personal profile: $fullname", "Personal profile: $fullname", "$fullname", "");
34 }
35
36
37 echo "<TABLE WIDTH=80% ALIGN=CENTER BORDER=0 CELLPADDING=1 CELLSPACING=1><TR><TD BGCOLOR=#888888>";
38 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=3 CELLSPACING=0><TR>";
39 echo "<TD WIDTH=100 BGCOLOR=\"$THEME->body\" VALIGN=top>";
40 if ($user->picture) {
41 echo "<IMG BORDER=0 ALIGN=left WIDTH=100 SRC=\"pix.php/$user->id/f1.jpg\">";
42 } else {
43 echo "<IMG BORDER=0 ALIGN=left WIDTH=100 SRC=\"default/f1.jpg\">";
44 }
45 echo "</TD><TD WIDTH=100% BGCOLOR=#FFFFFF>";
46
47
48 // Print name and edit button across top
49
50 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD NOWRAP>";
51 echo "<H3>$user->firstname $user->lastname</H3>";
52 echo "</TD><TD align=right>";
53 if ($id == $USER->id) {
54 echo "<P><FORM ACTION=edit.php METHOD=GET>";
55 echo "<INPUT type=hidden name=id value=\"$id\">";
56 echo "<INPUT type=hidden name=course value=\"$course->id\">";
57 echo "<INPUT type=submit value=\"Edit my profile\">";
58 echo "</FORM></P>";
59 }
60 echo "</TD></TR></TABLE>";
61
62
63
64 // Print the description
65
66 if ($user->description) {
67 echo "<P>".text_to_html($user->description)."</P><HR>";
68 }
69
70
71
72 // Print all the little details in a list
73
74 echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=2";
75
76 print_row("Location:", "$user->city, $user->country");
77
78 if (isteacher($course->id)) {
79 if ($user->address) {
80 print_row("Address:", "$user->address");
81 }
82 if ($user->phone1) {
83 print_row("Phone:", "$user->phone1");
84 }
85 if ($user->phone2) {
86 print_row("Phone:", "$user->phone2");
87 }
88 }
89
90 print_row("Email:", "<A HREF=\"mailto:$user->email\">$user->email</A>");
91
92 if ($user->url) {
93 print_row("Web page:", "<A HREF=\"$user->url\">$user->url</A>");
94 }
95
96 if ($user->icq) {
97 print_row("ICQ:","<A HREF=\"http://wwp.icq.com/$user->icq\">$user->icq <IMG SRC=\"http://online.mirabilis.com/scripts/online.dll?icq=$user->icq&img=5\" WIDTH=18 HEIGHT=18 BORDER=0></A>");
98 }
99
100 $datestring = userdate($user->lastaccess)."&nbsp (".format_time(time() - $user->lastaccess).")";
101 print_row("Last access:", $datestring);
102
103 echo "</TABLE>";
104
105 echo "</TD></TR></TABLE></TABLE>";
106
107 print_footer($course);
108
109/// Functions ///////
110
111function print_row($left, $right) {
112 echo "<TR><TD NOWRAP ALIGN=right><P>$left</TD><TD align=left><P>$right</P></TD></TR>";
113}
114
115?>