function load_choices() {
        if (is_array($this->choices)) {
            return true;
        }
        list($sort, $sortparams) = users_order_by_sql('u');
        if (!empty($sortparams)) {
            throw new coding_exception('users_order_by_sql returned some query parameters. ' .
                    'This is unexpected, and a problem because there is no way to pass these ' .
                    'parameters to get_users_by_capability. See MDL-34657.');
        }
        $userfields = 'u.id, u.username, ' . get_all_user_name_fields(true, 'u');
        $users = get_users_by_capability(context_system::instance(), $this->capability, $userfields, $sort);
        $this->choices = array(
            '$@NONE@$' => get_string('nobody'),
            '$@ALL@$' => get_string('everyonewhocan', 'admin', get_capability_string($this->capability)),
        );
        if ($this->includeadmins) {
            $admins = get_admins();
            foreach ($admins as $user) {
                $this->choices[$user->id] = fullname($user);
            }
        }
        if (is_array($users)) {
            foreach ($users as $user) {
                $this->choices[$user->id] = fullname($user);
            }
        }
        return true;
    }
function load_choices() {
        if (is_array($this->choices)) {
            return true;
        }
        list($sort, $sortparams) = users_order_by_sql('u');
        if (!empty($sortparams)) {
            throw new coding_exception('users_order_by_sql returned some query parameters. ' .
                    'This is unexpected, and a problem because there is no way to pass these ' .
                    'parameters to get_users_by_capability. See MDL-34657.');
        }
        $userfields = 'u.id, u.username, ' . get_all_user_name_fields(true, 'u');
        $users = get_users_by_capability(context_system::instance(), $this->capability, $userfields, $sort);
        $this->choices = array(
            '$@NONE@$' => get_string('nobody'),
            '$@ALL@$' => get_string('everyonewhocan', 'admin', get_capability_string($this->capability)),
        );
        if ($this->includeadmins) {
            $admins = get_admins();
            foreach ($admins as $user) {
                $this->choices[$user->id] = fullname($user);
            }
        }
        if (is_array($users)) {
            foreach ($users as $user) {
                $this->choices[$user->id] = fullname($user);
            }
        }
        return true;
    }
function load_choices ( ) { if ( is_array ( $ this -> choices ) ) { return true ; } list ( $ sort , $ sortparams ) = users_order_by_sql ( 'u' ) ; if ( ! empty ( $ sortparams ) ) { throw new coding_exception ( 'users_order_by_sql returned some query parameters. ' . 'This is unexpected, and a problem because there is no way to pass these ' . 'parameters to get_users_by_capability. See MDL-34657.' ) ; } $ userfields = 'u.id, u.username, ' . get_all_user_name_fields ( true , 'u' ) ; $ users = get_users_by_capability ( context_system :: instance ( ) , $ this -> capability , $ userfields , $ sort ) ; $ this -> choices = array ( '$@NONE@$' => get_string ( 'nobody' ) , '$@ALL@$' => get_string ( 'everyonewhocan' , 'admin' , get_capability_string ( $ this -> capability ) ) , ) ; if ( $ this -> includeadmins ) { $ admins = get_admins ( ) ; foreach ( $ admins as $ user ) { $ this -> choices [ $ user -> id ] = fullname ( $ user ) ; } } if ( is_array ( $ users ) ) { foreach ( $ users as $ user ) { $ this -> choices [ $ user -> id ] = fullname ( $ user ) ; } } return true ; }
Load all of the uses who have the capability into choice array

@return bool Always returns true
Load all of the uses who have the capability into choice array