MDL-66237 message_popup: Get redirecturl from notification contexturl

This commit is contained in:
Paul Holden 2020-01-07 11:16:13 +08:00 committed by Michael Hawkins
parent c55402486b
commit 8725ac5f42
4 changed files with 8 additions and 8 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -226,9 +226,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str', 'core/url',
var notificationurlparams = {
notificationid: notification.id
};
if (notification.contexturl) {
notificationurlparams.redirecturl = encodeURIComponent(notification.contexturl);
}
notification.contexturl = URL.relativeUrl('message/output/popup/mark_notification_read.php', notificationurlparams);
var promise = Templates.render('message_popup/notification_content_item', notification)

View File

@ -31,11 +31,13 @@ if (isguestuser()) {
}
$notificationid = required_param('notificationid', PARAM_INT);
$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)) {
if (!empty($notification->contexturl)) {
$redirecturl = new moodle_url($notification->contexturl);
} else {
$redirecturl = new moodle_url('/message/output/popup/notifications.php', ['notificationid' => $notificationid]);
}
@ -45,4 +47,4 @@ if ($USER->id != $notification->useridto) {
}
\core_message\api::mark_notification_as_read($notification);
redirect(new moodle_url($redirecturl));
redirect($redirecturl);