1
<?PHP // $Id: view.php,v 1.66.2.4 2004/10/27 05:57:34 moodler Exp $
1
<?PHP // $Id: view.php,v 1.93.2.1 2005/05/29 07:58:37 moodler Exp $
3
3
// Display profile for a particular user
5
5
require_once("../config.php");
6
require_once("../mod/forum/lib.php");
8
optional_variable($id);
9
optional_variable($course);
10
optional_variable($enable, "");
11
optional_variable($disable, "");
7
$id = optional_param('id', 0, PARAM_INT); // user id
8
$course = optional_param('course', SITEID, PARAM_INT); // course id (defaults to Site)
9
$enable = optional_param('enable', ''); // enable email
10
$disable = optional_param('disable', ''); // disable email
13
13
if (empty($id)) { // See your own profile by default
18
if (empty($course)) { // See it at site level by default
22
18
if (! $user = get_record("user", "id", $id) ) {
23
19
error("No such user in this course");
103
99
print_heading(get_string("userdeleted"));
106
echo "<table width=\"80%\" align=\"center\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" class=\"userinfobox\">";
103
/// Print tabs at top
104
/// This same call is made in:
108
$currenttab = 'profile';
113
echo "<table width=\"80%\" align=\"center\" border=\"0\" cellspacing=\"0\" class=\"userinfobox\">";
108
echo "<td width=\"100\" valign=\"top\" class=\"userinfoboxside\">";
115
echo "<td width=\"100\" valign=\"top\" class=\"side\">";
109
116
print_user_picture($user->id, $course->id, $user->picture, true, false, false);
110
echo "</td><td width=\"100%\" bgcolor=\"$THEME->cellcontent\" class=\"userinfoboxcontent\">";
113
// Print name and edit button across top
115
echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td nowrap>";
116
echo "<h3>$fullname</h3>";
117
echo "</td><td align=\"right\">";
118
if (($currentuser and !isguest()) or isadmin()) {
119
if(empty($CFG->loginhttps)) {
120
$wwwroot = $CFG->wwwroot;
122
$wwwroot = str_replace('http','https',$CFG->wwwroot);
124
echo "<p><form action=\"$wwwroot/user/edit.php\" method=\"get\">";
125
echo "<input type=\"hidden\" name=\"id\" value=\"$id\" />";
126
echo "<input type=\"hidden\" name=\"course\" value=\"$course->id\" />";
127
echo "<input type=\"submit\" value=\"".get_string("editmyprofile")."\" />";
130
echo "</td></tr></table>";
117
echo "</td><td width=\"100%\" class=\"content\">";
133
119
// Print the description
135
121
if ($user->description) {
136
echo "<p>".format_text($user->description, FORMAT_MOODLE)."</p><hr>";
122
echo format_text($user->description, FORMAT_MOODLE)."<hr />";
139
125
// Print all the little details in a list
141
echo "<table border=\"0\" cellpadding=\"5\" cellspacing=\"2\">";
127
echo '<table border="0" cellpadding="0" cellspacing="0" class="list">';
143
129
if ($user->city or $user->country) {
144
130
$countries = get_list_of_countries();
236
235
echo "</td></tr></table>";
238
238
$internalpassword = false;
239
if (is_internal_auth()) {
240
if(empty($CFG->loginhttps)) {
241
$internalpassword = "$CFG->wwwroot/login/change_password.php";
239
if (is_internal_auth() or (!empty($CFG->{'auth_'.$USER->auth.'_stdchangepassword'}))) {
240
if (empty($CFG->loginhttps)) {
241
$internalpassword = "$CFG->wwwroot/login/change_password.php";
243
243
$internalpassword = str_replace('http','https',$CFG->wwwroot.'/login/change_password.php');
247
247
// Print other functions
248
echo "<center><table align=center><tr>";
248
echo '<div class="buttons"><table align="center"><tr>';
249
249
if ($currentuser and !isguest()) {
250
if ($internalpassword) {
251
echo "<td nowrap><p><form action=\"$internalpassword\" method=get>";
252
echo "<input type=hidden name=id value=\"$course->id\">";
253
echo "<input type=submit value=\"".get_string("changepassword")."\">";
254
echo "</form></p></td>";
255
} else if (strlen($CFG->changepassword) > 1) {
256
echo "<td nowrap><p><form action=\"$CFG->changepassword\" method=get>";
257
echo "<input type=submit value=\"".get_string("changepassword")."\">";
258
echo "</form></p></td>";
250
if ($internalpassword ) {
251
echo "<td nowrap=\"nowrap\"><form action=\"$internalpassword\" method=\"get\">";
252
echo "<input type=\"hidden\" name=\"id\" value=\"$course->id\" />";
253
echo "<input type=\"submit\" value=\"".get_string("changepassword")."\" />";
255
} else if ( strlen($CFG->changepassword) > 1 ) {
256
echo "<td nowrap=\"nowrap\"><form action=\"$CFG->changepassword\" method=\"get\">";
257
echo "<input type=\"submit\" value=\"".get_string("changepassword")."\" />";
261
261
if ($course->category and
262
262
((isstudent($course->id) and ($user->id == $USER->id) and !isguest() and $CFG->allowunenroll) or
263
263
(isteacheredit($course->id) and isstudent($course->id, $user->id))) ) {
264
echo "<td nowrap><p><form action=\"../course/unenrol.php\" method=get>";
265
echo "<input type=hidden name=id value=\"$course->id\">";
266
echo "<input type=hidden name=user value=\"$user->id\">";
267
echo "<input type=submit value=\"".get_string("unenrolme", "", $course->shortname)."\">";
268
echo "</form></p></td>";
270
if (isteacher($course->id) or ($course->showreports and $USER->id == $user->id)) {
271
echo "<td nowrap><p><form action=\"../course/user.php\" method=get>";
272
echo "<input type=hidden name=id value=\"$course->id\">";
273
echo "<input type=hidden name=user value=\"$user->id\">";
274
echo "<input type=submit value=\"".get_string("activityreport")."\">";
275
echo "</form></p></td>";
277
if (isteacher($course->id) and ($USER->id != $user->id) and !iscreator($user->id)) {
278
echo "<td nowrap><p><form action=\"../course/loginas.php\" method=get>";
279
echo "<input type=hidden name=id value=\"$course->id\">";
280
echo "<input type=hidden name=user value=\"$user->id\">";
281
echo "<input type=submit value=\"".get_string("loginas")."\">";
282
echo "</form></p></td>";
284
echo "</tr></table></center>\n";
286
$isseparategroups = ($course->groupmode == SEPARATEGROUPS and
287
$course->groupmodeforce and
288
!isteacheredit($course->id));
290
$groupid = $isseparategroups ? get_current_group($course->id) : NULL;
292
forum_print_user_discussions($course->id, $user->id, $groupid);
264
echo "<td nowrap=\"nowrap\"><form action=\"../course/unenrol.php\" method=\"get\" />";
265
echo "<input type=\"hidden\" name=\"id\" value=\"$course->id\" />";
266
echo "<input type=\"hidden\" name=\"user\" value=\"$user->id\" />";
267
echo "<input type=\"submit\" value=\"".get_string("unenrolme", "", $course->shortname)."\">";
270
/* if (isteacher($course->id) or ($course->showreports and $USER->id == $user->id)) {
271
echo "<td nowrap=\"nowrap\"><form action=\"../course/user.php\" method=\"get\">";
272
echo "<input type=\"hidden\" name=\"id\" value=\"$course->id\" />";
273
echo "<input type=\"hidden\" name=\"user\" value=\"$user->id\" />";
274
echo "<input type=\"submit\" value=\"".get_string("activityreport")."\" />";
278
if ((isadmin() and !isadmin($user->id)) or (isteacher($course->id) and ($USER->id != $user->id) and !iscreator($user->id))) {
279
echo "<td nowrap=\"nowrap\"><form action=\"../course/loginas.php\" method=\"get\">";
280
echo "<input type=\"hidden\" name=\"id\" value=\"$course->id\" />";
281
echo "<input type=\"hidden\" name=\"user\" value=\"$user->id\" />";
282
echo "<input type=\"submit\" value=\"".get_string("loginas")."\" />";
285
if (!empty($CFG->messaging) and !isguest()) {
286
if (!empty($USER->id) and ($USER->id == $user->id)) {
287
if ($countmessages = count_records('message', 'useridto', $user->id)) {
288
$messagebuttonname = get_string("messages", "message")."($countmessages)";
290
$messagebuttonname = get_string("messages", "message");
292
echo "<td nowrap=\"nowrap\"><form target=\"message\" action=\"../message/index.php\" method=\"get\">";
293
echo "<input type=\"submit\" value=\"$messagebuttonname\" onclick=\"return openpopup('/message/index.php', 'message', 'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500', 0);\" />";
296
echo "<td nowrap=\"nowrap\"><form target=\"message_$user->id\" action=\"../message/discussion.php\" method=\"get\">";
297
echo "<input type=\"hidden\" name=\"id\" value=\"$user->id\" />";
298
echo "<input type=\"submit\" value=\"".get_string("sendmessage", "message")."\" onclick=\"return openpopup('/message/discussion.php?id=$user->id', 'message_$user->id', 'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500', 0);\" />";
303
echo "</tr></table></div>\n";
294
306
print_footer($course);
296
308
/// Functions ///////
298
310
function print_row($left, $right) {
299
echo "<tr><td nowrap align=right valign=top><p>$left</td><td align=left valign=top><p>$right</p></td></tr>";
311
echo "\n<tr><td nowrap=\"nowrap\" align=\"right\" valign=\"top\" class=\"label c0\">$left</td><td align=\"left\" valign=\"top\" class=\"info c1\">$right</td></tr>\n";