MDL-10689:
[moodle-linuxchix.git] / message / user.php
blob98846c3717f1d9831ad5fee3bb6c823985959631
1 <?php // $Id$
3 require('../config.php');
4 require('lib.php');
6 require_login();
8 if (isguest()) {
9 redirect($CFG->wwwroot);
12 if (empty($CFG->messaging)) {
13 error("Messaging is disabled on this site");
16 /// Script parameters
17 $userid = required_param('id', PARAM_INT);
19 $addcontact = optional_param('addcontact', 0, PARAM_INT); // adding a contact
20 $removecontact = optional_param('removecontact', 0, PARAM_INT); // removing a contact
21 $blockcontact = optional_param('blockcontact', 0, PARAM_INT); // blocking a contact
22 $unblockcontact = optional_param('unblockcontact', 0, PARAM_INT); // unblocking a contact
24 /// Check the user we are talking to is valid
25 if (! $user = get_record('user', 'id', $userid)) {
26 error("User ID was incorrect");
29 /// Possibly change some contacts if requested
31 if ($addcontact and confirm_sesskey()) {
32 add_to_log(SITEID, 'message', 'add contact',
33 'history.php?user1='.$addcontact.'&amp;user2='.$USER->id, $addcontact);
34 message_add_contact($addcontact);
36 if ($removecontact and confirm_sesskey()) {
37 add_to_log(SITEID, 'message', 'remove contact',
38 'history.php?user1='.$removecontact.'&amp;user2='.$USER->id, $removecontact);
39 message_remove_contact($removecontact);
41 if ($blockcontact and confirm_sesskey()) {
42 add_to_log(SITEID, 'message', 'block contact',
43 'history.php?user1='.$blockcontact.'&amp;user2='.$USER->id, $blockcontact);
44 message_block_contact($blockcontact);
46 if ($unblockcontact and confirm_sesskey()) {
47 add_to_log(SITEID, 'message', 'unblock contact',
48 'history.php?user1='.$unblockcontact.'&amp;user2='.$USER->id, $unblockcontact);
49 message_unblock_contact($unblockcontact);
52 print_header('','','','','',false,'','',false,'');
53 echo '<table width="100%" cellpadding="0" cellspacing="0"><tr>';
54 echo '<td width="100">';
55 echo print_user_picture($user->id, SITEID, $user->picture, true, true, true, 'userwindow').'</td>';
56 echo '<td valign="middle" align="center">';
58 echo '<div class="name">'.fullname($user).'</div>';
60 //echo '<br /><font size="1">'; /// Print login status of this user
61 //if ($user->lastaccess) {
62 // if (time() - $user->lastaccess > $CFG->message_offline_time) {
63 // echo get_string('offline', 'message').': '.format_time(time() - $user->lastaccess);
64 // } else {
65 // echo get_string('lastaccess').': '.get_string('ago', 'message', format_time(time() - $user->lastaccess));
66 // }
67 //} else {
68 // echo get_string("lastaccess").":". get_string("never");
69 //}
70 //echo '</font>';
72 echo '<div class="commands">';
73 if ($contact = get_record('message_contacts', 'userid', $USER->id, 'contactid', $user->id)) {
74 if ($contact->blocked) {
75 message_contact_link($user->id, 'add', false, 'user.php?id='.$user->id, true);
76 message_contact_link($user->id, 'unblock', false, 'user.php?id='.$user->id, true);
77 } else {
78 message_contact_link($user->id, 'remove', false, 'user.php?id='.$user->id, true);
79 message_contact_link($user->id, 'block', false, 'user.php?id='.$user->id, true);
81 } else {
82 message_contact_link($user->id, 'add', false, 'user.php?id='.$user->id, true);
83 message_contact_link($user->id, 'block', false, 'user.php?id='.$user->id, true);
85 message_history_link($user->id, 0, false, '', '', 'both');
86 echo '</div>';
88 echo '</td></tr></table>';
90 echo '</div></div></body></html>'; // Close possible theme tables off