From 1834f1c9ce9b9fba528e89323aa0e37209925e96 Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Mon, 14 Jun 2021 10:49:37 +0800 Subject: [PATCH] MDL-67208 calendar: fix manage subscription redirection This patch fix the subcription page only adding the course parameter only when viewing the calendar on course context. It also passes the url to the form instance, so we have the course parameter on the form action attribute. --- calendar/managesubscriptions.php | 4 ++-- calendar/renderer.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/calendar/managesubscriptions.php b/calendar/managesubscriptions.php index 9c6af0adacc..91fbf6595cd 100644 --- a/calendar/managesubscriptions.php +++ b/calendar/managesubscriptions.php @@ -37,7 +37,7 @@ $groupcourseid = optional_param('groupcourseid', 0, PARAM_INT); $action = optional_param('action', '', PARAM_INT); $url = new moodle_url('/calendar/managesubscriptions.php'); -if ($courseid != SITEID) { +if ($courseid != SITEID && !empty($courseid)) { $url->param('course', $courseid); } if ($categoryid) { @@ -77,7 +77,7 @@ $customdata = [ 'courseid' => $course->id, 'groups' => $groups, ]; -$form = new \core_calendar\local\event\forms\managesubscriptions(null, $customdata); +$form = new \core_calendar\local\event\forms\managesubscriptions($url, $customdata); $form->set_data(array( 'course' => $course->id )); diff --git a/calendar/renderer.php b/calendar/renderer.php index a590cdfaf7b..314ecaf86a4 100644 --- a/calendar/renderer.php +++ b/calendar/renderer.php @@ -374,7 +374,7 @@ class core_calendar_renderer extends plugin_renderer_base { */ protected function subscription_action_form($subscription) { // Assemble form for the subscription row. - $html = html_writer::start_tag('form', array('action' => new moodle_url('/calendar/managesubscriptions.php'), 'method' => 'post')); + $html = html_writer::start_tag('form', ['action' => $this->page->url->out(false) , 'method' => 'post']); if (empty($subscription->url)) { // Don't update an iCal file, which has no URL. $html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'pollinterval', 'value' => '0'));