Merge branch 'MDL-62889_35' of git://github.com/markn86/moodle into MOODLE_35_STABLE

This commit is contained in:
Andrew Nicols 2018-07-17 12:13:01 +08:00
commit c2c97dee39
3 changed files with 15 additions and 7 deletions

File diff suppressed because one or more lines are too long

View file

@ -223,10 +223,13 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str', 'core/url',
});
// Link to mark read page before loading the actual link.
notification.contexturl = URL.relativeUrl('message/output/popup/mark_notification_read.php', {
notificationid: notification.id,
redirecturl: notification.contexturl
});
var notificationurlparams = {
notificationid: notification.id
};
if (notification.contexturl) {
notificationurlparams.redirecturl = notification.contexturl;
}
notification.contexturl = URL.relativeUrl('message/output/popup/mark_notification_read.php', notificationurlparams);
var promise = Templates.render('message_popup/notification_content_item', notification)
.then(function(html, js) {

View file

@ -31,13 +31,18 @@ if (isguestuser()) {
}
$notificationid = required_param('notificationid', PARAM_INT);
$redirecturl = optional_param('redirecturl', $CFG->wwwroot, PARAM_LOCALURL);
$redirecturl = optional_param('redirecturl', '', PARAM_URL);
$notification = $DB->get_record('notifications', array('id' => $notificationid));
// If the redirect URL after filtering is empty, or it was never passed, then redirect to the notification page.
if (empty($redirecturl)) {
$redirecturl = new moodle_url('/message/output/popup/notifications.php', ['notificationid' => $notificationid]);
}
// Check notification belongs to this user.
if ($USER->id != $notification->useridto) {
redirect($CFG->wwwroot);
}
\core_message\api::mark_notification_as_read($notification);
redirect($redirecturl);
redirect(new moodle_url($redirecturl));