Moved creation of guest user to login page - this means it can be
[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
b51e9913 38 if ($course->category) {
39 if (!isstudent($course->id, $user->id) && !isteacher($course->id, $user->id)) {
40 print_heading("$fullname is not enrolled in this course");
41 print_footer($course);
42 die;
43 }
8a3b358b 44 }
45
f9903ed0 46 echo "<TABLE WIDTH=80% ALIGN=CENTER BORDER=0 CELLPADDING=1 CELLSPACING=1><TR><TD BGCOLOR=#888888>";
47 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=3 CELLSPACING=0><TR>";
48 echo "<TD WIDTH=100 BGCOLOR=\"$THEME->body\" VALIGN=top>";
49 if ($user->picture) {
50 echo "<IMG BORDER=0 ALIGN=left WIDTH=100 SRC=\"pix.php/$user->id/f1.jpg\">";
51 } else {
52 echo "<IMG BORDER=0 ALIGN=left WIDTH=100 SRC=\"default/f1.jpg\">";
53 }
54 echo "</TD><TD WIDTH=100% BGCOLOR=#FFFFFF>";
55
56
57 // Print name and edit button across top
58
59 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD NOWRAP>";
60 echo "<H3>$user->firstname $user->lastname</H3>";
61 echo "</TD><TD align=right>";
62 if ($id == $USER->id) {
63 echo "<P><FORM ACTION=edit.php METHOD=GET>";
64 echo "<INPUT type=hidden name=id value=\"$id\">";
65 echo "<INPUT type=hidden name=course value=\"$course->id\">";
66 echo "<INPUT type=submit value=\"Edit my profile\">";
67 echo "</FORM></P>";
68 }
69 echo "</TD></TR></TABLE>";
70
71
f9903ed0 72 // Print the description
73
74 if ($user->description) {
75 echo "<P>".text_to_html($user->description)."</P><HR>";
76 }
77
78
f9903ed0 79 // Print all the little details in a list
80
81 echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=2";
82
bda8d43a 83 print_row("Location:", "$user->city, ".$COUNTRIES["$user->country"]);
f9903ed0 84
85 if (isteacher($course->id)) {
86 if ($user->address) {
87 print_row("Address:", "$user->address");
88 }
89 if ($user->phone1) {
90 print_row("Phone:", "$user->phone1");
91 }
92 if ($user->phone2) {
93 print_row("Phone:", "$user->phone2");
94 }
95 }
96
97 print_row("Email:", "<A HREF=\"mailto:$user->email\">$user->email</A>");
98
99 if ($user->url) {
100 print_row("Web page:", "<A HREF=\"$user->url\">$user->url</A>");
101 }
102
103 if ($user->icq) {
104 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>");
105 }
106
107 $datestring = userdate($user->lastaccess)."&nbsp (".format_time(time() - $user->lastaccess).")";
108 print_row("Last access:", $datestring);
109
110 echo "</TABLE>";
111
112 echo "</TD></TR></TABLE></TABLE>";
113
c888501c 114// Print other functions
18798c6f 115 if ($id == $USER->id) {
116 echo "<CENTER><TABLE ALIGN=CENTER><TR>";
117 echo "<TD NOWRAP><P><FORM ACTION=\"../course/unenrol.php\" METHOD=GET>";
118 echo "<INPUT type=hidden name=id value=\"$course->id\">";
119 echo "<INPUT type=submit value=\"Unenrol me from $course->shortname\">";
120 echo "</FORM></P></TD>";
121 echo "</TR></TABLE></CENTER>\n";
122 }
c888501c 123
f9903ed0 124 print_footer($course);
125
126/// Functions ///////
127
128function print_row($left, $right) {
129 echo "<TR><TD NOWRAP ALIGN=right><P>$left</TD><TD align=left><P>$right</P></TD></TR>";
130}
131
132?>