From 8825279be6a0ef75d5fc7cc45b22d46edf1ad993 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Fri, 17 Sep 2021 12:17:24 +0100 Subject: [PATCH] MDL-72599 blocks: handle editing/deletion on admin notification page. This was broken by changes in fdd5aef0, as the sesskey URL parameter was required on admin/index.php in order for block related actions to be performed uninterrupted by any redirections. --- lib/blocklib.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/blocklib.php b/lib/blocklib.php index 849f848720f..d82c6eed3d0 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -1284,6 +1284,12 @@ class block_manager { $str = new lang_string('configureblock', 'block', $blocktitle); $editactionurl = new moodle_url($actionurl, ['bui_editid' => $block->instance->id]); $editactionurl->remove_params(['sesskey']); + + // Handle editing block on admin index page, prevent the page redirecting before block action can begin. + if ($editactionurl->compare(new moodle_url('/admin/index.php'), URL_MATCH_BASE)) { + $editactionurl->param('cache', 1); + } + $controls[] = new action_menu_link_secondary( $editactionurl, new pix_icon('t/edit', $str, 'moodle', array('class' => 'iconsmall', 'title' => '')), @@ -1350,6 +1356,12 @@ class block_manager { $str = new lang_string('deleteblock', 'block', $blocktitle); $deleteactionurl = new moodle_url($actionurl, ['bui_deleteid' => $block->instance->id]); $deleteactionurl->remove_params(['sesskey']); + + // Handle deleting block on admin index page, prevent the page redirecting before block action can begin. + if ($deleteactionurl->compare(new moodle_url('/admin/index.php'), URL_MATCH_BASE)) { + $deleteactionurl->param('cache', 1); + } + $controls[] = new action_menu_link_secondary( $deleteactionurl, new pix_icon('t/delete', $str, 'moodle', array('class' => 'iconsmall', 'title' => '')),