MDL-63387 enrol_cohort: show both roles names in instance config form.
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user