Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

message MDL-26404 trimming course short to prevent long names messing…

… up the UI
  • Loading branch information...
commit b2bce32ff05c9c841036f42d43eefbb1e5eff609 1 parent fa188aa
Andrew authored andyjdavis committed
Showing with 8 additions and 1 deletion.
  1. +8 −1 message/lib.php
View
9 message/lib.php
@@ -68,6 +68,7 @@
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;
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.