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]

Handles synchronising members using the enrolment LTI.

Copyright: 2016 Mark Nelson <markn@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 463 lines (20 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: sync_members  - X-Ref

Task for synchronising members using the enrolment LTI.

get_name()   X-Ref
Get a descriptive name for this task.

return: string

execute()   X-Ref
Performs the synchronisation of members.


fetch_members_from_consumer(ToolConsumer $consumer)   X-Ref
Fetches the members that belong to a ToolConsumer.

param: ToolConsumer $consumer
return: bool|User[]

should_sync_unenrol($syncmode)   X-Ref
Method to determine whether to sync unenrolments or not.

param: int $syncmode The tool's membersyncmode.
return: bool

should_sync_enrol($syncmode)   X-Ref
Method to determine whether to sync enrolments or not.

param: int $syncmode The tool's membersyncmode.
return: bool

sync_member_information(stdClass $tool, ToolConsumer $consumer, $members)   X-Ref
Performs synchronisation of member information and enrolments.

param: stdClass $tool
param: ToolConsumer $consumer
param: User[] $members
return: array An array of users from processed members and the number that were enrolled.

sync_unenrol(stdClass $tool, string $consumerkey, array $currentusers)   X-Ref
Performs unenrolment of users that are no longer enrolled in the consumer side.

param: stdClass $tool The tool record object.
param: string $consumerkey ensure we only unenrol users from this tool consumer.
param: array $currentusers The list of current users.
return: int The number of users that have been unenrolled.

sync_profile_images()   X-Ref
Performs synchronisation of user profile images.


do_context_membership_request(Context $context, ResourceLink $resourcelink = null,$membershipsurltemplate = '')   X-Ref
Performs membership service request using an LTI Context object.

If the context has a 'custom_context_memberships_url' setting, we use this to perform the membership service request.
Otherwise, if a context is associated with resource link, we try first to get the members using the
ResourceLink::doMembershipsService() method.
If we're still unable to fetch members from the resource link, we try to build a memberships URL from the memberships URL
endpoint template that is defined in the ToolConsumer profile and substitute the parameters accordingly.

param: Context $context The context object.
param: ResourceLink $resourcelink The resource link object.
param: string $membershipsurltemplate The memberships endpoint URL template.
return: bool|User[] Array of User objects upon successful membership service request. False, otherwise.

do_resourcelink_membership_request(ResourceLink $resourcelink)   X-Ref
Performs membership service request using ResourceLink::doMembershipsService() method.

param: ResourceLink $resourcelink
return: bool|User[] Array of User objects upon successful membership service request. False, otherwise.