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

@ -532,17 +532,17 @@ function mod_bigbluebuttonbn_core_calendar_is_event_visible(calendar_event $even
* @param navigation_node $nodenav The node to add module settings to
*/
function bigbluebuttonbn_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $nodenav) {
global $PAGE, $USER;
global $USER;
// Don't add validate completion if the callback for meetingevents is NOT enabled.
if (!(boolean) \mod_bigbluebuttonbn\local\config::get('meetingevents_enabled')) {
return;
}
// Don't add validate completion if user is not allowed to edit the activity.
$context = context_module::instance($PAGE->cm->id);
$context = context_module::instance($settingsnav->get_page()->cm->id);
if (!has_capability('moodle/course:manageactivities', $context, $USER->id)) {
return;
}
$completionvalidate = '#action=completion_validate&bigbluebuttonbn=' . $PAGE->cm->instance;
$completionvalidate = '#action=completion_validate&bigbluebuttonbn=' . $settingsnav->get_page()->cm->instance;
$nodenav->add(get_string('completionvalidatestate', 'bigbluebuttonbn'),
$completionvalidate, navigation_node::TYPE_CONTAINER);
}