MDL-36941 message_popup: use new WS for marking notifications as read
Also changed the observer to listen for the notification_viewed event, rather than the message_viewed event.
This commit is contained in:
@@ -1 +1 @@
|
||||
define(["core/ajax","core/notification"],function(a,b){var c=function(c){"undefined"==typeof c.limit&&(c.limit=20),"undefined"==typeof c.offset&&(c.offset=0);var d={methodname:"message_popup_get_popup_notifications",args:c},e=a.call([d])[0];return e.fail(b.exception),e},d=function(c){var d={methodname:"message_popup_get_unread_popup_notification_count",args:c},e=a.call([d])[0];return e.fail(b.exception),e},e=function(c){var d={methodname:"core_message_mark_all_notifications_as_read",args:c},e=a.call([d])[0];return e.fail(b.exception),e},f=function(c,d){var e={messageid:c};d&&(e.timeread=d);var f={methodname:"core_message_mark_message_read",args:e},g=a.call([f])[0];return g.fail(b.exception),g};return{query:c,countUnread:d,markAllAsRead:e,markAsRead:f}});
|
||||
define(["core/ajax","core/notification"],function(a,b){var c=function(c){"undefined"==typeof c.limit&&(c.limit=20),"undefined"==typeof c.offset&&(c.offset=0);var d={methodname:"message_popup_get_popup_notifications",args:c},e=a.call([d])[0];return e.fail(b.exception),e},d=function(c){var d={methodname:"message_popup_get_unread_popup_notification_count",args:c},e=a.call([d])[0];return e.fail(b.exception),e},e=function(c){var d={methodname:"core_message_mark_all_notifications_as_read",args:c},e=a.call([d])[0];return e.fail(b.exception),e},f=function(c,d){var e={notificationid:c};d&&(e.timeread=d);var f={methodname:"core_message_mark_notification_read",args:e},g=a.call([f])[0];return g.fail(b.exception),g};return{query:c,countUnread:d,markAllAsRead:e,markAsRead:f}});
|
||||
@@ -97,7 +97,7 @@ define(['core/ajax', 'core/notification'], function(Ajax, Notification) {
|
||||
*/
|
||||
var markAsRead = function(id, timeread) {
|
||||
var args = {
|
||||
messageid: id,
|
||||
notificationid: id,
|
||||
};
|
||||
|
||||
if (timeread) {
|
||||
@@ -105,7 +105,7 @@ define(['core/ajax', 'core/notification'], function(Ajax, Notification) {
|
||||
}
|
||||
|
||||
var request = {
|
||||
methodname: 'core_message_mark_message_read',
|
||||
methodname: 'core_message_mark_notification_read',
|
||||
args: args
|
||||
};
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@ defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$observers = array(
|
||||
|
||||
// Message viewed.
|
||||
// Notification viewed.
|
||||
array(
|
||||
'eventname' => '\core\event\message_viewed',
|
||||
'callback' => 'message_output_popup::message_viewed',
|
||||
'eventname' => '\core\event\notification_viewed',
|
||||
'callback' => 'message_output_popup::notification_viewed',
|
||||
'includefile' => '/message/output/popup/message_output_popup.php'
|
||||
)
|
||||
);
|
||||
|
||||
@@ -115,15 +115,14 @@ class message_output_popup extends message_output {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the message_viewed event to keep data in sync.
|
||||
* Handles the notification_viewed event to keep data in sync.
|
||||
*
|
||||
* @param \core\event\base $event The event data
|
||||
*/
|
||||
public static function message_viewed(\core\event\base $event) {
|
||||
public static function notification_viewed(\core\event\base $event) {
|
||||
global $DB;
|
||||
|
||||
if ($record = $DB->get_record('message_popup', ['messageid' => $event->other['messageid']])) {
|
||||
$record->messageid = $event->objectid;
|
||||
if ($record = $DB->get_record('message_popup', ['messageid' => $event->objectid])) {
|
||||
$record->isread = 1;
|
||||
$DB->update_record('message_popup', $record);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2017111300; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2018020500; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2017110800; // Requires this Moodle version
|
||||
$plugin->component = 'message_popup'; // Full name of the plugin (used for diagnostics)
|
||||
|
||||
Reference in New Issue
Block a user