mirror of
https://github.com/moodle/moodle.git
synced 2025-01-29 19:50:14 +01:00
MDL-42214 core_message:prevented popup notifications of messages from blocked users
This commit is contained in:
parent
5fd0df97c5
commit
727c69ca9e
@ -8752,17 +8752,19 @@ function message_popup_window() {
|
||||
|
||||
// A quick query to check whether the user has new messages.
|
||||
$messagecount = $DB->count_records('message', array('useridto' => $USER->id));
|
||||
if ($messagecount<1) {
|
||||
if ($messagecount < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Got unread messages so now do another query that joins with the user table.
|
||||
// There are unread messages so now do a more complex but slower query.
|
||||
$namefields = get_all_user_name_fields(true, 'u');
|
||||
$messagesql = "SELECT m.id, m.smallmessage, m.fullmessageformat, m.notification, $namefields
|
||||
$messagesql = "SELECT m.id, m.smallmessage, m.fullmessageformat, m.notification, m.useridto, m.useridfrom, $namefields, c.blocked
|
||||
FROM {message} m
|
||||
JOIN {message_working} mw ON m.id=mw.unreadmessageid
|
||||
JOIN {message_processors} p ON mw.processorid=p.id
|
||||
JOIN {user} u ON m.useridfrom=u.id
|
||||
LEFT JOIN {message_contacts} c ON c.contactid = m.useridfrom
|
||||
AND c.userid = m.useridto
|
||||
WHERE m.useridto = :userid
|
||||
AND p.name='popup'";
|
||||
|
||||
@ -8775,10 +8777,18 @@ function message_popup_window() {
|
||||
|
||||
$messageusers = $DB->get_records_sql($messagesql, array('userid' => $USER->id, 'lastpopuptime' => $USER->message_lastpopup));
|
||||
|
||||
// If we have new messages to notify the user about.
|
||||
if (!empty($messageusers)) {
|
||||
$validmessages = 0;
|
||||
foreach($messageusers as $message) {
|
||||
if ($message->blocked) {
|
||||
// Message is from a user who has since been blocked so just mark it read.
|
||||
message_mark_message_read($message, time());
|
||||
} else {
|
||||
$validmessages++;
|
||||
}
|
||||
}
|
||||
|
||||
$strmessages = get_string('unreadnewmessages', 'message', count($messageusers));
|
||||
if ($validmessages > 0) {
|
||||
$strmessages = get_string('unreadnewmessages', 'message', $validmessages);
|
||||
$strgomessage = get_string('gotomessages', 'message');
|
||||
$strstaymessage = get_string('ignore', 'admin');
|
||||
|
||||
|
@ -2352,7 +2352,7 @@ function message_move_userfrom_unread2read($userid) {
|
||||
* @param int $fromuserid the id of the message sender
|
||||
* @return void
|
||||
*/
|
||||
function message_mark_messages_read($touserid, $fromuserid){
|
||||
function message_mark_messages_read($touserid, $fromuserid) {
|
||||
global $DB;
|
||||
|
||||
$sql = 'SELECT m.* FROM {message} m WHERE m.useridto=:useridto AND m.useridfrom=:useridfrom';
|
||||
|
Loading…
x
Reference in New Issue
Block a user