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

This commit is contained in:
Andrew Nicols
2018-07-18 15:36:50 +08:00
3 changed files with 15 additions and 7 deletions
File diff suppressed because one or more lines are too long
@@ -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) {
@@ -31,10 +31,15 @@ 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('message', array('id' => $notificationid, 'notification' => 1));
// 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]);
}
// If found, is unread, so mark read if belongs to this user.
if ($notification) {
if ($USER->id == $notification->useridto) {
@@ -44,4 +49,4 @@ if ($notification) {
}
}
redirect($redirecturl);
redirect(new moodle_url($redirecturl));