diff --git a/admin/settings/appearance.php b/admin/settings/appearance.php index da078d7824761..f3f63c91e394b 100644 --- a/admin/settings/appearance.php +++ b/admin/settings/appearance.php @@ -110,6 +110,7 @@ ); $temp->add(new admin_setting_configselect('defaulthomepage', new lang_string('defaulthomepage', 'admin'), new lang_string('configdefaulthomepage', 'admin'), HOMEPAGE_SITE, $choices)); $temp->add(new admin_setting_configcheckbox('allowguestmymoodle', new lang_string('allowguestmymoodle', 'admin'), new lang_string('configallowguestmymoodle', 'admin'), 1)); + $temp->add(new admin_setting_configcheckbox('navshowfullcoursenames', new lang_string('navshowfullcoursenames', 'admin'), new lang_string('navshowfullcoursenames_help', 'admin'), 0)); $temp->add(new admin_setting_configcheckbox('navshowcategories', new lang_string('navshowcategories', 'admin'), new lang_string('confignavshowcategories', 'admin'), 1)); $temp->add(new admin_setting_configcheckbox('navshowmycoursecategories', new lang_string('navshowmycoursecategories', 'admin'), new lang_string('navshowmycoursecategories_help', 'admin'), 0)); $temp->add(new admin_setting_configcheckbox('navshowallcourses', new lang_string('navshowallcourses', 'admin'), new lang_string('confignavshowallcourses', 'admin'), 0)); diff --git a/lang/en/admin.php b/lang/en/admin.php index df948f3dc4974..c1c536c4cb206 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -737,6 +737,8 @@ $string['navadduserpostslinks_help'] = 'If enabled two links will be added to each user in the navigation to view discussions the user has started and posts the user has made in forums throughout the site or in specific courses.'; $string['navigationupgrade'] = 'This upgrade introduces two new navigation blocks that will replace these blocks: Administration, Courses, Activities and Participants. If you had set any special permissions on those blocks you should check to make sure everything is behaving as you want it.'; $string['navcourselimit'] = 'Course limit'; +$string['navshowfullcoursenames'] = 'Show course full names'; +$string['navshowfullcoursenames_help'] = 'If enabled courses in the navigation will be shown with using their full name rather than their short name.'; $string['navshowfrontpagemods'] = 'Show front page activities in the navigation'; $string['navshowfrontpagemods_help'] = 'If enabled, front page activities will be shown on the navigation under site pages.'; $string['navshowallcourses'] = 'Show all courses'; diff --git a/lib/navigationlib.php b/lib/navigationlib.php index 93a3518cb2d0e..c43c6e46f3e5d 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -2339,12 +2339,15 @@ public function add_course(stdClass $course, $forcegeneric = false, $coursetype $issite = ($course->id == $SITE->id); $shortname = format_string($course->shortname, true, array('context' => $coursecontext)); + $fullname = format_string($course->fullname, true, array('context' => $coursecontext)); + // This is the name that will be shown for the course. + $coursename = empty($CFG->navshowfullcoursenames) ? $shortname : $fullname; if ($issite) { $parent = $this; $url = null; if (empty($CFG->usesitenameforsitepages)) { - $shortname = get_string('sitepages'); + $coursename = get_string('sitepages'); } } else if ($coursetype == self::COURSE_CURRENT) { $parent = $this->rootnodes['currentcourse']; @@ -2374,10 +2377,10 @@ public function add_course(stdClass $course, $forcegeneric = false, $coursetype } } - $coursenode = $parent->add($shortname, $url, self::TYPE_COURSE, $shortname, $course->id); + $coursenode = $parent->add($coursename, $url, self::TYPE_COURSE, $shortname, $course->id); $coursenode->nodetype = self::NODETYPE_BRANCH; $coursenode->hidden = (!$course->visible); - $coursenode->title(format_string($course->fullname, true, array('context' => context_course::instance($course->id)))); + $coursenode->title($fullname); if (!$forcegeneric) { $this->addedcourses[$course->id] = $coursenode; }