~ubuntu-branches/ubuntu/breezy/moodle/breezy

« back to all changes in this revision

Viewing changes to user/view.php

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2005-10-13 02:00:59 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051013020059-y2qcyo41t7nqppcg
Tags: 1.5.2-1ubuntu1
* Resync with debian (security update)
* changed dependencys to php5
* changed apache dependency to apache2 
* References
  CAN-2005-2247

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 $
2
2
 
3
3
//  Display profile for a particular user
4
4
 
5
5
    require_once("../config.php");
6
 
    require_once("../mod/forum/lib.php");
7
 
 
8
 
    optional_variable($id);
9
 
    optional_variable($course);
10
 
    optional_variable($enable, "");
11
 
    optional_variable($disable, "");
 
6
 
 
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
 
11
 
12
12
 
13
13
    if (empty($id)) {         // See your own profile by default
14
14
        require_login();
15
15
        $id = $USER->id;
16
16
    }
17
17
 
18
 
    if (empty($course)) {     // See it at site level by default
19
 
        $course = SITEID;
20
 
    }
21
 
 
22
18
    if (! $user = get_record("user", "id", $id) ) {
23
19
        error("No such user in this course");
24
20
    }
59
55
    if (groupmode($course) == SEPARATEGROUPS and !isteacheredit($course->id)) {   // Groups must be kept separate
60
56
        require_login();
61
57
 
62
 
        if (!isteacheredit($course->id, $user->id) and !ismember(mygroupid($course->id), $user->id)) {
 
58
        if (!$currentuser && !isteacheredit($course->id, $user->id) && !ismember(mygroupid($course->id), $user->id)) {
63
59
            print_header("$personalprofile: ", "$personalprofile: ",
64
60
                         "<a href=\"../course/view.php?id=$course->id\">$course->shortname</a> ->
65
61
                          <a href=\"index.php?id=$course->id\">$participants</a>",
68
64
        }
69
65
    }
70
66
 
71
 
    if (!$course->category and !$currentuser) {  // To reduce possibility of "browsing" userbase at site level
72
 
        if (!isteacher() and !isteacher(0, $user->id) ) {  // Teachers can browse and be browsed at site level
 
67
    if ($course->id == SITEID and !$currentuser) {  // To reduce possibility of "browsing" userbase at site level
 
68
        if (!isteacherinanycourse() and !isteacherinanycourse($user->id) ) {  // Teachers can browse and be browsed at site level
73
69
            print_header("$personalprofile: ", "$personalprofile: ",
74
70
                          "<a href=\"index.php?id=$course->id\">$participants</a>",
75
71
                          "", "", true, "&nbsp;", navmenu($course));
103
99
        print_heading(get_string("userdeleted"));
104
100
    }
105
101
 
106
 
    echo "<table width=\"80%\" align=\"center\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" class=\"userinfobox\">";
 
102
 
 
103
/// Print tabs at top
 
104
/// This same call is made in:
 
105
///     /user/view.php
 
106
///     /user/edit.php
 
107
///     /course/user.php
 
108
    $currenttab = 'profile';
 
109
    include('tabs.php');
 
110
 
 
111
 
 
112
 
 
113
    echo "<table width=\"80%\" align=\"center\" border=\"0\" cellspacing=\"0\" class=\"userinfobox\">";
107
114
    echo "<tr>";
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\">";
111
 
 
112
 
 
113
 
    // Print name and edit button across top
114
 
 
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;
121
 
        } else {
122
 
            $wwwroot = str_replace('http','https',$CFG->wwwroot);
123
 
        }
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")."\" />";
128
 
        echo "</form></p>";
129
 
    }
130
 
    echo "</td></tr></table>";
131
 
 
 
117
    echo "</td><td width=\"100%\" class=\"content\">";
132
118
 
133
119
    // Print the description
134
120
 
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 />";
137
123
    }
138
124
 
139
125
    // Print all the little details in a list
140
126
 
141
 
    echo "<table border=\"0\" cellpadding=\"5\" cellspacing=\"2\">";
 
127
    echo '<table border="0" cellpadding="0" cellspacing="0" class="list">';
142
128
 
143
129
    if ($user->city or $user->country) {
144
130
        $countries = get_list_of_countries();
186
172
                $switchclick = get_string('emaildisableclick');
187
173
                $switchpix   = 'email.gif';
188
174
            }
189
 
            $emailswitch = "&nbsp<a title=\"$switchclick\" ".
190
 
                           "href=\"view.php?id=$user->id&course=$course->id&$switchparam=1\">".
191
 
                           "<img border=\"0\" width=11 height=11 src=\"$CFG->pixpath/t/$switchpix\"></a>";
 
175
            $emailswitch = "&nbsp;<a title=\"$switchclick\" ".
 
176
                           "href=\"view.php?id=$user->id&amp;course=$course->id&amp;$switchparam=1\">".
 
177
                           "<img border=\"0\" width=\"11\" height=\"11\" src=\"$CFG->pixpath/t/$switchpix\" alt=\"\" /></a>";
192
178
 
193
179
        } else if ($currentuser) {         /// Can only re-enable an email this way
194
180
            if ($user->emailstop) {   // Include link that tells how to re-enable their email
196
182
                $switchtitle = get_string('emaildisable');
197
183
                $switchclick = get_string('emailenableclick');
198
184
 
199
 
                $emailswitch = "&nbsp(<a title=\"$switchclick\" ".
200
 
                               "href=\"view.php?id=$user->id&course=$course->id&enable=1\">$switchtitle</a>)";
 
185
                $emailswitch = "&nbsp;(<a title=\"$switchclick\" ".
 
186
                               "href=\"view.php?id=$user->id&amp;course=$course->id&amp;enable=1\">$switchtitle</a>)";
201
187
            }
202
188
        }
203
189
 
209
195
    }
