Fixed a link
[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");
501cdbd8 7 require("../mod/forum/lib.php");
f9903ed0 8 require("lib.php");
9
10 require_variable($id);
11 require_variable($course);
12
13
14 if (! $user = get_record("user", "id", $id) ) {
15 error("No such user in this course");
16 }
17
18 if (! $course = get_record("course", "id", $course) ) {
19 error("No such course id");
20 }
21
22 if ($course->category) {
23 require_login($course->id);
24 }
25
da3a08d7 26 add_to_log($course->id, "user", "view", "view.php?id=$user->id&course=$course->id", "$user->id");
f9903ed0 27
fa0626c6 28 $fullname = "$user->firstname $user->lastname";
29 $personalprofile = get_string("personalprofile");
30 $participants = get_string("participants");
31
f9903ed0 32 if ($course->category) {
fa0626c6 33 print_header("$personalprofile: $fullname", "$personalprofile: $fullname",
f9903ed0 34 "<A HREF=\"../course/view.php?id=$course->id\">$course->shortname</A> ->
fa0626c6 35 <A HREF=\"index.php?id=$course->id\">$participants</A> -> $fullname", "");
f9903ed0 36 } else {
0087d8a6 37 print_header("$course->fullname: $personalprofile: $fullname", "$course->fullname", "$fullname", "");
f9903ed0 38 }
39
603d4c72 40 if ($course->category and ! isguest() ) {
b51e9913 41 if (!isstudent($course->id, $user->id) && !isteacher($course->id, $user->id)) {
fa0626c6 42 print_heading(get_string("notenrolled", "", $fullname));
b51e9913 43 print_footer($course);
44 die;
45 }
8a3b358b 46 }
47
bb09fb11 48 if ($user->deleted) {
49 print_heading(get_string("userdeleted"));
50 }
51
f9903ed0 52 echo "<TABLE WIDTH=80% ALIGN=CENTER BORDER=0 CELLPADDING=1 CELLSPACING=1><TR><TD BGCOLOR=#888888>";
53 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=3 CELLSPACING=0><TR>";
54 echo "<TD WIDTH=100 BGCOLOR=\"$THEME->body\" VALIGN=top>";
15e4b2ec 55 print_user_picture($user->id, $course->id, $user->picture, true, false, false);
f9903ed0 56 echo "</TD><TD WIDTH=100% BGCOLOR=#FFFFFF>";
57
58
59 // Print name and edit button across top
60
61 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD NOWRAP>";
fa0626c6 62 echo "<H3>$fullname</H3>";
f9903ed0 63 echo "</TD><TD align=right>";
61e96406 64 if (empty($USER->id)) {
65 $currentuser = false;
66 } else {
67 $currentuser = ($user->id == $USER->id);
68 }
69 if (($currentuser and !isguest()) or isadmin()) {
f9903ed0 70 echo "<P><FORM ACTION=edit.php METHOD=GET>";
71 echo "<INPUT type=hidden name=id value=\"$id\">";
72 echo "<INPUT type=hidden name=course value=\"$course->id\">";
fa0626c6 73 echo "<INPUT type=submit value=\"".get_string("editmyprofile")."\">";
f9903ed0 74 echo "</FORM></P>";
75 }
76 echo "</TD></TR></TABLE>";
77
78
f9903ed0 79 // Print the description
80
81 if ($user->description) {
82 echo "<P>".text_to_html($user->description)."</P><HR>";
83 }
84
85
f9903ed0 86 // Print all the little details in a list
87
88 echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=2";
89
603d4c72 90 if ($user->city or $user->country) {
fa0626c6 91 print_row(get_string("location").":", "$user->city, ".$COUNTRIES["$user->country"]);
603d4c72 92 }
f9903ed0 93
94 if (isteacher($course->id)) {
95 if ($user->address) {
fa0626c6 96 print_row(get_string("address").":", "$user->address");
f9903ed0 97 }
98 if ($user->phone1) {
fa0626c6 99 print_row(get_string("phone").":", "$user->phone1");
f9903ed0 100 }
101 if ($user->phone2) {
fa0626c6 102 print_row(get_string("phone").":", "$user->phone2");
f9903ed0 103 }
104 }
105
55e078c0 106 if ($user->maildisplay == 1 or ($user->maildisplay == 2 and $course->category) or isteacher($course->id)) {
107 print_row(get_string("email").":", "<A HREF=\"mailto:$user->email\">$user->email</A>");
108 }
f9903ed0 109
110 if ($user->url) {
fa0626c6 111 print_row(get_string("webpage").":", "<A HREF=\"$user->url\">$user->url</A>");
f9903ed0 112 }
113
114 if ($user->icq) {
49f5bb05 115 print_row("ICQ:","<A HREF=\"http://web.icq.com/wwp?Uin=$user->icq\">$user->icq <IMG SRC=\"http://web.icq.com/whitepages/online?icq=$user->icq&img=5\" WIDTH=18 HEIGHT=18 BORDER=0></A>");
f9903ed0 116 }
117
d21fef3a 118 if ($user->lastaccess) {
119 $datestring = userdate($user->lastaccess)."&nbsp (".format_time(time() - $user->lastaccess).")";
120 } else {
121 $datestring = "-";
122 }
fa0626c6 123 print_row(get_string("lastaccess").":", $datestring);
f9903ed0 124
125 echo "</TABLE>";
126
127 echo "</TD></TR></TABLE></TABLE>";
128
3086f3f6 129 $internalpassword = false;
130 if ($CFG->auth == "email" or $CFG->auth == "none") {
131 $internalpassword = "$CFG->wwwroot/login/change_password.php";
132 }
133
c888501c 134// Print other functions
803b2c76 135 echo "<CENTER><TABLE ALIGN=CENTER><TR>";
61e96406 136 if ($currentuser and !isguest()) {
3086f3f6 137 if ($CFG->auth == "email" or $CFG->auth == "none") {
138 echo "<TD NOWRAP><P><FORM ACTION=\"$CFG->wwwroot/login/change_password.php\" METHOD=GET>";
139 echo "<INPUT type=hidden name=id value=\"$course->id\">";
140 echo "<INPUT type=submit value=\"".get_string("changepassword")."\">";
141 echo "</FORM></P></TD>";
142 } else if ($CFG->changepassword) {
143 echo "<TD NOWRAP><P><FORM ACTION=\"$CFG->changepassword\" METHOD=GET>";
144 echo "<INPUT type=submit value=\"".get_string("changepassword")."\">";
145 echo "</FORM></P></TD>";
146 }
e1ac4272 147 }
ebc3bd2b 148 if ($course->category and
149 ((isstudent($course->id) and ($user->id == $USER->id) and !isguest()) or
150 (isteacher($course->id) and isstudent($course->id, $user->id))) ) {
18798c6f 151 echo "<TD NOWRAP><P><FORM ACTION=\"../course/unenrol.php\" METHOD=GET>";
152 echo "<INPUT type=hidden name=id value=\"$course->id\">";
803b2c76 153 echo "<INPUT type=hidden name=user value=\"$user->id\">";
fa0626c6 154 echo "<INPUT type=submit value=\"".get_string("unenrolme", "", $course->shortname)."\">";
18798c6f 155 echo "</FORM></P></TD>";
18798c6f 156 }
803b2c76 157 if (isteacher($course->id)) {
158 echo "<TD NOWRAP><P><FORM ACTION=\"../course/user.php\" METHOD=GET>";
159 echo "<INPUT type=hidden name=id value=\"$course->id\">";
160 echo "<INPUT type=hidden name=user value=\"$user->id\">";
161 echo "<INPUT type=submit value=\"".get_string("activityreport")."\">";
162 echo "</FORM></P></TD>";
0bfa3ba2 163 if ($user->id != $USER->id) {
164 echo "<TD NOWRAP><P><FORM ACTION=\"../course/loginas.php\" METHOD=GET>";
165 echo "<INPUT type=hidden name=id value=\"$course->id\">";
166 echo "<INPUT type=hidden name=user value=\"$user->id\">";
167 echo "<INPUT type=submit value=\"".get_string("loginas")."\">";
168 echo "</FORM></P></TD>";
169 }
803b2c76 170 }
171 echo "</TR></TABLE></CENTER>\n";
c888501c 172
11b0c469 173 forum_print_user_discussions($course->id, $user->id);
51feb9d5 174
f9903ed0 175 print_footer($course);
176
177/// Functions ///////
178
179function print_row($left, $right) {
180 echo "<TR><TD NOWRAP ALIGN=right><P>$left</TD><TD align=left><P>$right</P></TD></TR>";
181}
182
183?>