mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
message MDL-24970 removed no longer used messaging code
This commit is contained in:
parent
7ee2741bb8
commit
a51a2f5c54
@ -16,7 +16,8 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Part of the message section of Moodle
|
||||
* This file was replaced by index.php in Moodle 2.0
|
||||
* It now simply redirects to index.php
|
||||
*
|
||||
* @author Luis Rodrigues and Martin Dougiamas
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
@ -26,351 +27,13 @@
|
||||
require('../config.php');
|
||||
require('lib.php');
|
||||
|
||||
require_login();
|
||||
$PAGE->set_context(get_system_context());
|
||||
|
||||
if (isguestuser()) {
|
||||
redirect($CFG->wwwroot);
|
||||
}
|
||||
|
||||
if (empty($CFG->messaging)) {
|
||||
print_error('disabled', 'message');
|
||||
}
|
||||
|
||||
/// Script parameters
|
||||
$userid = required_param('id', PARAM_INT);
|
||||
$noframesjs = optional_param('noframesjs', 0, PARAM_BOOL);
|
||||
|
||||
$url = new moodle_url('/message/discussion.php', array('id'=>$userid));
|
||||
if ($noframesjs !== 0) {
|
||||
$url->param('noframesjs', $noframesjs);
|
||||
$params = array('id'=>$userid);
|
||||
if (!empty($noframesjs)) {
|
||||
$params['noframesjs'] = $noframesjs;
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
/// Check the user we are talking to is valid
|
||||
if (! $user = $DB->get_record('user', array('id'=>$userid))) {
|
||||
print_error('invaliduserid');
|
||||
}
|
||||
|
||||
if ($user->deleted) {
|
||||
$PAGE->set_pagelayout('popup');
|
||||
$PAGE->set_title(get_string('discussion', 'message').': '.fullname($user));
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('userdeleted'), 1);
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
|
||||
/// Check if frame&jsless mode selected
|
||||
if (!get_user_preferences('message_noframesjs', 0) and !$noframesjs) {
|
||||
|
||||
/// Print frameset to contain all the various panes
|
||||
@header('Content-Type: text/html; charset=utf-8');
|
||||
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<title><?php echo get_string('discussion', 'message').': '.fullname($user) ?></title>
|
||||
<link rel="shortcut icon" href="<?php echo $CFG->wwwroot.'/theme/'.$PAGE->theme->name; ?>/pix/favicon.ico" />
|
||||
</head>
|
||||
<frameset rows="110,*,0,220">
|
||||
<noframes><body><?php
|
||||
echo '<a href="discussion.php?id='.$userid.'&noframesjs=1">'.get_string('noframesjs', 'message').'</a>';
|
||||
?></body></noframes>
|
||||
|
||||
<frame src="user.php?id=<?php p($user->id)?>&frame=user" name="user"
|
||||
scrolling="no" marginwidth="0" marginheight="0" frameborder="0" />
|
||||
<frame src="messages.php" name="messages"
|
||||
scrolling="yes" marginwidth="10" marginheight="10" frameborder="0" />
|
||||
<frame src="refresh.php?id=<?php p($user->id)?>&name=<?php echo urlencode(fullname($user)) ?>" name="refresh"
|
||||
scrolling="no" marginwidth="0" marginheight="0" frameborder="0" />
|
||||
|
||||
<frame src="send.php?id=<?php p($user->id)?>" name="send"
|
||||
scrolling="no" marginwidth="2" marginheight="2" frameborder="0" />
|
||||
</frameset>
|
||||
</html>
|
||||
|
||||
<?php
|
||||
die;
|
||||
}
|
||||
|
||||
/// user wants simple frame&js-less mode
|
||||
|
||||
$start = optional_param('start', time(), PARAM_INT);
|
||||
$message = optional_param('message', '', PARAM_CLEAN); //TODO: this is wrong we must use text_format() instead
|
||||
$format = optional_param('format', FORMAT_MOODLE, PARAM_INT);
|
||||
$refresh = optional_param('refresh', '', PARAM_RAW);
|
||||
$last = optional_param('last', 0, PARAM_INT);
|
||||
$newonly = optional_param('newonly', 0, PARAM_BOOL);
|
||||
|
||||
$addcontact = optional_param('addcontact', 0, PARAM_INT); // adding a contact
|
||||
$removecontact = optional_param('removecontact', 0, PARAM_INT); // removing a contact
|
||||
$blockcontact = optional_param('blockcontact', 0, PARAM_INT); // blocking a contact
|
||||
$unblockcontact = optional_param('unblockcontact', 0, PARAM_INT); // unblocking a contact
|
||||
|
||||
if ($addcontact and confirm_sesskey()) {
|
||||
add_to_log(SITEID, 'message', 'add contact',
|
||||
'discussion.php?user1='.$addcontact.'&user2='.$USER->id, $addcontact);
|
||||
message_add_contact($addcontact);
|
||||
}
|
||||
if ($removecontact and confirm_sesskey()) {
|
||||
add_to_log(SITEID, 'message', 'remove contact',
|
||||
'discussion.php?user1='.$removecontact.'&user2='.$USER->id, $removecontact);
|
||||
message_remove_contact($removecontact);
|
||||
}
|
||||
if ($blockcontact and confirm_sesskey()) {
|
||||
add_to_log(SITEID, 'message', 'block contact',
|
||||
'discussion.php?user1='.$blockcontact.'&user2='.$USER->id, $blockcontact);
|
||||
message_block_contact($blockcontact);
|
||||
}
|
||||
if ($unblockcontact and confirm_sesskey()) {
|
||||
add_to_log(SITEID, 'message', 'unblock contact',
|
||||
'history.php?user1='.$unblockcontact.'&user2='.$USER->id, $unblockcontact);
|
||||
message_unblock_contact($unblockcontact);
|
||||
}
|
||||
|
||||
/// Check that the user is not blocking us!!
|
||||
if ($contact = $DB->get_record('message_contacts', array('userid'=>$user->id, 'contactid'=>$USER->id))) {
|
||||
if ($contact->blocked and !has_capability('moodle/site:readallmessages', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
echo $OUTPUT->heading(get_string('userisblockingyou', 'message'));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if (get_user_preferences('message_blocknoncontacts', 0, $user->id)) { // User is blocking non-contacts
|
||||
if (empty($contact)) { // We are not a contact!
|
||||
echo $OUTPUT->heading(get_string('userisblockingyounoncontact', 'message'));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$refreshedmessage = '';
|
||||
|
||||
if (!empty($refresh) and data_submitted()) {
|
||||
$refreshedmessage = $message;
|
||||
|
||||
} else if (empty($refresh) and data_submitted() and confirm_sesskey()) {
|
||||
if ($message!='') {
|
||||
message_post_message($USER, $user, $message, $format, 'direct');
|
||||
}
|
||||
redirect('discussion.php?id='.$userid.'&start='.$start.'&noframesjs='.$noframesjs.'&newonly='.$newonly.'&last='.$last);
|
||||
}
|
||||
|
||||
|
||||
$userfullname = fullname($user);
|
||||
$mefullname = fullname($USER);
|
||||
|
||||
$PAGE->set_pagelayout('popup');
|
||||
$PAGE->set_title(get_string('discussion', 'message').': '.fullname($user));
|
||||
echo $OUTPUT->header();
|
||||
|
||||
echo '<div class="message-discussion-noframes">';
|
||||
echo '<div id="userinfo">';
|
||||
echo $OUTPUT->user_picture($user, array('size'=>48, 'courseid'=>SITEID));
|
||||
echo '<div class="name"><h1>'.$userfullname.'</h1></div>';
|
||||
echo '<div class="commands"><ul>';
|
||||
if ($contact = $DB->get_record('message_contacts', array('userid'=>$USER->id, 'contactid'=>$user->id))) {
|
||||
if ($contact->blocked) {
|
||||
echo '<li>';
|
||||
message_contact_link($user->id, 'add', false, 'discussion.php?id='.$user->id.'&noframesjs='.$noframesjs.'&newonly='.$newonly.'&last='.$last, true);
|
||||
echo '</li><li>';
|
||||
message_contact_link($user->id, 'unblock', false, 'discussion.php?id='.$user->id.'&noframesjs='.$noframesjs.'&newonly='.$newonly.'&last='.$last, true);
|
||||
echo '</li>';
|
||||
} else {
|
||||
echo '<li>';
|
||||
message_contact_link($user->id, 'remove', false, 'discussion.php?id='.$user->id.'&noframesjs='.$noframesjs.'&newonly='.$newonly.'&last='.$last, true);
|
||||
echo '</li><li>';
|
||||
message_contact_link($user->id, 'block', false, 'discussion.php?id='.$user->id.'&noframesjs='.$noframesjs.'&newonly='.$newonly.'&last='.$last, true);
|
||||
echo '</li>';
|
||||
}
|
||||
} else {
|
||||
echo '<li>';
|
||||
message_contact_link($user->id, 'add', false, 'discussion.php?id='.$user->id.'&noframesjs='.$noframesjs.'&newonly='.$newonly.'&last='.$last, true);
|
||||
echo '</li><li>';
|
||||
message_contact_link($user->id, 'block', false, 'discussion.php?id='.$user->id.'&noframesjs='.$noframesjs.'&newonly='.$newonly.'&last='.$last, true);
|
||||
echo '</li>';
|
||||
}
|
||||
echo '<li>';
|
||||
message_history_link($user->id, 0, false, '', '', 'both');
|
||||
echo '</li>';
|
||||
echo '</ul>';
|
||||
echo '</div>';
|
||||
echo '</div>'; // class="userinfo"
|
||||
|
||||
echo '<div id="send">';
|
||||
echo '<form id="editing" method="post" action="discussion.php">';
|
||||
|
||||
$usehtmleditor = (can_use_html_editor() && get_user_preferences('message_usehtmleditor', 0));
|
||||
echo '<h1><label for="edit-message">'.get_string('sendmessage', 'message').'</label></h1>';
|
||||
echo '<div>';
|
||||
if ($usehtmleditor) {
|
||||
print_textarea(true, 8, 34, 100, 100, 'message', $refreshedmessage);
|
||||
echo '<input type="hidden" name="format" value="'.FORMAT_HTML.'" />';
|
||||
} else {
|
||||
print_textarea(false, 8, 50, 0, 0, 'message', $refreshedmessage);
|
||||
echo '<input type="hidden" name="format" value="'.FORMAT_MOODLE.'" />';
|
||||
}
|
||||
echo '</div><div>';
|
||||
echo '<input type="hidden" name="id" value="'.$user->id.'" />';
|
||||
echo '<input type="hidden" name="start" value="'.$start.'" />';
|
||||
echo '<input type="hidden" name="noframesjs" value="'.$noframesjs.'" />';
|
||||
echo '<input type="hidden" name="last" value="'.time().'" />';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<input type="submit" value="'.get_string('sendmessage', 'message').'" /> ';
|
||||
echo '<input type="submit" name="refresh" value="'.get_string('refresh').'" />';
|
||||
echo '<input type="checkbox" name="newonly" id="newonly" '.($newonly?'checked="checked" ':'').'/><label for="newonly">'.get_string('newonlymsg', 'message').'</label>';
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div id="messages">';
|
||||
echo '<h1>'.get_string('messages', 'message').'</h1>';
|
||||
|
||||
$allmessages = array();
|
||||
$playbeep = false;
|
||||
$options = new stdClass();
|
||||
$options->para = false;
|
||||
$options->newlines = true;
|
||||
|
||||
$params = array('uid1'=>$USER->id ,'userid1'=>$userid, 'start1'=>$start, 'uid2'=>$USER->id ,'userid2'=>$userid, 'start2'=>$start);
|
||||
if ($newonly) {
|
||||
$lastsql1 = " AND timecreated > :last1";
|
||||
$lastsql2 = " AND timecreated > :last2";
|
||||
$params['last1'] = $last;
|
||||
$params['last2'] = $last;
|
||||
} else {
|
||||
$lastsql1 = "";
|
||||
$lastsql2 = "";
|
||||
}
|
||||
|
||||
//LR: change here the way to
|
||||
if ($messages = $DB->get_records_select('message_read', "(useridto = :uid1 AND useridfrom = :userid1 AND timeread > :start1 $lastsql1) OR (useridto = :userid2 AND useridfrom = :uid2 AND timeread > :start2 $lastsql2)", $params)) {
|
||||
foreach ($messages as $message) {
|
||||
$time = userdate($message->timecreated, get_string('strftimedatetimeshort'));
|
||||
|
||||
if ($message->useridfrom == $USER->id) {
|
||||
$fullname = $mefullname;
|
||||
} else {
|
||||
$fullname = $userfullname;
|
||||
}
|
||||
|
||||
if ($message->fullmessageformat == FORMAT_HTML){
|
||||
$printmessage = format_text($message->fullmessagehtml, $message->fullmessageformat, $options, 0);
|
||||
} else{
|
||||
$printmessage = format_text($message->fullmessage, $message->fullmessageformat, $options, 0);
|
||||
}
|
||||
$printmessage = '<div class="message other"><span class="author">'.$fullname.'</span> '.
|
||||
'<span class="time">['.$time.']</span>: '.
|
||||
'<span class="content">'.$printmessage.'</span></div>';
|
||||
$i=0;
|
||||
$sortkey = $message->timecreated."$i"; // we need string because we would run out of int range
|
||||
while (array_key_exists($sortkey, $allmessages)) {
|
||||
$i++;
|
||||
$sortkey = $message->timecreated."$i";
|
||||
}
|
||||
$allmessages[$sortkey] = $printmessage;
|
||||
}
|
||||
}
|
||||
|
||||
if ($messages = $DB->get_records_select('message', "useridto = :userid1 AND useridfrom = :uid1 $lastsql1", $params)) {
|
||||
foreach ($messages as $message) {
|
||||
$time = userdate($message->timecreated, get_string('strftimedatetimeshort'));
|
||||
|
||||
if ($message->fullmessageformat == FORMAT_HTML){
|
||||
$printmessage = format_text($message->fullmessagehtml, $message->fullmessageformat, $options, 0);
|
||||
} else{
|
||||
$printmessage = format_text($message->fullmessage, $message->fullmessageformat, $options, 0);
|
||||
}
|
||||
$printmessage = '<div class="message other"><span class="author">'.$mefullname.'</span> '.
|
||||
'<span class="time">['.$time.']</span>: '.
|
||||
'<span class="content">'.$printmessage.'</span></div>';
|
||||
$i=0;
|
||||
$sortkey = $message->timecreated."$i"; // we need string because we would run out of int range
|
||||
while (array_key_exists($sortkey, $allmessages)) {
|
||||
$i++;
|
||||
$sortkey = $message->timecreated."$i";
|
||||
}
|
||||
$allmessages[$sortkey] = $printmessage;
|
||||
}
|
||||
}
|
||||
/*Get still to be read message, use message/lib.php function*/
|
||||
$messages = message_get_popup_messages($USER->id, $userid);
|
||||
if ($messages) {
|
||||
foreach ($messages as $message) {
|
||||
$time = userdate($message->timecreated, get_string('strftimedatetimeshort'));
|
||||
|
||||
if ($message->fullmessageformat == FORMAT_HTML){
|
||||
$printmessage = format_text($message->fullmessagehtml, $message->fullmessageformat, $options, 0);
|
||||
} else{
|
||||
$printmessage = format_text($message->fullmessage, $message->fullmessageformat, $options, 0);
|
||||
}
|
||||
$printmessage = '<div class="message other"><span class="author">'.$userfullname.'</span> '.
|
||||
'<span class="time">['.$time.']</span>: '.
|
||||
'<span class="content">'.$printmessage.'</span></div>';
|
||||
$i=0;
|
||||
$sortkey = $message->timecreated."$i"; // we need string because we would run out of int range
|
||||
while (array_key_exists($sortkey, $allmessages)) {
|
||||
$i++;
|
||||
$sortkey = $message->timecreated."$i";
|
||||
}
|
||||
$allmessages[$sortkey] = $printmessage;
|
||||
|
||||
if ($message->timecreated < $start) {
|
||||
$start = $message->timecreated; // move start back so that we see all current history
|
||||
}
|
||||
}
|
||||
$playbeep = true;
|
||||
}
|
||||
/* old code, to be deleted
|
||||
if ($messages = $DB->get_records_select('message', "useridto = :uid2 AND useridfrom = userid2 $lastsql2", $params)) {
|
||||
foreach ($messages as $message) {
|
||||
$time = userdate($message->timecreated, get_string('strftimedatetimeshort'));
|
||||
|
||||
$printmessage = format_text($message->message, $message->format, $options, 0);
|
||||
$printmessage = '<div class="message other"><span class="author">'.$userfullname.'</span> '.
|
||||
'<span class="time">['.$time.']</span>: '.
|
||||
'<span class="content">'.$printmessage.'</span></div>';
|
||||
$i=0;
|
||||
$sortkey = $message->timecreated."$i"; // we need string because 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();
|
||||
$DB->insert_record('message_read', $message);
|
||||
$DB->delete_records('message', array('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 '<ul class="messagelist">';
|
||||
foreach ($allmessages as $message) {
|
||||
echo '<li>';
|
||||
echo $message;
|
||||
echo '</li>';
|
||||
}
|
||||
echo '</ul>';
|
||||
if ($playbeep and get_user_preferences('message_beepnewmessage', 0)) {
|
||||
echo '<embed src="bell.wav" autostart="true" hidden="true" name="bell" />';
|
||||
}
|
||||
}
|
||||
|
||||
echo '</div></div>';
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
?>
|
||||
$url = new moodle_url('/message/index.php', $params);
|
||||
redirect($url);
|
||||
?>
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* @copyright Luis Rodrigues
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @package message
|
||||
*/
|
||||
|
||||
require('../config.php');
|
||||
|
||||
@header('Content-Type: text/html; charset=utf-8');
|
||||
|
||||
$PAGE->set_pagelayout('popup');
|
||||
$PAGE->set_url('/message/messages.php');
|
||||
$PAGE->set_title(get_string('messages', 'message').' - '.format_string($SITE->fullname));
|
||||
echo $OUTPUT->header();
|
||||
echo "<div id='messages'></div>";
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -4,23 +4,6 @@ M.core_message.init_focus = function(Y, eid) {
|
||||
document.getElementById(eid).focus();
|
||||
};
|
||||
|
||||
M.core_message.init_refresh_parent_frame = function(Y, msgcount, msg) {
|
||||
var add_message = function (messagestr) {
|
||||
var messageblock = parent.messages.document.getElementById('messages');
|
||||
var message = document.createElement('div');
|
||||
message.innerHTML = messagestr;
|
||||
messageblock.appendChild(message);
|
||||
};
|
||||
|
||||
if (msgcount>0) {
|
||||
for (var i=0; i < msgcount; i++) {
|
||||
add_message(msg[i])
|
||||
}
|
||||
}
|
||||
parent.messages.scroll(1,5000000);
|
||||
parent.send.focus();
|
||||
};
|
||||
|
||||
M.core_message.init_refresh_page = function(Y, delay, url) {
|
||||
var delay_callback = function() {
|
||||
document.location.replace(url);
|
||||
@ -28,15 +11,6 @@ M.core_message.init_refresh_page = function(Y, delay, url) {
|
||||
setTimeout(delay_callback, delay);
|
||||
};
|
||||
|
||||
/*M.core_message.init_search_page = function(Y, defaultsearchterm) {
|
||||
this.Y = Y;
|
||||
this.defaultsearchterm = defaultsearchterm;
|
||||
|
||||
var combinedsearchbox = this.Y.one('#combinedsearch');
|
||||
combinedsearchbox.on('focus', this.combinedsearchgotfocus, this);
|
||||
};*/
|
||||
|
||||
|
||||
M.core_message.combinedsearchgotfocus = function(e) {
|
||||
if (e.target.get('value')==this.defaultsearchterm) {
|
||||
e.target.select();
|
||||
|
@ -1,91 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* @author Luis Rodrigues and Martin Dougiamas
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @package message
|
||||
*/
|
||||
|
||||
require('../config.php');
|
||||
require('lib.php');
|
||||
|
||||
define('MESSAGE_DEFAULT_REFRESH', 5);
|
||||
|
||||
require_login();
|
||||
|
||||
if (isguestuser()) {
|
||||
redirect($CFG->wwwroot);
|
||||
}
|
||||
|
||||
if (empty($CFG->messaging)) {
|
||||
print_error('disabled', 'message');
|
||||
}
|
||||
|
||||
$PAGE->set_pagelayout('popup');
|
||||
$PAGE->set_title(get_string('messages', 'message').' - '.format_string($SITE->fullname));
|
||||
$PAGE->set_url('/message/refresh.php');
|
||||
header('Expires: Sun, 28 Dec 1997 09:32:45 GMT');
|
||||
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
|
||||
header('Cache-Control: no-cache, must-revalidate');
|
||||
header('Pragma: no-cache');
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
|
||||
/// Script parameters
|
||||
$userid = required_param('id', PARAM_INT);
|
||||
$userfullname = strip_tags(required_param('name', PARAM_RAW));
|
||||
$wait = optional_param('wait', MESSAGE_DEFAULT_REFRESH, PARAM_INT);
|
||||
|
||||
/*Get still to be read message, use message/lib.php function*/
|
||||
$messages = message_get_popup_messages($USER->id, $userid);
|
||||
$jsmessages = Array();
|
||||
if ($messages ) {
|
||||
foreach ($messages as $message) {
|
||||
$time = userdate($message->timecreated, get_string('strftimedatetimeshort'));
|
||||
|
||||
$options = new stdClass();
|
||||
$options->para = false;
|
||||
$options->newlines = true;
|
||||
$printmessage = format_text($message->fullmessage, $message->fullmessageformat, $options, 0);
|
||||
$printmessage = '<div class="message other"><span class="author">'.s($userfullname).'</span> '.
|
||||
'<span class="time">['.$time.']</span>: '.
|
||||
'<span class="content">'.$printmessage.'</span></div>';
|
||||
$jsmessages[count($jsmessages)] = $printmessage;
|
||||
}
|
||||
if (get_user_preferences('message_beepnewmessage', 0)) {
|
||||
$playbeep = true;
|
||||
}
|
||||
$wait = MESSAGE_DEFAULT_REFRESH;
|
||||
} else {
|
||||
if ($wait < 300) { // Until the wait is five minutes
|
||||
$wait = ceil(1.2 * (float)$wait); // Exponential growth
|
||||
}
|
||||
}
|
||||
|
||||
$PAGE->requires->js_init_call('M.core_message.init_refresh_parent_frame', array(count($jsmessages), $jsmessages));
|
||||
|
||||
echo $OUTPUT->header();
|
||||
if (!empty($playbeep)) {
|
||||
echo '<embed src="bell.wav" autostart="true" hidden="true" name="bell" />';
|
||||
$PAGE->requires->js_function_call('parent.send.focus');
|
||||
}
|
||||
|
||||
// Javascript for Mozilla to cope with the redirect bug from editor being on in this page
|
||||
$PAGE->requires->js_init_call('M.core_message.init_refresh_page', array(($wait*1000), "refresh.php?id=$userid&name=".urlencode($userfullname)."&wait=$wait"));
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
124
message/send.php
124
message/send.php
@ -1,124 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* @author Luis Rodrigues and Martin Dougiamas
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @package message
|
||||
*/
|
||||
|
||||
require('../config.php');
|
||||
require('lib.php');
|
||||
require('send_form.php');
|
||||
|
||||
require_login();
|
||||
|
||||
if (isguestuser()) {
|
||||
redirect($CFG->wwwroot);
|
||||
}
|
||||
|
||||
if (empty($CFG->messaging)) {
|
||||
print_error('disabled', 'message');
|
||||
}
|
||||
|
||||
if (has_capability('moodle/site:sendmessage', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
|
||||
$PAGE->set_pagelayout('popup');
|
||||
$PAGE->set_title('send');
|
||||
|
||||
/// Script parameters
|
||||
$userid = required_param('id', PARAM_INT);
|
||||
|
||||
$PAGE->set_url('/message/send.php', array('id'=>$userid));
|
||||
|
||||
/// Check the user we are talking to is valid
|
||||
if (! $user = $DB->get_record('user', array('id'=>$userid))) {
|
||||
print_error('invaliduserid');
|
||||
}
|
||||
|
||||
/// Check that the user is not blocking us!!
|
||||
if ($contact = $DB->get_record('message_contacts', array('userid'=>$user->id, 'contactid'=>$USER->id))) {
|
||||
if ($contact->blocked and !has_capability('moodle/site:readallmessages', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('userisblockingyou', 'message'), 1);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$userpreferences = get_user_preferences(NULL, NULL, $user->id);
|
||||
|
||||
if (!empty($userpreferences['message_blocknoncontacts'])) { // User is blocking non-contacts
|
||||
if (empty($contact)) { // We are not a contact!
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('userisblockingyounoncontact', 'message'), 1);
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$mform = new send_form();
|
||||
$defaultmessage = new stdClass;
|
||||
$defaultmessage->id = $userid;
|
||||
$defaultmessage->message = '';
|
||||
if (can_use_html_editor() && get_user_preferences('message_usehtmleditor', 0)) {
|
||||
$defaultmessage->messageformat = FORMAT_HTML;
|
||||
} else {
|
||||
$defaultmessage->messageformat = FORMAT_MOODLE;
|
||||
}
|
||||
$mform->set_data($defaultmessage);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
if ($data = $mform->get_data()) { /// Current user has just sent a message
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('invalidsesskey');
|
||||
}
|
||||
|
||||
/// Save it to the database...
|
||||
$messageid = message_post_message($USER, $user, $data->message, $data->messageformat, 'direct');
|
||||
|
||||
/// Format the message as HTML
|
||||
$options = new stdClass;
|
||||
$options->para = false;
|
||||
$options->newlines = true;
|
||||
$message = format_text($data->message, $data->messageformat, $options);
|
||||
|
||||
$time = userdate(time(), get_string('strftimedatetimeshort'));
|
||||
$message = '<div class="message me"><span class="author">'.fullname($USER).'</span> '.
|
||||
'<span class="time">['.$time.']</span>: '.
|
||||
'<span class="content">'.$message.'</span></div>';
|
||||
//$PAGE->requires->js_function_call('parent.messages.document.write', Array($message));
|
||||
$PAGE->requires->js_function_call('parent.refresh.add_message', Array($message));
|
||||
$PAGE->requires->js_function_call('parent.messages.scroll', Array(1,5000000));
|
||||
|
||||
add_to_log(SITEID, 'message', 'write', 'history.php?user1='.$user->id.'&user2='.$USER->id.'#m'.$messageid, $user->id);
|
||||
echo $OUTPUT->notification(get_string('mailsent', 'message'), 'notifysuccess');
|
||||
$mform->reset_message();
|
||||
}
|
||||
|
||||
$mform->display();
|
||||
/* TODO: frames are a nono, this has to be redesigned
|
||||
echo $OUTPUT->box_start('noframesjslink');
|
||||
$aurl = new moodle_url('/message/discussion.php', array('id'=>$userid, 'noframesjs'=>1));
|
||||
echo $OUTPUT->action_link($aurl, get_string('noframesjs', 'message'), );
|
||||
echo $OUTPUT->box_end();
|
||||
*/
|
||||
|
||||
$PAGE->requires->js_init_call('M.core_message.init_focus', array('id_message_editor'));
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
}
|
117
message/user.php
117
message/user.php
@ -1,117 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* @author Luis Rodrigues and Martin Dougiamas
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @package message
|
||||
*/
|
||||
|
||||
require('../config.php');
|
||||
require('lib.php');
|
||||
|
||||
require_login();
|
||||
|
||||
if (isguestuser()) {
|
||||
redirect($CFG->wwwroot);
|
||||
}
|
||||
|
||||
if (empty($CFG->messaging)) {
|
||||
print_error('disabled', 'message');
|
||||
}
|
||||
|
||||
/// Script parameters
|
||||
$userid = required_param('id', PARAM_INT);
|
||||
|
||||
$addcontact = optional_param('addcontact', 0, PARAM_INT); // adding a contact
|
||||
$removecontact = optional_param('removecontact', 0, PARAM_INT); // removing a contact
|
||||
$blockcontact = optional_param('blockcontact', 0, PARAM_INT); // blocking a contact
|
||||
$unblockcontact = optional_param('unblockcontact', 0, PARAM_INT); // unblocking a contact
|
||||
|
||||
$url = new moodle_url('/message/user.php', array('id'=>$userid));
|
||||
if ($addcontact !== 0) {
|
||||
$url->param('addcontact', $addcontact);
|
||||
}
|
||||
if ($removecontact !== 0) {
|
||||
$url->param('removecontact', $removecontact);
|
||||
}
|
||||
if ($blockcontact !== 0) {
|
||||
$url->param('blockcontact', $blockcontact);
|
||||
}
|
||||
if ($unblockcontact !== 0) {
|
||||
$url->param('unblockcontact', $unblockcontact);
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
/// Check the user we are talking to is valid
|
||||
if (! $user = $DB->get_record('user', array('id'=>$userid))) {
|
||||
print_error('invaliduserid');
|
||||
}
|
||||
|
||||
/// Possibly change some contacts if requested
|
||||
|
||||
if ($addcontact and confirm_sesskey()) {
|
||||
add_to_log(SITEID, 'message', 'add contact',
|
||||
'history.php?user1='.$addcontact.'&user2='.$USER->id, $addcontact);
|
||||
message_add_contact($addcontact);
|
||||
}
|
||||
if ($removecontact and confirm_sesskey()) {
|
||||
add_to_log(SITEID, 'message', 'remove contact',
|
||||
'history.php?user1='.$removecontact.'&user2='.$USER->id, $removecontact);
|
||||
message_remove_contact($removecontact);
|
||||
}
|
||||
if ($blockcontact and confirm_sesskey()) {
|
||||
add_to_log(SITEID, 'message', 'block contact',
|
||||
'history.php?user1='.$blockcontact.'&user2='.$USER->id, $blockcontact);
|
||||
message_block_contact($blockcontact);
|
||||
}
|
||||
if ($unblockcontact and confirm_sesskey()) {
|
||||
add_to_log(SITEID, 'message', 'unblock contact',
|
||||
'history.php?user1='.$unblockcontact.'&user2='.$USER->id, $unblockcontact);
|
||||
message_unblock_contact($unblockcontact);
|
||||
}
|
||||
|
||||
//$PAGE->set_title('Message History');
|
||||
$PAGE->set_pagelayout('popup');
|
||||
echo $OUTPUT->header();
|
||||
echo '<table width="100%" cellpadding="0" cellspacing="0"><tr>';
|
||||
echo '<td width="100">';
|
||||
echo $OUTPUT->user_picture($user, array('size'=>48, 'courseid'=>SITEID)) .'</td>';
|
||||
echo '<td valign="middle" align="center">';
|
||||
|
||||
echo '<div class="name">'.fullname($user).'</div>';
|
||||
|
||||
echo '<div class="commands">';
|
||||
if ($contact = $DB->get_record('message_contacts', array('userid'=>$USER->id, 'contactid'=>$user->id))) {
|
||||
if ($contact->blocked) {
|
||||
message_contact_link($user->id, 'add', false, 'user.php?id='.$user->id, true);
|
||||
message_contact_link($user->id, 'unblock', false, 'user.php?id='.$user->id, true);
|
||||
} else {
|
||||
message_contact_link($user->id, 'remove', false, 'user.php?id='.$user->id, true);
|
||||
message_contact_link($user->id, 'block', false, 'user.php?id='.$user->id, true);
|
||||
}
|
||||
} else {
|
||||
message_contact_link($user->id, 'add', false, 'user.php?id='.$user->id, true);
|
||||
message_contact_link($user->id, 'block', false, 'user.php?id='.$user->id, true);
|
||||
}
|
||||
message_history_link($user->id, 0, false, '', '', 'both');
|
||||
echo '</div>';
|
||||
|
||||
echo '</td></tr></table>';
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
Loading…
x
Reference in New Issue
Block a user