From b48c9da40009fb8074bac14cfe98155b6794ff07 Mon Sep 17 00:00:00 2001
From: Paul Holden <paulh@moodle.com>
Date: Tue, 30 Jul 2019 14:05:12 +0100
Subject: [PATCH] MDL-66237 message_popup: get redirecturl from notification
 contexturl.

---
 .../amd/build/notification_popover_controller.min.js  | Bin 5169 -> 5106 bytes
 .../popup/amd/src/notification_popover_controller.js  |   4 +---
 message/output/popup/mark_notification_read.php       |   8 +++++---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/message/output/popup/amd/build/notification_popover_controller.min.js b/message/output/popup/amd/build/notification_popover_controller.min.js
index 9dcc43c0162d2e3c8be3d2304abd85bf8e402dab..b180ba9e9cd4334f8b170605f889e8c729d003fc 100644
GIT binary patch
delta 12
Tcmdm}@kxDy1lQ(pu3MY{A^ilr

delta 64
zcmeyQzENX?1edXznnt=_QEEzNQEGBYX;F@CYF=`FN@{43r*nR8L4ICpUWrDMUUGh3
RNooa1UQ<(NGY{7@P5|}07dij{

diff --git a/message/output/popup/amd/src/notification_popover_controller.js b/message/output/popup/amd/src/notification_popover_controller.js
index 8a6b04f..c1e44e6 100644
--- a/message/output/popup/amd/src/notification_popover_controller.js
+++ b/message/output/popup/amd/src/notification_popover_controller.js
@@ -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)
diff --git a/message/output/popup/mark_notification_read.php b/message/output/popup/mark_notification_read.php
index 0458678..9a8515a 100644
--- a/message/output/popup/mark_notification_read.php
+++ b/message/output/popup/mark_notification_read.php
@@ -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);
-- 
2.7.4

