Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
/enrol/meta/ -> lib.php (source)

Meta course enrolment plugin.

Copyright: 2010 Petr Skoda {@link http://skodak.org}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 465 lines (18 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: enrol_meta_plugin  - X-Ref

Meta course enrolment plugin.

get_instance_name($instance)   X-Ref
Returns localised name of enrol instance

param: stdClass $instance (null is accepted too)
return: string

can_add_instance($courseid)   X-Ref
Returns true if we can add a new instance to this course.

param: int $courseid
return: boolean

allow_unenrol_user(stdClass $instance, stdClass $ue)   X-Ref
Does this plugin allow manual unenrolment of a specific user?
Yes, but only if user suspended...

param: stdClass $instance course enrol instance
param: stdClass $ue record from user_enrolments table
return: bool - true means user with 'enrol/xxx:unenrol' may unenrol this user, false means nobody may touch this user enrolment

course_updated($inserted, $course, $data)   X-Ref
Called after updating/inserting course.

param: bool $inserted true if course just inserted
param: stdClass $course
param: stdClass $data form data
return: void

add_instance($course, array $fields = null)   X-Ref
Add new instance of enrol plugin.

param: object $course
param: array $fields instance fields
return: int id of last instance, null if can not be created

update_instance($instance, $data)   X-Ref
Update instance of enrol plugin.

param: stdClass $instance
param: stdClass $data modified instance fields
return: boolean

update_status($instance, $newstatus)   X-Ref
Update instance status

param: stdClass $instance
param: int $newstatus ENROL_INSTANCE_ENABLED, ENROL_INSTANCE_DISABLED
return: void

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

param: stdClass $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

use_standard_editing_ui()   X-Ref
We are a good plugin and don't invent our own UI/validation code path.

return: boolean

get_course_options($instance, $coursecontext)   X-Ref
Return an array of valid options for the courses.

param: stdClass $instance
param: context $coursecontext
return: array

get_group_options($coursecontext)   X-Ref
Return an array of valid options for the groups.

param: context $coursecontext
return: array

edit_instance_form($instance, MoodleQuickForm $mform, $coursecontext)   X-Ref
Add elements to the edit instance form.

param: stdClass $instance
param: MoodleQuickForm $mform
param: context $coursecontext
return: bool

edit_instance_validation($data, $files, $instance, $context)   X-Ref
Perform custom validation of the data used to edit the instance.

param: array $data array of ("fieldname"=>value) of submitted data
param: array $files array of uploaded files "element_name"=>tmp_file_path
param: object $instance The instance loaded from the DB
param: context $context The context of the instance we are editing
return: array of "element_name"=>"error_description" if there are errors,
return: void

restore_instance(restore_enrolments_structure_step $step, stdClass $data, $course, $oldid)   X-Ref
Restore instance and map settings.

param: restore_enrolments_structure_step $step
param: stdClass $data
param: stdClass $course
param: int $oldid

restore_user_enrolment(restore_enrolments_structure_step $step, $data, $instance, $userid, $oldinstancestatus)   X-Ref
Restore user enrolment.

param: restore_enrolments_structure_step $step
param: stdClass $data
param: stdClass $instance
param: int $userid
param: int $oldinstancestatus

restore_group_member($instance, $groupid, $userid)   X-Ref
Restore user group membership.

param: stdClass $instance
param: int $groupid
param: int $userid