Skip to content
Browse files

MDL-11784 - On the role assign page, list who is assigned the role fo…

…r roles with only a few assignments. Merged from MOODLE_19_STABLE.
  • Loading branch information...
1 parent c0fa4bc commit dcd55b7e80b52a5af30af4c25d2fbf6a0fcd28c3 tjhunt committed Oct 23, 2007
Showing with 21 additions and 4 deletions.
  1. +18 −4 admin/roles/assign.php
  2. +1 −0 lang/en_utf8/role.php
  3. +1 −0 theme/standard/styles_fonts.css
  4. +1 −0 theme/standard/styles_layout.css
View
22 admin/roles/assign.php
@@ -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.'&amp;roleid='.$roleid.'">'.$rolename.'</a>',$description, $countusers);
+ $table->data[] = array('<a href="'.$baseurl.'&amp;roleid='.$roleid.'">'.$rolename.'</a>',$description, $countusers, $strroleusers);
}
print_table($table);
View
1 lang/en_utf8/role.php
@@ -85,6 +85,7 @@
$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';
View
1 theme/standard/styles_fonts.css
@@ -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;
}
View
1 theme/standard/styles_layout.css
@@ -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;
}

0 comments on commit dcd55b7

Please sign in to comment.
Something went wrong with that request. Please try again.