From d3932d2b5132e5632f28fb18619a4eeefeeafeaa Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Wed, 27 Jul 2016 14:13:25 +0800 Subject: [PATCH] MDL-53765 core: Deprecate update_module_button functions First stage deprecation for the functions update_module_button and core_renderer::update_module_button(). --- lib/deprecatedlib.php | 27 +++++++++++++++++++++++++++ lib/outputrenderers.php | 7 +++++++ mod/upgrade.txt | 3 +++ 3 files changed, 37 insertions(+) diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 65065cf9bc8..aed61653f0f 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -1111,6 +1111,33 @@ function print_checkbox($name, $value, $checked = true, $label = '', $alt = '', throw new coding_exception('print_checkbox() can not be used any more. Please use html_writer::checkbox() instead.'); } +/** + * Prints the 'update this xxx' button that appears on module pages. + * + * @deprecated since Moodle 3.2 + * + * @param string $cmid the course_module id. + * @param string $ignored not used any more. (Used to be courseid.) + * @param string $string the module name - get_string('modulename', 'xxx') + * @return string the HTML for the button, if this user has permission to edit it, else an empty string. + */ +function update_module_button($cmid, $ignored, $string) { + global $CFG, $OUTPUT; + + debugging('update_module_button() has been deprecated and should not be used anymore. Activity modules should not add the ' . + 'edit module button, the link is already available in the Administration block. Themes can choose to display the link ' . + 'in the buttons row consistently for all module types.', DEBUG_DEVELOPER); + + if (has_capability('moodle/course:manageactivities', context_module::instance($cmid))) { + $string = get_string('updatethis', '', $string); + + $url = new moodle_url("$CFG->wwwroot/course/mod.php", array('update' => $cmid, 'return' => true, 'sesskey' => sesskey())); + return $OUTPUT->single_button($url, $string); + } else { + return ''; + } +} + /** * @deprecated use $OUTPUT->navbar() instead */ diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 4f89e2751c2..63be693e289 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -2685,12 +2685,19 @@ EOD; /** * Returns HTML to display the 'Update this Modulename' button that appears on module pages. * + * @deprecated since Moodle 3.2 + * * @param string $cmid the course_module id. * @param string $modulename the module name, eg. "forum", "quiz" or "workshop" * @return string the HTML for the button, if this user has permission to edit it, else an empty string. */ public function update_module_button($cmid, $modulename) { global $CFG; + + debugging('core_renderer::update_module_button() has been deprecated and should not be used anymore. Activity modules ' . + 'should not add the edit module button, the link is already available in the Administration block. Themes can choose ' . + 'to display the link in the buttons row consistently for all module types.', DEBUG_DEVELOPER); + if (has_capability('moodle/course:manageactivities', context_module::instance($cmid))) { $modulename = get_string('modulename', $modulename); $string = get_string('updatethis', '', $modulename); diff --git a/mod/upgrade.txt b/mod/upgrade.txt index 74e8d008859..09f129816b1 100644 --- a/mod/upgrade.txt +++ b/mod/upgrade.txt @@ -4,6 +4,9 @@ information provided here is intended especially for developers. === 3.2 === * Callback delete_course is deprecated and should be replaced with observer for event \core\event\course_content_deleted +* update_module_button() and core_renderer::update_module_button() have been deprecated and should not be used anymore. + Activity modules should not add the edit module button, the link is already available in the Administration block. + Themes can choose to display the link in the buttons row consistently for all module types. === 3.1 === -- 2.43.0