Added access to discussion histories
This commit is contained in:
+13
-8
@@ -5,43 +5,48 @@ $string['ago'] = '$a ago';
|
||||
$string['allmine'] = 'All messages to me or from me';
|
||||
$string['allstudents'] = 'All messages between students in course';
|
||||
$string['allusers'] = 'All messages from all users';
|
||||
$string['beepnewmessage'] = 'Beep when a new message comes in';
|
||||
$string['blockcontact'] = 'Block contact';
|
||||
$string['blockedmessages'] = '$a message(s) to/from blocked users';
|
||||
$string['deletemessagesdays'] = 'Number of days before old messages are automatically deleted';
|
||||
$string['discussion'] = 'Discussion';
|
||||
$string['emailmessages'] = 'Email messages when I am offline';
|
||||
$string['emptysearchstring'] = 'You must search for something';
|
||||
$string['includeblockedusers'] = 'Include blocked users';
|
||||
$string['incomingcontacts'] = 'Incoming Contacts ($a)';
|
||||
$string['keywords'] = 'Keywords';
|
||||
$string['keywordssearchresults'] = 'Search results: $a messages found';
|
||||
$string['maxmessages'] = 'Maximum number of messages to show in the discussion history';
|
||||
$string['message'] = 'Message';
|
||||
$string['messagehistory'] = 'Message History';
|
||||
$string['messages'] = 'Messages';
|
||||
$string['messaging'] = 'Messaging';
|
||||
$string['mycontacts'] = 'My Contacts';
|
||||
$string['newsearch'] = 'New search';
|
||||
$string['nosearchresults'] = 'There were no results from your search';
|
||||
$string['nomessages'] = 'No messages waiting';
|
||||
$string['nomessagesfound'] = 'No messages were found';
|
||||
$string['offlinecontacts'] = 'Offline Contacts ($a)';
|
||||
$string['onlinecontacts'] = 'Online Contacts ($a)';
|
||||
$string['onlyfromme'] = 'Only messages from me';
|
||||
$string['onlymycourses'] = 'Only in my courses';
|
||||
$string['onlytome'] = 'Only messages to me';
|
||||
$string['pagerefreshes'] = 'This page refreshes automatically every $a seconds';
|
||||
$string['removecontact'] = 'Remove contact';
|
||||
$string['savemysettings'] = 'Save my settings';
|
||||
$string['searchforperson'] = 'Search for a person';
|
||||
$string['searchmessages'] = 'Search messages';
|
||||
$string['sendmessage'] = 'Send message';
|
||||
$string['sendmessageto'] = 'Send message to $a';
|
||||
$string['settingssaved'] = 'Your settings have been saved';
|
||||
$string['showmessagewindow'] = 'Automatically show Message window when I get new messages (your browser needs to be set so that it doesn\'t block popups on this site)';
|
||||
$string['strftimedaydatetime'] = '%%A, %%d %%B %%Y, %%I:%%M %%p';
|
||||
$string['timenosee'] = 'Minutes since I was last seen online';
|
||||
$string['timesent'] = 'Time Sent';
|
||||
$string['unblockcontact'] = 'Unblock contact';
|
||||
$string['unreadmessages'] = '$a unread messages';
|
||||
$string['userisblockingyou'] = 'This user has blocked you from sending messages to them';
|
||||
$string['userssearchresults'] = 'Search results: $a users found';
|
||||
|
||||
$string['savemysettings'] = 'Save my settings';
|
||||
$string['settingssaved'] = 'Your settings have been saved';
|
||||
$string['showmessagewindow'] = 'Automatically show Message window when I get new messages (your browser needs to be set so that it doesn\'t block popups on this site)';
|
||||
$string['beepnewmessage'] = 'Beep when a new message comes in';
|
||||
$string['maxmessages'] = 'Maximum number of messages to show in the discussion history';
|
||||
$string['deletemessagesdays'] = 'Number of days before old messages are automatically deleted';
|
||||
$string['emailmessages'] = 'Email messages when I am offline';
|
||||
$string['timenosee'] = 'Minutes since I was last seen online';
|
||||
|
||||
?>
|
||||
|
||||
+68
-7
@@ -1,17 +1,78 @@
|
||||
<?php // $Id$
|
||||
// For listing message histories
|
||||
// For listing message histories between any two users
|
||||
|
||||
require('../config.php');
|
||||
require('lib.php');
|
||||
|
||||
require_login();
|
||||
|
||||
/// Script parameters
|
||||
$userid = required_param('id', PARAM_INT);
|
||||
|
||||
/// Check the user we are talking to is valid
|
||||
if (! $user = get_record("user", "id", $userid)) {
|
||||
error("User ID was incorrect");
|
||||
$userid1 = required_param('user1', PARAM_INT);
|
||||
if (! $user1 = get_record("user", "id", $userid1)) { // Check it's correct
|
||||
error("User ID 1 was incorrect");
|
||||
}
|
||||
|
||||
print_heading('This script is not completed yet');
|
||||
if (isadmin()) { // Able to see any discussion
|
||||
$userid2 = optional_param('user2', $USER->id, PARAM_INT);
|
||||
if (! $user2 = get_record("user", "id", $userid2)) { // Check
|
||||
error("User ID 2 was incorrect");
|
||||
}
|
||||
} else {
|
||||
$userid2 = $USER->id; // Can only see messages involving yourself
|
||||
$user2 = $USER;
|
||||
}
|
||||
|
||||
/// Our two users are defined - let's set up the page
|
||||
|
||||
$THEME->body = $THEME->cellcontent;
|
||||
|
||||
print_header(get_string('messagehistory', 'message'));
|
||||
|
||||
/// Print out a heading including the users we are looking at
|
||||
|
||||
print_simple_box_start('center');
|
||||
echo '<table align="center" cellpadding="10"><tr>';
|
||||
echo '<td align="center">';
|
||||
echo print_user_picture($user1->id, SITEID, $user1->picture, 100, true, true, 'userwindow').'<br />';
|
||||
echo fullname($user1);
|
||||
echo '</td>';
|
||||
echo '<td align="center">';
|
||||
echo '<img src="'.$CFG->wwwroot.'/pix/t/left.gif">';
|
||||
echo '<img src="'.$CFG->wwwroot.'/pix/t/right.gif">';
|
||||
echo '</td>';
|
||||
echo '<td align="center">';
|
||||
echo print_user_picture($user2->id, SITEID, $user2->picture, 100, true, true, 'userwindow').'<br />';
|
||||
echo fullname($user2);
|
||||
echo '</td>';
|
||||
echo '</tr></table>';
|
||||
print_simple_box_end();
|
||||
|
||||
|
||||
/// Get all the messages and print them
|
||||
|
||||
if ($messages = message_get_history($user1, $user2)) {
|
||||
$current->day = '';
|
||||
$current->month = '';
|
||||
$current->year = '';
|
||||
$messagedate = get_string('strftimetime');
|
||||
$blockdate = get_string('strftimedaydate');
|
||||
foreach ($messages as $message) {
|
||||
$date = usergetdate($message->timecreated);
|
||||
if ($current->mday != $date['mday'] | $current->month != $date['month'] | $current->year != $date['year']) {
|
||||
$current->mday = $date['mday'];
|
||||
$current->month = $date['month'];
|
||||
$current->year = $date['year'];
|
||||
print_heading(userdate($message->timecreated, $blockdate), 'center', 4);
|
||||
}
|
||||
if ($message->useridfrom == $user1->id) {
|
||||
echo message_format_message($message, $user1, $messagedate);
|
||||
} else {
|
||||
echo message_format_message($message, $user2, $messagedate);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print_heading(get_string('nomessagesfound', 'message'));
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
+6
-1
@@ -31,7 +31,12 @@ if ($unblockcontact and confirm_sesskey()) {
|
||||
$tabprintfunction = 'message_print_'.$tab;
|
||||
|
||||
|
||||
print_header(get_string('messages', 'message').' - '.$SITE->fullname);
|
||||
if ($tab == 'contacts') {
|
||||
print_header(get_string('messages', 'message').' - '.$SITE->fullname, '', '', '',
|
||||
'<meta http-equiv="refresh" content="'. MESSAGE_CONTACTS_REFRESH .'; url=index.php" />');
|
||||
} else {
|
||||
print_header(get_string('messages', 'message').' - '.$SITE->fullname);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
+34
-10
@@ -4,6 +4,7 @@
|
||||
|
||||
define ('MESSAGE_SHORTLENGTH', 300);
|
||||
define ('MESSAGE_WINDOW', true);
|
||||
define ('MESSAGE_CONTACTS_REFRESH', 30);
|
||||
|
||||
|
||||
function message_print_contacts() {
|
||||
@@ -62,7 +63,7 @@ function message_print_contacts() {
|
||||
/// link to remove from contact list
|
||||
$strcontact .= message_contact_link($contact->id, 'remove', true);
|
||||
|
||||
echo '<tr><td class="message_pic">';
|
||||
echo '<tr><td class="message_pix">';
|
||||
print_user_picture($contact->id, SITEID, $contact->picture, 20, false, false);
|
||||
echo '</td>';
|
||||
echo '<td class="message_contact">';
|
||||
@@ -100,7 +101,7 @@ function message_print_contacts() {
|
||||
/// link to remove from contact list
|
||||
$strcontact .= message_contact_link($contact->id, 'remove', true);
|
||||
|
||||
echo '<tr><td class="message_pic">';
|
||||
echo '<tr><td class="message_pix">';
|
||||
print_user_picture($contact->id, SITEID, $contact->picture, 20, false, false);
|
||||
echo '</td>';
|
||||
echo '<td class="message_contact">';
|
||||
@@ -159,7 +160,7 @@ function message_print_contacts() {
|
||||
$strcontact .= message_contact_link($messageuser->useridfrom, 'add', true);
|
||||
$strblock = message_contact_link($messageuser->useridfrom, 'block', true);
|
||||
|
||||
echo '<tr><td class="message_pic">';
|
||||
echo '<tr><td class="message_pix">';
|
||||
print_user_picture($messageuser->useridfrom, SITEID, $messageuser->picture, 20, false, false);
|
||||
echo '</td>';
|
||||
echo '<td class="message_contact">';
|
||||
@@ -174,6 +175,8 @@ function message_print_contacts() {
|
||||
}
|
||||
|
||||
echo '</table>';
|
||||
|
||||
echo '<p align="center" class="message_small_note">'.get_string('pagerefreshes', 'message', MESSAGE_CONTACTS_REFRESH).'</p>';
|
||||
}
|
||||
|
||||
|
||||
@@ -344,7 +347,7 @@ function message_print_search_results($frm) {
|
||||
$strblock = message_contact_link($user->id, 'block', true);
|
||||
}
|
||||
|
||||
echo '<tr><td class="message_pic">';
|
||||
echo '<tr><td class="message_pix">';
|
||||
print_user_picture($user->id, SITEID, $user->picture, 20, false, false);
|
||||
echo '</td>';
|
||||
echo '<td class="message_contact">';
|
||||
@@ -404,8 +407,8 @@ function message_print_search_results($frm) {
|
||||
/// print table headings
|
||||
echo '<table class="message_users" cellpadding="5" border="1">';
|
||||
echo '<tr>';
|
||||
echo '<td align="center"><strong>'.get_string('to').'</strong></td>';
|
||||
echo '<td align="center"><strong>'.get_string('from').'</strong></td>';
|
||||
echo '<td align="center"><strong>'.get_string('to').'</strong></td>';
|
||||
echo '<td align="center"><strong>'.get_string('message', 'message').'</strong></td>';
|
||||
echo '<td align="center"><strong>'.get_string('timesent', 'message').'</strong></td>';
|
||||
echo "</tr>\n";
|
||||
@@ -452,13 +455,13 @@ function message_print_search_results($frm) {
|
||||
/// print out message row
|
||||
echo '<tr valign="top">';
|
||||
echo '<td class="message_contact">';
|
||||
message_print_user($userto, $tocontact, $toblocked);
|
||||
echo '</td>';
|
||||
echo '<td class="message_contact">';
|
||||
message_print_user($userfrom, $fromcontact, $fromblocked);
|
||||
echo '</td>';
|
||||
echo '<td>'.message_shorten_message($message->message, 20).'</td>';
|
||||
echo '<td>'.userdate($message->timecreated, get_string('strftimedatetime')).'</td>';
|
||||
echo '<td class="message_contact">';
|
||||
message_print_user($userto, $tocontact, $toblocked);
|
||||
echo '</td>';
|
||||
echo '<td class="message_summary">'.message_shorten_message($message->message, 20).'</td>';
|
||||
echo '<td class="message_date">'.userdate($message->timecreated, get_string('strftimedatetime')).'</td>';
|
||||
echo "</tr>\n";
|
||||
}
|
||||
|
||||
@@ -777,6 +780,27 @@ function message_shorten_message($message, $minlength=0) {
|
||||
return substr($message, 0, $truncate);
|
||||
}
|
||||
|
||||
function message_get_history($user1, $user2) {
|
||||
$messages = get_records_select('message_read', "(useridto = '$user1->id' AND useridfrom = '$user2->id') OR
|
||||
(useridto = '$user2->id' AND useridfrom = '$user1->id')",
|
||||
'timecreated');
|
||||
if ($messages_new = get_records_select('message', "(useridto = '$user1->id' AND useridfrom = '$user2->id') OR
|
||||
(useridto = '$user2->id' AND useridfrom = '$user1->id')",
|
||||
'timecreated')) {
|
||||
foreach ($messages_new as $message) {
|
||||
$messages[] = $message;
|
||||
}
|
||||
}
|
||||
return $messages;
|
||||
}
|
||||
|
||||
function message_format_message(&$message, &$user, $format='') {
|
||||
if (empty($format)) {
|
||||
$format = get_string('strftimemessage', 'chat');
|
||||
}
|
||||
$time = userdate($message->timecreated, $format);
|
||||
return '<p><font size="-1"><b>'.addslashes($user->firstname).'</b> ['.$time.']: '.$message->message.'</font></p>';
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
+6
-2
@@ -41,7 +41,7 @@
|
||||
case 'info': /// Print the top frame with information and links
|
||||
print_header();
|
||||
echo '<table width="100%" cellpadding="0" cellspacing="0"><tr>';
|
||||
echo '<td>'.print_user_picture($user->id, SITEID, $user->picture, true, true, false).'</td>';
|
||||
echo '<td>'.print_user_picture($user->id, SITEID, $user->picture, true, true, true, 'userwindow').'</td>';
|
||||
echo '<td>';
|
||||
echo fullname($user);
|
||||
echo '<br /><font size="1">';
|
||||
@@ -52,6 +52,10 @@
|
||||
}
|
||||
echo get_string("lastaccess").":", $datestring;
|
||||
echo '</font>';
|
||||
echo '<br /><font size="2">';
|
||||
echo '<a target="message_history'.$user->id.'" '.
|
||||
link_to_popup_window("/message/history.php?user1=$user->id", "message_history_$user->id",
|
||||
get_string('messagehistory', 'message'), 500, 500, '');
|
||||
echo '</td>';
|
||||
echo '</tr></table>';
|
||||
echo '</table></table></body>'; // Close possible theme tables off
|
||||
@@ -149,7 +153,7 @@
|
||||
$message = str_replace("\n", ' ', $message);
|
||||
|
||||
/// Then write it to our own screen immediately
|
||||
$time = userdate(time(), get_string('strftimemessage', 'chat'));
|
||||
$time = userdate(time(), get_string('strftimedaytime'));
|
||||
$message = '<p><font size="-1"><b>'.addslashes($USER->firstname).' ['.$time.']</b>: '.$message.'</font></p>';
|
||||
|
||||
$script = "<script>\n";
|
||||
|
||||
Reference in New Issue
Block a user