Changes to improve the user activity reports
[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");
51feb9d5 8 require("../mod/discuss/lib.php");
f9903ed0 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 {
fa0626c6 37 print_header("$personalprofile: $fullname", "$personalprofile: $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>";
51 if ($user->picture) {
52 echo "<IMG BORDER=0 ALIGN=left WIDTH=100 SRC=\"pix.php/$user->id/f1.jpg\">";
53 } else {
54 echo "<IMG BORDER=0 ALIGN=left WIDTH=100 SRC=\"default/f1.jpg\">";
55 }
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>";
603d4c72 64 if ($id == $USER->id and !isguest()) {
f9903ed0 65 echo "<P><FORM ACTION=edit.php METHOD=GET>";
66 echo "<INPUT type=hidden name=id value=\"$id\">";
67 echo "<INPUT type=hidden name=course value=\"$course->id\">";
fa0626c6 68 echo "<INPUT type=submit value=\"".get_string("editmyprofile")."\">";
f9903ed0 69 echo "</FORM></P>";
70 }
71 echo "</TD></TR></TABLE>";
72
73
f9903ed0 74 // Print the description
75
76 if ($user->description) {
77 echo "<P>".text_to_html($user->description)."</P><HR>";
78 }
79
80
f9903ed0 81 // Print all the little details in a list
82
83 echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=2";
84
603d4c72 85 if ($user->city or $user->country) {
fa0626c6 86 print_row(get_string("location").":", "$user->city, ".$COUNTRIES["$user->country"]);
603d4c72 87 }
f9903ed0 88
89 if (isteacher($course->id)) {
90 if ($user->address) {
fa0626c6 91 print_row(get_string("address").":", "$user->address");
f9903ed0 92 }
93 if ($user->phone1) {
fa0626c6 94 print_row(get_string("phone").":", "$user->phone1");
f9903ed0 95 }
96 if ($user->phone2) {
fa0626c6 97 print_row(get_string("phone").":", "$user->phone2");
f9903ed0 98 }
99 }
100
fa0626c6 101 print_row(get_string("email").":", "<A HREF=\"mailto:$user->email\">$user->email</A>");
f9903ed0 102
103 if ($user->url) {
fa0626c6 104 print_row(get_string("webpage").":", "<A HREF=\"$user->url\">$user->url</A>");
f9903ed0 105 }
106
107 if ($user->icq) {
108 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>");
109 }
110
111 $datestring = userdate($user->lastaccess)."&nbsp (".format_time(time() - $user->lastaccess).")";
fa0626c6 112 print_row(get_string("lastaccess").":", $datestring);
f9903ed0 113
114 echo "</TABLE>";
115
116 echo "</TD></TR></TABLE></TABLE>";
117
c888501c 118// Print other functions
51feb9d5 119 if ($user->id == $USER->id and !isguest() ) {
18798c6f 120 echo "<CENTER><TABLE ALIGN=CENTER><TR>";
121 echo "<TD NOWRAP><P><FORM ACTION=\"../course/unenrol.php\" METHOD=GET>";
122 echo "<INPUT type=hidden name=id value=\"$course->id\">";
fa0626c6 123 echo "<INPUT type=submit value=\"".get_string("unenrolme", "", $course->shortname)."\">";
18798c6f 124 echo "</FORM></P></TD>";
125 echo "</TR></TABLE></CENTER>\n";
126 }
c888501c 127
51feb9d5 128 print_user_discussions($course, $user);
129
f9903ed0 130 print_footer($course);
131
132/// Functions ///////
133
134function print_row($left, $right) {
135 echo "<TR><TD NOWRAP ALIGN=right><P>$left</TD><TD align=left><P>$right</P></TD></TR>";
136}
137
138?>