From d81da7aba13f507fee6a8d59bde09a4f7afb4de3 Mon Sep 17 00:00:00 2001 From: David Woloszyn Date: Tue, 9 May 2023 10:31:24 +1000 Subject: [PATCH] MDL-77144 core_grades: deprecated showtitle in print_grade_page_head --- grade/lib.php | 34 +++++++++++----------------------- grade/upgrade.txt | 4 ++++ 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/grade/lib.php b/grade/lib.php index c7524e9d52f..147c0dc9430 100644 --- a/grade/lib.php +++ b/grade/lib.php @@ -842,7 +842,7 @@ class grade_plugin_info { * @param string $active_type The type of the current page (report, settings, * import, export, scales, outcomes, letters) * @param string|null $active_plugin The plugin of the current page (grader, fullview etc...) - * @param string|bool $heading The heading of the page. Tries to guess if none is given + * @param string|bool $heading The heading of the page. * @param boolean $return Whether to return (true) or echo (false) the HTML generated by this function * @param string|bool $buttons Additional buttons to display on the page * @param boolean $shownavigation should the gradebook navigation be shown? @@ -852,14 +852,18 @@ class grade_plugin_info { * @param actionbar|null $actionbar The actions bar which will be displayed on the page if $shownavigation is set * to true. If $actionbar is not explicitly defined, the general action bar * (\core_grades\output\general_action_bar) will be used by default. - * @param boolean $showtitle If set to false just show course full name as a title. + * @param null $unused This parameter has been deprecated since 4.3 and should not be used anymore. * @return string HTML code or nothing if $return == false */ -function print_grade_page_head(int $courseid, string $active_type, ?string $active_plugin = null, $heading = false, +function print_grade_page_head(int $courseid, string $active_type, ?string $active_plugin = null, string|bool $heading = false, bool $return = false, $buttons = false, bool $shownavigation = true, ?string $headerhelpidentifier = null, - ?string $headerhelpcomponent = null, ?stdClass $user = null, ?action_bar $actionbar = null, $showtitle = true) { + ?string $headerhelpcomponent = null, ?stdClass $user = null, ?action_bar $actionbar = null, $unused = null) { global $CFG, $OUTPUT, $PAGE; + if ($unused !== null) { + debugging('Deprecated argument passed to ' . __FUNCTION__, DEBUG_DEVELOPER); + } + // Put a warning on all gradebook pages if the course has modules currently scheduled for background deletion. require_once($CFG->dirroot . '/course/lib.php'); if (course_modules_pending_deletion($courseid, true)) { @@ -875,24 +879,15 @@ function print_grade_page_head(int $courseid, string $active_type, ?string $acti $plugin_info = grade_get_plugin_info($courseid, $active_type, $active_plugin); // Determine the string of the active plugin - $stractive_plugin = ($active_plugin) ? $plugin_info['strings']['active_plugin_str'] : $heading; $stractive_type = $plugin_info['strings'][$active_type]; - if (!$showtitle) { - $title = $PAGE->course->fullname; - } else if (empty($plugin_info[$active_type]->id) || !empty($plugin_info[$active_type]->parent)) { - $title = $PAGE->course->fullname.': ' . $stractive_type . ': ' . $stractive_plugin; - } else { - $title = $PAGE->course->fullname.': ' . $stractive_plugin; - } - if ($active_type == 'report') { $PAGE->set_pagelayout('report'); } else { $PAGE->set_pagelayout('admin'); } $PAGE->set_title(get_string('grades') . ': ' . $stractive_type); - $PAGE->set_heading($title); + $PAGE->set_heading($PAGE->course->fullname); $PAGE->set_secondary_active_tab('grades'); if ($buttons instanceof single_button) { @@ -914,15 +909,6 @@ function print_grade_page_head(int $courseid, string $active_type, ?string $acti echo $returnval; } - // Guess heading if not given explicitly - if (!$heading) { - $heading = $stractive_plugin; - } - - if (!$showtitle) { - $heading = ''; - } - if ($shownavigation) { $renderer = $PAGE->get_renderer('core_grades'); // If the navigation action bar is not explicitly defined, use the general (default) action bar. @@ -937,6 +923,8 @@ function print_grade_page_head(int $courseid, string $active_type, ?string $acti } } + $heading = !empty($heading) ? $heading : ''; + $output = ''; // Add a help dialogue box if provided. if (isset($headerhelpidentifier)) { diff --git a/grade/upgrade.txt b/grade/upgrade.txt index c51175a4936..420d320dd0a 100644 --- a/grade/upgrade.txt +++ b/grade/upgrade.txt @@ -1,6 +1,10 @@ This file describes API changes in /grade/* ; Information provided here is intended especially for developers. +=== 4.3 === + +* The $showtitle parameter in the print_grade_page_head function located inside grade/lib.php has been deprecated and is not used anymore. + === 4.1 === * The $importactiveurl parameter in the constructor of the core_grades\output\import_action_bar class has been deprecated and is not used anymore. * The $exportactiveurl parameter in the constructor of the core_grades\output\export_action_bar class has been deprecated and is not used anymore.