From 8ebbb06adf8a3fe90d665e2995cf9b5647278a73 Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Wed, 7 Sep 2011 11:46:28 +1200 Subject: [PATCH] MDL-29189 mutlilang Reviewed the uses of course shortname and ensured things are being formatted consistently --- backup/backup_scheduled.php | 2 +- backup/util/dbops/backup_plan_dbops.class.php | 2 + .../util/helper/backup_cron_helper.class.php | 2 +- backup/util/ui/renderer.php | 4 +- blocks/course_list/block_course_list.php | 9 ++- blog/lib.php | 60 ++++++++++++------- calendar/export_execute.php | 3 +- calendar/renderer.php | 3 +- course/delete.php | 9 +-- course/info.php | 2 +- course/lib.php | 25 +++++--- course/publish/index.php | 10 ++-- course/publish/metadata.php | 4 +- course/report/completion/index.php | 6 +- course/report/log/graph.php | 4 +- course/report/progress/index.php | 5 +- course/report/stats/report.php | 2 +- enrol/authorize/localfuncs.php | 6 +- enrol/authorize/locallib.php | 15 +++-- enrol/flatfile/lib.php | 6 +- enrol/ldap/lib.php | 5 +- enrol/meta/addinstance_form.php | 2 +- enrol/paypal/ipn.php | 8 ++- enrol/paypal/lib.php | 7 ++- grade/export/ods/grade_export_ods.php | 4 +- grade/export/txt/grade_export_txt.php | 3 +- grade/export/xls/grade_export_xls.php | 3 +- grade/export/xml/grade_export_xml.php | 3 +- grade/report/overview/lib.php | 6 +- group/index.php | 2 +- group/overview.php | 2 +- lib/accesslib.php | 2 +- lib/enrollib.php | 6 +- lib/navigationlib.php | 9 ++- lib/outputrenderers.php | 2 +- message/lib.php | 9 +-- mod/assignment/lib.php | 27 +++++---- mod/chat/gui_ajax/index.php | 6 +- mod/chat/gui_header_js/index.php | 3 +- mod/chat/gui_sockets/index.php | 4 +- mod/chat/view.php | 3 +- mod/choice/view.php | 5 +- mod/data/edit.php | 4 +- mod/data/rsslib.php | 6 +- mod/data/view.php | 6 +- mod/feedback/analysis_course.php | 19 +++--- mod/feedback/analysis_to_excel.php | 5 +- mod/feedback/item/info/lib.php | 6 +- mod/feedback/lib.php | 9 ++- mod/feedback/mapcourse.php | 4 +- mod/forum/discuss.php | 2 +- mod/forum/index.php | 5 +- mod/forum/lib.php | 19 +++--- mod/forum/view.php | 2 +- mod/glossary/view.php | 2 +- mod/quiz/report/overview/report.php | 10 +++- mod/quiz/report/responses/report.php | 10 +++- mod/quiz/report/statistics/report.php | 4 +- mod/scorm/player.php | 6 +- mod/scorm/report/basic/report.php | 4 +- mod/scorm/view.php | 3 +- mod/survey/download.php | 8 ++- mod/url/locallib.php | 8 ++- notes/index.php | 2 +- repository/coursefiles/lib.php | 2 +- tag/coursetags_edit.php | 2 +- tag/coursetags_more.php | 3 +- user/index.php | 5 +- user/lib.php | 3 +- user/view.php | 2 +- 70 files changed, 295 insertions(+), 166 deletions(-) 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 ''; if ($course->id == SITEID) { + $courseshortname = format_string($courses[$log->course], true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID))); echo "\n"; - echo " wwwroot}/course/view.php?id={$log->course}\">".$courses[$log->course]."\n"; + echo " wwwroot}/course/view.php?id={$log->course}\">".$courseshortname."\n"; echo "\n"; } echo "".userdate($log->time, '%a'). @@ -591,8 +592,9 @@ function print_log_csv($course, $user, $date, $order='l.time DESC', $modname, $log->info = format_string($log->info); $log->info = strip_tags(urldecode($log->info)); // Some XSS protection - $firstField = $courses[$log->course]; - $fullname = fullname($log, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id))); + $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); + $firstField = format_string($courses[$log->course], true, array('context' => $coursecontext)); + $fullname = fullname($log, has_capability('moodle/site:viewfullnames', $coursecontext)); $row = array($firstField, userdate($log->time, $strftimedatetime), $log->ip, $fullname, $log->module.' '.$log->action, $log->info); $text = implode("\t", $row); echo $text." \n"; @@ -697,10 +699,12 @@ function print_log_xls($course, $user, $date, $order='l.time DESC', $modname, } } - $myxls->write($row, 0, $courses[$log->course], ''); + $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); + + $myxls->write($row, 0, format_string($courses[$log->course], true, array('context' => $coursecontext)), ''); $myxls->write_date($row, 1, $log->time, $formatDate); // write_date() does conversion/timezone support. MDL-14934 $myxls->write($row, 2, $log->ip, ''); - $fullname = fullname($log, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id))); + $fullname = fullname($log, has_capability('moodle/site:viewfullnames', $coursecontext)); $myxls->write($row, 3, $fullname, ''); $myxls->write($row, 4, $log->module.' '.$log->action, ''); $myxls->write($row, 5, $log->info, ''); @@ -808,10 +812,12 @@ function print_log_ods($course, $user, $date, $order='l.time DESC', $modname, } } - $myxls->write_string($row, 0, $courses[$log->course]); + $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); + + $myxls->write_string($row, 0, format_string($courses[$log->course], true, array('context' => $context))); $myxls->write_date($row, 1, $log->time); $myxls->write_string($row, 2, $log->ip); - $fullname = fullname($log, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id))); + $fullname = fullname($log, has_capability('moodle/site:viewfullnames', $coursecontext)); $myxls->write_string($row, 3, $fullname); $myxls->write_string($row, 4, $log->module.' '.$log->action); $myxls->write_string($row, 5, $log->info); @@ -3254,7 +3260,10 @@ function make_editing_buttons(stdClass $mod, $absolute = true, $moveselect = tru */ function course_format_name ($course,$max=100) { - $str = $course->shortname.': '. $course->fullname; + $context = get_context_instance(CONTEXT_COURSE, $course->id); + $shortname = format_string($course->shortname, true, array('context' => $context)); + + $str = $shortname.': '. $course->fullname; if (strlen($str) <= $max) { return $str; } diff --git a/course/publish/index.php b/course/publish/index.php index 4d048ae0a58..962775051c8 100644 --- a/course/publish/index.php +++ b/course/publish/index.php @@ -37,6 +37,8 @@ $huburl = optional_param('huburl', 0, PARAM_URL); $course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); require_login($course); +$context = get_context_instance(CONTEXT_COURSE, $course->id); +$shortname = format_string($course->shortname, true, array('context' => $context)); $PAGE->set_url('/course/publish/index.php', array('id' => $course->id)); $PAGE->set_pagelayout('course'); @@ -48,7 +50,7 @@ if (!extension_loaded('xmlrpc')) { $notificationerror = $OUTPUT->doc_link('admin/environment/php_extension/xmlrpc', ''); $notificationerror .= get_string('xmlrpcdisabledpublish', 'hub'); echo $OUTPUT->header(); - echo $OUTPUT->heading(get_string('publishcourse', 'hub', $course->shortname), 3, 'main'); + echo $OUTPUT->heading(get_string('publishcourse', 'hub', $shortname), 3, 'main'); echo $OUTPUT->notification($notificationerror); echo $OUTPUT->footer(); die(); @@ -144,9 +146,9 @@ if (has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE, } else { //display confirmation page for unpublishing - + echo $OUTPUT->header(); - echo $OUTPUT->heading(get_string('unpublishcourse', 'hub', $course->shortname), 3, 'main'); + echo $OUTPUT->heading(get_string('unpublishcourse', 'hub', $shortname), 3, 'main'); echo $renderer->confirmunpublishing($publication); echo $OUTPUT->footer(); die(); @@ -164,7 +166,7 @@ if (has_capability('moodle/course:publish', get_context_instance(CONTEXT_COURSE, echo $OUTPUT->header(); echo $confirmmessage; - echo $OUTPUT->heading(get_string('publishcourse', 'hub', $course->shortname), 3, 'main'); + echo $OUTPUT->heading(get_string('publishcourse', 'hub', $shortname), 3, 'main'); echo $renderer->publicationselector($course->id); $publications = $publicationmanager->get_course_publications($course->id); diff --git a/course/publish/metadata.php b/course/publish/metadata.php index 9a952f7dd1c..b8a8caa6385 100644 --- a/course/publish/metadata.php +++ b/course/publish/metadata.php @@ -53,8 +53,10 @@ $PAGE->set_heading($course->fullname); if (!extension_loaded('xmlrpc')) { $errornotification = $OUTPUT->doc_link('admin/environment/php_extension/xmlrpc', ''); $errornotification .= get_string('xmlrpcdisabledpublish', 'hub'); + $context = get_context_instance(CONTEXT_COURSE, $course->id); + $shortname = format_string($course->shortname, true, array('context' => $context)); echo $OUTPUT->header(); - echo $OUTPUT->heading(get_string('publishcourse', 'hub', $course->shortname), 3, 'main'); + echo $OUTPUT->heading(get_string('publishcourse', 'hub', $shortname), 3, 'main'); echo $OUTPUT->notification($errornotification); echo $OUTPUT->footer(); die(); diff --git a/course/report/completion/index.php b/course/report/completion/index.php index 2c222bf1405..702220a6c38 100644 --- a/course/report/completion/index.php +++ b/course/report/completion/index.php @@ -143,8 +143,10 @@ if (!$csv) { * Setup page header */ if ($csv) { + $shortname = format_string($course->shortname, true, array('context' => $context)); + $textlib = textlib_get_instance(); header('Content-Disposition: attachment; filename=progress.'. - preg_replace('/[^a-z0-9-]/','_',strtolower($course->shortname)).'.csv'); + preg_replace('/[^a-z0-9-]/','_',$textlib->strtolower(strip_tags($shortname))).'.csv'); // Unicode byte-order mark for Excel if($excel) { header('Content-Type: text/csv; charset=UTF-16LE'); @@ -486,7 +488,7 @@ if(!$csv) { // Display icon $iconlink = $CFG->wwwroot.'/course/view.php?id='.$criterion->courseinstance; $icontitle = $crs->fullname; - $iconalt = $crs->shortname; + $iconalt = format_string($crs->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $crs->id))); break; case COMPLETION_CRITERIA_TYPE_ROLE: diff --git a/course/report/log/graph.php b/course/report/log/graph.php index a2c7ff23637..cf13b2cae97 100644 --- a/course/report/log/graph.php +++ b/course/report/log/graph.php @@ -120,7 +120,7 @@ switch ($type) { $graph = new graph(750, 400); - $a->coursename = $course->shortname; + $a->coursename = format_string($course->shortname, true, array('context' => $context)); $a->username = fullname($user, true); $graph->parameter['title'] = get_string("hitsoncourse", "", $a); @@ -183,7 +183,7 @@ switch ($type) { $graph = new graph(750, 400); - $a->coursename = $course->shortname; + $a->coursename = format_string($course->shortname, true, array('context' => $context)); $a->username = fullname($user, true); $graph->parameter['title'] = get_string("hitsoncoursetoday", "", $a); diff --git a/course/report/progress/index.php b/course/report/progress/index.php index d246139874c..b205c0bd46b 100644 --- a/course/report/progress/index.php +++ b/course/report/progress/index.php @@ -108,8 +108,11 @@ if ($total) { } if($csv && $grandtotal && count($activities)>0) { // Only show CSV if there are some users/actvs + + $shortname = format_string($course->shortname, true, array('context' => $context)); + $textlib = textlib_get_instance(); header('Content-Disposition: attachment; filename=progress.'. - preg_replace('/[^a-z0-9-]/','_',strtolower($course->shortname)).'.csv'); + preg_replace('/[^a-z0-9-]/','_',$textlib->strtolower(strip_tags($shortname))).'.csv'); // Unicode byte-order mark for Excel if($excel) { header('Content-Type: text/csv; charset=UTF-16LE'); diff --git a/course/report/stats/report.php b/course/report/stats/report.php index e13f06423b6..c6a2108c4ac 100644 --- a/course/report/stats/report.php +++ b/course/report/stats/report.php @@ -11,7 +11,7 @@ $context = get_context_instance(CONTEXT_COURSE, $c->id); if (has_capability('coursereport/stats:view', $context)) { - $courseoptions[$c->id] = $c->shortname; + $courseoptions[$c->id] = format_string($c->shortname, true, array('context' => $context)); } } diff --git a/enrol/authorize/localfuncs.php b/enrol/authorize/localfuncs.php index a05c20e63dd..f95f37045ec 100644 --- a/enrol/authorize/localfuncs.php +++ b/enrol/authorize/localfuncs.php @@ -232,6 +232,7 @@ function send_welcome_messages($orderdata) { $a->profileurl = "$CFG->wwwroot/user/view.php?id=$lastuserid"; $a->paymenturl = "$CFG->wwwroot/enrol/authorize/index.php?user=$lastuserid"; $emailmessage = get_string('welcometocoursesemail', 'enrol_authorize', $a); + $subject = get_string("enrolmentnew", '', format_string($SITE->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID)))); $eventdata = new stdClass(); $eventdata->modulename = 'moodle'; @@ -239,7 +240,7 @@ function send_welcome_messages($orderdata) { $eventdata->name = 'authorize_enrolment'; $eventdata->userfrom = $sender; $eventdata->userto = $user; - $eventdata->subject = get_string("enrolmentnew", '', $SITE->shortname); + $eventdata->subject = $subject; $eventdata->fullmessage = $emailmessage; $eventdata->fullmessageformat = FORMAT_PLAIN; $eventdata->fullmessagehtml = ''; @@ -267,6 +268,7 @@ function authorize_verify_account() { $original_antest = $plugin->get_config('an_test'); $plugin->set_config('an_test', 1); // Test mode + $shortname = format_string($SITE->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID))); $order = new stdClass(); $order->id = -1; @@ -293,7 +295,7 @@ function authorize_verify_account() { $extra->x_country = $USER->country; $extra->x_invoice_num = $order->id; - $extra->x_description = $SITE->shortname . ' - Authorize.net Merchant Account Verification Test'; + $extra->x_description = $shortname . ' - Authorize.net Merchant Account Verification Test'; $ret = ''; $message = ''; diff --git a/enrol/authorize/locallib.php b/enrol/authorize/locallib.php index 4a3a0bd6319..6dc069e162c 100644 --- a/enrol/authorize/locallib.php +++ b/enrol/authorize/locallib.php @@ -54,6 +54,8 @@ function authorize_print_orders($courseid, $userid) { $searchtype = optional_param('searchtype', 'orderid', PARAM_ALPHA); $status = optional_param('status', AN_STATUS_NONE, PARAM_INT); + $coursecontext = get_context_instance(CONTEXT_USER, $USER->id); + $searchmenu = array('orderid' => $authstrs->orderid, 'transid' => $authstrs->transid, 'cclastfour' => $authstrs->cclastfour); $buttons = "
"; $buttons .= html_writer::select($searchmenu, 'searchtype', $searchtype, false); @@ -61,11 +63,11 @@ function authorize_print_orders($courseid, $userid) { $buttons .= ""; $buttons .= "
"; - if (has_capability('enrol/authorize:uploadcsv', get_context_instance(CONTEXT_USER, $USER->id))) { + if (has_capability('enrol/authorize:uploadcsv', $coursecontext)) { $buttons .= "
"; } - $canmanagepayments = has_capability('enrol/authorize:managepayments', get_context_instance(CONTEXT_COURSE, $courseid)); + $canmanagepayments = has_capability('enrol/authorize:managepayments', $coursecontext); if ($showonlymy || !$canmanagepayments) { $userid = $USER->id; } @@ -104,7 +106,8 @@ function authorize_print_orders($courseid, $userid) { } if (SITEID != $courseid) { - $PAGE->navbar->add($course->shortname, new moodle_url('/course/view.php', array('id'=>$course->id))); + $shortname = format_string($course->shortname, true, array('context' => $coursecontext)); + $PAGE->navbar->add($shortname, new moodle_url('/course/view.php', array('id'=>$course->id))); } $PAGE->navbar->add($authstrs->paymentmanagement, 'index.php'); $PAGE->set_title("$course->shortname: $authstrs->paymentmanagement"); @@ -297,7 +300,8 @@ function authorize_print_order($orderid) } if (SITEID != $course->id) { - $PAGE->navbar->add($course->shortname, new moodle_url('/course/view.php', array('id'=>$course->id))); + $shortname = format_string($course->shortname, true, array('context' => $coursecontext)); + $PAGE->navbar->add($shortname, new moodle_url('/course/view.php', array('id'=>$course->id))); } $PAGE->navbar->add($authstrs->paymentmanagement, 'index.php?course='.$course->id); $PAGE->navbar->add($authstrs->orderid . ': ' . $orderid, 'index.php'); @@ -343,7 +347,8 @@ function authorize_print_order($orderid) redirect("$CFG->wwwroot/enrol/authorize/index.php?order=$orderid"); } else { - redirect("$CFG->wwwroot/enrol/authorize/index.php?order=$orderid", "Error while trying to enrol ".fullname($user)." in '" . format_string($course->shortname) . "'", 20); + $shortname = format_string($course->shortname, true, array('context' => $coursecontext)); + redirect("$CFG->wwwroot/enrol/authorize/index.php?order=$orderid", "Error while trying to enrol ".fullname($user)." in '" . $shortname . "'", 20); } } else { diff --git a/enrol/flatfile/lib.php b/enrol/flatfile/lib.php index 9831613bf82..b37c1603a0c 100644 --- a/enrol/flatfile/lib.php +++ b/enrol/flatfile/lib.php @@ -276,6 +276,7 @@ class enrol_flatfile_plugin extends enrol_plugin { $a = new stdClass(); $a->coursename = "$course->fullname"; $a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id"; + $subject = get_string("enrolmentnew", 'enrol', format_string($course->shortname, true, array('context' => $context))); $eventdata = new stdClass(); $eventdata->modulename = 'moodle'; @@ -283,7 +284,7 @@ class enrol_flatfile_plugin extends enrol_plugin { $eventdata->name = 'flatfile_enrolment'; $eventdata->userfrom = $teacher; $eventdata->userto = $user; - $eventdata->subject = get_string("enrolmentnew", 'enrol', $course->shortname); + $eventdata->subject = $subject; $eventdata->fullmessage = get_string('welcometocoursetext', '', $a); $eventdata->fullmessageformat = FORMAT_PLAIN; $eventdata->fullmessagehtml = ''; @@ -298,6 +299,7 @@ class enrol_flatfile_plugin extends enrol_plugin { $a = new stdClass(); $a->course = "$course->fullname"; $a->user = fullname($user); + $subject = get_string("enrolmentnew", 'enrol', format_string($course->shortname, true, array('context' => $context))); $eventdata = new stdClass(); $eventdata->modulename = 'moodle'; @@ -305,7 +307,7 @@ class enrol_flatfile_plugin extends enrol_plugin { $eventdata->name = 'flatfile_enrolment'; $eventdata->userfrom = $user; $eventdata->userto = $teacher; - $eventdata->subject = get_string("enrolmentnew", 'enrol', $course->shortname); + $eventdata->subject = $subject; $eventdata->fullmessage = get_string('enrolmentnewuser', 'enrol', $a); $eventdata->fullmessageformat = FORMAT_PLAIN; $eventdata->fullmessagehtml = ''; diff --git a/enrol/ldap/lib.php b/enrol/ldap/lib.php index 492aa4d0394..90c083053cd 100644 --- a/enrol/ldap/lib.php +++ b/enrol/ldap/lib.php @@ -448,19 +448,20 @@ class enrol_ldap_plugin extends enrol_plugin { JOIN {enrol} e ON (e.id = ue.enrolid) WHERE u.deleted = 0 AND e.courseid = :courseid "; $params = array('roleid'=>$role->id, 'courseid'=>$course_obj->id); + $context = get_context_instance(CONTEXT_COURSE, $course_obj->id); if (!empty($ldapmembers)) { list($ldapml, $params2) = $DB->get_in_or_equal($ldapmembers, SQL_PARAMS_NAMED, 'm', false); $sql .= "AND u.idnumber $ldapml"; $params = array_merge($params, $params2); unset($params2); } else { + $shortname = format_string($course_obj->shortname, true, array('context' => $context)); print_string('emptyenrolment', 'enrol_ldap', array('role_shortname'=> $role->shortname, - 'course_shortname'=>$course_obj->shortname)); + 'course_shortname' => $shortname)); } $todelete = $DB->get_records_sql($sql, $params); - $context = get_context_instance(CONTEXT_COURSE, $course_obj->id); if (!empty($todelete)) { $transaction = $DB->start_delegated_transaction(); foreach ($todelete as $row) { diff --git a/enrol/meta/addinstance_form.php b/enrol/meta/addinstance_form.php index 0bba4dfa372..eba5d15064e 100644 --- a/enrol/meta/addinstance_form.php +++ b/enrol/meta/addinstance_form.php @@ -54,7 +54,7 @@ class enrol_meta_addinstance_form extends moodleform { if (!has_capability('enrol/meta:selectaslinked', $coursecontext)) { continue; } - $courses[$c->id] = format_string($c->fullname). ' ['.$c->shortname.']'; + $courses[$c->id] = format_string($c->fullname). ' ['.format_string($c->shortname, true, array('context' => $coursecontext)).']'; } $rs->close(); diff --git a/enrol/paypal/ipn.php b/enrol/paypal/ipn.php index 3d1b608d702..b34570f10fc 100644 --- a/enrol/paypal/ipn.php +++ b/enrol/paypal/ipn.php @@ -228,6 +228,8 @@ while (!feof($fp)) { $mailstudents = $plugin->get_config('mailstudents'); $mailteachers = $plugin->get_config('mailteachers'); $mailadmins = $plugin->get_config('mailadmins'); + $shortname = format_string($course->shortname, true, array('context' => $context)); + if (!empty($mailstudents)) { $a->coursename = $course->fullname; @@ -239,7 +241,7 @@ while (!feof($fp)) { $eventdata->name = 'paypal_enrolment'; $eventdata->userfrom = $teacher; $eventdata->userto = $user; - $eventdata->subject = get_string("enrolmentnew", '', $course->shortname); + $eventdata->subject = get_string("enrolmentnew", '', $shortname); $eventdata->fullmessage = get_string('welcometocoursetext', '', $a); $eventdata->fullmessageformat = FORMAT_PLAIN; $eventdata->fullmessagehtml = ''; @@ -258,7 +260,7 @@ while (!feof($fp)) { $eventdata->name = 'paypal_enrolment'; $eventdata->userfrom = $user; $eventdata->userto = $teacher; - $eventdata->subject = get_string("enrolmentnew", '', $course->shortname); + $eventdata->subject = get_string("enrolmentnew", '', $shortname); $eventdata->fullmessage = get_string('enrolmentnewuser', '', $a); $eventdata->fullmessageformat = FORMAT_PLAIN; $eventdata->fullmessagehtml = ''; @@ -277,7 +279,7 @@ while (!feof($fp)) { $eventdata->name = 'paypal_enrolment'; $eventdata->userfrom = $user; $eventdata->userto = $admin; - $eventdata->subject = get_string("enrolmentnew", '', $course->shortname); + $eventdata->subject = get_string("enrolmentnew", '', $shortname); $eventdata->fullmessage = get_string('enrolmentnewuser', '', $a); $eventdata->fullmessageformat = FORMAT_PLAIN; $eventdata->fullmessagehtml = ''; diff --git a/enrol/paypal/lib.php b/enrol/paypal/lib.php index 9d6f14a9e3b..d9f9d498d9b 100644 --- a/enrol/paypal/lib.php +++ b/enrol/paypal/lib.php @@ -151,11 +151,12 @@ class enrol_paypal_plugin extends enrol_plugin { } $course = $DB->get_record('course', array('id'=>$instance->courseid)); + $context = get_context_instance(CONTEXT_COURSE, $course->id); - $strloginto = get_string("loginto", "", $course->shortname); + $shortname = format_string($course->shortname, true, array('context' => $context)); + $strloginto = get_string("loginto", "", $shortname); $strcourses = get_string("courses"); - $context = get_context_instance(CONTEXT_COURSE, $course->id); // Pass $view=true to filter hidden caps if the user cannot see them if ($users = get_users_by_capability($context, 'moodle/course:update', 'u.*', 'u.id ASC', '', '', '', '', false, true)) { @@ -190,7 +191,7 @@ class enrol_paypal_plugin extends enrol_plugin { } else { //Sanitise some fields before building the PayPal form $coursefullname = format_string($course->fullname, true, array('context'=>$context)); - $courseshortname = $course->shortname; + $courseshortname = $shortname; $userfullname = fullname($USER); $userfirstname = $USER->firstname; $userlastname = $USER->lastname; diff --git a/grade/export/ods/grade_export_ods.php b/grade/export/ods/grade_export_ods.php index 8d2c4c19c35..e9ff0950756 100644 --- a/grade/export/ods/grade_export_ods.php +++ b/grade/export/ods/grade_export_ods.php @@ -32,8 +32,10 @@ class grade_export_ods extends grade_export { $strgrades = get_string('grades'); + $shortname = format_string($this->course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $this->course->id))); + /// Calculate file name - $downloadfilename = clean_filename("{$this->course->shortname} $strgrades.ods"); + $downloadfilename = clean_filename("$shortname $strgrades.ods"); /// Creating a workbook $workbook = new MoodleODSWorkbook("-"); /// Sending HTTP headers diff --git a/grade/export/txt/grade_export_txt.php b/grade/export/txt/grade_export_txt.php index 4fd17e56ad7..77f804bb515 100644 --- a/grade/export/txt/grade_export_txt.php +++ b/grade/export/txt/grade_export_txt.php @@ -66,7 +66,8 @@ class grade_export_txt extends grade_export { @header('Pragma: no-cache'); } header("Content-Type: application/download\n"); - $downloadfilename = clean_filename("{$this->course->shortname} $strgrades"); + $shortname = format_string($this->course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $this->course->id))); + $downloadfilename = clean_filename("$shortname $strgrades"); header("Content-Disposition: attachment; filename=\"$downloadfilename.txt\""); /// Print names of all the fields diff --git a/grade/export/xls/grade_export_xls.php b/grade/export/xls/grade_export_xls.php index 89c32924d4a..f1efc6ee306 100644 --- a/grade/export/xls/grade_export_xls.php +++ b/grade/export/xls/grade_export_xls.php @@ -33,7 +33,8 @@ class grade_export_xls extends grade_export { $strgrades = get_string('grades'); /// Calculate file name - $downloadfilename = clean_filename("{$this->course->shortname} $strgrades.xls"); + $shortname = format_string($this->course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $this->course->id))); + $downloadfilename = clean_filename("$shortname $strgrades.xls"); /// Creating a workbook $workbook = new MoodleExcelWorkbook("-"); /// Sending HTTP headers diff --git a/grade/export/xml/grade_export_xml.php b/grade/export/xml/grade_export_xml.php index a978b0dbe20..5924bb35861 100644 --- a/grade/export/xml/grade_export_xml.php +++ b/grade/export/xml/grade_export_xml.php @@ -38,7 +38,8 @@ class grade_export_xml extends grade_export { $strgrades = get_string('grades'); /// Calculate file name - $downloadfilename = clean_filename("{$this->course->shortname} $strgrades.xml"); + $shortname = format_string($this->course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $this->course->id))); + $downloadfilename = clean_filename("$shortname $strgrades.xml"); make_upload_directory('temp/gradeexport'); $tempfilename = $CFG->dataroot .'/temp/gradeexport/'. md5(sesskey().microtime().$downloadfilename); diff --git a/grade/report/overview/lib.php b/grade/report/overview/lib.php index 1b9a8803928..cf8b7574083 100644 --- a/grade/report/overview/lib.php +++ b/grade/report/overview/lib.php @@ -119,8 +119,10 @@ class grade_report_overview extends grade_report { if (!$course->showgrades) { continue; } - $courselink = ''.$course->shortname.''; - $canviewhidden = has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_COURSE, $course->id)); + $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); + $courseshortname = format_string($course->shortname, true, array('context' => $coursecontext)); + $courselink = html_writer::link(new moodle_url('/grade/report/user/index.php', array('id' => $course->id, 'userid' => $this->user->id)), $courseshortname); + $canviewhidden = has_capability('moodle/grade:viewhidden', $coursecontext); // Get course grade_item $course_item = grade_item::fetch_course_item($course->id); diff --git a/group/index.php b/group/index.php index 3d8bfb03c1d..4b75d8ef8a5 100644 --- a/group/index.php +++ b/group/index.php @@ -155,7 +155,7 @@ if (ajaxenabled()) { $deletegroup_disabled = ''; } -echo $OUTPUT->heading(format_string($course->shortname) .' '.$strgroups, 3); +echo $OUTPUT->heading(format_string($course->shortname, true, array('context' => $context)) .' '.$strgroups, 3); echo '
'."\n"; echo '
'."\n"; echo ''."\n"; diff --git a/group/overview.php b/group/overview.php index 88d348cfe1a..75efcc791a7 100644 --- a/group/overview.php +++ b/group/overview.php @@ -114,7 +114,7 @@ $currenttab = 'overview'; require('tabs.php'); /// Print overview -echo $OUTPUT->heading(format_string($course->shortname) .' '.$stroverview, 3); +echo $OUTPUT->heading(format_string($course->shortname, true, array('context' => $context)) .' '.$stroverview, 3); echo $strfiltergroups; diff --git a/lib/accesslib.php b/lib/accesslib.php index 03d6cf985ba..2eea1e56246 100644 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -3597,7 +3597,7 @@ function print_context_name($context, $withprefix = true, $short = false) { $name = get_string('course').': '; } if ($short){ - $name .= format_string($course->shortname); + $name .= format_string($course->shortname, true, array('context' => $context)); } else { $name .= format_string($course->fullname); } diff --git a/lib/enrollib.php b/lib/enrollib.php index 1484e4be85f..a2003ab5446 100644 --- a/lib/enrollib.php +++ b/lib/enrollib.php @@ -434,7 +434,8 @@ function enrol_add_course_navigation(navigation_node $coursenode, $course) { } $plugin = $plugins[$instance->enrol]; if ($unenrollink = $plugin->get_unenrolself_link($instance)) { - $coursenode->add(get_string('unenrolme', 'core_enrol', format_string($course->shortname)), $unenrollink, navigation_node::TYPE_SETTING, null, 'unenrolself', new pix_icon('i/user', '')); + $shortname = format_string($course->shortname, true, array('context' => $coursecontext)); + $coursenode->add(get_string('unenrolme', 'core_enrol', $shortname), $unenrollink, navigation_node::TYPE_SETTING, null, 'unenrolself', new pix_icon('i/user', '')); break; //TODO. deal with multiple unenrol links - not likely case, but still... } @@ -450,7 +451,8 @@ function enrol_add_course_navigation(navigation_node $coursenode, $course) { $plugin = $plugins[$instance->enrol]; if ($plugin->show_enrolme_link($instance)) { $url = new moodle_url('/enrol/index.php', array('id'=>$course->id)); - $coursenode->add(get_string('enrolme', 'core_enrol', format_string($course->shortname)), $url, navigation_node::TYPE_SETTING, null, 'enrolself', new pix_icon('i/user', '')); + $shortname = format_string($course->shortname, true, array('context' => $coursecontext)); + $coursenode->add(get_string('enrolme', 'core_enrol', $shortname), $url, navigation_node::TYPE_SETTING, null, 'enrolself', new pix_icon('i/user', '')); break; } } diff --git a/lib/navigationlib.php b/lib/navigationlib.php index b2a619a2c25..b2cf0a90822 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -2030,7 +2030,8 @@ class global_navigation extends navigation_node { foreach ($userscourses as $usercourse) { $usercoursecontext = get_context_instance(CONTEXT_COURSE, $usercourse->id); - $usercoursenode = $userscoursesnode->add($usercourse->shortname, new moodle_url('/user/view.php', array('id'=>$user->id, 'course'=>$usercourse->id)), self::TYPE_CONTAINER); + $usercourseshortname = format_string($usercourse->shortname, true, array('context' => $usercoursecontext)); + $usercoursenode = $userscoursesnode->add($usercourseshortname, new moodle_url('/user/view.php', array('id'=>$user->id, 'course'=>$usercourse->id)), self::TYPE_CONTAINER); $gradeavailable = has_capability('moodle/grade:viewall', $usercoursecontext); if (!$gradeavailable && !empty($usercourse->showgrades) && is_array($reports) && !empty($reports)) { @@ -2140,17 +2141,19 @@ class global_navigation extends navigation_node { return $this->addedcourses[$course->id]; } + $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); + if ($course->id != SITEID && !$course->visible) { if (is_role_switched($course->id)) { // user has to be able to access course in order to switch, let's skip the visibility test here - } else if (!has_capability('moodle/course:viewhiddencourses', get_context_instance(CONTEXT_COURSE, $course->id))) { + } else if (!has_capability('moodle/course:viewhiddencourses', $coursecontext)) { return false; } } $issite = ($course->id == SITEID); $ismycourse = ($ismycourse && !$forcegeneric); - $shortname = $course->shortname; + $shortname = format_string($course->shortname, true, array('context' => $coursecontext)); if ($issite) { $parent = $this; diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index d685cd270c8..ab77c6c91fe 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -545,7 +545,7 @@ class core_renderer extends renderer_base { } else { return ''; + format_string($this->page->course->shortname, true, array('context' => $this->page->context)) . '
'; } } diff --git a/message/lib.php b/message/lib.php index 3eb5ead6938..eae88ae4be1 100644 --- a/message/lib.php +++ b/message/lib.php @@ -487,10 +487,11 @@ function message_print_usergroup_selector($viewing, $courses, $coursecontexts, $ foreach($courses as $course) { if (has_capability('moodle/course:viewparticipants', $coursecontexts[$course->id])) { //Not using short_text() as we want the end of the course name. Not the beginning. - if ($textlib->strlen($course->shortname) > MESSAGE_MAX_COURSE_NAME_LENGTH) { - $courses_options[MESSAGE_VIEW_COURSE.$course->id] = '...'.$textlib->substr($course->shortname, -MESSAGE_MAX_COURSE_NAME_LENGTH); + $shortname = format_string($course->shortname, true, array('context' => $coursecontexts[$course->id])); + if ($textlib->strlen($shortname) > MESSAGE_MAX_COURSE_NAME_LENGTH) { + $courses_options[MESSAGE_VIEW_COURSE.$course->id] = '...'.$textlib->substr($shortname, -MESSAGE_MAX_COURSE_NAME_LENGTH); } else { - $courses_options[MESSAGE_VIEW_COURSE.$course->id] = $course->shortname; + $courses_options[MESSAGE_VIEW_COURSE.$course->id] = $shortname; } } } @@ -2021,7 +2022,7 @@ function message_post_message($userfrom, $userto, $message, $format) { $eventdata->smallmessage = $message;//store the message unfiltered. Clean up on output. $s = new stdClass(); - $s->sitename = $SITE->shortname; + $s->sitename = format_string($SITE->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID))); $s->url = $CFG->wwwroot.'/message/index.php?user='.$userto->id.'&id='.$userfrom->id; $emailtagline = get_string_manager()->get_string('emailtagline', 'message', $s, $userto->lang); diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index 2f18113c32d..6f17416f5f4 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -54,6 +54,8 @@ class assignment_base { var $cm; /** @var object */ var $course; + /** @var stdClass */ + var $coursecontext; /** @var object */ var $assignment; /** @var string */ @@ -119,6 +121,8 @@ class assignment_base { } else if (! $this->course = $DB->get_record('course', array('id'=>$this->cm->course))) { print_error('invalidid', 'assignment'); } + $this->coursecontext = get_context_instance(CONTEXT_COURSE, $this->course->id); + $courseshortname = format_text($this->course->shortname, true, array('context' => $coursecontext)); if ($assignment) { $this->assignment = $assignment; @@ -133,7 +137,7 @@ class assignment_base { $this->strassignments = get_string('modulenameplural', 'assignment'); $this->strsubmissions = get_string('submissions', 'assignment'); $this->strlastmodified = get_string('lastmodified'); - $this->pagetitle = strip_tags($this->course->shortname.': '.$this->strassignment.': '.format_string($this->assignment->name,true)); + $this->pagetitle = strip_tags($courseshortname.': '.$this->strassignment.': '.format_string($this->assignment->name, true, array('context' => $this->context))); // visibility handled by require_login() with $cm parameter // get current group only when really needed @@ -1849,8 +1853,9 @@ class assignment_base { * @return string */ function email_teachers_text($info) { - $posttext = format_string($this->course->shortname).' -> '.$this->strassignments.' -> '. - format_string($this->assignment->name)."\n"; + $posttext = format_string($this->course->shortname, true, array('context' => $this->coursecontext)).' -> '. + $this->strassignments.' -> '. + format_string($this->assignment->name, true, array('context' => $this->context))."\n"; $posttext .= '---------------------------------------------------------------------'."\n"; $posttext .= get_string("emailteachermail", "assignment", $info)."\n"; $posttext .= "\n---------------------------------------------------------------------\n"; @@ -1866,9 +1871,9 @@ class assignment_base { function email_teachers_html($info) { global $CFG; $posthtml = '

'. - ''.format_string($this->course->shortname).' ->'. + ''.format_string($this->course->shortname, true, array('context' => $this->coursecontext)).' ->'. ''.$this->strassignments.' ->'. - ''.format_string($this->assignment->name).'

'; + ''.format_string($this->assignment->name, true, array('context' => $this->context)).'

'; $posthtml .= '
'; $posthtml .= '

'.get_string('emailteachermailhtml', 'assignment', $info).'

'; $posthtml .= '

'; @@ -2589,8 +2594,10 @@ function assignment_cron () { /// mail is customised for the receiver. cron_setup_user($user, $course); - if (!is_enrolled(get_context_instance(CONTEXT_COURSE, $submission->course), $user->id)) { - echo fullname($user)." not an active participant in " . format_string($course->shortname) . "\n"; + $coursecontext = get_context_instance(CONTEXT_COURSE, $submission->course); + $courseshortname = format_string($course->shortname, true, array('context' => $coursecontext)); + if (!is_enrolled($coursecontext, $user->id)) { + echo fullname($user)." not an active participant in " . $courseshortname . "\n"; continue; } @@ -2616,15 +2623,15 @@ function assignment_cron () { $assignmentinfo->assignment = format_string($submission->name,true); $assignmentinfo->url = "$CFG->wwwroot/mod/assignment/view.php?id=$mod->id"; - $postsubject = "$course->shortname: $strassignments: ".format_string($submission->name,true); - $posttext = "$course->shortname -> $strassignments -> ".format_string($submission->name,true)."\n"; + $postsubject = "$courseshortname: $strassignments: ".format_string($submission->name,true); + $posttext = "$courseshortname -> $strassignments -> ".format_string($submission->name,true)."\n"; $posttext .= "---------------------------------------------------------------------\n"; $posttext .= get_string("assignmentmail", "assignment", $assignmentinfo)."\n"; $posttext .= "---------------------------------------------------------------------\n"; if ($user->mailformat == 1) { // HTML $posthtml = "

". - "wwwroot/course/view.php?id=$course->id\">$course->shortname ->". + "wwwroot/course/view.php?id=$course->id\">$courseshortname ->". "wwwroot/mod/assignment/index.php?id=$course->id\">$strassignments ->". "wwwroot/mod/assignment/view.php?id=$mod->id\">".format_string($submission->name,true)."

"; $posthtml .= "
"; diff --git a/mod/chat/gui_ajax/index.php b/mod/chat/gui_ajax/index.php index 7b480f7891f..99dc589fb0b 100644 --- a/mod/chat/gui_ajax/index.php +++ b/mod/chat/gui_ajax/index.php @@ -44,7 +44,7 @@ if (!file_exists(dirname(__FILE__) . '/theme/'.$theme.'/chat.css')) { if (!$chat_sid = chat_login_user($chat->id, 'ajax', $groupid, $course)) { print_error('cantlogin', 'chat'); } - +$courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))); $module = array( 'name' => 'mod_chat_ajax', // chat gui's are not real plugins, we have to break the naming standards for JS modules here :-( 'fullpath' => '/mod/chat/gui_ajax/module.js', @@ -61,11 +61,11 @@ $modulecfg = array( 'timer'=>3000, 'chat_lasttime'=>0, 'chat_lastrow'=>null, - 'chatroom_name'=>format_string($course->shortname) . ": ".format_string($chat->name,true).$groupname + 'chatroom_name' => $courseshortname . ": " . format_string($chat->name, true) . $groupname ); $PAGE->requires->js_init_call('M.mod_chat_ajax.init', array($modulecfg), false, $module); -$PAGE->set_title(get_string('modulename', 'chat').": $course->shortname: ".format_string($chat->name,true)."$groupname"); +$PAGE->set_title(get_string('modulename', 'chat').": $courseshortname: ".format_string($chat->name,true)."$groupname"); $PAGE->add_body_class('yui-skin-sam'); $PAGE->set_pagelayout('embedded'); $PAGE->requires->css('/mod/chat/gui_ajax/theme/'.$theme.'/chat.css'); diff --git a/mod/chat/gui_header_js/index.php b/mod/chat/gui_header_js/index.php index 92621f9e88d..5c298ba6f50 100644 --- a/mod/chat/gui_header_js/index.php +++ b/mod/chat/gui_header_js/index.php @@ -59,6 +59,7 @@ if (!empty($CFG->chat_normal_updatemode)) { $updatemode = $CFG->chat_normal_updatemode; } +$courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))); ?> @@ -66,7 +67,7 @@ if (!empty($CFG->chat_normal_updatemode)) { - <?php echo "$strchat: " . format_string($course->shortname) . ": ".format_string($chat->name,true)."$groupname" ?> + <?php echo "$strchat: " . $courseshortname . ": ".format_string($chat->name, true, array('context' => $context)) . "$groupname" ?> diff --git a/mod/chat/gui_sockets/index.php b/mod/chat/gui_sockets/index.php index 78b83394dc8..40cc52e6146 100644 --- a/mod/chat/gui_sockets/index.php +++ b/mod/chat/gui_sockets/index.php @@ -25,6 +25,7 @@ if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) { } require_login($course, false, $cm); +$context = get_context_instance(CONTEXT_MODULE, $cm->id); if (isguestuser()) { print_error('noguests', 'chat'); @@ -52,13 +53,14 @@ if (!$chat_sid = chat_login_user($chat->id, 'sockets', $groupid, $course)) { } $params = "chat_sid=$chat_sid"; +$courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))); ?> - <?php echo "$strchat: " . format_string($course->shortname) . ": ".format_string($chat->name,true)."$groupname" ?> + <?php echo "$strchat: " . $courseshortname . ": ".format_string($chat->name, true, array('context' => $context)) . "$groupname" ?> diff --git a/mod/chat/view.php b/mod/chat/view.php index 0475e8a2d87..0b86e50b334 100644 --- a/mod/chat/view.php +++ b/mod/chat/view.php @@ -77,7 +77,8 @@ $stridle = get_string('idle', 'chat'); $strcurrentusers = get_string('currentusers', 'chat'); $strnextsession = get_string('nextsession', 'chat'); -$title = $course->shortname . ': ' . format_string($chat->name); +$courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))); +$title = $courseshortname . ': ' . format_string($chat->name); // Mark viewed by user (if required) $completion = new completion_info($course); diff --git a/mod/choice/view.php b/mod/choice/view.php index b35e017c526..e4a49b0b928 100644 --- a/mod/choice/view.php +++ b/mod/choice/view.php @@ -144,10 +144,13 @@ $SESSION->wantsurl = $FULLME; $SESSION->enrolcancel = (!empty($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : ''; + $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); + $courseshortname = format_string($course->shortname, true, array('context' => $coursecontext)); + echo $OUTPUT->box_start('generalbox', 'notice'); echo '

'. get_string('notenrolledchoose', 'choice') .'

'; echo $OUTPUT->container_start('continuebutton'); - echo $OUTPUT->single_button(new moodle_url('/enrol/index.php?', array('id'=>$course->id)), get_string('enrolme', 'core_enrol', format_string($course->shortname))); + echo $OUTPUT->single_button(new moodle_url('/enrol/index.php?', array('id'=>$course->id)), get_string('enrolme', 'core_enrol', $courseshortname)); echo $OUTPUT->container_end(); echo $OUTPUT->box_end(); diff --git a/mod/data/edit.php b/mod/data/edit.php index 4ad9c58c361..e406dc2da8d 100644 --- a/mod/data/edit.php +++ b/mod/data/edit.php @@ -107,8 +107,8 @@ if ($cancel) { /// RSS and CSS and JS meta if (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds) && $data->rssarticles > 0) { $rsspath = rss_get_url($context->id, $USER->id, 'mod_data', $data->id); - $PAGE->add_alternate_version(format_string($course->shortname) . ': %fullname%', - $rsspath, 'application/rss+xml'); + $courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))); + $PAGE->add_alternate_version($courseshortname . ': %fullname%', $rsspath, 'application/rss+xml'); } if ($data->csstemplate) { $PAGE->requires->css('/mod/data/css.php?d='.$data->id); diff --git a/mod/data/rsslib.php b/mod/data/rsslib.php index aefe77d6c75..25791df73b1 100644 --- a/mod/data/rsslib.php +++ b/mod/data/rsslib.php @@ -78,11 +78,13 @@ array_push($items, $item); } $course = $DB->get_record('course', array('id'=>$data->course)); + $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); + $courseshortname = format_string($course->shortname, true, array('context' => $coursecontext)); // First all rss feeds common headers. - $header = rss_standard_header($course->shortname.': '.format_string($data->name,true), + $header = rss_standard_header($courseshortname . ': ' . format_string($data->name, true, array('context' => $context)), $CFG->wwwroot."/mod/data/view.php?d=".$data->id, - format_string($data->intro,true)); //TODO: fix format + format_text($data->intro, $data->introformat, array('context' => $context))); if (!empty($header)) { $articles = rss_add_items($items); diff --git a/mod/data/view.php b/mod/data/view.php index 3a68ae97ded..aa1e04533d0 100644 --- a/mod/data/view.php +++ b/mod/data/view.php @@ -276,10 +276,12 @@ $USER->editing = $edit; } + $courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))); + /// RSS and CSS and JS meta $meta = ''; if (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds) && $data->rssarticles > 0) { - $rsstitle = format_string($course->shortname) . ': %fullname%'; + $rsstitle = $courseshortname . ': %fullname%'; rss_add_http_header($context, 'mod_data', $data, $rsstitle); } if ($data->csstemplate) { @@ -296,7 +298,7 @@ /// Print the page header // Note: MDL-19010 there will be further changes to printing header and blocks. // The code will be much nicer than this eventually. - $title = $course->shortname.': ' . format_string($data->name); + $title = $courseshortname.': ' . format_string($data->name); if ($PAGE->user_allowed_editing()) { $buttons = ''; - echo '
'. diff --git a/mod/feedback/analysis_course.php b/mod/feedback/analysis_course.php index b1743a6a49b..1b500df8cd0 100644 --- a/mod/feedback/analysis_course.php +++ b/mod/feedback/analysis_course.php @@ -120,16 +120,17 @@ if ($courseitemfilter > 0) { GROUP BY course_id, shortname ORDER BY avgvalue desc", array($courseitemfiltertyp, $courseitemfilter))) { - $item = $DB->get_record('feedback_item', array('id'=>$courseitemfilter)); - echo '
'.$item->name.'
'; - echo ''; - $sep_dec = get_string('separator_decimal', 'feedback'); - $sep_thous = get_string('separator_thousand', 'feedback'); + $item = $DB->get_record('feedback_item', array('id'=>$courseitemfilter)); + echo ''; + echo ''; } else { echo ''; diff --git a/mod/feedback/analysis_to_excel.php b/mod/feedback/analysis_to_excel.php index 33920e588ec..7f978f2034e 100644 --- a/mod/feedback/analysis_to_excel.php +++ b/mod/feedback/analysis_to_excel.php @@ -310,8 +310,9 @@ function feedback_excelprint_detailed_items(&$worksheet, $xlsFormats, $completed } $worksheet->write_number($rowOffset, $colOffset, $courseid, $xlsFormats->default); $colOffset++; - if(isset($courseid) AND $course = $DB->get_record('course', array('id'=>$courseid))) { - $worksheet->write_string($rowOffset, $colOffset, $course->shortname, $xlsFormats->default); + if (isset($courseid) AND $course = $DB->get_record('course', array('id' => $courseid))) { + $shortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $courseid))); + $worksheet->write_string($rowOffset, $colOffset, $shortname, $xlsFormats->default); } return $rowOffset + 1; } diff --git a/mod/feedback/item/info/lib.php b/mod/feedback/item/info/lib.php index b6311a84eb3..4f2395aaddb 100644 --- a/mod/feedback/item/info/lib.php +++ b/mod/feedback/item/info/lib.php @@ -183,7 +183,8 @@ class feedback_item_info extends feedback_item_base { $itemshowvalue = UserDate($itemvalue); break; case 2: - $itemvalue = $course->shortname; + $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); + $itemvalue = format_string($course->shortname, true, array('context' => $coursecontext)); $itemshowvalue = $itemvalue; break; case 3: @@ -239,7 +240,8 @@ class feedback_item_info extends feedback_item_base { $itemshowvalue = UserDate($itemvalue); break; case 2: - $itemvalue = $course->shortname; + $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); + $itemvalue = format_string($course->shortname, true, array('context' => $coursecontext)); $itemshowvalue = $itemvalue; break; case 3: diff --git a/mod/feedback/lib.php b/mod/feedback/lib.php index c403112f38e..9d884dd0011 100644 --- a/mod/feedback/lib.php +++ b/mod/feedback/lib.php @@ -2684,7 +2684,9 @@ function feedback_send_email_anonym($cm, $feedback, $course) { * @return string the text you want to post */ function feedback_send_email_text($info, $course) { - $posttext = $course->shortname.' -> '.get_string('modulenameplural', 'feedback').' -> '. + $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); + $courseshortname = format_string($course->shortname, true, array('context' => $coursecontext)); + $posttext = $courseshortname.' -> '.get_string('modulenameplural', 'feedback').' -> '. $info->feedback."\n"; $posttext .= '---------------------------------------------------------------------'."\n"; $posttext .= get_string("emailteachermail", "feedback", $info)."\n"; @@ -2703,8 +2705,11 @@ function feedback_send_email_text($info, $course) { */ function feedback_send_email_html($info, $course, $cm) { global $CFG; + $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); + $courseshortname = format_string($course->shortname, true, array('context' => $coursecontext)); + $posthtml = '

'. - ''.$course->shortname.' ->'. + ''.$courseshortname.' ->'. ''.get_string('modulenameplural', 'feedback').' ->'. ''.$info->feedback.'

'; $posthtml .= '
'; diff --git a/mod/feedback/mapcourse.php b/mod/feedback/mapcourse.php index df7bc8c929f..8495cf7d84f 100644 --- a/mod/feedback/mapcourse.php +++ b/mod/feedback/mapcourse.php @@ -115,8 +115,10 @@ if($coursemap = feedback_get_courses_from_sitecourse_map($feedback->id)) { $unmapurl = new moodle_url('/mod/feedback/unmapcourse.php'); foreach ($coursemap as $cmap) { + $cmapcontext = get_context_instance(CONTEXT_COURSE, $cmap->id); + $cmapshortname = format_string($cmap->shortname, true, array('context' => $coursecontext)); $unmapurl->params(array('id'=>$id, 'cmapid'=>$cmap->id)); - $table->add_data(array('Delete ('.$cmap->shortname.') '.$cmap->fullname)); + $table->add_data(array('Delete ('.$cmapshortname.') '.$cmap->fullname)); } $table->print_html(); diff --git a/mod/forum/discuss.php b/mod/forum/discuss.php index ad095bd89bc..0e42828c9cc 100644 --- a/mod/forum/discuss.php +++ b/mod/forum/discuss.php @@ -60,7 +60,7 @@ if (!empty($CFG->enablerssfeeds) && !empty($CFG->forum_enablerssfeeds) && $forum->rsstype && $forum->rssarticles) { require_once("$CFG->libdir/rsslib.php"); - $rsstitle = format_string($course->shortname) . ': %fullname%'; + $rsstitle = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))) . ': %fullname%'; rss_add_http_header($modcontext, 'mod_forum', $forum, $rsstitle); } diff --git a/mod/forum/index.php b/mod/forum/index.php index ce365c705cd..18f054b4d0f 100644 --- a/mod/forum/index.php +++ b/mod/forum/index.php @@ -175,12 +175,13 @@ if (!is_null($subscribe) and !isguestuser()) { } } $returnto = forum_go_back_to("index.php?id=$course->id"); + $shortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))); if ($subscribe) { add_to_log($course->id, 'forum', 'subscribeall', "index.php?id=$course->id", $course->id); - redirect($returnto, get_string('nowallsubscribed', 'forum', format_string($course->shortname)), 1); + redirect($returnto, get_string('nowallsubscribed', 'forum', $shortname), 1); } else { add_to_log($course->id, 'forum', 'unsubscribeall', "index.php?id=$course->id", $course->id); - redirect($returnto, get_string('nowallunsubscribed', 'forum', format_string($course->shortname)), 1); + redirect($returnto, get_string('nowallunsubscribed', 'forum', $shortname), 1); } } diff --git a/mod/forum/lib.php b/mod/forum/lib.php index da89d0a498e..68cfc095368 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -610,7 +610,9 @@ function forum_cron() { $userfrom->customheaders[] = 'References: parent.'@'.$hostname.'>'; } - $postsubject = "$course->shortname: ".format_string($post->subject,true); + $shortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))); + + $postsubject = "$shortname: ".format_string($post->subject,true); $posttext = forum_make_mail_text($course, $cm, $forum, $discussion, $post, $userfrom, $userto); $posthtml = forum_make_mail_html($course, $cm, $forum, $discussion, $post, $userfrom, $userto); @@ -631,7 +633,7 @@ function forum_cron() { $smallmessagestrings = new stdClass(); $smallmessagestrings->user = fullname($userfrom); - $smallmessagestrings->forumname = "{$course->shortname}: ".format_string($forum->name,true).": ".$discussion->name; + $smallmessagestrings->forumname = "$shortname: ".format_string($forum->name,true).": ".$discussion->name; $smallmessagestrings->message = $post->message; //make sure strings are in message recipients language $eventdata->smallmessage = get_string_manager()->get_string('smallmessage', 'forum', $smallmessagestrings, $userto->lang); @@ -833,18 +835,19 @@ function forum_cron() { $strforums = get_string('forums', 'forum'); $canunsubscribe = ! forum_is_forcesubscribed($forum); $canreply = $userto->canpost[$discussion->id]; + $shortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))); $posttext .= "\n \n"; $posttext .= '====================================================================='; $posttext .= "\n \n"; - $posttext .= "$course->shortname -> $strforums -> ".format_string($forum->name,true); + $posttext .= "$shortname -> $strforums -> ".format_string($forum->name,true); if ($discussion->name != $forum->name) { $posttext .= " -> ".format_string($discussion->name,true); } $posttext .= "\n"; $posthtml .= "

". - "wwwroot/course/view.php?id=$course->id\">$course->shortname -> ". + "wwwroot/course/view.php?id=$course->id\">$shortname -> ". "wwwroot/mod/forum/index.php?id=$course->id\">$strforums -> ". "wwwroot/mod/forum/view.php?f=$forum->id\">".format_string($forum->name,true).""; if ($discussion->name == $forum->name) { @@ -1005,7 +1008,8 @@ function forum_make_mail_text($course, $cm, $forum, $discussion, $post, $userfro $posttext = ''; if (!$bare) { - $posttext = "$course->shortname -> $strforums -> ".format_string($forum->name,true); + $shortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))); + $posttext = "$shortname -> $strforums -> ".format_string($forum->name,true); if ($discussion->name != $forum->name) { $posttext .= " -> ".format_string($discussion->name,true); @@ -1028,7 +1032,7 @@ function forum_make_mail_text($course, $cm, $forum, $discussion, $post, $userfro if (!$bare && $canreply) { $posttext .= "---------------------------------------------------------------------\n"; - $posttext .= get_string("postmailinfo", "forum", $course->shortname)."\n"; + $posttext .= get_string("postmailinfo", "forum", $shortname)."\n"; $posttext .= "$CFG->wwwroot/mod/forum/post.php?reply=$post->id\n"; } if (!$bare && $canunsubscribe) { @@ -1068,6 +1072,7 @@ function forum_make_mail_html($course, $cm, $forum, $discussion, $post, $userfro $strforums = get_string('forums', 'forum'); $canunsubscribe = ! forum_is_forcesubscribed($forum); + $shortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))); $posthtml = ''; /* foreach ($CFG->stylesheets as $stylesheet) { @@ -1078,7 +1083,7 @@ function forum_make_mail_html($course, $cm, $forum, $discussion, $post, $userfro $posthtml .= "\n\n\n"; $posthtml .= '

CourseAverage
'.$item->name.'
'; + echo ''; + $sep_dec = get_string('separator_decimal', 'feedback'); + $sep_thous = get_string('separator_thousand', 'feedback'); - foreach ($courses as $c) { - echo ''; - } + foreach ($courses as $c) { + $shortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $c->course_id))); + echo ''; + } echo '
CourseAverage
'.$c->shortname.''.number_format(($c->avgvalue), 2, $sep_dec, $sep_thous).'
'.$shortname.''.number_format(($c->avgvalue), 2, $sep_dec, $sep_thous).'
'.get_string('noresults').'