210
196
 
211
197
    if ($user->icq) {
212
 
        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>");
 
198
        print_row(get_string('icqnumber').':',"<a href=\"http://web.icq.com/wwp?uin=$user->icq\">$user->icq <img src=\"http://web.icq.com/whitepages/online?icq=$user->icq&amp;img=5\" width=\"18\" height=\"18\" border=\"0\" alt=\"\" /></a>");
 
199
    }
 
200
 
 
201
    if ($user->skype) {
 
202
        print_row(get_string('skypeid').':','<a href="callto:'.urlencode($user->skype).'">'.s($user->skype).'</a>');
 
203
    }
 
204
    if ($user->yahoo) {
 
205
        print_row(get_string('yahooid').':', '<a href="http://edit.yahoo.com/config/send_webmesg?.target='.s($user->yahoo).'&amp;.src=pg">'.s($user->yahoo).'</a>');
 
206
    }
 
207
    if ($user->aim) {
 
208
        print_row(get_string('aimid').':', '<a href="aim:goim?screenname='.s($user->aim).'">'.s($user->aim).'</a>');
 
209
    }
 
210
    if ($user->msn) {
 
211
        print_row(get_string('msnid').':', s($user->msn));
213
212
    }
214
213
 
215
214
    if (isteacher($course->id)) {
217
216
            $courselisting = '';
218
217
            foreach ($mycourses as $mycourse) {
219
218
                if ($mycourse->visible and $mycourse->category) {
220
 
                    $courselisting .= "<a href=\"$CFG->wwwroot/user/view.php?id=$user->id&course=$mycourse->id\">$mycourse->fullname</a>, ";
 
219
                    $courselisting .= "<a href=\"$CFG->wwwroot/user/view.php?id=$user->id&amp;course=$mycourse->id\">$mycourse->fullname</a>, ";
221
220
                }
222
221
            }
223
222
            print_row(get_string('courses').':', rtrim($courselisting,', '));
225
224
    }
226
225
 
227
226
    if ($user->lastaccess) {
228
 
        $datestring = userdate($user->lastaccess)."&nbsp (".format_time(time() - $user->lastaccess).")";
 
227
        $datestring = userdate($user->lastaccess)."&nbsp; (".format_time(time() - $user->lastaccess).")";
229
228
    } else {
230
229
        $datestring = get_string("never");
231
230
    }
235
234
 
236
235
    echo "</td></tr></table>";
237
236
 
 
237
 
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";
242
242
        } else {
243
243
            $internalpassword = str_replace('http','https',$CFG->wwwroot.'/login/change_password.php');
244
244
        }
245
245
    }
246
246
 
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")."\" />";
 
254
            echo "</form></td>";
 
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")."\" />";
 
258
            echo "</form></td>";
259
259
        }
260
260
    }
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>";
269
 
    }
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>";
276
 
    }
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>";
283
 
    }
284
 
    echo "</tr></table></center>\n";
285
 
 
286
 
    $isseparategroups = ($course->groupmode == SEPARATEGROUPS and
287
 
                         $course->groupmodeforce and
288
 
                         !isteacheredit($course->id));
289
 
 
290
 
    $groupid = $isseparategroups ? get_current_group($course->id) : NULL;
291
 
 
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)."\">";
 
268
        echo "</form></td>";
 
269
    }
 
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")."\" />";
 
275
        echo "</form></td>";
 
276
    }
 
277
*/
 
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")."\" />";
 
283
        echo "</form></td>";
 
284
    }
 
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)";
 
289
            } else {
 
290
                $messagebuttonname = get_string("messages", "message");
 
291
            }
 
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);\" />";
 
294
            echo "</form></td>";
 
295
        } else {
 
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);\" />";
 
299
            echo "</form></td>";
 
300
        }
 
301
    }
 
302
    echo "<td></td>";
 
303
    echo "</tr></table></div>\n";
 
304
 
293
305
 
294
306
    print_footer($course);
295
307
 
296
308
/// Functions ///////
297
309
 
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";
300
312
}
301
313
 
302
314
?>