message MDL-26404 trimming course short to prevent long names messing up the UI

This commit is contained in:
Andrew
2011-02-23 11:00:41 +08:00
committed by Andrew Davis (andyjdavis)
parent fa188aa0a2
commit b2bce32ff0
+8 -1
View File
@@ -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;
}
}
}