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

@ -1321,20 +1321,20 @@ function chat_extend_navigation($navigation, $course, $module, $cm) {
* @param navigation_node $chatnode The node to add module settings to
*/
function chat_extend_settings_navigation(settings_navigation $settings, navigation_node $chatnode) {
global $DB, $PAGE, $USER;
$chat = $DB->get_record("chat", array("id" => $PAGE->cm->instance));
global $DB;
$chat = $DB->get_record("chat", array("id" => $settings->get_page()->cm->instance));
$currentgroup = groups_get_activity_group($PAGE->cm, true);
$currentgroup = groups_get_activity_group($settings->get_page()->cm, true);
if ($currentgroup) {
$groupselect = " AND groupid = '$currentgroup'";
} else {
$groupselect = '';
}
if ($chat->studentlogs || has_capability('mod/chat:readlog', $PAGE->cm->context)) {
if ($chat->studentlogs || has_capability('mod/chat:readlog', $settings->get_page()->cm->context)) {
if ($DB->get_records_select('chat_messages', "chatid = ? $groupselect", array($chat->id))) {
$chatnode->add(get_string('pastsessions', 'chat'),
new moodle_url('/mod/chat/report.php', array('id' => $PAGE->cm->id)));
new moodle_url('/mod/chat/report.php', array('id' => $settings->get_page()->cm->id)));
}
}
}