From d20337f180a716ce95a936c8ca0fb818b11590fe Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Thu, 24 Jan 2013 09:29:25 +1300 Subject: [PATCH] MDL-37644 navigation: new option to display course full names --- admin/settings/appearance.php | 1 + lang/en/admin.php | 2 ++ lib/navigationlib.php | 9 ++++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/admin/settings/appearance.php b/admin/settings/appearance.php index da078d78247..f3f63c91e39 100644 --- a/admin/settings/appearance.php +++ b/admin/settings/appearance.php @@ -110,6 +110,7 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page ); $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 df948f3dc49..c1c536c4cb2 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -737,6 +737,8 @@ $string['navadduserpostslinks'] = 'Add links to view user posts'; $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 93a3518cb2d..c43c6e46f3e 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -2339,12 +2339,15 @@ class global_navigation extends navigation_node { $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 @@ class global_navigation extends navigation_node { } } - $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; }