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