]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11784 - On the role assign page, list who is assigned the role for roles with...
authortjhunt <tjhunt>
Tue, 23 Oct 2007 16:27:25 +0000 (16:27 +0000)
committertjhunt <tjhunt>
Tue, 23 Oct 2007 16:27:25 +0000 (16:27 +0000)
admin/roles/assign.php
lang/en_utf8/role.php
theme/standard/styles_fonts.css
theme/standard/styles_layout.css

index ddeaa054e5b12a977a7b2767d03fe8add275ce43..df682f79b946c497d0d639aec634e4a33c206ddf 100755 (executable)
@@ -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
         $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);
index e04da188058dc62118469691ebcd6d1cdcedbc5c..92a9cf727a5356436eb1160557a530d4ead0252e 100644 (file)
@@ -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';
index 2eb5094e0e3f42d0f135ee58e517909b54821331..07da3c2e3a0e35de4b32aa15ae6a9fe47f89c970 100644 (file)
@@ -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;
 }
index bf2869c5ad8c358a540533a9f9b9987dc9e097bb..da33152d9ed48fcaa918fead56f35ae59541b943 100644 (file)
@@ -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;
 }