Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

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

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: 465 lines (19 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 containing the number of members that were processed and the number of members that were enrolled.

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

param: stdClass $tool The tool record object.
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.