diff --git a/grade/report/grader/index.php b/grade/report/grader/index.php index 9068c79e7b9..f294c0a9d85 100644 --- a/grade/report/grader/index.php +++ b/grade/report/grader/index.php @@ -81,29 +81,18 @@ if (!isset($USER->grade_last_report)) { } $USER->grade_last_report[$course->id] = 'grader'; -// Build editing on/off buttons +// Build editing on/off buttons. $buttons = ''; -if (has_capability('moodle/grade:edit', $context)) { - if (($edit != - 1) and $PAGE->user_allowed_editing()) { +$PAGE->set_other_editing_capability('moodle/grade:edit'); +if ($PAGE->user_allowed_editing() && !$PAGE->theme->haseditswitch) { + if ($edit != - 1) { $USER->editing = $edit; } - // page params for the turn editting on + // Page params for the turn editing on button. $options = $gpr->get_options(); - $options['sesskey'] = sesskey(); - - if (isset($USER->editing) && $USER->editing) { - $options['edit'] = 0; - $string = get_string('turneditingoff'); - } else { - $options['edit'] = 1; - $string = get_string('turneditingon'); - } - - if (!$PAGE->theme->haseditswitch) { - $buttons = new single_button(new moodle_url('index.php', $options), $string, 'get'); - } + $buttons = $OUTPUT->edit_button(new moodle_url($PAGE->url, $options), 'get'); } $gradeserror = array(); diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index f379e2e44fd..e86201b8015 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -2819,9 +2819,10 @@ EOD; * Returns HTML to display a "Turn editing on/off" button in a form. * * @param moodle_url $url The URL + params to send through when clicking the button + * @param string $method * @return string HTML the button */ - public function edit_button(moodle_url $url) { + public function edit_button(moodle_url $url, string $method = 'post') { if ($this->page->theme->haseditswitch == true) { return; @@ -2835,7 +2836,7 @@ EOD; $editstring = get_string('turneditingon'); } - return $this->single_button($url, $editstring); + return $this->single_button($url, $editstring, $method); } /** diff --git a/lib/upgrade.txt b/lib/upgrade.txt index a272a8df4bf..7a0dd3da2b9 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -13,6 +13,7 @@ information provided here is intended especially for developers. - Breaking: 3rd party log readers implementing interface sql_reader will need to implement get_events_select_exists() * Added $strictness parameter to persistent `get_record` method, optionally allowing caller to ensure record exists * New DML driver method `$DB->sql_cast_to_char` for casting given field/expression to char +* The core renderer `edit_button` method now accepts an optional `$method` argument (get/post) for the button * For plugins that override secondary navigation, the namespace for the custom secondary navigation class has changed. It was (for example) mod_mymodule\local\views\secondary but is now mod_mymodule\navigation\views\secondary. The old location will continue to work, but is deprecated. diff --git a/theme/boost/classes/output/core_renderer.php b/theme/boost/classes/output/core_renderer.php index e21f98d3272..8047d6df207 100644 --- a/theme/boost/classes/output/core_renderer.php +++ b/theme/boost/classes/output/core_renderer.php @@ -31,7 +31,14 @@ defined('MOODLE_INTERNAL') || die; */ class core_renderer extends \core_renderer { - public function edit_button(moodle_url $url) { + /** + * Returns HTML to display a "Turn editing on/off" button in a form. + * + * @param moodle_url $url The URL + params to send through when clicking the button + * @param string $method + * @return string HTML the button + */ + public function edit_button(moodle_url $url, string $method = 'post') { if ($this->page->theme->haseditswitch) { return; } @@ -43,7 +50,7 @@ class core_renderer extends \core_renderer { $url->param('edit', 'on'); $editstring = get_string('turneditingon'); } - $button = new \single_button($url, $editstring, 'post', ['class' => 'btn btn-primary']); + $button = new \single_button($url, $editstring, $method, ['class' => 'btn btn-primary']); return $this->render_single_button($button); }