Permalink
Browse files

MDL-37644 navigation: new option to display course full names

  • Loading branch information...
1 parent b3778a0 commit d20337f180a716ce95a936c8ca0fb818b11590fe Sam Hemelryk committed Jan 23, 2013
Showing with 9 additions and 3 deletions.
  1. +1 −0 admin/settings/appearance.php
  2. +2 −0 lang/en/admin.php
  3. +6 −3 lib/navigationlib.php
View
1 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));
View
2 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';
View
9 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;
}

0 comments on commit d20337f

Please sign in to comment.