From f6a2d57b3ed860db31b18bf3737dae0f41b9c29e Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Tue, 1 Sep 2020 11:34:40 +0100 Subject: [PATCH] MDL-63387 enrol_cohort: show both roles names in instance config form. --- enrol/cohort/lib.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/enrol/cohort/lib.php b/enrol/cohort/lib.php index aaca643ba58..1f5214b2d8d 100644 --- a/enrol/cohort/lib.php +++ b/enrol/cohort/lib.php @@ -68,7 +68,7 @@ class enrol_cohort_plugin extends enrol_plugin { } $cohortname = format_string($cohort->name, true, array('context'=>context::instance_by_id($cohort->contextid))); if ($role = $DB->get_record('role', array('id'=>$instance->roleid))) { - $role = role_get_name($role, context_course::instance($instance->courseid, IGNORE_MISSING)); + $role = role_get_name($role, context_course::instance($instance->courseid, IGNORE_MISSING), ROLENAME_BOTH); return get_string('pluginname', 'enrol_'.$enrol) . ' (' . $cohortname . ' - ' . $role .')'; } else { return get_string('pluginname', 'enrol_'.$enrol) . ' (' . $cohortname . ')'; @@ -364,13 +364,14 @@ class enrol_cohort_plugin extends enrol_plugin { protected function get_role_options($instance, $coursecontext) { global $DB; - $roles = get_assignable_roles($coursecontext); + $roles = get_assignable_roles($coursecontext, ROLENAME_BOTH); $roles[0] = get_string('none'); $roles = array_reverse($roles, true); // Descending default sortorder. + + // If the instance is already configured, but the configured role is no longer assignable in the course then add it back. if ($instance->id and !isset($roles[$instance->roleid])) { if ($role = $DB->get_record('role', array('id' => $instance->roleid))) { - $roles = role_fix_names($roles, $coursecontext, ROLENAME_ALIAS, true); - $roles[$instance->roleid] = role_get_name($role, $coursecontext); + $roles[$instance->roleid] = role_get_name($role, $coursecontext, ROLENAME_BOTH); } else { $roles[$instance->roleid] = get_string('error'); } -- 2.43.0