Merge branch MDL-29187-master of git://github.com/samhemelryk/moodle
[moodle.git] / course / lib.php
index 84a8e3e..1a9b5e6 100644 (file)
@@ -2009,11 +2009,14 @@ function make_categories_list(&$list, &$parents, $requiredcapability = '',
             return;
         }
 
+        $context = get_context_instance(CONTEXT_COURSECAT, $category->id);
+        $categoryname = format_string($category->name, true, array('context' => $context));
+
         // Update $path.
         if ($path) {
-            $path = $path.' / '.format_string($category->name);
+            $path = $path.' / '.$categoryname;
         } else {
-            $path = format_string($category->name);
+            $path = $categoryname;
         }
 
         // Add this category to $list, if the permissions check out.
@@ -2021,9 +2024,8 @@ function make_categories_list(&$list, &$parents, $requiredcapability = '',
             $list[$category->id] = $path;
 
         } else {
-            ensure_context_subobj_present($category, CONTEXT_COURSECAT);
             $requiredcapability = (array)$requiredcapability;
-            if (has_all_capabilities($requiredcapability, $category->context)) {
+            if (has_all_capabilities($requiredcapability, $context)) {
                 $list[$category->id] = $path;
             }
         }
@@ -2196,11 +2198,14 @@ function print_category_info($category, $depth=0, $showcourses = false) {
     }
 
     $courses = get_courses($category->id, 'c.sortorder ASC', 'c.id,c.sortorder,c.visible,c.fullname,c.shortname,c.summary');
+    $context = get_context_instance(CONTEXT_COURSECAT, $category->id);
+    $fullname = format_string($category->name, true, array('context' => $context));
+
     if ($showcourses and $coursecount) {
         echo '<div class="categorylist clearfix">';
         $cat = '';
         $cat .= html_writer::tag('div', $catimage, array('class'=>'image'));
-        $catlink = html_writer::link(new moodle_url('/course/category.php', array('id'=>$category->id)), format_string($category->name), $catlinkcss);
+        $catlink = html_writer::link(new moodle_url('/course/category.php', array('id'=>$category->id)), $fullname, $catlinkcss);
         $cat .= html_writer::tag('div', $catlink, array('class'=>'name'));
 
         $html = '';
@@ -2258,7 +2263,7 @@ function print_category_info($category, $depth=0, $showcourses = false) {
     } else {
         echo '<div class="categorylist">';
         $html = '';
-        $cat = html_writer::link(new moodle_url('/course/category.php', array('id'=>$category->id)), format_string($category->name), $catlinkcss);
+        $cat = html_writer::link(new moodle_url('/course/category.php', array('id'=>$category->id)), $fullname, $catlinkcss);
         $cat .= html_writer::tag('span', ' ('.count($courses).')', array('title'=>get_string('numberofcourses'), 'class'=>'numberofcourse'));
 
         if ($depth > 0) {