Respect role names for logged students. MDL-16569 ; merged from 19_STABLE.
authorstronk7 <stronk7>
Thu, 18 Sep 2008 15:16:02 +0000 (15:16 +0000)
committerstronk7 <stronk7>
Thu, 18 Sep 2008 15:16:02 +0000 (15:16 +0000)
Credit goes to Otakar Šprdlík

course/lib.php

index a18ba28a2675b0c2cba1b4a375a24d9bc3897402..ea68ec5169710c0f37cf112e7c56555bf9518aaa 100644 (file)
@@ -2018,8 +2018,20 @@ function print_course($course) {
                                      true, '', 'r.sortorder ASC, u.lastname ASC', $canseehidden);
             if (is_array($rusers) && count($rusers)) {
                 $canviewfullnames = has_capability('moodle/site:viewfullnames', $context);
+
+                /// Rename some of the role names if needed
+                if (isset($context)) {
+                    $aliasnames = $DB->get_records('role_names', array('contextid'=>$context->id), '', 'roleid,contextid,name');
+                }
+
                 foreach ($rusers as $teacher) {
                     $fullname = fullname($teacher, $canviewfullnames);
+
+                    /// Apply role names
+                    if (isset($aliasnames[$teacher->roleid])) {
+                        $teacher->rolename = $aliasnames[$teacher->roleid]->name;
+                    }
+
                     $namesarray[] = format_string($teacher->rolename)
                         . ': <a href="'.$CFG->wwwroot.'/user/view.php?id='.$teacher->id.'&amp;course='.SITEID.'">'
                         . $fullname . '</a>';