Cleanups for footer on home page
[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
f9903ed0 48 echo "<TABLE WIDTH=80% ALIGN=CENTER BORDER=0 CELLPADDING=1 CELLSPACING=1><TR><TD BGCOLOR=#888888>";
49 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=3 CELLSPACING=0><TR>";
50 echo "<TD WIDTH=100 BGCOLOR=\"$THEME->body\" VALIGN=top>";
b0ccbd92 51 print_user_picture($user->id, $course->id, $user->picture, true);
f9903ed0 52 echo "</TD><TD WIDTH=100% BGCOLOR=#FFFFFF>";
53
54
55 // Print name and edit button across top
56
57 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD NOWRAP>";
fa0626c6 58 echo "<H3>$fullname</H3>";
f9903ed0 59 echo "</TD><TD align=right>";
243c518b 60 if (($id == $USER->id and !isguest()) or isadmin()) {
f9903ed0 61 echo "<P><FORM ACTION=edit.php METHOD=GET>";
62 echo "<INPUT type=hidden name=id value=\"$id\">";
63 echo "<INPUT type=hidden name=course value=\"$course->id\">";
fa0626c6 64 echo "<INPUT type=submit value=\"".get_string("editmyprofile")."\">";
f9903ed0 65 echo "</FORM></P>";
66 }
67 echo "</TD></TR></TABLE>";
68
69
f9903ed0 70 // Print the description
71
72 if ($user->description) {
73 echo "<P>".text_to_html($user->description)."</P><HR>";
74 }
75
76
f9903ed0 77 // Print all the little details in a list
78
79 echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=2";
80
603d4c72 81 if ($user->city or $user->country) {
fa0626c6 82 print_row(get_string("location").":", "$user->city, ".$COUNTRIES["$user->country"]);
603d4c72 83 }
f9903ed0 84
85 if (isteacher($course->id)) {
86 if ($user->address) {
fa0626c6 87 print_row(get_string("address").":", "$user->address");
f9903ed0 88 }
89 if ($user->phone1) {
fa0626c6 90 print_row(get_string("phone").":", "$user->phone1");
f9903ed0 91 }
92 if ($user->phone2) {
fa0626c6 93 print_row(get_string("phone").":", "$user->phone2");
f9903ed0 94 }
95 }
96
fa0626c6 97 print_row(get_string("email").":", "<A HREF=\"mailto:$user->email\">$user->email</A>");
f9903ed0 98
99 if ($user->url) {
fa0626c6 100 print_row(get_string("webpage").":", "<A HREF=\"$user->url\">$user->url</A>");
f9903ed0 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).")";
fa0626c6 108 print_row(get_string("lastaccess").":", $datestring);
f9903ed0 109
110 echo "</TABLE>";
111
112 echo "</TD></TR></TABLE></TABLE>";
113
c888501c 114// Print other functions
803b2c76 115 echo "<CENTER><TABLE ALIGN=CENTER><TR>";
92356678 116 if ((isstudent($course->id) and ($user->id == $USER->id)) or
117 (isteacher($course->id) and isstudent($course->id, $user->id)) ) {
18798c6f 118 echo "<TD NOWRAP><P><FORM ACTION=\"../course/unenrol.php\" METHOD=GET>";
119 echo "<INPUT type=hidden name=id value=\"$course->id\">";
803b2c76 120 echo "<INPUT type=hidden name=user value=\"$user->id\">";
fa0626c6 121 echo "<INPUT type=submit value=\"".get_string("unenrolme", "", $course->shortname)."\">";
18798c6f 122 echo "</FORM></P></TD>";
18798c6f 123 }
803b2c76 124 if (isteacher($course->id)) {
125 echo "<TD NOWRAP><P><FORM ACTION=\"../course/user.php\" METHOD=GET>";
126 echo "<INPUT type=hidden name=id value=\"$course->id\">";
127 echo "<INPUT type=hidden name=user value=\"$user->id\">";
128 echo "<INPUT type=submit value=\"".get_string("activityreport")."\">";
129 echo "</FORM></P></TD>";
130 echo "<TD NOWRAP><P><FORM ACTION=\"../course/loginas.php\" METHOD=GET>";
131 echo "<INPUT type=hidden name=id value=\"$course->id\">";
132 echo "<INPUT type=hidden name=user value=\"$user->id\">";
133 echo "<INPUT type=submit value=\"".get_string("loginas")."\">";
134 echo "</FORM></P></TD>";
135 }
136 echo "</TR></TABLE></CENTER>\n";
c888501c 137
11b0c469 138 forum_print_user_discussions($course->id, $user->id);
51feb9d5 139
f9903ed0 140 print_footer($course);
141
142/// Functions ///////
143
144function print_row($left, $right) {
145 echo "<TR><TD NOWRAP ALIGN=right><P>$left</TD><TD align=left><P>$right</P></TD></TR>";
146}
147
148?>