Skip to content

Commit

Permalink
MDL-37644 navigation: new option to display course full names
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Hemelryk committed Jan 27, 2013
1 parent b3778a0 commit d20337f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions admin/settings/appearance.php
Expand Up @@ -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));
Expand Down
2 changes: 2 additions & 0 deletions lang/en/admin.php
Expand Up @@ -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';
Expand Down
9 changes: 6 additions & 3 deletions lib/navigationlib.php
Expand Up @@ -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'];
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit d20337f

Please sign in to comment.