diff --git a/backup/backup_scheduled.php b/backup/backup_scheduled.php
index cf396c0d846..49d5dd3adf1 100644
--- a/backup/backup_scheduled.php
+++ b/backup/backup_scheduled.php
@@ -194,7 +194,7 @@ function schedule_backup_cron() {
//Build the message subject
$site = get_site();
- $prefix = $site->shortname.": ";
+ $prefix = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID))).": ";
if ($count_error != 0 || $count_unfinished != 0) {
$prefix .= "[".strtoupper(get_string('error'))."] ";
}
diff --git a/backup/util/dbops/backup_plan_dbops.class.php b/backup/util/dbops/backup_plan_dbops.class.php
index 3d620f5b27d..f6e25b7f498 100644
--- a/backup/util/dbops/backup_plan_dbops.class.php
+++ b/backup/util/dbops/backup_plan_dbops.class.php
@@ -214,6 +214,8 @@ abstract class backup_plan_dbops extends backup_dbops {
switch ($type) {
case backup::TYPE_1COURSE:
$shortname = $DB->get_field('course', 'shortname', array('id' => $id));
+ $context = get_context_instance(CONTEXT_COURSE, $id);
+ $shortname = format_string($shortname, true, array('context' => $context));
break;
case backup::TYPE_1SECTION:
if (!$shortname = $DB->get_field('course_sections', 'name', array('id' => $id))) {
diff --git a/backup/util/helper/backup_cron_helper.class.php b/backup/util/helper/backup_cron_helper.class.php
index be15523e77b..6b6f2855713 100644
--- a/backup/util/helper/backup_cron_helper.class.php
+++ b/backup/util/helper/backup_cron_helper.class.php
@@ -197,7 +197,7 @@ abstract class backup_cron_automated_helper {
//Build the message subject
$site = get_site();
- $prefix = $site->shortname.": ";
+ $prefix = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID))).": ";
if ($haserrors) {
$prefix .= "[".strtoupper(get_string('error'))."] ";
}
diff --git a/backup/util/ui/renderer.php b/backup/util/ui/renderer.php
index b96bad254ea..9b891a62e35 100644
--- a/backup/util/ui/renderer.php
+++ b/backup/util/ui/renderer.php
@@ -523,7 +523,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,
+ format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))),
$course->fullname
);
$table->data[] = $row;
@@ -587,7 +587,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,
+ format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))),
$course->fullname
);
$table->data[] = $row;
diff --git a/blocks/course_list/block_course_list.php b/blocks/course_list/block_course_list.php
index 52fc1826149..e8356579984 100644
--- a/blocks/course_list/block_course_list.php
+++ b/blocks/course_list/block_course_list.php
@@ -36,8 +36,9 @@ class block_course_list extends block_list {
!(has_capability('moodle/course:update', get_context_instance(CONTEXT_SYSTEM)) and $adminseesall)) { // Just print My Courses
if ($courses = enrol_get_my_courses(NULL, 'visible DESC, fullname ASC')) {
foreach ($courses as $course) {
+ $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
$linkcss = $course->visible ? "" : " class=\"dimmed\" ";
- $this->content->items[]="shortname) . "\" ".
+ $this->content->items[]="shortname, true, array('context' => $coursecontext)) . "\" ".
"href=\"$CFG->wwwroot/course/view.php?id=$course->id\">".$icon.format_string($course->fullname). "";
}
$this->title = get_string('mycourses');
@@ -70,10 +71,11 @@ class block_course_list extends block_list {
if ($courses) {
foreach ($courses as $course) {
+ $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
$linkcss = $course->visible ? "" : " class=\"dimmed\" ";
$this->content->items[]="shortname)."\" ".
+ . format_string($course->shortname, true, array('context' => $coursecontext))."\" ".
"href=\"$CFG->wwwroot/course/view.php?id=$course->id\">"
.$icon. format_string($course->fullname) . "";
}
@@ -117,7 +119,8 @@ class block_course_list extends block_list {
$this->content->items[] = get_string('remotecourses','mnet');
$this->content->icons[] = '';
foreach ($courses as $course) {
- $this->content->items[]="shortname) . "\" ".
+ $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+ $this->content->items[]="shortname, true, array('context' => $coursecontext)) . "\" ".
"href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$course->hostid}&wantsurl=/course/view.php?id={$course->remoteid}\">"
.$icon. format_string($course->fullname) . "";
}
diff --git a/blog/lib.php b/blog/lib.php
index c37af10a1a3..55d6b73eb9b 100644
--- a/blog/lib.php
+++ b/blog/lib.php
@@ -748,10 +748,11 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
// Case 1: No entry, mod, course or user params: all site entries to be shown (filtered by search and tag/tagid)
// Note: if action is set to 'add' or 'edit', we do this at the end
if (empty($entryid) && empty($modid) && empty($courseid) && empty($userid) && !in_array($action, array('edit', 'add'))) {
+ $shortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
$PAGE->navbar->add($strblogentries, $blogurl);
- $PAGE->set_title("$site->shortname: " . get_string('blog', 'blog'));
- $PAGE->set_heading("$site->shortname: " . get_string('blog', 'blog'));
- $headers['heading'] = get_string('siteblog', 'blog', $site->shortname);
+ $PAGE->set_title("$shortname: " . get_string('blog', 'blog'));
+ $PAGE->set_heading("$shortname: " . get_string('blog', 'blog'));
+ $headers['heading'] = get_string('siteblog', 'blog', $shortname);
// $headers['strview'] = get_string('viewsiteentries', 'blog');
}
@@ -770,14 +771,14 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
} else {
$mycourseid = $site->id;
}
+ $shortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
$PAGE->navbar->add($strblogentries, $blogurl);
$blogurl->remove_params('userid');
$PAGE->navbar->add($entry->subject, $blogurl);
-
- $PAGE->set_title("$site->shortname: " . fullname($user) . ": $entry->subject");
- $PAGE->set_heading("$site->shortname: " . fullname($user) . ": $entry->subject");
+ $PAGE->set_title("$shortname: " . fullname($user) . ": $entry->subject");
+ $PAGE->set_heading("$shortname: " . fullname($user) . ": $entry->subject");
$headers['heading'] = get_string('blogentrybyuser', 'blog', fullname($user));
// We ignore tag and search params
@@ -789,9 +790,10 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
// Case 3: A user's blog entries
if (!empty($userid) && empty($entryid) && ((empty($courseid) && empty($modid)) || !$CFG->useblogassociations)) {
+ $shortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
$blogurl->param('userid', $userid);
- $PAGE->set_title("$site->shortname: " . fullname($user) . ": " . get_string('blog', 'blog'));
- $PAGE->set_heading("$site->shortname: " . fullname($user) . ": " . get_string('blog', 'blog'));
+ $PAGE->set_title("$shortname: " . fullname($user) . ": " . get_string('blog', 'blog'));
+ $PAGE->set_heading("$shortname: " . fullname($user) . ": " . get_string('blog', 'blog'));
$headers['heading'] = get_string('userblog', 'blog', fullname($user));
$headers['strview'] = get_string('viewuserentries', 'blog', fullname($user));
@@ -799,13 +801,15 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
// Case 4: No blog associations, no userid
if (!$CFG->useblogassociations && empty($userid) && !in_array($action, array('edit', 'add'))) {
- $PAGE->set_title("$site->shortname: " . get_string('blog', 'blog'));
- $PAGE->set_heading("$site->shortname: " . get_string('blog', 'blog'));
- $headers['heading'] = get_string('siteblog', 'blog', $site->shortname);
+ $shortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
+ $PAGE->set_title("$shortname: " . get_string('blog', 'blog'));
+ $PAGE->set_heading("$shortname: " . get_string('blog', 'blog'));
+ $headers['heading'] = get_string('siteblog', 'blog', $shortname);
} else
// Case 5: Blog entries associated with an activity by a specific user (courseid ignored)
if (!empty($userid) && !empty($modid) && empty($entryid)) {
+ $shortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
$blogurl->param('userid', $userid);
$blogurl->param('modid', $modid);
@@ -814,8 +818,8 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$PAGE->navbar->add(fullname($user), "$CFG->wwwroot/user/view.php?id=$user->id");
$PAGE->navbar->add($strblogentries, $blogurl);
- $PAGE->set_title("$site->shortname: $cm->name: " . fullname($user) . ': ' . get_string('blogentries', 'blog'));
- $PAGE->set_heading("$site->shortname: $cm->name: " . fullname($user) . ': ' . get_string('blogentries', 'blog'));
+ $PAGE->set_title("$shortname: $cm->name: " . fullname($user) . ': ' . get_string('blogentries', 'blog'));
+ $PAGE->set_heading("$shortname: $cm->name: " . fullname($user) . ': ' . get_string('blogentries', 'blog'));
$a = new stdClass();
$a->user = fullname($user);
@@ -828,13 +832,15 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
// Case 6: Blog entries associated with a course by a specific user
if (!empty($userid) && !empty($courseid) && empty($modid) && empty($entryid)) {
+ $siteshortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
+ $courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
$blogurl->param('userid', $userid);
$blogurl->param('courseid', $courseid);
$PAGE->navbar->add($strblogentries, $blogurl);
- $PAGE->set_title("$site->shortname: $course->shortname: " . fullname($user) . ': ' . get_string('blogentries', 'blog'));
- $PAGE->set_heading("$site->shortname: $course->shortname: " . fullname($user) . ': ' . get_string('blogentries', 'blog'));
+ $PAGE->set_title("$siteshortname: $courseshortname: " . fullname($user) . ': ' . get_string('blogentries', 'blog'));
+ $PAGE->set_heading("$siteshortname: $courseshortname: " . fullname($user) . ': ' . get_string('blogentries', 'blog'));
$a = new stdClass();
$a->user = fullname($user);
@@ -850,6 +856,8 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
// Case 7: Blog entries by members of a group, associated with that group's course
if (!empty($groupid) && empty($modid) && empty($entryid)) {
+ $siteshortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
+ $courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
$blogurl->param('courseid', $course->id);
$PAGE->navbar->add($strblogentries, $blogurl);
@@ -857,8 +865,8 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$blogurl->param('groupid', $groupid);
$PAGE->navbar->add($group->name, $blogurl);
- $PAGE->set_title("$site->shortname: $course->shortname: " . get_string('blogentries', 'blog') . ": $group->name");
- $PAGE->set_heading("$site->shortname: $course->shortname: " . get_string('blogentries', 'blog') . ": $group->name");
+ $PAGE->set_title("$siteshortname: $courseshortname: " . get_string('blogentries', 'blog') . ": $group->name");
+ $PAGE->set_heading("$siteshortname: $courseshortname: " . get_string('blogentries', 'blog') . ": $group->name");
$a = new stdClass();
$a->group = $group->name;
@@ -871,6 +879,8 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
// Case 8: Blog entries by members of a group, associated with an activity in that course
if (!empty($groupid) && !empty($modid) && empty($entryid)) {
+ $siteshortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
+ $courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
$headers['cm'] = $cm;
$blogurl->param('modid', $modid);
$PAGE->navbar->add($strblogentries, $blogurl);
@@ -878,8 +888,8 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
$blogurl->param('groupid', $groupid);
$PAGE->navbar->add($group->name, $blogurl);
- $PAGE->set_title("$site->shortname: $course->shortname: $cm->name: " . get_string('blogentries', 'blog') . ": $group->name");
- $PAGE->set_heading("$site->shortname: $course->shortname: $cm->name: " . get_string('blogentries', 'blog') . ": $group->name");
+ $PAGE->set_title("$siteshortname: $courseshortname: $cm->name: " . get_string('blogentries', 'blog') . ": $group->name");
+ $PAGE->set_heading("$siteshortname: $courseshortname: $cm->name: " . get_string('blogentries', 'blog') . ": $group->name");
$a = new stdClass();
$a->group = $group->name;
@@ -893,11 +903,13 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
// Case 9: All blog entries associated with an activity
if (!empty($modid) && empty($userid) && empty($groupid) && empty($entryid)) {
+ $siteshortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
+ $courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
$PAGE->set_cm($cm, $course);
$blogurl->param('modid', $modid);
$PAGE->navbar->add($strblogentries, $blogurl);
- $PAGE->set_title("$site->shortname: $course->shortname: $cm->name: " . get_string('blogentries', 'blog'));
- $PAGE->set_heading("$site->shortname: $course->shortname: $cm->name: " . get_string('blogentries', 'blog'));
+ $PAGE->set_title("$siteshortname: $courseshortname: $cm->name: " . get_string('blogentries', 'blog'));
+ $PAGE->set_heading("$siteshortname: $courseshortname: $cm->name: " . get_string('blogentries', 'blog'));
$headers['heading'] = get_string('blogentriesabout', 'blog', $cm->name);
$a = new stdClass();
$a->type = get_string('modulename', $cm->modname);
@@ -907,10 +919,12 @@ function blog_get_headers($courseid=null, $groupid=null, $userid=null, $tagid=nu
// Case 10: All blog entries associated with a course
if (!empty($courseid) && empty($userid) && empty($groupid) && empty($modid) && empty($entryid)) {
+ $siteshortname = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)));
+ $courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
$blogurl->param('courseid', $courseid);
$PAGE->navbar->add($strblogentries, $blogurl);
- $PAGE->set_title("$site->shortname: $course->shortname: " . get_string('blogentries', 'blog'));
- $PAGE->set_heading("$site->shortname: $course->shortname: " . get_string('blogentries', 'blog'));
+ $PAGE->set_title("$siteshortname: $courseshortname: " . get_string('blogentries', 'blog'));
+ $PAGE->set_heading("$siteshortname: $courseshortname: " . get_string('blogentries', 'blog'));
$a = new stdClass();
$a->type = get_string('course');
$headers['heading'] = get_string('blogentriesabout', 'blog', $course->fullname);
diff --git a/calendar/export_execute.php b/calendar/export_execute.php
index bfda4578521..e50123eb6a4 100644
--- a/calendar/export_execute.php
+++ b/calendar/export_execute.php
@@ -140,7 +140,8 @@ foreach($events as $event) {
$ev->add_property('dtend', Bennu::timestamp_to_datetime($event->timestart + $event->timeduration));
}
if ($event->courseid != 0) {
- $ev->add_property('categories', $courses[$event->courseid]->shortname);
+ $coursecontext = get_context_instance(CONTEXT_COURSE, $event->courseid);
+ $ev->add_property('categories', format_string($courses[$event->courseid]->shortname, true, array('context' => $coursecontext)));
}
$ical->add_component($ev);
}
diff --git a/calendar/renderer.php b/calendar/renderer.php
index e9ba82d892d..8e502a82e6d 100644
--- a/calendar/renderer.php
+++ b/calendar/renderer.php
@@ -692,7 +692,8 @@ class core_calendar_renderer extends plugin_renderer_base {
$courseoptions = array();
$courseoptions[SITEID] = get_string('fulllistofcourses');
foreach ($courses as $course) {
- $courseoptions[$course->id] = format_string($course->shortname);
+ $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+ $courseoptions[$course->id] = format_string($course->shortname, true, array('context' => $coursecontext));
}
if ($this->page->course->id !== SITEID) {
diff --git a/course/delete.php b/course/delete.php
index c0a60ca8872..3a4eb2f7dda 100644
--- a/course/delete.php
+++ b/course/delete.php
@@ -30,12 +30,13 @@
}
$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)));
$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)));
if (! $delete) {
- $strdeletecheck = get_string("deletecheck", "", $course->shortname);
+ $strdeletecheck = get_string("deletecheck", "", $courseshortname);
$strdeletecoursecheck = get_string("deletecoursecheck");
$PAGE->navbar->add($strdeletecheck);
@@ -43,7 +44,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) . " (" . $courseshortname . ")";
echo $OUTPUT->confirm($message, "delete.php?id=$course->id&delete=".md5($course->timemodified), "category.php?id=$course->category");
echo $OUTPUT->footer();
@@ -62,7 +63,7 @@
add_to_log(SITEID, "course", "delete", "view.php?id=$course->id", "$course->fullname (ID $course->id)");
- $strdeletingcourse = get_string("deletingcourse", "", format_string($course->shortname));
+ $strdeletingcourse = get_string("deletingcourse", "", $courseshortname);
$PAGE->navbar->add($strdeletingcourse);
$PAGE->set_title("$site->shortname: $strdeletingcourse");
@@ -73,7 +74,7 @@
delete_course($course);
fix_course_sortorder(); //update course count in catagories
- echo $OUTPUT->heading( get_string("deletedcourse", "", format_string($course->shortname)) );
+ echo $OUTPUT->heading( get_string("deletedcourse", "", $courseshortname) );
echo $OUTPUT->continue_button("category.php?id=$course->category");
diff --git a/course/info.php b/course/info.php
index e7ded1720e3..aca5105489b 100644
--- a/course/info.php
+++ b/course/info.php
@@ -42,7 +42,7 @@
$PAGE->navbar->add(get_string('summary'));
echo $OUTPUT->header();
- echo $OUTPUT->heading(''.format_string($course->fullname) . '
(' . format_string($course->shortname) . ')');
+ echo $OUTPUT->heading(''.format_string($course->fullname) . '
(' . format_string($course->shortname, true, array('context' => $context)) . ')');
// print enrol info
if ($texts = enrol_get_course_description_texts($course)) {
diff --git a/course/lib.php b/course/lib.php
index fe8630fb5fa..411277235dd 100644
--- a/course/lib.php
+++ b/course/lib.php
@@ -498,8 +498,9 @@ function print_mnet_log($hostid, $course, $user=0, $date=0, $order="l.time ASC",
echo '