Merge branch 'MDL-74565-400' of https://github.com/paulholden/moodle into MOODLE_400_STABLE

This commit is contained in:
Jun Pataleta
2022-06-15 23:21:06 +08:00
4 changed files with 21 additions and 21 deletions
+6 -17
View File
@@ -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();
+3 -2
View File
@@ -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);
}
/**
+3
View File
@@ -1,6 +1,9 @@
This files describes API changes in core libraries and APIs,
information provided here is intended especially for developers.
=== 4.0.2 ===
* The core renderer `edit_button` method now accepts an optional `$method` argument (get/post) for the button
=== 4.0 ===
* To better detect wrong floats (like, for example, unformatted, using local-dependent separators ones) a number of
+9 -2
View File
@@ -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);
}