diff --git a/admin/settings/appearance.php b/admin/settings/appearance.php
index 1278df2..0f6da7e 100644
--- a/admin/settings/appearance.php
+++ b/admin/settings/appearance.php
@@ -13,6 +13,12 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
$temp->add(new admin_setting_configcheckbox('allowcategorythemes', get_string('allowcategorythemes', 'admin'), get_string('configallowcategorythemes', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('allowuserblockhiding', get_string('allowuserblockhiding', 'admin'), get_string('configallowuserblockhiding', 'admin'), 1));
$temp->add(new admin_setting_configcheckbox('showblocksonmodpages', get_string('showblocksonmodpages', 'admin'), get_string('configshowblocksonmodpages', 'admin'), 0));
+ $temp->add(new admin_setting_configselect('hidecategorynavlink', get_string('hidecategorynavlink', 'admin'), get_string('confighidecategorynavlink', 'admin'), 0,
+ array(
+ 0 => get_string('hidefromnone', 'admin'),
+ 1 => get_string('hidefromstudents', 'admin'),
+ 2 => get_string('hidefromall', 'admin')
+ )));
$temp->add(new admin_setting_configselect('hideactivitytypenavlink', get_string('hideactivitytypenavlink', 'admin'), get_string('confighideactivitytypenavlink', 'admin'), 0,
array(
0 => get_string('hidefromnone', 'admin'),
diff --git a/course/category.php b/course/category.php
index 91bc446..d0a3664 100644
--- a/course/category.php
+++ b/course/category.php
@@ -85,8 +85,14 @@
$strcourses = get_string('courses');
$navlinks = array();
- $navlinks[] = array('name' => $strcategories, 'link' => 'index.php', 'type' => 'misc');
- $navlinks[] = array('name' => format_string($category->name), 'link' => null, 'type' => 'misc');
+ $cattype = $category->visible ? "category" : "hiddencategory";
+ $navlinks[] = array('name' => format_string($category->name), 'link' => null, 'type' => $cattype);
+ $cattree = clone($category);
+ while ($cattree->parent) {
+ $cattree = get_record("course_categories", "id", $cattree->parent);
+ $cattype = $cattree->visible ? "category" : "hiddencategory";
+ array_unshift($navlinks, array('name' => format_string($cattree->name), 'link' => "category.php?id=$cattree->id", 'type' => $cattype));
+ }
$navigation = build_navigation($navlinks);
if ($editingon && update_category_button()) {
diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php
index e78f6ac..c4eb5c1 100644
--- a/lang/en_utf8/admin.php
+++ b/lang/en_utf8/admin.php
@@ -144,6 +144,7 @@ $string['configgradeexport'] = 'Choose which gradebook export formats are your p
$string['configguestroleid'] = 'This role is automatically assigned to the guest user. It is also temporarily assigned to not enrolled users when they enter course that allows guests without password. Please verify that the role has moodle/legacy:guest and moodle/course:view capability.';
$string['confighiddenuserfields'] = 'Select which user information fields you wish to hide from other users other than course teachers/admins. This will increase student privacy. Hold CTRL key to select multiple fields.';
$string['confighideactivitytypenavlink'] = 'Select from whom to hide the activity type (e.g. Quizzes) link in the navigation displayed for activity modules.';
+$string['confighidecategorynavlink'] = 'Select from whom to hide the category (e.g. Miscellaneous) link in the navigation menu.';
$string['confightmleditor'] = 'Choose whether or not to allow use of the embedded HTML text editor. Even if you choose allow, this editor will only appear when the user is using a compatible web browser. Users can also choose not to use it.';
$string['configidnumber'] = 'This option specifies whether (a) Users are not be asked for an ID number at all, (b) Users are asked for an ID number but can leave it blank or (c) Users are asked for an ID Number and cannot leave it blank. If given the User\'s ID number is displayed in their Profile.';
$string['configintcachemax'] = 'For internal cache only. Maximum number of records to keep in the cache. Recommended value: 50. Use lower values to reduce memory usage.';
@@ -424,6 +425,7 @@ $string['helpupcomingmaxevents'] = 'How many (maximum) upcoming events are shown
$string['helpweekenddays'] = 'Which days of the week are treated as \"weekend\" and shown with a different colour?';
$string['hiddenuserfields'] = 'Hide user fields';
$string['hideactivitytypenavlink'] = 'Hide activity type navigation';
+$string['hidecategorynavlink'] = 'Hide category navigation';
$string['hidefromall'] = 'Hide from all users';
$string['hidefromnone'] = 'Hide from nobody';
$string['hidefromstudents'] = 'Hide from students';
diff --git a/lib/weblib.php b/lib/weblib.php
index 6c4b15e..ae69295 100644
--- a/lib/weblib.php
+++ b/lib/weblib.php
@@ -3788,6 +3788,37 @@ function build_navigation($extranavlinks, $cm = null) {
'type' => 'home');
}
+ if (!isset($CFG->hidecategorynavlink)) {
+ // use default = show
+ $CFG->hidecategorynavlink = 0;
+ }
+ if ($CFG->hidecategorynavlink == 0) {
+ // Hide from nobody
+ $showcategory = true;
+ }
+ if ($CFG->hidecategorynavlink == 1) {
+ // Hide from students
+ $showcategory = !has_capability('moodle/course:view', get_context_instance(CONTEXT_COURSE, $COURSE->id), '', false);
+ }
+ if ($CFG->hidecategorynavlink == 2) {
+ // Hide from all users
+ $showcategory = false;
+ }
+
+ if (isset($COURSE) && $showcategory && $COURSE->id != SITEID) {
+ $catlinks = array();
+ if ($cattree = get_record("course_categories", "id", $COURSE->category)) {
+ $cattype = $cattree->visible ? "category" : "hiddencategory";
+ $catlinks[] = array('name' => $cattree->name, 'link' => "category.php?id=$cattree->id", 'type' => $cattype);
+ while ($cattree->parent) {
+ $cattree = get_record("course_categories", "id", $cattree->parent);
+ $cattype = $cattree->visible ? "category" : "hiddencategory";
+ array_unshift($catlinks, array('name' => $cattree->name, 'link' => "category.php?id=$cattree->id", 'type' => $cattype));
+ }
+ }
+ $navlinks = array_merge($navlinks, $catlinks);
+ }
+
// Course name, if appropriate.
if (isset($COURSE) && $COURSE->id != SITEID) {
$navlinks[] = array(
@@ -3866,7 +3897,11 @@ function build_navigation($extranavlinks, $cm = null) {
$navigation .= get_separator();
}
if ((!empty($navlink['link'])) && !$last) {
- $navigation .= "framename'\" href=\"{$navlink['link']}\">";
+ if ($navlink['type'] == 'hiddencategory') {
+ $navigation .= "framename'\" href=\"{$navlink['link']}\">";
+ } else {
+ $navigation .= "framename'\" href=\"{$navlink['link']}\">";
+ }
}
$navigation .= "{$navlink['name']}";
if ((!empty($navlink['link'])) && !$last) {