MDL-63387 user: show both role names on course participants page.
authorPaul Holden <paulh@moodle.com>
Tue, 16 Jun 2020 21:38:46 +0000 (22:38 +0100)
committerPaul Holden <paulh@moodle.com>
Tue, 1 Sep 2020 11:05:26 +0000 (12:05 +0100)
user/classes/output/participants_filter.php
user/classes/output/user_roles_editable.php
user/classes/table/participants.php

index 443c5a2..17dd34c 100644 (file)
@@ -129,10 +129,10 @@ class participants_filter implements renderable, templatable {
     protected function get_roles_filter(): ?stdClass {
         $roles = [];
         $roles += [-1 => get_string('noroles', 'role')];
     protected function get_roles_filter(): ?stdClass {
         $roles = [];
         $roles += [-1 => get_string('noroles', 'role')];
-        $roles += get_viewable_roles($this->context);
+        $roles += get_viewable_roles($this->context, null, ROLENAME_BOTH);
 
         if (has_capability('moodle/role:assign', $this->context)) {
 
         if (has_capability('moodle/role:assign', $this->context)) {
-            $roles += get_assignable_roles($this->context, ROLENAME_ALIAS);
+            $roles += get_assignable_roles($this->context, ROLENAME_BOTH);
         }
 
         return $this->get_filter_object(
         }
 
         return $this->get_filter_object(
index 4ee1961..cc75328 100644 (file)
@@ -173,8 +173,8 @@ class user_roles_editable extends \core\output\inplace_editable {
         }
 
         // Check that all the groups belong to the course.
         }
 
         // Check that all the groups belong to the course.
-        $allroles = role_fix_names(get_all_roles($context), $context);
-        $assignableroles = get_assignable_roles($context, ROLENAME_ALIAS, false);
+        $allroles = role_fix_names(get_all_roles($context), $context, ROLENAME_BOTH);
+        $assignableroles = get_assignable_roles($context, ROLENAME_BOTH, false);
         $viewableroles = get_viewable_roles($context);
         $userrolesbyid = get_user_roles($context, $userid, true, 'c.contextlevel DESC, r.sortorder ASC');
         $profileroles = get_profile_roles($context);
         $viewableroles = get_viewable_roles($context);
         $userrolesbyid = get_user_roles($context, $userid, true, 'c.contextlevel DESC, r.sortorder ASC');
         $profileroles = get_profile_roles($context);
index 04d47f5..f03abed 100644 (file)
@@ -202,8 +202,11 @@ class participants extends \table_sql implements dynamic_table {
         if ($canseegroups) {
             $this->groups = groups_get_all_groups($this->courseid, 0, 0, 'g.*', true);
         }
         if ($canseegroups) {
             $this->groups = groups_get_all_groups($this->courseid, 0, 0, 'g.*', true);
         }
-        $this->allroles = role_fix_names(get_all_roles($this->context), $this->context);
-        $this->assignableroles = get_assignable_roles($this->context, ROLENAME_ALIAS, false);
+
+        // If user has capability to review enrol, show them both role names.
+        $allrolesnamedisplay = ($canreviewenrol ? ROLENAME_BOTH : ROLENAME_ALIAS);
+        $this->allroles = role_fix_names(get_all_roles($this->context), $this->context, $allrolesnamedisplay);
+        $this->assignableroles = get_assignable_roles($this->context, ROLENAME_BOTH, false);
         $this->profileroles = get_profile_roles($this->context);
         $this->viewableroles = get_viewable_roles($this->context);
 
         $this->profileroles = get_profile_roles($this->context);
         $this->viewableroles = get_viewable_roles($this->context);