New help translation
[moodle.git] / user / view.php
blob7b3d8a028af54d675e396e5e4119271ee88b910c
1 <?PHP // $Id$
3 // Display profile for a particular user
5 require_once("../config.php");
6 require_once("../mod/forum/lib.php");
7 require_once("lib.php");
9 require_variable($id);
10 require_variable($course);
13 if (! $user = get_record("user", "id", $id) ) {
14 error("No such user in this course");
17 if (! $course = get_record("course", "id", $course) ) {
18 error("No such course id");
21 if ($course->category) {
22 require_login($course->id);
25 $countries = get_list_of_countries();
27 add_to_log($course->id, "user", "view", "view.php?id=$user->id&course=$course->id", "$user->id");
29 $fullname = "$user->firstname $user->lastname";
30 $personalprofile = get_string("personalprofile");
31 $participants = get_string("participants");
33 $loggedinas = "<p class=\"logininfo\">".user_login_string($course, $USER)."</p>";
35 if ($course->category) {
36 print_header("$personalprofile: $fullname", "$personalprofile: $fullname",
37 "<A HREF=\"../course/view.php?id=$course->id\">$course->shortname</A> ->
38 <A HREF=\"index.php?id=$course->id\">$participants</A> -> $fullname",
39 "", "", true, "&nbsp;", $loggedinas);
40 } else {
41 print_header("$course->fullname: $personalprofile: $fullname", "$course->fullname",
42 "$fullname", "", "", true, "&nbsp;", $loggedinas);
45 if ($course->category and ! isguest() ) {
46 if (!isstudent($course->id, $user->id) && !isteacher($course->id, $user->id)) {
47 print_heading(get_string("notenrolled", "", $fullname));
48 print_footer($course);
49 die;
53 if ($user->deleted) {
54 print_heading(get_string("userdeleted"));
57 echo "<TABLE WIDTH=80% ALIGN=CENTER BORDER=0 CELLPADDING=1 CELLSPACING=1><TR><TD BGCOLOR=#888888>";
58 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=3 CELLSPACING=0><TR>";
59 echo "<TD WIDTH=100 BGCOLOR=\"$THEME->body\" VALIGN=top>";
60 print_user_picture($user->id, $course->id, $user->picture, true, false, false);
61 echo "</TD><TD WIDTH=100% BGCOLOR=#FFFFFF>";
64 // Print name and edit button across top
66 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD NOWRAP>";
67 echo "<H3>$fullname</H3>";
68 echo "</TD><TD align=right>";
69 if (empty($USER->id)) {
70 $currentuser = false;
71 } else {
72 $currentuser = ($user->id == $USER->id);
74 if (($currentuser and !isguest()) or isadmin()) {
75 echo "<P><FORM ACTION=edit.php METHOD=GET>";
76 echo "<INPUT type=hidden name=id value=\"$id\">";
77 echo "<INPUT type=hidden name=course value=\"$course->id\">";
78 echo "<INPUT type=submit value=\"".get_string("editmyprofile")."\">";
79 echo "</FORM></P>";
81 echo "</TD></TR></TABLE>";
84 // Print the description
86 if ($user->description) {
87 echo "<P>".text_to_html($user->description)."</P><HR>";
90 // Print all the little details in a list
92 echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=2";
94 if ($user->city or $user->country) {
95 print_row(get_string("location").":", "$user->city, ".$countries["$user->country"]);
98 if (isteacher($course->id)) {
99 if ($user->address) {
100 print_row(get_string("address").":", "$user->address");
102 if ($user->phone1) {
103 print_row(get_string("phone").":", "$user->phone1");
105 if ($user->phone2) {
106 print_row(get_string("phone").":", "$user->phone2");
110 if ($user->maildisplay == 1 or ($user->maildisplay == 2 and $course->category) or isteacher($course->id)) {
111 print_row(get_string("email").":", obfuscate_mailto($user->email));
114 if ($user->url) {
115 print_row(get_string("webpage").":", "<A HREF=\"$user->url\">$user->url</A>");
118 if ($user->icq) {
119 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>");
122 if ($user->lastaccess) {
123 $datestring = userdate($user->lastaccess)."&nbsp (".format_time(time() - $user->lastaccess).")";
124 } else {
125 $datestring = "-";
127 print_row(get_string("lastaccess").":", $datestring);
129 echo "</TABLE>";
131 echo "</TD></TR></TABLE></TABLE>";
133 $internalpassword = false;
134 if (is_internal_auth()) {
135 $internalpassword = "$CFG->wwwroot/login/change_password.php";
138 // Print other functions
139 echo "<CENTER><TABLE ALIGN=CENTER><TR>";
140 if ($currentuser and !isguest()) {
141 if ($internalpassword) {
142 echo "<TD NOWRAP><P><FORM ACTION=\"$internalpassword\" METHOD=GET>";
143 echo "<INPUT type=hidden name=id value=\"$course->id\">";
144 echo "<INPUT type=submit value=\"".get_string("changepassword")."\">";
145 echo "</FORM></P></TD>";
146 } else if (strlen($CFG->changepassword) > 1) {
147 echo "<TD NOWRAP><P><FORM ACTION=\"$CFG->changepassword\" METHOD=GET>";
148 echo "<INPUT type=submit value=\"".get_string("changepassword")."\">";
149 echo "</FORM></P></TD>";
152 if ($course->category and
153 ((isstudent($course->id) and ($user->id == $USER->id) and !isguest() and $CFG->allowunenroll) or
154 (isteacher($course->id) and isstudent($course->id, $user->id))) ) {
155 echo "<TD NOWRAP><P><FORM ACTION=\"../course/unenrol.php\" METHOD=GET>";
156 echo "<INPUT type=hidden name=id value=\"$course->id\">";
157 echo "<INPUT type=hidden name=user value=\"$user->id\">";
158 echo "<INPUT type=submit value=\"".get_string("unenrolme", "", $course->shortname)."\">";
159 echo "</FORM></P></TD>";
161 if (isteacher($course->id)) {
162 echo "<TD NOWRAP><P><FORM ACTION=\"../course/user.php\" METHOD=GET>";
163 echo "<INPUT type=hidden name=id value=\"$course->id\">";
164 echo "<INPUT type=hidden name=user value=\"$user->id\">";
165 echo "<INPUT type=submit value=\"".get_string("activityreport")."\">";
166 echo "</FORM></P></TD>";
167 if ($user->id != $USER->id) {
168 echo "<TD NOWRAP><P><FORM ACTION=\"../course/loginas.php\" METHOD=GET>";
169 echo "<INPUT type=hidden name=id value=\"$course->id\">";
170 echo "<INPUT type=hidden name=user value=\"$user->id\">";
171 echo "<INPUT type=submit value=\"".get_string("loginas")."\">";
172 echo "</FORM></P></TD>";
175 echo "</TR></TABLE></CENTER>\n";
177 forum_print_user_discussions($course->id, $user->id);
179 print_footer($course);
181 /// Functions ///////
183 function print_row($left, $right) {
184 echo "<TR><TD NOWRAP ALIGN=right><P>$left</TD><TD align=left><P>$right</P></TD></TR>";