mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
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:
parent
bf27303955
commit
4a9c83ac9e
@ -408,7 +408,7 @@ function assign_supports($feature) {
|
||||
* @return void
|
||||
*/
|
||||
function assign_extend_settings_navigation(settings_navigation $settings, navigation_node $navref) {
|
||||
global $PAGE, $DB;
|
||||
global $DB;
|
||||
|
||||
// We want to add these new nodes after the Edit settings node, and before the
|
||||
// Locally assigned roles node. Of course, both of those are controlled by capabilities.
|
||||
@ -421,20 +421,20 @@ function assign_extend_settings_navigation(settings_navigation $settings, naviga
|
||||
$beforekey = $keys[$i + 1];
|
||||
}
|
||||
|
||||
$cm = $PAGE->cm;
|
||||
$cm = $settings->get_page()->cm;
|
||||
if (!$cm) {
|
||||
return;
|
||||
}
|
||||
|
||||
$context = $cm->context;
|
||||
$course = $PAGE->course;
|
||||
$course = $settings->get_page()->course;
|
||||
|
||||
if (!$course) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (has_capability('mod/assign:manageoverrides', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/mod/assign/overrides.php', array('cmid' => $PAGE->cm->id, 'mode' => 'user'));
|
||||
if (has_capability('mod/assign:manageoverrides', $settings->get_page()->cm->context)) {
|
||||
$url = new moodle_url('/mod/assign/overrides.php', ['cmid' => $settings->get_page()->cm->id, 'mode' => 'user']);
|
||||
|
||||
$node = navigation_node::create(get_string('overrides', 'assign'),
|
||||
$url,
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ function book_supports($feature) {
|
||||
* @return void
|
||||
*/
|
||||
function book_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $booknode) {
|
||||
global $USER, $PAGE, $OUTPUT;
|
||||
global $USER, $OUTPUT;
|
||||
|
||||
if ($booknode->children->count() > 0) {
|
||||
$firstkey = $booknode->children->get_key_list()[0];
|
||||
@ -336,10 +336,10 @@ function book_extend_settings_navigation(settings_navigation $settingsnav, navig
|
||||
$firstkey = null;
|
||||
}
|
||||
|
||||
$params = $PAGE->url->params();
|
||||
$params = $settingsnav->get_page()->url->params();
|
||||
|
||||
if ($PAGE->cm->modname === 'book' and !empty($params['id']) and !empty($params['chapterid'])
|
||||
and has_capability('mod/book:edit', $PAGE->cm->context)) {
|
||||
if ($settingsnav->get_page()->cm->modname === 'book' and !empty($params['id']) and !empty($params['chapterid'])
|
||||
and has_capability('mod/book:edit', $settingsnav->get_page()->cm->context)) {
|
||||
if (!empty($USER->editing)) {
|
||||
$string = get_string("turneditingoff");
|
||||
$edit = '0';
|
||||
@ -351,8 +351,8 @@ function book_extend_settings_navigation(settings_navigation $settingsnav, navig
|
||||
$editnode = navigation_node::create($string, $url, navigation_node::TYPE_SETTING);
|
||||
$editnode->set_show_in_secondary_navigation(false);
|
||||
$booknode->add_node($editnode, $firstkey);
|
||||
if (!$PAGE->theme->haseditswitch) {
|
||||
$PAGE->set_button($OUTPUT->single_button($url, $string));
|
||||
if (!$settingsnav->get_page()->theme->haseditswitch) {
|
||||
$settingsnav->get_page()->set_button($OUTPUT->single_button($url, $string));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,10 +31,8 @@ defined('MOODLE_INTERNAL') || die;
|
||||
* @param navigation_node $node The node to add module settings to
|
||||
*/
|
||||
function booktool_exportimscp_extend_settings_navigation(settings_navigation $settings, navigation_node $node) {
|
||||
global $PAGE;
|
||||
|
||||
if (has_capability('booktool/exportimscp:export', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/mod/book/tool/exportimscp/index.php', array('id'=>$PAGE->cm->id));
|
||||
if (has_capability('booktool/exportimscp:export', $settings->get_page()->cm->context)) {
|
||||
$url = new moodle_url('/mod/book/tool/exportimscp/index.php', array('id' => $settings->get_page()->cm->id));
|
||||
$icon = new pix_icon('generate', '', 'booktool_exportimscp', array('class'=>'icon'));
|
||||
$umscpnode = $node->add(get_string('generateimscp', 'booktool_exportimscp'), $url,
|
||||
navigation_node::TYPE_SETTING, null, null, $icon);
|
||||
|
@ -31,10 +31,8 @@ defined('MOODLE_INTERNAL') || die;
|
||||
* @param navigation_node $node The node to add module settings to
|
||||
*/
|
||||
function booktool_importhtml_extend_settings_navigation(settings_navigation $settings, navigation_node $node) {
|
||||
global $PAGE;
|
||||
|
||||
if (has_capability('booktool/importhtml:import', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/mod/book/tool/importhtml/index.php', array('id'=>$PAGE->cm->id));
|
||||
if (has_capability('booktool/importhtml:import', $settings->get_page()->cm->context)) {
|
||||
$url = new moodle_url('/mod/book/tool/importhtml/index.php', array('id' => $settings->get_page()->cm->id));
|
||||
$node->add(get_string('import', 'booktool_importhtml'), $url, navigation_node::TYPE_SETTING, null, 'importchapter', null);
|
||||
}
|
||||
}
|
||||
|
@ -31,14 +31,12 @@ defined('MOODLE_INTERNAL') || die;
|
||||
* @param navigation_node $node The node to add module settings to
|
||||
*/
|
||||
function booktool_print_extend_settings_navigation(settings_navigation $settings, navigation_node $node) {
|
||||
global $USER, $PAGE, $CFG, $DB, $OUTPUT;
|
||||
|
||||
$params = $PAGE->url->params();
|
||||
$params = $settings->get_page()->url->params();
|
||||
if (empty($params['id']) or empty($params['chapterid'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (has_capability('booktool/print:print', $PAGE->cm->context)) {
|
||||
if (has_capability('booktool/print:print', $settings->get_page()->cm->context)) {
|
||||
$url1 = new moodle_url('/mod/book/tool/print/index.php', array('id'=>$params['id']));
|
||||
$url2 = new moodle_url('/mod/book/tool/print/index.php', array('id'=>$params['id'], 'chapterid'=>$params['chapterid']));
|
||||
$action = new action_link($url1, get_string('printbook', 'booktool_print'), new popup_action('click', $url1));
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -862,11 +862,9 @@ function choice_supports($feature) {
|
||||
* @param navigation_node $choicenode The node to add module settings to
|
||||
*/
|
||||
function choice_extend_settings_navigation(settings_navigation $settings, navigation_node $choicenode) {
|
||||
global $PAGE;
|
||||
|
||||
if (has_capability('mod/choice:readresponses', $PAGE->cm->context)) {
|
||||
if (has_capability('mod/choice:readresponses', $settings->get_page()->cm->context)) {
|
||||
$choicenode->add(get_string('responses', 'choice'),
|
||||
new moodle_url('/mod/choice/report.php', array('id' => $PAGE->cm->id)));
|
||||
new moodle_url('/mod/choice/report.php', array('id' => $settings->get_page()->cm->id)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3588,38 +3588,39 @@ function data_extend_navigation($navigation, $course, $module, $cm) {
|
||||
* @param navigation_node $datanode The node to add module settings to
|
||||
*/
|
||||
function data_extend_settings_navigation(settings_navigation $settings, navigation_node $datanode) {
|
||||
global $PAGE, $DB, $CFG, $USER;
|
||||
global $DB, $CFG, $USER;
|
||||
|
||||
$data = $DB->get_record('data', array("id" => $PAGE->cm->instance));
|
||||
$data = $DB->get_record('data', array("id" => $settings->get_page()->cm->instance));
|
||||
|
||||
$currentgroup = groups_get_activity_group($PAGE->cm);
|
||||
$groupmode = groups_get_activity_groupmode($PAGE->cm);
|
||||
$currentgroup = groups_get_activity_group($settings->get_page()->cm);
|
||||
$groupmode = groups_get_activity_groupmode($settings->get_page()->cm);
|
||||
|
||||
if (data_user_can_add_entry($data, $currentgroup, $groupmode, $PAGE->cm->context)) { // took out participation list here!
|
||||
// Took out participation list here!
|
||||
if (data_user_can_add_entry($data, $currentgroup, $groupmode, $settings->get_page()->cm->context)) {
|
||||
if (empty($editentry)) { //TODO: undefined
|
||||
$addstring = get_string('add', 'data');
|
||||
} else {
|
||||
$addstring = get_string('editentry', 'data');
|
||||
}
|
||||
$addentrynode = $datanode->add($addstring,
|
||||
new moodle_url('/mod/data/edit.php', array('d' => $PAGE->cm->instance)));
|
||||
new moodle_url('/mod/data/edit.php', array('d' => $settings->get_page()->cm->instance)));
|
||||
$addentrynode->set_show_in_secondary_navigation(false);
|
||||
}
|
||||
|
||||
if (has_capability(DATA_CAP_EXPORT, $PAGE->cm->context)) {
|
||||
if (has_capability(DATA_CAP_EXPORT, $settings->get_page()->cm->context)) {
|
||||
// The capability required to Export database records is centrally defined in 'lib.php'
|
||||
// and should be weaker than those required to edit Templates, Fields and Presets.
|
||||
$exportentriesnode = $datanode->add(get_string('exportentries', 'data'),
|
||||
new moodle_url('/mod/data/export.php', array('d' => $data->id)));
|
||||
$exportentriesnode->set_show_in_secondary_navigation(false);
|
||||
}
|
||||
if (has_capability('mod/data:manageentries', $PAGE->cm->context)) {
|
||||
if (has_capability('mod/data:manageentries', $settings->get_page()->cm->context)) {
|
||||
$importentriesnode = $datanode->add(get_string('importentries', 'data'),
|
||||
new moodle_url('/mod/data/import.php', array('d' => $data->id)));
|
||||
$importentriesnode->set_show_in_secondary_navigation(false);
|
||||
}
|
||||
|
||||
if (has_capability('mod/data:managetemplates', $PAGE->cm->context)) {
|
||||
if (has_capability('mod/data:managetemplates', $settings->get_page()->cm->context)) {
|
||||
$currenttab = '';
|
||||
if ($currenttab == 'list') {
|
||||
$defaultemplate = 'listtemplate';
|
||||
@ -3643,7 +3644,7 @@ function data_extend_settings_navigation(settings_navigation $settings, navigati
|
||||
|
||||
$string = get_string('rsstype', 'data');
|
||||
|
||||
$url = new moodle_url(rss_get_url($PAGE->cm->context->id, $USER->id, 'mod_data', $data->id));
|
||||
$url = new moodle_url(rss_get_url($settings->get_page()->cm->context->id, $USER->id, 'mod_data', $data->id));
|
||||
$datanode->add($string, $url, settings_navigation::TYPE_SETTING, null, null, new pix_icon('i/rss', ''));
|
||||
}
|
||||
}
|
||||
|
@ -2797,13 +2797,9 @@ function feedback_encode_target_url($url) {
|
||||
* @param settings_navigation $settings The settings navigation object
|
||||
* @param navigation_node $feedbacknode The node to add module settings to
|
||||
*/
|
||||
function feedback_extend_settings_navigation(settings_navigation $settings,
|
||||
navigation_node $feedbacknode) {
|
||||
|
||||
global $PAGE;
|
||||
|
||||
$hassecondary = $PAGE->has_secondary_navigation();
|
||||
if (!$context = context_module::instance($PAGE->cm->id, IGNORE_MISSING)) {
|
||||
function feedback_extend_settings_navigation(settings_navigation $settings, navigation_node $feedbacknode) {
|
||||
$hassecondary = $settings->get_page()->has_secondary_navigation();
|
||||
if (!$context = context_module::instance($settings->get_page()->cm->id, IGNORE_MISSING)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
|
||||
@ -2811,53 +2807,49 @@ function feedback_extend_settings_navigation(settings_navigation $settings,
|
||||
$questionnode = $feedbacknode->add(get_string('questions', 'feedback'), null,
|
||||
navigation_node::TYPE_CUSTOM, null, 'questionnode');
|
||||
$questionnode->add(get_string('edit_items', 'feedback'),
|
||||
new moodle_url('/mod/feedback/edit.php',
|
||||
['id' => $PAGE->cm->id]));
|
||||
new moodle_url('/mod/feedback/edit.php', ['id' => $settings->get_page()->cm->id]));
|
||||
|
||||
$questionnode->add(get_string('export_questions', 'feedback'),
|
||||
new moodle_url('/mod/feedback/export.php',
|
||||
array('id' => $PAGE->cm->id,
|
||||
'action' => 'exportfile')));
|
||||
new moodle_url('/mod/feedback/export.php', ['id' => $settings->get_page()->cm->id, 'action' => 'exportfile']));
|
||||
|
||||
$questionnode->add(get_string('import_questions', 'feedback'),
|
||||
new moodle_url('/mod/feedback/import.php',
|
||||
array('id' => $PAGE->cm->id)));
|
||||
new moodle_url('/mod/feedback/import.php', ['id' => $settings->get_page()->cm->id]));
|
||||
|
||||
$feedbacknode->add(get_string('templates', 'feedback'),
|
||||
new moodle_url('/mod/feedback/manage_templates.php', ['id' => $PAGE->cm->id, 'mode' => 'manage']),
|
||||
navigation_node::TYPE_CUSTOM, null, 'templatenode');
|
||||
new moodle_url('/mod/feedback/manage_templates.php', ['id' => $settings->get_page()->cm->id, 'mode' => 'manage']),
|
||||
navigation_node::TYPE_CUSTOM, null, 'templatenode');
|
||||
}
|
||||
|
||||
if (has_capability('mod/feedback:mapcourse', $context) && $PAGE->course->id == SITEID) {
|
||||
if (has_capability('mod/feedback:mapcourse', $context) && $settings->get_page()->course->id == SITEID) {
|
||||
$feedbacknode->add(get_string('mappedcourses', 'feedback'),
|
||||
new moodle_url('/mod/feedback/mapcourse.php', ['id' => $PAGE->cm->id]),
|
||||
navigation_node::TYPE_CUSTOM, null, 'mapcourse');
|
||||
new moodle_url('/mod/feedback/mapcourse.php', ['id' => $settings->get_page()->cm->id]),
|
||||
navigation_node::TYPE_CUSTOM, null, 'mapcourse');
|
||||
}
|
||||
|
||||
$feedback = $PAGE->activityrecord;
|
||||
$feedback = $settings->get_page()->activityrecord;
|
||||
if ($feedback->course == SITEID) {
|
||||
$analysisnode = navigation_node::create(get_string('analysis', 'feedback'),
|
||||
new moodle_url('/mod/feedback/analysis_course.php', ['id' => $PAGE->cm->id]),
|
||||
new moodle_url('/mod/feedback/analysis_course.php', ['id' => $settings->get_page()->cm->id]),
|
||||
navigation_node::TYPE_CUSTOM, null, 'feedbackanalysis');
|
||||
} else {
|
||||
$analysisnode = navigation_node::create(get_string('analysis', 'feedback'),
|
||||
new moodle_url('/mod/feedback/analysis.php', ['id' => $PAGE->cm->id]),
|
||||
new moodle_url('/mod/feedback/analysis.php', ['id' => $settings->get_page()->cm->id]),
|
||||
navigation_node::TYPE_CUSTOM, null, 'feedbackanalysis');
|
||||
}
|
||||
|
||||
if (has_capability('mod/feedback:viewreports', $context)) {
|
||||
$feedbacknode->add_node($analysisnode);
|
||||
$feedbacknode->add(get_string(($hassecondary ? 'responses' : 'show_entries'), 'feedback'),
|
||||
new moodle_url('/mod/feedback/show_entries.php', ['id' => $PAGE->cm->id]),
|
||||
navigation_node::TYPE_CUSTOM, null, 'responses');
|
||||
new moodle_url('/mod/feedback/show_entries.php', ['id' => $settings->get_page()->cm->id]),
|
||||
navigation_node::TYPE_CUSTOM, null, 'responses');
|
||||
|
||||
if ($feedback->anonymous == FEEDBACK_ANONYMOUS_NO AND $feedback->course != SITEID) {
|
||||
$feedbacknode->add(get_string('show_nonrespondents', 'feedback'),
|
||||
new moodle_url('/mod/feedback/show_nonrespondents.php', ['id' => $PAGE->cm->id]),
|
||||
navigation_node::TYPE_CUSTOM, null, 'nonrespondents');
|
||||
new moodle_url('/mod/feedback/show_nonrespondents.php', ['id' => $settings->get_page()->cm->id]),
|
||||
navigation_node::TYPE_CUSTOM, null, 'nonrespondents');
|
||||
}
|
||||
} else {
|
||||
$feedbackcompletion = new mod_feedback_completion($feedback, $context, $PAGE->course->id);
|
||||
$feedbackcompletion = new mod_feedback_completion($feedback, $context, $settings->get_page()->course->id);
|
||||
if ($feedbackcompletion->can_view_analysis()) {
|
||||
$feedbacknode->add_node($analysisnode);
|
||||
}
|
||||
|
@ -5473,29 +5473,29 @@ function forum_get_extra_capabilities() {
|
||||
* @param navigation_node $forumnode The node to add module settings to
|
||||
*/
|
||||
function forum_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $forumnode) {
|
||||
global $USER, $PAGE, $CFG, $DB, $OUTPUT;
|
||||
global $USER, $CFG;
|
||||
|
||||
if (empty($PAGE->cm->context)) {
|
||||
$PAGE->cm->context = context_module::instance($PAGE->cm->instance);
|
||||
if (empty($settingsnav->get_page()->cm->context)) {
|
||||
$settingsnav->get_page()->cm->context = context_module::instance($settingsnav->get_page()->cm->instance);
|
||||
}
|
||||
|
||||
$vaultfactory = mod_forum\local\container::get_vault_factory();
|
||||
$managerfactory = mod_forum\local\container::get_manager_factory();
|
||||
$legacydatamapperfactory = mod_forum\local\container::get_legacy_data_mapper_factory();
|
||||
$forumvault = $vaultfactory->get_forum_vault();
|
||||
$forumentity = $forumvault->get_from_id($PAGE->cm->instance);
|
||||
$forumentity = $forumvault->get_from_id($settingsnav->get_page()->cm->instance);
|
||||
$forumobject = $legacydatamapperfactory->get_forum_data_mapper()->to_legacy_object($forumentity);
|
||||
|
||||
$params = $PAGE->url->params();
|
||||
$params = $settingsnav->get_page()->url->params();
|
||||
if (!empty($params['d'])) {
|
||||
$discussionid = $params['d'];
|
||||
}
|
||||
|
||||
// For some actions you need to be enrolled, being admin is not enough sometimes here.
|
||||
$enrolled = is_enrolled($PAGE->cm->context, $USER, '', false);
|
||||
$activeenrolled = is_enrolled($PAGE->cm->context, $USER, '', true);
|
||||
$enrolled = is_enrolled($settingsnav->get_page()->context, $USER, '', false);
|
||||
$activeenrolled = is_enrolled($settingsnav->get_page()->context, $USER, '', true);
|
||||
|
||||
$canmanage = has_capability('mod/forum:managesubscriptions', $PAGE->cm->context);
|
||||
$canmanage = has_capability('mod/forum:managesubscriptions', $settingsnav->get_page()->context);
|
||||
$subscriptionmode = \mod_forum\subscriptions::get_subscription_mode($forumobject);
|
||||
$cansubscribe = $activeenrolled && !\mod_forum\subscriptions::is_forcesubscribed($forumobject) &&
|
||||
(!\mod_forum\subscriptions::subscription_disabled($forumobject) || $canmanage);
|
||||
@ -5598,7 +5598,7 @@ function forum_extend_settings_navigation(settings_navigation $settingsnav, navi
|
||||
}
|
||||
}
|
||||
|
||||
if (has_capability('mod/forum:viewsubscribers', $PAGE->cm->context)) {
|
||||
if (has_capability('mod/forum:viewsubscribers', $settingsnav->get_page()->context)) {
|
||||
$url = new moodle_url('/mod/forum/subscribers.php', ['id' => $forumobject->id, 'edit' => 'off']);
|
||||
$forumnode->add(get_string('subscriptions', 'forum'), $url, navigation_node::TYPE_SETTING, null, 'forumsubscriptions');
|
||||
}
|
||||
@ -5608,7 +5608,7 @@ function forum_extend_settings_navigation(settings_navigation $settingsnav, navi
|
||||
$reportnames = array_keys(core_component::get_plugin_list('forumreport'));
|
||||
|
||||
foreach ($reportnames as $reportname) {
|
||||
if (has_capability("forumreport/{$reportname}:view", $PAGE->cm->context)) {
|
||||
if (has_capability("forumreport/{$reportname}:view", $settingsnav->get_page()->context)) {
|
||||
$reportlinkparams = [
|
||||
'courseid' => $forumobject->course,
|
||||
'forumid' => $forumobject->id,
|
||||
@ -5635,13 +5635,14 @@ function forum_extend_settings_navigation(settings_navigation $settingsnav, navi
|
||||
}
|
||||
}
|
||||
|
||||
if (!isloggedin() && $PAGE->course->id == SITEID) {
|
||||
if (!isloggedin() && $settingsnav->get_page()->course->id == SITEID) {
|
||||
$userid = guest_user()->id;
|
||||
} else {
|
||||
$userid = $USER->id;
|
||||
}
|
||||
|
||||
$hascourseaccess = ($PAGE->course->id == SITEID) || can_access_course($PAGE->course, $userid);
|
||||
$hascourseaccess = ($settingsnav->get_page()->course->id == SITEID) ||
|
||||
can_access_course($settingsnav->get_page()->course, $userid);
|
||||
$enablerssfeeds = !empty($CFG->enablerssfeeds) && !empty($CFG->forum_enablerssfeeds);
|
||||
|
||||
if ($enablerssfeeds && $forumobject->rsstype && $forumobject->rssarticles && $hascourseaccess) {
|
||||
@ -5656,7 +5657,8 @@ function forum_extend_settings_navigation(settings_navigation $settingsnav, navi
|
||||
$string = get_string('rsssubscriberssposts','forum');
|
||||
}
|
||||
|
||||
$url = new moodle_url(rss_get_url($PAGE->cm->context->id, $userid, "mod_forum", $forumobject->id));
|
||||
$url = new moodle_url(rss_get_url($settingsnav->get_page()->cm->context->id, $userid, "mod_forum",
|
||||
$forumobject->id));
|
||||
$forumnode->add($string, $url, settings_navigation::TYPE_SETTING, null, null, new pix_icon('i/rss', ''));
|
||||
}
|
||||
|
||||
|
@ -3137,45 +3137,50 @@ function glossary_extend_navigation($navigation, $course, $module, $cm) {
|
||||
* @param navigation_node $glossarynode The node to add module settings to
|
||||
*/
|
||||
function glossary_extend_settings_navigation(settings_navigation $settings, navigation_node $glossarynode) {
|
||||
global $PAGE, $DB, $CFG, $USER;
|
||||
global $DB, $CFG, $USER;
|
||||
|
||||
$mode = optional_param('mode', '', PARAM_ALPHA);
|
||||
$hook = optional_param('hook', 'ALL', PARAM_CLEAN);
|
||||
|
||||
if (has_capability('mod/glossary:import', $PAGE->cm->context)) {
|
||||
if (has_capability('mod/glossary:import', $settings->get_page()->cm->context)) {
|
||||
$node = $glossarynode->add(get_string('importentries', 'glossary'),
|
||||
new moodle_url('/mod/glossary/import.php', ['id' => $PAGE->cm->id]));
|
||||
new moodle_url('/mod/glossary/import.php', ['id' => $settings->get_page()->cm->id]));
|
||||
$node->set_show_in_secondary_navigation(false);
|
||||
}
|
||||
|
||||
if (has_capability('mod/glossary:export', $PAGE->cm->context)) {
|
||||
if (has_capability('mod/glossary:export', $settings->get_page()->cm->context)) {
|
||||
$node = $glossarynode->add(get_string('exportentries', 'glossary'),
|
||||
new moodle_url('/mod/glossary/export.php', ['id' => $PAGE->cm->id, 'mode' => $mode, 'hook' => $hook]));
|
||||
new moodle_url('/mod/glossary/export.php', ['id' => $settings->get_page()->cm->id, 'mode' => $mode,
|
||||
'hook' => $hook]));
|
||||
$node->set_show_in_secondary_navigation(false);
|
||||
}
|
||||
|
||||
$glossary = $DB->get_record('glossary', array("id" => $PAGE->cm->instance));
|
||||
$hiddenentries = $DB->count_records('glossary_entries', ['glossaryid' => $PAGE->cm->instance, 'approved' => 0]);
|
||||
$glossary = $DB->get_record('glossary', array("id" => $settings->get_page()->cm->instance));
|
||||
$hiddenentries = $DB->count_records('glossary_entries', ['glossaryid' => $settings->get_page()->cm->instance,
|
||||
'approved' => 0]);
|
||||
|
||||
// Safe guard check - Ideally, there shouldn't be any hidden entries if the glossary has 'defaultapproval'.
|
||||
if (has_capability('mod/glossary:approve', $PAGE->cm->context) && (!$glossary->defaultapproval || $hiddenentries)) {
|
||||
if (has_capability('mod/glossary:approve', $settings->get_page()->cm->context) &&
|
||||
(!$glossary->defaultapproval || $hiddenentries)) {
|
||||
$glossarynode->add(get_string('pendingapproval', 'glossary'),
|
||||
new moodle_url('/mod/glossary/view.php', ['id' => $PAGE->cm->id, 'mode' => 'approval']),
|
||||
new moodle_url('/mod/glossary/view.php', ['id' => $settings->get_page()->cm->id, 'mode' => 'approval']),
|
||||
navigation_node::TYPE_CUSTOM, null, 'pendingapproval');
|
||||
}
|
||||
|
||||
if (has_capability('mod/glossary:write', $PAGE->cm->context)) {
|
||||
if (has_capability('mod/glossary:write', $settings->get_page()->cm->context)) {
|
||||
$node = $glossarynode->add(get_string('addentry', 'glossary'),
|
||||
new moodle_url('/mod/glossary/edit.php', ['cmid' => $PAGE->cm->id]));
|
||||
new moodle_url('/mod/glossary/edit.php', ['cmid' => $settings->get_page()->cm->id]));
|
||||
$node->set_show_in_secondary_navigation(false);
|
||||
}
|
||||
|
||||
if (!empty($CFG->enablerssfeeds) && !empty($CFG->glossary_enablerssfeeds) && $glossary->rsstype && $glossary->rssarticles && has_capability('mod/glossary:view', $PAGE->cm->context)) {
|
||||
if (!empty($CFG->enablerssfeeds) && !empty($CFG->glossary_enablerssfeeds) && $glossary->rsstype &&
|
||||
$glossary->rssarticles && has_capability('mod/glossary:view', $settings->get_page()->cm->context)) {
|
||||
require_once("$CFG->libdir/rsslib.php");
|
||||
|
||||
$string = get_string('rsstype', 'glossary');
|
||||
|
||||
$url = new moodle_url(rss_get_url($PAGE->cm->context->id, $USER->id, 'mod_glossary', $glossary->id));
|
||||
$url = new moodle_url(rss_get_url($settings->get_page()->cm->context->id, $USER->id, 'mod_glossary',
|
||||
$glossary->id));
|
||||
$node = $glossarynode->add($string, $url, settings_navigation::TYPE_SETTING, null, null, new pix_icon('i/rss', ''));
|
||||
$node->set_show_in_secondary_navigation(false);
|
||||
}
|
||||
|
@ -837,18 +837,19 @@ function h5pactivity_fetch_recent_activity(array $submissions, int $courseid) :
|
||||
*/
|
||||
function h5pactivity_extend_settings_navigation(settings_navigation $settingsnav,
|
||||
navigation_node $h5pactivitynode = null) {
|
||||
global $PAGE, $USER;
|
||||
global $USER;
|
||||
|
||||
$manager = manager::create_from_coursemodule($PAGE->cm);
|
||||
$manager = manager::create_from_coursemodule($settingsnav->get_page()->cm);
|
||||
|
||||
// Attempts report.
|
||||
if ($manager->can_view_all_attempts()) {
|
||||
$attemptsreporturl = new moodle_url('/mod/h5pactivity/report.php', ['a' => $PAGE->cm->instance]);
|
||||
$attemptsreporturl = new moodle_url('/mod/h5pactivity/report.php',
|
||||
['a' => $settingsnav->get_page()->cm->instance]);
|
||||
$h5pactivitynode->add(get_string('attempts_report', 'h5pactivity'), $attemptsreporturl,
|
||||
settings_navigation::TYPE_SETTING, '', 'attemptsreport');
|
||||
} else if ($manager->can_view_own_attempts() && $manager->count_attempts($USER->id)) {
|
||||
$attemptsreporturl = new moodle_url('/mod/h5pactivity/report.php',
|
||||
['a' => $PAGE->cm->instance, 'userid' => $USER->id]);
|
||||
['a' => $settingsnav->get_page()->cm->instance, 'userid' => $USER->id]);
|
||||
$h5pactivitynode->add(get_string('attempts_report', 'h5pactivity'), $attemptsreporturl,
|
||||
settings_navigation::TYPE_SETTING, '', 'attemptsreport');
|
||||
}
|
||||
|
@ -1019,9 +1019,7 @@ function lesson_supports($feature) {
|
||||
* @param settings_navigation $settings
|
||||
* @param navigation_node $lessonnode
|
||||
*/
|
||||
function lesson_extend_settings_navigation($settings, $lessonnode) {
|
||||
global $PAGE, $DB;
|
||||
|
||||
function lesson_extend_settings_navigation(settings_navigation $settings, navigation_node $lessonnode) {
|
||||
// We want to add these new nodes after the Edit settings node, and before the
|
||||
// Locally assigned roles node. Of course, both of those are controlled by capabilities.
|
||||
$keys = $lessonnode->get_children_key_list();
|
||||
@ -1033,17 +1031,18 @@ function lesson_extend_settings_navigation($settings, $lessonnode) {
|
||||
$beforekey = $keys[$i + 1];
|
||||
}
|
||||
|
||||
if (has_capability('mod/lesson:manageoverrides', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/mod/lesson/overrides.php', array('cmid' => $PAGE->cm->id, 'mode' => 'user'));
|
||||
if (has_capability('mod/lesson:manageoverrides', $settings->get_page()->cm->context)) {
|
||||
$url = new moodle_url('/mod/lesson/overrides.php', ['cmid' => $settings->get_page()->cm->id, 'mode' => 'user']);
|
||||
$node = navigation_node::create(get_string('overrides', 'lesson'), $url,
|
||||
navigation_node::TYPE_SETTING, null, 'mod_lesson_useroverrides');
|
||||
$lessonnode->add_node($node, $beforekey);
|
||||
}
|
||||
|
||||
if (has_capability('mod/lesson:viewreports', $PAGE->cm->context)) {
|
||||
if (has_capability('mod/lesson:viewreports', $settings->get_page()->cm->context)) {
|
||||
$reportsnode = $lessonnode->add(
|
||||
get_string('reports', 'lesson'),
|
||||
new moodle_url('/mod/lesson/report.php', ['id' => $PAGE->cm->id, 'action' => 'reportoverview'])
|
||||
new moodle_url('/mod/lesson/report.php', ['id' => $settings->get_page()->cm->id,
|
||||
'action' => 'reportoverview'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1705,8 +1705,8 @@ function quiz_get_extra_capabilities() {
|
||||
* @param navigation_node $quiznode
|
||||
* @return void
|
||||
*/
|
||||
function quiz_extend_settings_navigation($settings, $quiznode) {
|
||||
global $PAGE, $CFG;
|
||||
function quiz_extend_settings_navigation(settings_navigation $settings, navigation_node $quiznode) {
|
||||
global $CFG;
|
||||
|
||||
// Require {@link questionlib.php}
|
||||
// Included here as we only ever want to include this file if we really need to.
|
||||
@ -1723,25 +1723,24 @@ function quiz_extend_settings_navigation($settings, $quiznode) {
|
||||
$beforekey = $keys[$i + 1];
|
||||
}
|
||||
|
||||
if (has_any_capability(['mod/quiz:manageoverrides', 'mod/quiz:viewoverrides'], $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/mod/quiz/overrides.php', array('cmid' => $PAGE->cm->id, 'mode' => 'user'));
|
||||
if (has_any_capability(['mod/quiz:manageoverrides', 'mod/quiz:viewoverrides'], $settings->get_page()->cm->context)) {
|
||||
$url = new moodle_url('/mod/quiz/overrides.php', ['cmid' => $settings->get_page()->cm->id, 'mode' => 'user']);
|
||||
$node = navigation_node::create(get_string('overrides', 'quiz'),
|
||||
$url, navigation_node::TYPE_SETTING, null, 'mod_quiz_useroverrides');
|
||||
$quiznode->add_node($node, $beforekey);
|
||||
}
|
||||
|
||||
if (has_capability('mod/quiz:manage', $PAGE->cm->context)) {
|
||||
if (has_capability('mod/quiz:manage', $settings->get_page()->cm->context)) {
|
||||
$node = navigation_node::create(get_string('editquiz', 'quiz'),
|
||||
new moodle_url('/mod/quiz/edit.php', array('cmid'=>$PAGE->cm->id)),
|
||||
navigation_node::TYPE_SETTING, null, 'mod_quiz_edit',
|
||||
new pix_icon('t/edit', ''));
|
||||
new moodle_url('/mod/quiz/edit.php', array('cmid' => $settings->get_page()->cm->id)),
|
||||
navigation_node::TYPE_SETTING, null, 'mod_quiz_edit', new pix_icon('t/edit', ''));
|
||||
$editquiznode = $quiznode->add_node($node, $beforekey);
|
||||
$editquiznode->set_show_in_secondary_navigation(false);
|
||||
}
|
||||
|
||||
if (has_capability('mod/quiz:preview', $PAGE->cm->context)) {
|
||||
if (has_capability('mod/quiz:preview', $settings->get_page()->cm->context)) {
|
||||
$url = new moodle_url('/mod/quiz/startattempt.php',
|
||||
array('cmid'=>$PAGE->cm->id, 'sesskey'=>sesskey()));
|
||||
array('cmid' => $settings->get_page()->cm->id, 'sesskey' => sesskey()));
|
||||
$node = navigation_node::create(get_string('preview', 'quiz'), $url,
|
||||
navigation_node::TYPE_SETTING, null, 'mod_quiz_preview',
|
||||
new pix_icon('i/preview', ''));
|
||||
@ -1749,21 +1748,20 @@ function quiz_extend_settings_navigation($settings, $quiznode) {
|
||||
$previewnode->set_show_in_secondary_navigation(false);
|
||||
}
|
||||
|
||||
question_extend_settings_navigation($quiznode, $PAGE->cm->context)->trim_if_empty();
|
||||
question_extend_settings_navigation($quiznode, $settings->get_page()->cm->context)->trim_if_empty();
|
||||
|
||||
if (has_any_capability(array('mod/quiz:viewreports', 'mod/quiz:grade'), $PAGE->cm->context)) {
|
||||
if (has_any_capability(array('mod/quiz:viewreports', 'mod/quiz:grade'), $settings->get_page()->cm->context)) {
|
||||
require_once($CFG->dirroot . '/mod/quiz/report/reportlib.php');
|
||||
$reportlist = quiz_report_list($PAGE->cm->context);
|
||||
$reportlist = quiz_report_list($settings->get_page()->cm->context);
|
||||
|
||||
$url = new moodle_url('/mod/quiz/report.php',
|
||||
array('id' => $PAGE->cm->id, 'mode' => reset($reportlist)));
|
||||
array('id' => $settings->get_page()->cm->id, 'mode' => reset($reportlist)));
|
||||
$reportnode = $quiznode->add_node(navigation_node::create(get_string('results', 'quiz'), $url,
|
||||
navigation_node::TYPE_SETTING,
|
||||
null, null, new pix_icon('i/report', '')));
|
||||
|
||||
foreach ($reportlist as $report) {
|
||||
$url = new moodle_url('/mod/quiz/report.php',
|
||||
array('id' => $PAGE->cm->id, 'mode' => $report));
|
||||
$url = new moodle_url('/mod/quiz/report.php', ['id' => $settings->get_page()->cm->id, 'mode' => $report]);
|
||||
$reportnode->add_node(navigation_node::create(get_string($report, 'quiz_'.$report), $url,
|
||||
navigation_node::TYPE_SETTING,
|
||||
null, 'quiz_report_' . $report, new pix_icon('i/item', '')));
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
@ -807,14 +807,13 @@ function survey_supports($feature) {
|
||||
* 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
|
||||
* @param settings_navigation $settings
|
||||
* @param navigation_node $surveynode
|
||||
*/
|
||||
function survey_extend_settings_navigation($settings, $surveynode) {
|
||||
global $PAGE;
|
||||
|
||||
if (has_capability('mod/survey:readresponses', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/mod/survey/report.php', array('id' => $PAGE->cm->id, 'action' => 'summary'));
|
||||
function survey_extend_settings_navigation(settings_navigation $settings, navigation_node $surveynode) {
|
||||
if (has_capability('mod/survey:readresponses', $settings->get_page()->cm->context)) {
|
||||
$url = new moodle_url('/mod/survey/report.php', array('id' => $settings->get_page()->cm->id,
|
||||
'action' => 'summary'));
|
||||
$surveynode->add(get_string("responsereports", "survey"), $url);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,10 @@ information provided here is intended especially for developers.
|
||||
|
||||
=== 4.0 ===
|
||||
* A new API function introduced to handle custom completion logic. Refer to completion/upgrade.txt for additional information.
|
||||
* Modules that extend the settings navigation via '_extend_settings_navigation()' should use the get_page() method from
|
||||
the settings_navigation class in order to obtain the correct moodle_page information associated to the given settings
|
||||
navigation. After the recent changes to the navigation in single activity courses, using the global $PAGE may result
|
||||
in returning inaccurate data in this course format, therefore it is advisable to use $settingsnavigation->get_page().
|
||||
|
||||
=== 3.9 ===
|
||||
|
||||
|
@ -1628,17 +1628,13 @@ function workshop_extend_navigation(navigation_node $navref, stdclass $course, s
|
||||
* @param navigation_node $workshopnode {@link navigation_node}
|
||||
*/
|
||||
function workshop_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $workshopnode=null) {
|
||||
global $PAGE;
|
||||
|
||||
//$workshopobject = $DB->get_record("workshop", array("id" => $PAGE->cm->instance));
|
||||
|
||||
if (has_capability('mod/workshop:editdimensions', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/mod/workshop/editform.php', array('cmid' => $PAGE->cm->id));
|
||||
if (has_capability('mod/workshop:editdimensions', $settingsnav->get_page()->cm->context)) {
|
||||
$url = new moodle_url('/mod/workshop/editform.php', array('cmid' => $settingsnav->get_page()->cm->id));
|
||||
$workshopnode->add(get_string('assessmentform', 'workshop'), $url,
|
||||
settings_navigation::TYPE_SETTING, null, 'workshopassessement');
|
||||
}
|
||||
if (has_capability('mod/workshop:allocate', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/mod/workshop/allocation.php', array('cmid' => $PAGE->cm->id));
|
||||
if (has_capability('mod/workshop:allocate', $settingsnav->get_page()->cm->context)) {
|
||||
$url = new moodle_url('/mod/workshop/allocation.php', array('cmid' => $settingsnav->get_page()->cm->id));
|
||||
$workshopnode->add(get_string('submissionsallocation', 'workshop'), $url, settings_navigation::TYPE_SETTING);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user