MDL-11784 - On the role assign page, list who is assigned the role for roles with only a few assignments. Merged from MOODLE_19_STABLE.
This commit is contained in:
+18
-4
@@ -6,6 +6,7 @@
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
define("MAX_USERS_PER_PAGE", 5000);
|
||||
define("MAX_USERS_TO_LIST_PER_ROLE", 10);
|
||||
|
||||
$contextid = required_param('contextid',PARAM_INT); // context id
|
||||
$roleid = optional_param('roleid', 0, PARAM_INT); // required role id
|
||||
@@ -424,14 +425,27 @@
|
||||
$table->cellpadding = 5;
|
||||
$table->cellspacing = 0;
|
||||
$table->width = '60%';
|
||||
$table->head = array(get_string('roles', 'role'), get_string('description'), get_string('users'));
|
||||
$table->wrap = array('nowrap', '', 'nowrap');
|
||||
$table->align = array('right', 'left', 'center');
|
||||
$table->head = array(get_string('roles', 'role'), get_string('description'), get_string('users'), '');
|
||||
$table->wrap = array('nowrap', '', 'nowrap', 'nowrap');
|
||||
$table->align = array('right', 'left', 'center', 'left');
|
||||
|
||||
foreach ($assignableroles as $roleid => $rolename) {
|
||||
$countusers = count_role_users($roleid, $context);
|
||||
$strroleusers = '';
|
||||
if (0 < $countusers && $countusers <= MAX_USERS_TO_LIST_PER_ROLE) {
|
||||
$roleusers = get_role_users($roleid, $context, false, 'u.id, u.lastname, u.firstname');
|
||||
if (!empty($roleusers)) {
|
||||
$strroleusers = array();
|
||||
foreach ($roleusers as $user) {
|
||||
$strroleusers[] = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '" >' . fullname($user) . '</a>';
|
||||
}
|
||||
$strroleusers = implode('<br />', $strroleusers);
|
||||
}
|
||||
} else if ($countusers > MAX_USERS_TO_LIST_PER_ROLE) {
|
||||
$strroleusers = get_string('morethan', 'role', MAX_USERS_TO_LIST_PER_ROLE);
|
||||
}
|
||||
$description = format_string(get_field('role', 'description', 'id', $roleid));
|
||||
$table->data[] = array('<a href="'.$baseurl.'&roleid='.$roleid.'">'.$rolename.'</a>',$description, $countusers);
|
||||
$table->data[] = array('<a href="'.$baseurl.'&roleid='.$roleid.'">'.$rolename.'</a>',$description, $countusers, $strroleusers);
|
||||
}
|
||||
|
||||
print_table($table);
|
||||
|
||||
@@ -85,6 +85,7 @@ $string['listallroles'] = 'List all roles';
|
||||
$string['manageroles'] = 'Manage roles';
|
||||
$string['metaassignerror'] = 'Can not assign this role to user \"$a\" because Manage metacourse capability is needed.';
|
||||
$string['metaunassignerror'] = 'Role of user \"$a\" was automatically reassigned, please unassign the role in child courses instead.';
|
||||
$string['morethan'] = 'More than $a';
|
||||
$string['my:manageblocks'] = 'Manage myMoodle page blocks';
|
||||
$string['nocapabilitiesincontext'] = 'No capabilities available in this context';
|
||||
$string['notset'] = 'Not set';
|
||||
|
||||
@@ -251,6 +251,7 @@ body#admin-index .copyright {
|
||||
}
|
||||
|
||||
#admin-roles-override .cell.c1,
|
||||
#admin-roles-assign .cell.c3,
|
||||
#admin-roles-assign .cell.c1 {
|
||||
font-size: 0.7em;
|
||||
}
|
||||
|
||||
@@ -985,6 +985,7 @@ body#admin-modules table.generaltable td.c0
|
||||
}
|
||||
|
||||
#admin-roles-override .cell.c1,
|
||||
#admin-roles-assign .cell.c3,
|
||||
#admin-roles-assign .cell.c1 {
|
||||
padding-top: 0.75em;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user