From b2bce32ff05c9c841036f42d43eefbb1e5eff609 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 20 Feb 2011 10:25:21 +0800 Subject: [PATCH] message MDL-26404 trimming course short to prevent long names messing up the UI --- message/lib.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/message/lib.php b/message/lib.php index df8535ca82d..e31a4d87230 100644 --- a/message/lib.php +++ b/message/lib.php @@ -68,6 +68,7 @@ define('SHOW_ACTION_LINKS_IN_CONTACT_LIST', true); define('MESSAGE_SEARCH_MAX_RESULTS', 200); define('MESSAGE_CONTACTS_PER_PAGE',10); +define('MESSAGE_MAX_COURSE_NAME_LENGTH', 30); if (!isset($CFG->message_contacts_refresh)) { // Refresh the contacts list every 60 seconds $CFG->message_contacts_refresh = 60; @@ -463,7 +464,13 @@ function message_print_usergroup_selector($viewing, $courses, $coursecontexts, $ foreach($courses as $course) { if (has_capability('moodle/course:viewparticipants', $coursecontexts[$course->id])) { - $courses_options[VIEW_COURSE.$course->id] = $course->shortname; + //Not using short_text() as we want the end of the course name. Not the beginning. + $textlib = textlib_get_instance(); + if ($textlib->strlen($course->shortname) > MESSAGE_MAX_COURSE_NAME_LENGTH) { + $courses_options[VIEW_COURSE.$course->id] = '...'.$textlib->substr($course->shortname, -MESSAGE_MAX_COURSE_NAME_LENGTH); + } else { + $courses_options[VIEW_COURSE.$course->id] = $course->shortname; + } } }