Merge branch MDL-29187-master of git://github.com/samhemelryk/moodle
authorAparup Banerjee <aparup@moodle.com>
Tue, 13 Sep 2011 05:52:31 +0000 (13:52 +0800)
committerAparup Banerjee <aparup@moodle.com>
Tue, 13 Sep 2011 05:52:31 +0000 (13:52 +0800)
  - resolved conflict.

backup/util/ui/renderer.php
blocks/course_list/block_course_list.php
course/category.php
course/delete.php
course/delete_category_form.php
course/index.php
course/lib.php
course/renderer.php
lib/accesslib.php
lib/navigationlib.php
mod/feedback/item/info/lib.php

index 9b891a6..b8237b1 100644 (file)
@@ -629,7 +629,7 @@ class core_backup_renderer extends plugin_renderer_base {
                 }
                 $row->cells = array(
                     html_writer::empty_tag('input', array('type'=>'radio', 'name'=>'targetid', 'value'=>$category->id)),
-                    $category->name,
+                    format_string($category->name, true, array('context' => get_context_instance(CONTEXT_COURSECAT, $category->id))),
                     format_text($category->description, $category->descriptionformat, array('overflowdiv'=>true))
                 );
                 $table->data[] = $row;
index e835657..3c773a6 100644 (file)
@@ -57,8 +57,9 @@ class block_course_list extends block_list {
         if ($categories) {   //Check we have categories
             if (count($categories) > 1 || (count($categories) == 1 && $DB->count_records('course') > 200)) {     // Just print top level category links
                 foreach ($categories as $category) {
+                    $categoryname = format_string($category->name, true, array('context' => get_context_instance(CONTEXT_COURSECAT, $category->id)));
                     $linkcss = $category->visible ? "" : " class=\"dimmed\" ";
-                    $this->content->items[]="<a $linkcss href=\"$CFG->wwwroot/course/category.php?id=$category->id\">".$icon . format_string($category->name) . "</a>";
+                    $this->content->items[]="<a $linkcss href=\"$CFG->wwwroot/course/category.php?id=$category->id\">".$icon . $categoryname . "</a>";
                 }
             /// If we can update any course of the view all isn't hidden, show the view all courses link
                 if (has_capability('moodle/course:update', get_context_instance(CONTEXT_SYSTEM)) || empty($CFG->block_course_list_hideallcourseslink)) {
@@ -77,7 +78,7 @@ class block_course_list extends block_list {
                         $this->content->items[]="<a $linkcss title=\""
                                    . format_string($course->shortname, true, array('context' => $coursecontext))."\" ".
                                    "href=\"$CFG->wwwroot/course/view.php?id=$course->id\">"
-                                   .$icon. format_string($course->fullname) . "</a>";
+                                   .$icon. format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))) . "</a>";
                     }
                 /// If we can update any course of the view all isn't hidden, show the view all courses link
                     if (has_capability('moodle/course:update', get_context_instance(CONTEXT_SYSTEM)) || empty($CFG->block_course_list_hideallcourseslink)) {
index 12558aa..9ed7ebc 100644 (file)
                 }
                 $catlinkcss = $subcategory->visible ? '' : ' class="dimmed" ';
                 echo '<a '.$catlinkcss.' href="category.php?id='.$subcategory->id.'">'.
-                     format_string($subcategory->name).'</a><br />';
+                     format_string($subcategory->name, true, array('context' => get_context_instance(CONTEXT_COURSECAT, $subcategory->id))).'</a><br />';
             }
         }
         if (!$firstentry) {
index 3a4eb2f..b0c1c31 100644 (file)
 
     $category = $DB->get_record("course_categories", array("id"=>$course->category));
     $courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
+    $categoryname = format_string($category->name, true, array('context' => get_context_instance(CONTEXT_COURSECAT, $category->id)));
 
     $PAGE->navbar->add($stradministration, new moodle_url('/admin/index.php/'));
     $PAGE->navbar->add($strcategories, new moodle_url('/course/index.php'));
-    $PAGE->navbar->add($category->name, new moodle_url('/course/category.php', array('id'=>$course->category)));
+    $PAGE->navbar->add($categoryname, new moodle_url('/course/category.php', array('id'=>$course->category)));
     if (! $delete) {
         $strdeletecheck = get_string("deletecheck", "", $courseshortname);
         $strdeletecoursecheck = get_string("deletecoursecheck");
index 7681bff..f2d394c 100644 (file)
@@ -78,11 +78,11 @@ class delete_category_form extends moodleform {
         }
 
     /// Now build the form.
-        $mform->addElement('header','general', get_string('categorycurrentcontents', '', format_string($category->name)));
+        $mform->addElement('header','general', get_string('categorycurrentcontents', '', format_string($category->name, true, array('context' => $categorycontext))));
 
         if ($containscourses || $containscategories || $containsquestions) {
             if (empty($options)) {
-                print_error('youcannotdeletecategory', 'error', 'index.php', format_string($category->name));
+                print_error('youcannotdeletecategory', 'error', 'index.php', format_string($category->name, true, array('context' => $categorycontext)));
             }
 
         /// Describe the contents of this category.
index b1998ef..f0a0c10 100644 (file)
@@ -125,7 +125,7 @@ if (!empty($delete) and confirm_sesskey()) {
     require_capability('moodle/category:manage', $context);
     require_capability('moodle/category:manage', get_category_or_system_context($deletecat->parent));
 
-    $heading = get_string('deletecategory', 'moodle', format_string($deletecat->name));
+    $heading = get_string('deletecategory', 'moodle', format_string($deletecat->name, true, array('context' => $context)));
     require_once('delete_category_form.php');
     $mform = new delete_category_form(null, $deletecat);
     $mform->set_data(array('delete'=>$delete));
@@ -151,7 +151,7 @@ if (!empty($delete) and confirm_sesskey()) {
         foreach($deletedcourses as $course) {
             echo $OUTPUT->notification(get_string('coursedeleted', '', $course->shortname), 'notifysuccess');
         }
-        echo $OUTPUT->notification(get_string('coursecategorydeleted', '', format_string($deletecat->name)), 'notifysuccess');
+        echo $OUTPUT->notification(get_string('coursecategorydeleted', '', format_string($deletecat->name, true, array('context' => $context))), 'notifysuccess');
 
     } else {
         category_delete_move($deletecat, $data->newparent, true);
@@ -315,7 +315,7 @@ function print_category_edit($category, $displaylist, $parentslist, $depth=-1, $
         $linkcss = $category->visible ? '' : ' class="dimmed" ';
         echo '<a '.$linkcss.' title="'.$str->edit.'" '.
              ' href="category.php?id='.$category->id.'&amp;categoryedit=on&amp;sesskey='.sesskey().'">'.
-             format_string($category->name).'</a>';
+             format_string($category->name, true, array('context' => $category->context)).'</a>';
         echo '</td>';
 
         echo '<td class="count">'.$category->coursecount.'</td>';
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) {
index 07b7bc5..3e9898c 100644 (file)
@@ -107,9 +107,11 @@ class core_course_renderer extends plugin_renderer_base {
                 $classes[] = 'collapsed';
             }
         }
+        $categoryname = format_string($category->name, true, array('context' => get_context_instance(CONTEXT_COURSECAT, $category->id)));
+
         $content .= html_writer::start_tag('div', array('class'=>join(' ', $classes)));
         $content .= html_writer::start_tag('div', array('class'=>'category_label'));
-        $content .= html_writer::link(new moodle_url('/course/category.php', array('id'=>$category->id)), $category->name, array('class'=>'category_link'));
+        $content .= html_writer::link(new moodle_url('/course/category.php', array('id'=>$category->id)), $categoryname, array('class'=>'category_link'));
         $content .= html_writer::end_tag('div');
         if ($hassubcategories) {
             $content .= html_writer::start_tag('div', array('class'=>'subcategories'));
index 2eea1e5..a2b50e2 100644 (file)
@@ -3584,7 +3584,7 @@ function print_context_name($context, $withprefix = true, $short = false) {
                 if ($withprefix){
                     $name = get_string('category').': ';
                 }
-                $name .=format_string($category->name);
+                $name .= format_string($category->name, true, array('context' => $context));
             }
             break;
 
index 382c003..71d735c 100644 (file)
@@ -1510,7 +1510,9 @@ class global_navigation extends navigation_node {
             continue;
         }
         $url = new moodle_url('/course/category.php', array('id' => $category->id));
-        $categorynode = $parent->add($category->name, $url, self::TYPE_CATEGORY, $category->name, $category->id);
+        $context = get_context_instance(CONTEXT_COURSECAT, $category->id);
+        $categoryname = format_string($category->name, true, array('context' => $context));
+        $categorynode = $parent->add($categoryname, $url, self::TYPE_CATEGORY, $categoryname, $category->id);
         if (empty($category->visible)) {
             if (has_capability('moodle/category:viewhiddencategories', get_system_context())) {
                 $categorynode->hidden = true;
index 4f2395a..cefe000 100644 (file)
@@ -188,7 +188,7 @@ class feedback_item_info extends feedback_item_base {
                 $itemshowvalue = $itemvalue;
                 break;
             case 3:
-                $itemvalue = $coursecategory->name;
+                $itemvalue = format_string($coursecategory->name, true, array('context' => get_context_instance(CONTEXT_COURSECAT, $coursecategory->id)));
                 $itemshowvalue = $itemvalue;
                 break;
         }
@@ -245,7 +245,7 @@ class feedback_item_info extends feedback_item_base {
                 $itemshowvalue = $itemvalue;
                 break;
             case 3:
-                $itemvalue = $coursecategory->name;
+                $itemvalue = format_string($coursecategory->name, true, array('context' => get_context_instance(CONTEXT_COURSECAT, $coursecategory->id)));
                 $itemshowvalue = $itemvalue;
                 break;
         }