diff --git a/admin/handlevirus.php b/admin/handlevirus.php
index 0ddfeaa2258..9e32cc0b653 100644
--- a/admin/handlevirus.php
+++ b/admin/handlevirus.php
@@ -39,13 +39,17 @@ while(!feof($fd)) {
$action = clam_handle_infected_file($file,$log->userid,true);
clam_replace_infected_file($file);
+ list($ctxselect, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
+ $sql = "SELECT c.id, c.fullname $ctxselect FROM {course} c $ctxjoin WHERE c.id = :courseid";
+ $course = $DB->get_record_sql($sql, array('courseid' => $log->course));
+ context_instance_preload($course);
+
$user = $DB->get_record("user", array("id"=>$log->userid));
- $course = $DB->get_record("course", array("id"=>$log->course));
$subject = get_string('virusfoundsubject','moodle',format_string($site->fullname));
$a->date = userdate($log->time);
$a->action = $action;
- $a->course = $course->fullname;
+ $a->course = format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
$a->user = fullname($user);
notify_user($user,$subject,$a);
diff --git a/admin/oacleanup.php b/admin/oacleanup.php
index 12a1e4413d6..891a20af947 100644
--- a/admin/oacleanup.php
+++ b/admin/oacleanup.php
@@ -42,12 +42,20 @@ function online_assignment_cleanup($output=false) {
/// get a list of all courses on this site
- $courses = $DB->get_records('course');
+ list($ctxselect, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
+ $sql = "SELECT c.* $ctxselect FROM {course} c $ctxjoin";
+ $courses = $DB->get_records_sql($sql);
/// cycle through each course
foreach ($courses as $course) {
+ context_instance_preload($course);
+ $context = get_context_instance(CONTEXT_COURSE, $course->id);
- $fullname = empty($course->fullname) ? 'Course: '.$course->id : $course->fullname;
+ if (empty($course->fullname)) {
+ $fullname = get_string('course').': '.$course->id;
+ } else {
+ $fullname = format_string($course->fullname, true, array('context' => $context));
+ }
if ($output) echo $OUTPUT->heading($fullname);
/// retrieve a list of sections beyond what is currently being shown
@@ -96,7 +104,9 @@ function online_assignment_cleanup($output=false) {
/// grab the section record
if (!($section = $DB->get_record('course_sections', array('id'=>$newsection)))) {
- if ($output) echo 'Serious error: Cannot retrieve section: '.$newsection.' for course: '. format_string($course->fullname) .'
';
+ if ($output) {
+ echo 'Serious error: Cannot retrieve section: '.$newsection.' for course: '. $fullname .'
';
+ }
continue;
}
@@ -117,7 +127,7 @@ function online_assignment_cleanup($output=false) {
/// grab the old section record
if (!($section = $DB->get_record('course_sections', array('id'=>$xsection->id)))) {
- if ($output) echo 'Serious error: Cannot retrieve old section: '.$xsection->id.' for course: '.$course->fullname.'
';
+ if ($output) echo 'Serious error: Cannot retrieve old section: '.$xsection->id.' for course: '.$fullname.'
';
continue;
}
diff --git a/admin/registration/forms.php b/admin/registration/forms.php
index 30ec47c26bc..659e0aa13a8 100644
--- a/admin/registration/forms.php
+++ b/admin/registration/forms.php
@@ -203,7 +203,7 @@ class site_registration_form extends moodleform {
$cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
$sitename = get_config('hub', 'site_name_' . $cleanhuburl);
if ($sitename === false) {
- $sitename = $site->fullname;
+ $sitename = format_string($site->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
}
$sitedescription = get_config('hub', 'site_description_' . $cleanhuburl);
if ($sitedescription === false) {
diff --git a/backup/util/ui/renderer.php b/backup/util/ui/renderer.php
index b96bad254ea..9aea78ed13b 100644
--- a/backup/util/ui/renderer.php
+++ b/backup/util/ui/renderer.php
@@ -524,7 +524,7 @@ class core_backup_renderer extends plugin_renderer_base {
$row->cells = array(
html_writer::empty_tag('input', array('type'=>'radio', 'name'=>'targetid', 'value'=>$course->id)),
$course->shortname,
- $course->fullname
+ format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)))
);
$table->data[] = $row;
}
@@ -588,7 +588,7 @@ class core_backup_renderer extends plugin_renderer_base {
$row->cells = array(
html_writer::empty_tag('input', array('type'=>'radio', 'name'=>'importid', 'value'=>$course->id)),
$course->shortname,
- $course->fullname
+ format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)))
);
$table->data[] = $row;
}
diff --git a/blog/edit_form.php b/blog/edit_form.php
index b44ae933ced..cbfd4aed4d8 100644
--- a/blog/edit_form.php
+++ b/blog/edit_form.php
@@ -76,7 +76,7 @@ class blog_edit_form extends moodleform {
$mform->addElement('header', 'assochdr', get_string('associations', 'blog'));
$context = get_context_instance(CONTEXT_COURSE, $courseid);
$a = new stdClass();
- $a->coursename = $course->fullname;
+ $a->coursename = format_string($course->fullname, true, array('context' => $context));
$contextid = $context->id;
} else {
$sql = 'SELECT fullname FROM {course} cr LEFT JOIN {context} ct ON ct.instanceid = cr.id WHERE ct.id = ?';
diff --git a/blog/lib.php b/blog/lib.php
index c37af10a1a3..d690b0a31d1 100644
--- a/blog/lib.php
+++ b/blog/lib.php
@@ -838,7 +838,7 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$a = new stdClass();
$a->user = fullname($user);
- $a->course = $course->fullname;
+ $a->course = format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $courseid)));
$a->type = get_string('course');
$headers['heading'] = get_string('blogentriesbyuseraboutcourse', 'blog', $a);
$headers['stradd'] = get_string('blogaboutthis', 'blog', $a);
@@ -862,7 +862,7 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$a = new stdClass();
$a->group = $group->name;
- $a->course = $course->fullname;
+ $a->course = format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $courseid)));
$a->type = get_string('course');
$headers['heading'] = get_string('blogentriesbygroupaboutcourse', 'blog', $a);
$headers['stradd'] = get_string('blogaboutthis', 'blog', $a);
@@ -913,7 +913,7 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$PAGE->set_heading("$site->shortname: $course->shortname: " . get_string('blogentries', 'blog'));
$a = new stdClass();
$a->type = get_string('course');
- $headers['heading'] = get_string('blogentriesabout', 'blog', $course->fullname);
+ $headers['heading'] = get_string('blogentriesabout', 'blog', format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $courseid))));
$headers['stradd'] = get_string('blogaboutthis', 'blog', $a);
$headers['strview'] = get_string('viewblogentries', 'blog', $a);
$blogurl->remove_params(array('userid'));
diff --git a/blog/rsslib.php b/blog/rsslib.php
index 3fea97f3bfc..e9ef072c051 100644
--- a/blog/rsslib.php
+++ b/blog/rsslib.php
@@ -186,9 +186,10 @@ function blog_rss_get_feed($context, $args) {
break;
case 'course':
$info = $DB->get_field('course', 'fullname', array('id'=>$id));
+ $info = format_string($info, true, array('context' => get_context_instance(CONTEXT_COURSE, $id)));
break;
case 'site':
- $info = $SITE->fullname;
+ $info = format_string($SITE->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
break;
case 'group':
$group = groups_get_group($id);
diff --git a/calendar/lib.php b/calendar/lib.php
index 9c963bc3b1e..95f3e9a01ff 100644
--- a/calendar/lib.php
+++ b/calendar/lib.php
@@ -537,9 +537,12 @@ function calendar_add_event_metadata($event) {
}
$icon = $OUTPUT->pix_url('icon', $event->modulename) . '';
+ $context = get_context_instance(CONTEXT_COURSE, $module->course);
+ $fullname = format_string($coursecache[$module->course]->fullname, true, array('context' => $context));
+
$event->icon = '';
$event->referer = ''.$event->name.'';
- $event->courselink = ''.$coursecache[$module->course]->fullname.'';
+ $event->courselink = ''.$fullname.'';
$event->cmid = $module->id;
@@ -548,8 +551,12 @@ function calendar_add_event_metadata($event) {
$event->cssclass = 'calendar_event_global';
} else if($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) { // Course event
calendar_get_course_cached($coursecache, $event->courseid);
+
+ $context = get_context_instance(CONTEXT_COURSE, $event->courseid);
+ $fullname = format_string($coursecache[$event->courseid]->fullname, true, array('context' => $context));
+
$event->icon = '
';
- $event->courselink = ''.$coursecache[$event->courseid]->fullname.'';
+ $event->courselink = ''.$fullname.'';
$event->cssclass = 'calendar_event_course';
} else if ($event->groupid) { // Group event
$event->icon = '
';
diff --git a/course/completion_form.php b/course/completion_form.php
index d27c96b086b..0a5b543aa1c 100644
--- a/course/completion_form.php
+++ b/course/completion_form.php
@@ -105,7 +105,7 @@ class course_completion_form extends moodleform {
$selectbox = array();
$selected = array();
foreach ($courses as $c) {
- $selectbox[$c->id] = $list[$c->category] . ' / ' . s($c->fullname);
+ $selectbox[$c->id] = $list[$c->category] . ' / ' . format_string($c->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $c->id)));
// If already selected
if ($c->selected) {
diff --git a/course/delete.php b/course/delete.php
index c0a60ca8872..cf2542c6af3 100644
--- a/course/delete.php
+++ b/course/delete.php
@@ -25,6 +25,8 @@
print_error("invalidcourseid", 'error', '', $id);
}
+ $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+
if (!can_delete_course($id)) {
print_error('cannotdeletecourse');
}
@@ -43,7 +45,7 @@
$PAGE->set_heading($site->fullname);
echo $OUTPUT->header();
- $message = "$strdeletecoursecheck
" . format_string($course->fullname) . " (" . format_string($course->shortname) . ")";
+ $message = "$strdeletecoursecheck
" . format_string($course->fullname, true, array('context' => $coursecontext)) . " (" . format_string($course->shortname) . ")";
echo $OUTPUT->confirm($message, "delete.php?id=$course->id&delete=".md5($course->timemodified), "category.php?id=$course->category");
echo $OUTPUT->footer();
diff --git a/course/lib.php b/course/lib.php
index fe8630fb5fa..d55a78084f4 100644
--- a/course/lib.php
+++ b/course/lib.php
@@ -855,13 +855,14 @@ function print_overview($courses, array $remote_courses=array()) {
}
}
foreach ($courses as $course) {
+ $fullname = format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
echo $OUTPUT->box_start('coursebox');
- $attributes = array('title' => s($course->fullname));
+ $attributes = array('title' => s($fullname));
if (empty($course->visible)) {
$attributes['class'] = 'dimmed';
}
echo $OUTPUT->heading(html_writer::link(
- new moodle_url('/course/view.php', array('id' => $course->id)), format_string($course->fullname), $attributes), 3);
+ new moodle_url('/course/view.php', array('id' => $course->id)), $fullname, $attributes), 3);
if (array_key_exists($course->id,$htmlarray)) {
foreach ($htmlarray[$course->id] as $modname => $html) {
echo $html;
@@ -3253,13 +3254,13 @@ function make_editing_buttons(stdClass $mod, $absolute = true, $moveselect = tru
* truncate the the number of chars allowed and add ... if it was too long
*/
function course_format_name ($course,$max=100) {
-
- $str = $course->shortname.': '. $course->fullname;
- if (strlen($str) <= $max) {
+ $fullname = format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
+ $str = $course->shortname.': '. $fullname;
+ $textlib = textlib_get_instance();
+ if ($textlib->strlen($str) <= $max) {
return $str;
- }
- else {
- return substr($str,0,$max-3).'...';
+ } else {
+ return $textlib->substr($str, 0, $max-3).'...';
}
}
@@ -4224,7 +4225,7 @@ class course_request {
$this->delete();
$a = new stdClass();
- $a->name = $course->fullname;
+ $a->name = format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
$a->url = $CFG->wwwroot.'/course/view.php?id=' . $course->id;
$this->notify($user, $USER, 'courserequestapproved', get_string('courseapprovedsubject'), get_string('courseapprovedemail2', 'moodle', $a));
diff --git a/course/report/completion/index.php b/course/report/completion/index.php
index 2c222bf1405..3e2150fd31b 100644
--- a/course/report/completion/index.php
+++ b/course/report/completion/index.php
@@ -485,7 +485,7 @@ if(!$csv) {
// Display icon
$iconlink = $CFG->wwwroot.'/course/view.php?id='.$criterion->courseinstance;
- $icontitle = $crs->fullname;
+ $icontitle = format_string($crs->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $crs->id, MUST_EXIST)));
$iconalt = $crs->shortname;
break;
diff --git a/course/user.php b/course/user.php
index ee9db653430..1796f086a91 100644
--- a/course/user.php
+++ b/course/user.php
@@ -467,7 +467,8 @@ switch ($mode) {
// Get course info
$c_course = $DB->get_record('course', array('id' => $c_info->course_id));
- $course_name = $c_course->fullname;
+ $course_context = get_context_instance(CONTEXT_COURSE, $c_course->id, MUST_EXIST);
+ $course_name = format_string($c_course->fullname, true, array('context' => $course_context));
// Get completions
$completions = $c_info->get_completions($user->id);
@@ -541,7 +542,7 @@ switch ($mode) {
// Display course name on first row
if ($first_row) {
- echo '