Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]

This file defines the userlist_collection class object. The userlist_collection is used to organize a collection of userlists.

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

Defines 1 class

userlist_collection:: (12 methods):
  __construct()
  get_context()
  add_userlist()
  get_userlists()
  get_userlist_for_component()
  current()
  key()
  next()
  valid()
  rewind()
  get_key_from_position()
  count()


Class: userlist_collection  - X-Ref

A collection of userlist items.

__construct(\context $context)   X-Ref
Constructor to create a new userlist_collection.

param: \context    $context The context to which this collection belongs.

get_context()   X-Ref
Return the context that this collection relates to.

return: int

add_userlist(userlist_base $userlist)   X-Ref
Add a userlist to this collection.

param: userlist_base $userlist the userlist to export.
return: $this

get_userlists()   X-Ref
Get the userlists in this collection.

return: array   the associative array of userlists in this collection, indexed by component name.

get_userlist_for_component(string $component)   X-Ref
Get the userlist for the specified component.

param: string      $component the frankenstyle name of the component to fetch for.
return: userlist_base|null

current()   X-Ref
Return the current contexlist.

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.

get_key_from_position()   X-Ref
Get the key for the current iterator position.

return: string

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