mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
MDL-56409 messages: Do not fetch notifications if they are disabled
This commit is contained in:
parent
7eb34671c1
commit
55af4309f7
@ -34,7 +34,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
class api {
|
||||
/**
|
||||
* Get popup notifications for the specified users.
|
||||
* Get popup notifications for the specified users. Nothing is returned if notifications are disabled.
|
||||
*
|
||||
* @param int $useridto the user id who received the notification
|
||||
* @param string $sort the column name to order by including optionally direction
|
||||
@ -61,6 +61,18 @@ class api {
|
||||
'useridto2' => $useridto,
|
||||
];
|
||||
|
||||
// Is notification enabled ?
|
||||
if ($useridto == $USER->id) {
|
||||
$disabled = $USER->emailstop;
|
||||
} else {
|
||||
$user = \core_user::get_user($useridto, "emailstop", MUST_EXIST);
|
||||
$disabled = $user->emailstop;
|
||||
}
|
||||
if ($disabled) {
|
||||
// Notifications are disabled, no need to run giant queries.
|
||||
return array();
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM (
|
||||
SELECT concat('r', r.id) as uniqueid, r.id, r.useridfrom, r.useridto,
|
||||
r.subject, r.fullmessage, r.fullmessageformat,
|
||||
|
Loading…
x
Reference in New Issue
Block a user