mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-73743 navigation: Add more nav nodes to site home
This commit is contained in:
parent
e94167174a
commit
25699339d9
@ -57,7 +57,7 @@ function tool_monitor_extend_navigation_frontpage($navigation, $course, $context
|
|||||||
$url = new moodle_url('/admin/tool/monitor/managerules.php', array('courseid' => $course->id));
|
$url = new moodle_url('/admin/tool/monitor/managerules.php', array('courseid' => $course->id));
|
||||||
$settingsnode = navigation_node::create(get_string('managerules', 'tool_monitor'), $url, navigation_node::TYPE_SETTING,
|
$settingsnode = navigation_node::create(get_string('managerules', 'tool_monitor'), $url, navigation_node::TYPE_SETTING,
|
||||||
null, null, new pix_icon('i/settings', ''));
|
null, null, new pix_icon('i/settings', ''));
|
||||||
$reportnode = $navigation->get('frontpagereports');
|
$reportnode = $navigation->get('coursereports');
|
||||||
|
|
||||||
if (isset($settingsnode) && !empty($reportnode)) {
|
if (isset($settingsnode) && !empty($reportnode)) {
|
||||||
$reportnode->add_node($settingsnode);
|
$reportnode->add_node($settingsnode);
|
||||||
|
@ -364,6 +364,8 @@ class secondary extends view {
|
|||||||
* node by default.
|
* node by default.
|
||||||
*/
|
*/
|
||||||
protected function load_course_navigation(?navigation_node $rootnode = null): void {
|
protected function load_course_navigation(?navigation_node $rootnode = null): void {
|
||||||
|
global $SITE;
|
||||||
|
|
||||||
$rootnode = $rootnode ?? $this;
|
$rootnode = $rootnode ?? $this;
|
||||||
$course = $this->page->course;
|
$course = $this->page->course;
|
||||||
// Initialise the main navigation and settings nav.
|
// Initialise the main navigation and settings nav.
|
||||||
@ -372,7 +374,15 @@ class secondary extends view {
|
|||||||
$navigation = $this->page->navigation;
|
$navigation = $this->page->navigation;
|
||||||
|
|
||||||
$url = new \moodle_url('/course/view.php', ['id' => $course->id]);
|
$url = new \moodle_url('/course/view.php', ['id' => $course->id]);
|
||||||
$rootnode->add(get_string('course'), $url, self::TYPE_COURSE, null, 'coursehome');
|
$firstnodeidentifier = get_string('course');
|
||||||
|
$issitecourse = $course->id == $SITE->id;
|
||||||
|
if ($issitecourse) {
|
||||||
|
$firstnodeidentifier = get_string('home');
|
||||||
|
if ($frontpage = $settingsnav->get('frontpage')) {
|
||||||
|
$settingsnav = $frontpage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$rootnode->add($firstnodeidentifier, $url, self::TYPE_COURSE, null, 'coursehome');
|
||||||
|
|
||||||
$nodes = $this->get_default_course_mapping();
|
$nodes = $this->get_default_course_mapping();
|
||||||
$nodesordered = $this->get_leaf_nodes($settingsnav, $nodes['settings'] ?? []);
|
$nodesordered = $this->get_leaf_nodes($settingsnav, $nodes['settings'] ?? []);
|
||||||
@ -381,17 +391,19 @@ class secondary extends view {
|
|||||||
|
|
||||||
// Try to get any custom nodes defined by a user which may include containers.
|
// Try to get any custom nodes defined by a user which may include containers.
|
||||||
$expectedcourseadmin = $this->get_expected_course_admin_nodes();
|
$expectedcourseadmin = $this->get_expected_course_admin_nodes();
|
||||||
|
$courseadminnode = $settingsnav;
|
||||||
|
if (!$issitecourse) {
|
||||||
|
$courseadminnode = $settingsnav->get('courseadmin');
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($settingsnav->children as $value) {
|
if ($courseadminnode) {
|
||||||
if ($value->key == 'courseadmin') {
|
foreach ($courseadminnode->children as $other) {
|
||||||
foreach ($value->children as $other) {
|
if (array_search($other->key, $expectedcourseadmin) === false) {
|
||||||
if (array_search($other->key, $expectedcourseadmin) === false) {
|
$othernode = $this->get_first_action_for_node($other);
|
||||||
$othernode = $this->get_first_action_for_node($other);
|
$recursivenode = $othernode && !$this->get($othernode->key) ? $othernode : $other;
|
||||||
$recursivenode = $othernode && !$this->get($othernode->key) ? $othernode : $other;
|
// Get the first node and check whether it's been added already.
|
||||||
// Get the first node and check whether it's been added already.
|
// Also check if the first node is an external link. If it is, add all children.
|
||||||
// Also check if the first node is an external link. If it is, add all children.
|
$this->add_external_nodes_to_secondary($recursivenode, $recursivenode);
|
||||||
$this->add_external_nodes_to_secondary($recursivenode, $recursivenode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -429,7 +441,7 @@ class secondary extends view {
|
|||||||
|
|
||||||
// Start with getting the base node for the front page or the course.
|
// Start with getting the base node for the front page or the course.
|
||||||
$node = null;
|
$node = null;
|
||||||
if ($this->page->course == $SITE->id) {
|
if ($this->page->course->id == $SITE->id) {
|
||||||
$node = $this->page->settingsnav->find('frontpage', navigation_node::TYPE_SETTING);
|
$node = $this->page->settingsnav->find('frontpage', navigation_node::TYPE_SETTING);
|
||||||
} else {
|
} else {
|
||||||
$node = $this->page->settingsnav->find('courseadmin', navigation_node::TYPE_COURSE);
|
$node = $this->page->settingsnav->find('courseadmin', navigation_node::TYPE_COURSE);
|
||||||
|
@ -2961,7 +2961,8 @@ class global_navigation extends navigation_node {
|
|||||||
|
|
||||||
// Participants.
|
// Participants.
|
||||||
if ($navoptions->participants) {
|
if ($navoptions->participants) {
|
||||||
$coursenode->add(get_string('participants'), new moodle_url('/user/index.php?id='.$course->id), self::TYPE_CUSTOM, get_string('participants'), 'participants');
|
$coursenode->add(get_string('participants'), new moodle_url('/user/index.php?id='.$course->id),
|
||||||
|
self::TYPE_CUSTOM, get_string('participants'), 'participants');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Blogs.
|
// Blogs.
|
||||||
@ -5517,7 +5518,8 @@ class settings_navigation extends navigation_node {
|
|||||||
if ($adminoptions->update) {
|
if ($adminoptions->update) {
|
||||||
// Add the course settings link
|
// Add the course settings link
|
||||||
$url = new moodle_url('/admin/settings.php', array('section'=>'frontpagesettings'));
|
$url = new moodle_url('/admin/settings.php', array('section'=>'frontpagesettings'));
|
||||||
$frontpage->add(get_string('editsettings'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/settings', ''));
|
$frontpage->add(get_string('settings'), $url, self::TYPE_SETTING, null,
|
||||||
|
'editsettings', new pix_icon('i/settings', ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
// add enrol nodes
|
// add enrol nodes
|
||||||
@ -5526,12 +5528,15 @@ class settings_navigation extends navigation_node {
|
|||||||
// Manage filters
|
// Manage filters
|
||||||
if ($adminoptions->filters) {
|
if ($adminoptions->filters) {
|
||||||
$url = new moodle_url('/filter/manage.php', array('contextid'=>$coursecontext->id));
|
$url = new moodle_url('/filter/manage.php', array('contextid'=>$coursecontext->id));
|
||||||
$frontpage->add(get_string('filters', 'admin'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/filter', ''));
|
$frontpage->add(get_string('filters', 'admin'), $url, self::TYPE_SETTING,
|
||||||
|
null, 'filtermanagement', new pix_icon('i/filter', ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
// View course reports.
|
// View course reports.
|
||||||
if ($adminoptions->reports) {
|
if ($adminoptions->reports) {
|
||||||
$frontpagenav = $frontpage->add(get_string('reports'), null, self::TYPE_CONTAINER, null, 'frontpagereports',
|
$frontpagenav = $frontpage->add(get_string('reports'), new moodle_url('/report/view.php',
|
||||||
|
['courseid' => $coursecontext->instanceid]),
|
||||||
|
self::TYPE_CONTAINER, null, 'coursereports',
|
||||||
new pix_icon('i/stats', ''));
|
new pix_icon('i/stats', ''));
|
||||||
$coursereports = core_component::get_plugin_list('coursereport');
|
$coursereports = core_component::get_plugin_list('coursereport');
|
||||||
foreach ($coursereports as $report=>$dir) {
|
foreach ($coursereports as $report=>$dir) {
|
||||||
@ -5554,13 +5559,13 @@ class settings_navigation extends navigation_node {
|
|||||||
// Backup this course
|
// Backup this course
|
||||||
if ($adminoptions->backup) {
|
if ($adminoptions->backup) {
|
||||||
$url = new moodle_url('/backup/backup.php', array('id'=>$course->id));
|
$url = new moodle_url('/backup/backup.php', array('id'=>$course->id));
|
||||||
$frontpage->add(get_string('backup'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/backup', ''));
|
$frontpage->add(get_string('backup'), $url, self::TYPE_SETTING, null, 'backup', new pix_icon('i/backup', ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore to this course
|
// Restore to this course
|
||||||
if ($adminoptions->restore) {
|
if ($adminoptions->restore) {
|
||||||
$url = new moodle_url('/backup/restorefile.php', array('contextid'=>$coursecontext->id));
|
$url = new moodle_url('/backup/restorefile.php', array('contextid'=>$coursecontext->id));
|
||||||
$frontpage->add(get_string('restore'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/restore', ''));
|
$frontpage->add(get_string('restore'), $url, self::TYPE_SETTING, null, 'restore', new pix_icon('i/restore', ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Questions
|
// Questions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user