3 // Display profile for a particular user
5 require_once("../config.php");
6 require_once("../lib/countries.php");
7 require_once("../mod/forum/lib.php");
8 require_once("lib.php");
10 require_variable($id);
11 require_variable($course);
14 if (! $user = get_record("user", "id", $id) ) {
15 error("No such user in this course");
18 if (! $course = get_record("course", "id", $course) ) {
19 error("No such course id");
22 if ($course->category
) {
23 require_login($course->id
);
26 add_to_log($course->id
, "user", "view", "view.php?id=$user->id&course=$course->id", "$user->id");
28 $fullname = "$user->firstname $user->lastname";
29 $personalprofile = get_string("personalprofile");
30 $participants = get_string("participants");
32 $loggedinas = "<p class=\"logininfo\">".user_login_string($course, $USER)."</p>";
34 if ($course->category
) {
35 print_header("$personalprofile: $fullname", "$personalprofile: $fullname",
36 "<A HREF=\"../course/view.php?id=$course->id\">$course->shortname</A> ->
37 <A HREF=\"index.php?id=$course->id\">$participants</A> -> $fullname",
38 "", "", true, " ", $loggedinas);
40 print_header("$course->fullname: $personalprofile: $fullname", "$course->fullname",
41 "$fullname", "", "", true, " ", $loggedinas);
44 if ($course->category
and ! isguest() ) {
45 if (!isstudent($course->id
, $user->id
) && !isteacher($course->id
, $user->id
)) {
46 print_heading(get_string("notenrolled", "", $fullname));
47 print_footer($course);
53 print_heading(get_string("userdeleted"));
56 echo "<TABLE WIDTH=80% ALIGN=CENTER BORDER=0 CELLPADDING=1 CELLSPACING=1><TR><TD BGCOLOR=#888888>";
57 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=3 CELLSPACING=0><TR>";
58 echo "<TD WIDTH=100 BGCOLOR=\"$THEME->body\" VALIGN=top>";
59 print_user_picture($user->id
, $course->id
, $user->picture
, true, false, false);
60 echo "</TD><TD WIDTH=100% BGCOLOR=#FFFFFF>";
63 // Print name and edit button across top
65 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD NOWRAP>";
66 echo "<H3>$fullname</H3>";
67 echo "</TD><TD align=right>";
68 if (empty($USER->id
)) {
71 $currentuser = ($user->id
== $USER->id
);
73 if (($currentuser and !isguest()) or isadmin()) {
74 echo "<P><FORM ACTION=edit.php METHOD=GET>";
75 echo "<INPUT type=hidden name=id value=\"$id\">";
76 echo "<INPUT type=hidden name=course value=\"$course->id\">";
77 echo "<INPUT type=submit value=\"".get_string("editmyprofile")."\">";
80 echo "</TD></TR></TABLE>";
83 // Print the description
85 if ($user->description
) {
86 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
)) {
100 print_row(get_string("address").":", "$user->address");
103 print_row(get_string("phone").":", "$user->phone1");
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
));
115 print_row(get_string("webpage").":", "<A HREF=\"$user->url\">$user->url</A>");
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
)."  (".format_time(time() - $user->lastaccess
).")";
127 print_row(get_string("lastaccess").":", $datestring);
131 echo "</TD></TR></TABLE></TABLE>";
133 $internalpassword = false;
134 if ($CFG->auth
== "email" or $CFG->auth
== "none" or $CFG->auth
== "manual") {
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 ($CFG->changepassword
) {
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()) 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>";