Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

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

IMS Enterprise file enrolment plugin. This plugin lets the user specify an IMS Enterprise file to be processed. The IMS Enterprise file is mainly parsed on a regular cron, but can also be imported via the UI (Admin Settings).

Author: Eugene Venter - based on code by Dan Stowell
Copyright: 2010 Eugene Venter
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 1054 lines (48 kb)
Included or required: 1 time
Referenced: 1 time
Includes or requires: 1 file
 enrol/imsenterprise/locallib.php

Defines 1 class


Class: enrol_imsenterprise_plugin  - X-Ref

IMS Enterprise file enrolment plugin.

cron()   X-Ref
Read in an IMS Enterprise file.
Originally designed to handle v1.1 files but should be able to handle
earlier types as well, I believe.
This cron feature has been converted to a scheduled task and it can now be scheduled
from the UI.


full_tag_found_in_cache($tagname, $latestline)   X-Ref
Check if a complete tag is found in the cached data, which usually happens
when the end of the tag has only just been loaded into the cache.

param: string $tagname Name of tag to look for
param: string $latestline The very last line in the cache (used for speeding up the match)
return: bool|string false, or the contents of the tag (including start and end).

remove_tag_from_cache($tagname)   X-Ref
Remove complete tag from the cached data (including all its contents) - so
that the cache doesn't grow to unmanageable size

param: string $tagname Name of tag to look for

get_recstatus($tagdata, $tagname)   X-Ref
Very simple convenience function to return the "recstatus" found in person/group/role tags.
1=Add, 2=Update, 3=Delete, as specified by IMS, and we also use 0 to indicate "unspecified".

param: string $tagdata the tag XML data
param: string $tagname the name of the tag we're interested in
return: int recstatus value

process_group_tag($tagcontents)   X-Ref
Process the group tag. This defines a Moodle course.

param: string $tagcontents The raw contents of the XML element

process_person_tag($tagcontents)   X-Ref
Process the person tag. This defines a Moodle user.

param: string $tagcontents The raw contents of the XML element

process_membership_tag($tagcontents)   X-Ref
Process the membership tag. This defines whether the specified Moodle users
should be added/removed as teachers/students.

param: string $tagcontents The raw contents of the XML element

process_properties_tag($tagcontents)   X-Ref
Process the properties tag. The only data from this element
that is relevant is whether a <target> is specified.

param: string $tagcontents The raw contents of the XML element

log_line($string)   X-Ref
Store logging information. This does two things: uses the {@link mtrace()}
function to print info to screen/STDOUT, and also writes log to a text file
if a path has been specified.

param: string $string Text to write (newline will be added automatically)

decode_timeframe($string)   X-Ref
Process the INNER contents of a <timeframe> tag, to return beginning/ending dates.

param: string $string tag to decode.
return: stdClass beginning and/or ending is returned, in unix time, zero indicating not specified.

load_role_mappings()   X-Ref
Load the role mappings (from the config), so we can easily refer to
how an IMS-E role corresponds to a Moodle role


load_course_mappings()   X-Ref
Load the name mappings (from the config), so we can easily refer to
how an IMS-E course properties corresponds to a Moodle course properties


get_default_category_id()   X-Ref
Get the default category id (often known as 'Miscellaneous'),
statically cached to avoid multiple DB lookups on big imports.

return: int id of default category.

get_category_from_group($categories)   X-Ref
Find the category using idnumber or name.

param: array $categories List of categories
return: int id of category found.

can_delete_instance($instance)   X-Ref
Is it possible to delete enrol instance via standard UI?

param: object $instance
return: bool

can_hide_show_instance($instance)   X-Ref
Is it possible to hide/show enrol instance via standard UI?

param: stdClass $instance
return: bool

enrol_imsenterprise_allow_group_member_remove($itemid, $groupid, $userid)   X-Ref
Called whenever anybody tries (from the normal interface) to remove a group
member which is registered as being created by this component. (Not called
when deleting an entire group or course at once.)

param: int $itemid Item ID that was stored in the group_members entry
param: int $groupid Group ID
param: int $userid User ID being removed from group
return: bool True if the remove is permitted, false to give an error