Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

Base implementation of a userlist.

Copyright: 2018 Andrew Nicols <andrew@nicols.co.uk>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 220 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

userlist_base:: (14 methods):
  __construct()
  set_userids()
  add_userids()
  get_userids()
  get_users()
  set_component()
  get_component()
  current()
  key()
  next()
  valid()
  rewind()
  count()
  get_context()


Class: userlist_base  - X-Ref

Base implementation of a userlist used to store a set of users.

__construct(\context $context, string $component)   X-Ref
Constructor to create a new userlist.

param: \context    $context
param: string      $component

set_userids(array $userids)   X-Ref
Set the userids.

return: $this
param: array   $userids The list of users.

add_userids(array $userids)   X-Ref
Add a set of additional userids.

return: $this
param: array   $userids The list of users.

get_userids()   X-Ref
Get the list of user IDs that relate to this request.

return: int[]

get_users()   X-Ref
Get the complete list of user objects that relate to this request.

return: \stdClass[]

set_component($component)   X-Ref
Sets the component for this userlist.

return: $this
param: string $component the frankenstyle component name.

get_component()   X-Ref
Get the name of the component to which this userlist belongs.

return: string the component name associated with this userlist.

current()   X-Ref
Return the current user.

return: \user

key()   X-Ref
Return the key of the current element.

return: mixed

next()   X-Ref
Move to the next user in the list.


valid()   X-Ref
Check if the current position is valid.

return: bool

rewind()   X-Ref
Rewind to the first found user.

The list of users is uniqued during the rewind.
The rewind is called at the start of most iterations.

count()   X-Ref
Return the number of users.


get_context()   X-Ref
Get the context for this userlist

return: \context