MDL-73532 navigation: Modify methods that extend the setting nav

Introduces some changes to the exising _extend_settings_navigation()
methods that utilize the global $PAGE object. In order to accomodate
the changes done for the secondary navigation for single activity
courses, the methods that extend the settings navigation can no longer
rely on the $PAGE object, instead the more reliabe way to obtain this
infomation is through the get_page() method from settings_navigation
class.
This commit is contained in:
Mihail Geshoski 2022-01-19 16:06:46 +08:00
parent bf27303955
commit 4a9c83ac9e
19 changed files with 132 additions and 145 deletions

View file

@ -1836,15 +1836,13 @@ function mod_scorm_core_calendar_get_event_action_string(string $eventtype): str
* It is safe to rely on PAGE here as we will only ever be within the module
* context when this is called
*
* @param navigation_node $settings navigation_node object.
* @param settings_navigation $settings navigation_node object.
* @param navigation_node $scormnode navigation_node object.
* @return void
*/
function scorm_extend_settings_navigation(navigation_node $settings, navigation_node $scormnode): void {
global $PAGE;
if (has_capability('mod/scorm:viewreport', $PAGE->cm->context)) {
$url = new moodle_url('/mod/scorm/report.php', ['id' => $PAGE->cm->id]);
function scorm_extend_settings_navigation(settings_navigation $settings, navigation_node $scormnode): void {
if (has_capability('mod/scorm:viewreport', $settings->get_page()->cm->context)) {
$url = new moodle_url('/mod/scorm/report.php', ['id' => $settings->get_page()->cm->id]);
$scormnode->add(get_string("reports", "scorm"), $url, navigation_node::TYPE_CUSTOM, null, 'scormreport');
}
}