';
echo print_user_picture($user, SITEID, $user->picture, 48, true, true, 'userwindow');
echo '
'.$userfullname.'
';
echo '
';
if ($contact = get_record('message_contacts', 'userid', $USER->id, 'contactid', $user->id)) {
if ($contact->blocked) {
echo '- ';
message_contact_link($user->id, 'add', false, 'discussion.php?id='.$user->id.'&noframesjs='.$noframesjs.'&newonly='.$newonly.'&last='.$last, true);
echo '
- ';
message_contact_link($user->id, 'unblock', false, 'discussion.php?id='.$user->id.'&noframesjs='.$noframesjs.'&newonly='.$newonly.'&last='.$last, true);
echo '
';
} else {
echo '- ';
message_contact_link($user->id, 'remove', false, 'discussion.php?id='.$user->id.'&noframesjs='.$noframesjs.'&newonly='.$newonly.'&last='.$last, true);
echo '
- ';
message_contact_link($user->id, 'block', false, 'discussion.php?id='.$user->id.'&noframesjs='.$noframesjs.'&newonly='.$newonly.'&last='.$last, true);
echo '
';
}
} else {
echo '- ';
message_contact_link($user->id, 'add', false, 'discussion.php?id='.$user->id.'&noframesjs='.$noframesjs.'&newonly='.$newonly.'&last='.$last, true);
echo '
- ';
message_contact_link($user->id, 'block', false, 'discussion.php?id='.$user->id.'&noframesjs='.$noframesjs.'&newonly='.$newonly.'&last='.$last, true);
echo '
';
}
echo '- ';
message_history_link($user->id, 0, false, '', '', 'both');
echo '
';
echo '
';
echo '
';
echo '
';
echo '
'.get_string('messages', 'message').'
';
$allmessages = array();
$playbeep = false;
$options = new object();
$options->para = false;
$options->newlines = true;
if ($newonly) {
$lastsql = " AND timecreated > $last";
} else {
$lastsql = "";
}
if ($messages = get_records_select('message_read', "(useridto = '$USER->id' AND useridfrom = '$userid' AND timeread > '$start' $lastsql) OR (useridto = '$userid' AND useridfrom = '$USER->id' AND timeread > '$start' $lastsql)")) {
foreach ($messages as $message) {
$time = userdate($message->timecreated, get_string('strftimedatetimeshort'));
if ($message->useridfrom == $USER->id) {
$fullname = $mefullname;
} else {
$fullname = $userfullname;
}
$printmessage = format_text($message->message, $message->format, $options, 0);
$printmessage = '
'.$fullname.' '.
'['.$time.']: '.
''.$printmessage.'
';
$i=0;
$sortkey = $message->timecreated."$i"; // we need string bacause we would run out of int range
while (array_key_exists($sortkey, $allmessages)) {
$i++;
$sortkey = $message->timecreated."$i";
}
$allmessages[$sortkey] = $printmessage;
}
}
if ($messages = get_records_select('message', "useridto = '$userid' AND useridfrom = '$USER->id' $lastsql")) {
foreach ($messages as $message) {
$time = userdate($message->timecreated, get_string('strftimedatetimeshort'));
$printmessage = format_text($message->message, $message->format, $options, 0);
$printmessage = '
'.$mefullname.' '.
'['.$time.']: '.
''.$printmessage.'
';
$i=0;
$sortkey = $message->timecreated."$i"; // we need string bacause we would run out of int range
while (array_key_exists($sortkey, $allmessages)) {
$i++;
$sortkey = $message->timecreated."$i";
}
$allmessages[$sortkey] = $printmessage;
}
}
if ($messages = get_records_select('message', "useridto = '$USER->id' AND useridfrom = '$userid' $lastsql")) {
foreach ($messages as $message) {
$time = userdate($message->timecreated, get_string('strftimedatetimeshort'));
$printmessage = format_text($message->message, $message->format, $options, 0);
$printmessage = '
'.$userfullname.' '.
'['.$time.']: '.
''.$printmessage.'
';
$i=0;
$sortkey = $message->timecreated."$i"; // we need string bacause we would run out of int range
while (array_key_exists($sortkey, $allmessages)) {
$i++;
$sortkey = $message->timecreated."$i";
}
$allmessages[$sortkey] = $printmessage;
/// Move the entry to the other table
$messageid = $message->id;
unset($message->id);
$message->timeread = time();
$message = addslashes_object($message);
if (insert_record('message_read', $message)) {
delete_records('message', 'id', $messageid);
}
if ($message->timecreated < $start) {
$start = $message->timecreated; // move start back so that we see all current history
}
}
$playbeep = true;
}
krsort($allmessages);
if (empty($allmessages)) {
echo get_string('nomessagesfound', 'message');
} else {
echo '
';
foreach ($allmessages as $message) {
echo '- ';
echo $message;
echo '
';
}
echo '
';
if ($playbeep and get_user_preferences('message_beepnewmessage', 0)) {
echo '
';
}
}
echo '