Permalink
Browse files

adminlib: MDL-19038 lazy-load the list of users in admin_setting_user…

…s_with_capability
  • Loading branch information...
1 parent 551d425 commit cb5c33b23520a94fee1e2ce8dae9b86447d24677 tjhunt committed May 1, 2009
Showing with 13 additions and 5 deletions.
  1. +13 −5 lib/adminlib.php
View
@@ -2572,16 +2572,24 @@ class admin_setting_users_with_capability extends admin_setting_configmultiselec
* @param string $capability string capability name.
*/
function admin_setting_users_with_capability($name, $visiblename, $description, $defaultsetting, $capability) {
+ $this->capability = $capability;
+ parent::admin_setting_configmultiselect($name, $visiblename, $description, $defaultsetting, NULL);
+ }
+
+ function load_choices() {
+ if (is_array($this->choices)) {
+ return true;
+ }
$users = get_users_by_capability(get_context_instance(CONTEXT_SYSTEM),
- $capability, 'u.id,u.username,u.firstname,u.lastname', 'u.lastname,u.firstname');
- $choices = array(
+ $this->capability, 'u.id,u.username,u.firstname,u.lastname', 'u.lastname,u.firstname');
+ $this->choices = array(
'$@NONE@$' => get_string('nobody'),
- '$@ALL@$' => get_string('everyonewhocan', 'admin', get_capability_string($capability)),
+ '$@ALL@$' => get_string('everyonewhocan', 'admin', get_capability_string($this->capability)),
);
foreach ($users as $user) {
- $choices[$user->username] = fullname($user);
+ $this->choices[$user->username] = fullname($user);
}
- parent::admin_setting_configmultiselect($name, $visiblename, $description, $defaultsetting, $choices);
+ return true;
}
function get_defaultsetting() {

0 comments on commit cb5c33b

Please sign in to comment.