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 | |
26 | $fullname = "$user->firstname $user->lastname"; |
27 | |
8a3b358b |
28 | |
da3a08d7 |
29 | add_to_log($course->id, "user", "view", "view.php?id=$user->id&course=$course->id", "$user->id"); |
f9903ed0 |
30 | |
31 | if ($course->category) { |
32 | print_header("Personal profile: $fullname", "Personal profile: $fullname", |
33 | "<A HREF=\"../course/view.php?id=$course->id\">$course->shortname</A> -> |
34 | <A HREF=\"index.php?id=$course->id\">Participants</A> -> $fullname", ""); |
35 | } else { |
36 | print_header("Personal profile: $fullname", "Personal profile: $fullname", "$fullname", ""); |
37 | } |
38 | |
603d4c72 |
39 | if ($course->category and ! isguest() ) { |
b51e9913 |
40 | if (!isstudent($course->id, $user->id) && !isteacher($course->id, $user->id)) { |
41 | print_heading("$fullname is not enrolled in this course"); |
42 | print_footer($course); |
43 | die; |
44 | } |
8a3b358b |
45 | } |
46 | |
f9903ed0 |
47 | echo "<TABLE WIDTH=80% ALIGN=CENTER BORDER=0 CELLPADDING=1 CELLSPACING=1><TR><TD BGCOLOR=#888888>"; |
48 | echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=3 CELLSPACING=0><TR>"; |
49 | echo "<TD WIDTH=100 BGCOLOR=\"$THEME->body\" VALIGN=top>"; |
50 | if ($user->picture) { |
51 | echo "<IMG BORDER=0 ALIGN=left WIDTH=100 SRC=\"pix.php/$user->id/f1.jpg\">"; |
52 | } else { |
53 | echo "<IMG BORDER=0 ALIGN=left WIDTH=100 SRC=\"default/f1.jpg\">"; |
54 | } |
55 | echo "</TD><TD WIDTH=100% BGCOLOR=#FFFFFF>"; |
56 | |
57 | |
58 | // Print name and edit button across top |
59 | |
60 | echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD NOWRAP>"; |
61 | echo "<H3>$user->firstname $user->lastname</H3>"; |
62 | echo "</TD><TD align=right>"; |
603d4c72 |
63 | if ($id == $USER->id and !isguest()) { |
f9903ed0 |
64 | echo "<P><FORM ACTION=edit.php METHOD=GET>"; |
65 | echo "<INPUT type=hidden name=id value=\"$id\">"; |
66 | echo "<INPUT type=hidden name=course value=\"$course->id\">"; |
67 | echo "<INPUT type=submit value=\"Edit my profile\">"; |
68 | echo "</FORM></P>"; |
69 | } |
70 | echo "</TD></TR></TABLE>"; |
71 | |
72 | |
f9903ed0 |
73 | // Print the description |
74 | |
75 | if ($user->description) { |
76 | echo "<P>".text_to_html($user->description)."</P><HR>"; |
77 | } |
78 | |
79 | |
f9903ed0 |
80 | // Print all the little details in a list |
81 | |
82 | echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=2"; |
83 | |
603d4c72 |
84 | if ($user->city or $user->country) { |
85 | print_row("Location:", "$user->city, ".$COUNTRIES["$user->country"]); |
86 | } |
f9903ed0 |
87 | |
88 | if (isteacher($course->id)) { |
89 | if ($user->address) { |
90 | print_row("Address:", "$user->address"); |
91 | } |
92 | if ($user->phone1) { |
93 | print_row("Phone:", "$user->phone1"); |
94 | } |
95 | if ($user->phone2) { |
96 | print_row("Phone:", "$user->phone2"); |
97 | } |
98 | } |
99 | |
100 | print_row("Email:", "<A HREF=\"mailto:$user->email\">$user->email</A>"); |
101 | |
102 | if ($user->url) { |
103 | print_row("Web page:", "<A HREF=\"$user->url\">$user->url</A>"); |
104 | } |
105 | |
106 | if ($user->icq) { |
107 | 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>"); |
108 | } |
109 | |
110 | $datestring = userdate($user->lastaccess)."  (".format_time(time() - $user->lastaccess).")"; |
111 | print_row("Last access:", $datestring); |
112 | |
113 | echo "</TABLE>"; |
114 | |
115 | echo "</TD></TR></TABLE></TABLE>"; |
116 | |
c888501c |
117 | // Print other functions |
51feb9d5 |
118 | if ($user->id == $USER->id and !isguest() ) { |
18798c6f |
119 | echo "<CENTER><TABLE ALIGN=CENTER><TR>"; |
120 | echo "<TD NOWRAP><P><FORM ACTION=\"../course/unenrol.php\" METHOD=GET>"; |
121 | echo "<INPUT type=hidden name=id value=\"$course->id\">"; |
122 | echo "<INPUT type=submit value=\"Unenrol me from $course->shortname\">"; |
123 | echo "</FORM></P></TD>"; |
124 | echo "</TR></TABLE></CENTER>\n"; |
125 | } |
c888501c |
126 | |
51feb9d5 |
127 | print_user_discussions($course, $user); |
128 | |
f9903ed0 |
129 | print_footer($course); |
130 | |
131 | /// Functions /////// |
132 | |
133 | function print_row($left, $right) { |
134 | echo "<TR><TD NOWRAP ALIGN=right><P>$left</TD><TD align=left><P>$right</P></TD></TR>"; |
135 | } |
136 | |
137 | ?> |