Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
|
Enrolment plugins abstract class. More...
Public Member Functions | |
add_course_navigation ($instancesnode, stdClass $instance) | |
Adds navigation links into course admin block. | |
add_custom_instance (stdClass $course, ?array $fields=null) | |
Add new instance of enrol plugin with custom settings, called when adding new instance manually or when adding new course. | |
add_default_instance ($course) | |
Add new instance of enrol plugin with default settings, called when adding new instance manually or when adding new course. | |
add_instance ($course, array $fields=NULL) | |
Add new instance of enrol plugin. | |
allow_enrol (stdClass $instance) | |
Does this plugin allow manual enrolments? | |
allow_manage (stdClass $instance) | |
Does this plugin allow manual changes in user_enrolments table? | |
allow_unenrol (stdClass $instance) | |
Does this plugin allow manual unenrolment of all users? All plugins allowing this must implement 'enrol/xxx:unenrol' capability. | |
allow_unenrol_user (stdClass $instance, stdClass $ue) | |
Does this plugin allow manual unenrolment of a specific user? All plugins allowing this must implement 'enrol/xxx:unenrol' capability. | |
backup_annotate_custom_fields (backup_enrolments_execution_step $step, stdClass $enrol) | |
Backup execution step hook to annotate custom fields. | |
can_add_instance ($courseid) | |
Return whether or not, given the current state, it is possible to add a new instance of this enrolment plugin to the course. | |
can_delete_instance ($instance) | |
Is it possible to delete enrol instance via standard UI? | |
can_edit_instance ($instance) | |
Return whether or not, given the current state, it is possible to edit an instance of this enrolment plugin in the course. | |
can_hide_show_instance ($instance) | |
Is it possible to hide/show enrol instance via standard UI? | |
can_self_enrol (stdClass $instance, $checkuserenrolment=true) | |
Checks if user can self enrol. | |
course_edit_form ($instance, MoodleQuickForm $mform, $data, $context) | |
Adds enrol instance UI to course edit form. | |
course_edit_validation ($instance, array $data, $context) | |
Validates course edit form data. | |
course_updated ($inserted, $course, $data) | |
Called after updating/inserting course. | |
cron () | |
Called for all enabled enrol plugins that returned true from is_cron_required(). | |
delete_instance ($instance) | |
Delete course enrol plugin instance, unenrol all users. | |
edit_instance_form ($instance, MoodleQuickForm $mform, $context) | |
Adds form elements to add/edit instance form. | |
edit_instance_validation ($data, $files, $instance, $context) | |
Perform custom validation of the data used to edit the instance. | |
enrol_page_hook (stdClass $instance) | |
Creates course enrol form, checks if form submitted and enrols user if necessary. | |
enrol_user (stdClass $instance, $userid, $roleid=null, $timestart=0, $timeend=0, $status=null, $recovergrades=null) | |
Enrol user into course via enrol instance. | |
fill_enrol_custom_fields (array $enrolmentdata, int $courseid) | |
Fill custom fields data for a given enrolment plugin. | |
find_instance (array $enrolmentdata, int $courseid) | |
Finds matching instances for a given course. | |
get_action_icons (stdClass $instance) | |
Returns edit icons for the page with list of instances. | |
get_bulk_operations (course_enrolment_manager $manager) | |
Return an array of enrol_bulk_enrolment_operation objects that define the bulk actions that can be performed on user enrolments by the plugin. | |
get_config ($name, $default=NULL) | |
Returns plugin config value. | |
get_description_text ($instance) | |
Returns optional enrolment instance description text. | |
get_enrol_info (stdClass $instance) | |
Return information for enrolment instance containing list of parameters required for enrolment, name of enrolment plugin etc. | |
get_info_icons (array $instances) | |
Returns optional enrolment information icons. | |
get_instance_defaults () | |
Returns defaults for new instances. | |
get_instance_name ($instance) | |
Returns localised name of enrol instance. | |
get_manual_enrol_button (course_enrolment_manager $manager) | |
Returns an enrol_user_button that takes the user to a page where they are able to enrol users into the managers course through this plugin. | |
get_manual_enrol_link ($instance) | |
Returns link to manual enrol UI if exists. | |
get_name () | |
Returns name of this enrol plugin. | |
get_newinstance_link ($courseid) | |
Returns link to page which may be used to add new instance of enrolment plugin in course. | |
get_unenrolself_link ($instance) | |
Returns list of unenrol links for all enrol instances in course. | |
get_user_enrolment_actions (course_enrolment_manager $manager, $ue) | |
Gets an array of the user enrolment actions. | |
get_welcome_message_contact (int $sendoption, context $context,) | |
Get the "from" contact which the message will be sent from. | |
has_bulk_operations (course_enrolment_manager $manager) | |
Returns true if the plugin has one or more bulk operations that can be performed on user enrolments. | |
instance_deleteable ($instance) | |
is_cron_required () | |
Reads version.php and determines if it is necessary to execute the cron job now. | |
is_csv_upload_supported () | |
Check if enrolment plugin is supported in csv course upload. | |
is_self_enrol_available (stdClass $instance) | |
Does this plugin support some way to self enrol? This function doesn't check user capabilities. | |
process_expirations (progress_trace $trace, $courseid=null) | |
Do any enrolments need expiration processing. | |
restore_group_member ($instance, $groupid, $userid) | |
Restore user group membership. | |
restore_instance (restore_enrolments_structure_step $step, stdClass $data, $course, $oldid) | |
Restore instance and map settings. | |
restore_role_assignment ($instance, $roleid, $userid, $contextid) | |
Restore role assignment. | |
restore_sync_course ($course) | |
Automatic enrol sync executed during restore. | |
restore_user_enrolment (restore_enrolments_structure_step $step, $data, $instance, $userid, $oldinstancestatus) | |
Restore user enrolment. | |
roles_protected () | |
Does this plugin assign protected roles are can they be manually removed? | |
send_course_welcome_message_to_user (stdClass $instance, int $userid, int $sendoption, ?string $message='',) | |
Send course welcome message to user. | |
send_expiry_notifications ($trace) | |
Send expiry notifications. | |
set_config ($name, $value) | |
Sets plugin config value. | |
show_enrolme_link (stdClass $instance) | |
Does this plugin support some way to user to self enrol? | |
sync_user_enrolments ($user) | |
Forces synchronisation of user enrolments. | |
try_autoenrol (stdClass $instance) | |
Attempt to automatically enrol current user in course without any interaction, calling code has to make sure the plugin and instance are active. | |
try_guestaccess (stdClass $instance) | |
Attempt to automatically gain temporary guest access to course, calling code has to make sure the plugin and instance are active. | |
unenrol_user (stdClass $instance, $userid) | |
Unenrol user from course, the last unenrolment removes all remaining roles. | |
update_communication (int $enrolmentinstanceid, string $action, stdClass $course) | |
Update instance members. | |
update_enrol_plugin_data (int $courseid, array $enrolmentdata, stdClass $instance) | |
Updates enrol plugin instance with provided data. | |
update_instance ($instance, $data) | |
Update instance of enrol plugin. | |
update_status ($instance, $newstatus) | |
Update instance status. | |
update_user_enrol (stdClass $instance, $userid, $status=NULL, $timestart=NULL, $timeend=NULL) | |
Store user_enrolments changes and trigger event. | |
use_standard_editing_ui () | |
This returns false for backwards compatibility, but it is really recommended. | |
user_delete ($user) | |
Called when user is about to be deleted. | |
validate_enrol_plugin_data (array $enrolmentdata, ?int $courseid=null) | |
Check if data is valid for a given enrolment plugin. | |
validate_param_types ($data, $rules) | |
Validate a list of parameter names and types. | |
validate_plugin_data_context (array $enrolmentdata, ?int $courseid=null) | |
Check if plugin custom data is allowed in relevant context. | |
Protected Member Functions | |
fetch_users_and_notify_expiry (int $timenow, string $name, progress_trace $trace) | |
Notify users about enrolment expiration. | |
get_enroller ($instanceid) | |
Returns the user who is responsible for enrolments for given instance. | |
get_expiry_message_body (stdClass $user, stdClass $ue, string $name, stdClass $enroller, context $context) | |
Generate subject and body messages for enrolment expiration notification. | |
load_config () | |
Makes sure config is loaded and cached. | |
notify_expiry_enrolled ($user, $ue, progress_trace $trace) | |
Notify user about incoming expiration of their enrolment, it is called only if notification of enrolled users (aka students) is enabled in course. | |
notify_expiry_enroller ($eid, $users, progress_trace $trace) | |
Notify person responsible for enrolments that some user enrolments will be expired soon, it is called only if notification of enrollers (aka teachers) is enabled in course. | |
Protected Attributes | |
$config = null | |
Enrolment plugins abstract class.
All enrol plugins should be based on this class, this is also the main source of documentation.
enrol_plugin::add_course_navigation | ( | $instancesnode, | |
stdClass | $instance ) |
Adds navigation links into course admin block.
By defaults looks for manage links only.
navigation_node | $instancesnode | |
stdClass | $instance |
void |
enrol_plugin::add_custom_instance | ( | stdClass | $course, |
?array | $fields = null ) |
Add new instance of enrol plugin with custom settings, called when adding new instance manually or when adding new course.
Used for example on course upload.
Not all plugins support this.
stdClass | $course | Course object |
array | null | $fields | instance fields |
int|null | id of new instance or null if not supported |
Reimplemented in enrol_cohort_plugin, and enrol_meta_plugin.
enrol_plugin::add_default_instance | ( | $course | ) |
Add new instance of enrol plugin with default settings, called when adding new instance manually or when adding new course.
Not all plugins support this.
object | $course |
?int | id of new instance or null if no default supported |
Reimplemented in enrol_guest_plugin, enrol_manual_plugin, and enrol_self_plugin.
enrol_plugin::add_instance | ( | $course, | |
array | $fields = NULL ) |
Add new instance of enrol plugin.
object | $course | |
array | instance fields |
int | id of new instance, null if can not be created |
Reimplemented in enrol_cohort_plugin, enrol_fee_plugin, enrol_guest_plugin, enrol_lti_plugin, enrol_manual_plugin, enrol_meta_plugin, enrol_paypal_plugin, and enrol_self_plugin.
enrol_plugin::allow_enrol | ( | stdClass | $instance | ) |
Does this plugin allow manual enrolments?
stdClass | $instance | course enrol instance All plugins allowing this must implement 'enrol/xxx:enrol' capability |
bool | - true means user with 'enrol/xxx:enrol' may enrol others freely, false means nobody may add more enrolments manually |
Reimplemented in enrol_manual_plugin.
enrol_plugin::allow_manage | ( | stdClass | $instance | ) |
Does this plugin allow manual changes in user_enrolments table?
All plugins allowing this must implement 'enrol/xxx:manage' capability
stdClass | $instance | course enrol instance |
bool | - true means it is possible to change enrol period and status in user_enrolments table |
Reimplemented in enrol_fee_plugin, enrol_flatfile_plugin, enrol_manual_plugin, enrol_paypal_plugin, and enrol_self_plugin.
enrol_plugin::allow_unenrol | ( | stdClass | $instance | ) |
Does this plugin allow manual unenrolment of all users? All plugins allowing this must implement 'enrol/xxx:unenrol' capability.
stdClass | $instance | course enrol instance |
bool | - true means user with 'enrol/xxx:unenrol' may unenrol others freely, false means nobody may touch user_enrolments |
Reimplemented in enrol_fee_plugin, enrol_flatfile_plugin, enrol_lti_plugin, enrol_manual_plugin, enrol_paypal_plugin, and enrol_self_plugin.
enrol_plugin::allow_unenrol_user | ( | stdClass | $instance, |
stdClass | $ue ) |
Does this plugin allow manual unenrolment of a specific user? All plugins allowing this must implement 'enrol/xxx:unenrol' capability.
This is useful especially for synchronisation plugins that do suspend instead of full unenrolment.
stdClass | $instance | course enrol instance |
stdClass | $ue | record from user_enrolments table, specifies user |
bool | - true means user with 'enrol/xxx:unenrol' may unenrol this user, false means nobody may touch this user enrolment |
Reimplemented in enrol_cohort_plugin, enrol_database_plugin, enrol_flatfile_plugin, and enrol_meta_plugin.
enrol_plugin::backup_annotate_custom_fields | ( | backup_enrolments_execution_step | $step, |
stdClass | $enrol ) |
Backup execution step hook to annotate custom fields.
backup_enrolments_execution_step | $step | |
stdClass | $enrol |
enrol_plugin::can_add_instance | ( | $courseid | ) |
Return whether or not, given the current state, it is possible to add a new instance of this enrolment plugin to the course.
Default implementation is just for backwards compatibility.
int | $courseid |
boolean |
Reimplemented in enrol_cohort_plugin, enrol_fee_plugin, enrol_guest_plugin, enrol_lti_plugin, enrol_manual_plugin, enrol_meta_plugin, enrol_mnet_plugin, enrol_paypal_plugin, and enrol_self_plugin.
enrol_plugin::can_delete_instance | ( | $instance | ) |
Is it possible to delete enrol instance via standard UI?
stdClass | $instance |
bool |
Reimplemented in enrol_category_plugin, enrol_cohort_plugin, enrol_database_plugin, enrol_fee_plugin, enrol_flatfile_plugin, enrol_guest_plugin, enrol_ldap_plugin, enrol_lti_plugin, enrol_manual_plugin, enrol_meta_plugin, enrol_mnet_plugin, enrol_paypal_plugin, and enrol_self_plugin.
enrol_plugin::can_edit_instance | ( | $instance | ) |
Return whether or not, given the current state, it is possible to edit an instance of this enrolment plugin in the course.
Used by the standard editing UI to generate a link to the edit instance form if editing is allowed.
stdClass | $instance |
boolean |
enrol_plugin::can_hide_show_instance | ( | $instance | ) |
Is it possible to hide/show enrol instance via standard UI?
stdClass | $instance |
bool |
Reimplemented in enrol_category_plugin, enrol_cohort_plugin, enrol_database_plugin, enrol_fee_plugin, enrol_flatfile_plugin, enrol_guest_plugin, enrol_ldap_plugin, enrol_lti_plugin, enrol_manual_plugin, enrol_meta_plugin, enrol_mnet_plugin, enrol_paypal_plugin, and enrol_self_plugin.
enrol_plugin::can_self_enrol | ( | stdClass | $instance, |
$checkuserenrolment = true ) |
Checks if user can self enrol.
stdClass | $instance | enrolment instance |
bool | $checkuserenrolment | if true will check if user enrolment is inactive. used by navigation to improve performance. |
bool|string | true if successful, else error message or false |
Reimplemented in enrol_self_plugin.
enrol_plugin::course_edit_form | ( | $instance, | |
MoodleQuickForm | $mform, | ||
$data, | |||
$context ) |
Adds enrol instance UI to course edit form.
object | $instance | enrol instance or null if does not exist yet |
MoodleQuickForm | $mform | |
object | $data | |
object | $context | context of existing course or parent category if course does not exist |
void |
enrol_plugin::course_edit_validation | ( | $instance, | |
array | $data, | ||
$context ) |
Validates course edit form data.
object | $instance | enrol instance or null if does not exist yet |
array | $data | |
object | $context | context of existing course or parent category if course does not exist |
array | errors array |
enrol_plugin::course_updated | ( | $inserted, | |
$course, | |||
$data ) |
Called after updating/inserting course.
bool | $inserted | true if course just inserted |
object | $course | |
object | $data | form data |
void |
Reimplemented in enrol_category_plugin, enrol_cohort_plugin, enrol_guest_plugin, and enrol_meta_plugin.
enrol_plugin::cron | ( | ) |
Called for all enabled enrol plugins that returned true from is_cron_required().
void |
Reimplemented in enrol_imsenterprise_plugin.
enrol_plugin::delete_instance | ( | $instance | ) |
Delete course enrol plugin instance, unenrol all users.
object | $instance |
void |
Reimplemented in enrol_lti_plugin.
enrol_plugin::edit_instance_form | ( | $instance, | |
MoodleQuickForm | $mform, | ||
$context ) |
Adds form elements to add/edit instance form.
object | $instance | enrol instance or null if does not exist yet |
MoodleQuickForm | $mform | |
context | $context |
void |
Reimplemented in enrol_cohort_plugin, enrol_fee_plugin, enrol_guest_plugin, enrol_lti_plugin, enrol_manual_plugin, enrol_meta_plugin, enrol_mnet_plugin, enrol_paypal_plugin, and enrol_self_plugin.
enrol_plugin::edit_instance_validation | ( | $data, | |
$files, | |||
$instance, | |||
$context ) |
Perform custom validation of the data used to edit the instance.
array | $data | array of ("fieldname"=>value) of submitted data |
array | $files | array of uploaded files "element_name"=>tmp_file_path |
object | $instance | The instance data loaded from the DB. |
context | $context | The context of the instance we are editing |
array | of "element_name"=>"error_description" if there are errors, or an empty array if everything is OK. |
Reimplemented in enrol_cohort_plugin, enrol_fee_plugin, enrol_guest_plugin, enrol_lti_plugin, enrol_manual_plugin, enrol_meta_plugin, enrol_mnet_plugin, enrol_paypal_plugin, and enrol_self_plugin.
enrol_plugin::enrol_page_hook | ( | stdClass | $instance | ) |
Creates course enrol form, checks if form submitted and enrols user if necessary.
It can also redirect.
stdClass | $instance |
string | html text, usually a form in a text box |
Reimplemented in enrol_fee_plugin, enrol_guest_plugin, enrol_paypal_plugin, and enrol_self_plugin.
enrol_plugin::enrol_user | ( | stdClass | $instance, |
$userid, | |||
$roleid = null, | |||
$timestart = 0, | |||
$timeend = 0, | |||
$status = null, | |||
$recovergrades = null ) |
Enrol user into course via enrol instance.
stdClass | $instance | |
int | $userid | |
int | $roleid | optional role id |
int | $timestart | 0 means unknown |
int | $timeend | 0 means forever |
int | $status | default to ENROL_USER_ACTIVE for new enrolments, no change by default in updates |
bool | $recovergrades | restore grade history |
void |
Reimplemented in enrol_flatfile_plugin, and enrol_guest_plugin.
|
protected |
Notify users about enrolment expiration.
Retrieves enrolment data from the database and notifies users about their upcoming course enrolment expiration based on expiry thresholds and notification settings.
int | $timenow | Current time. |
string | $name | Name of this enrol plugin. |
progress_trace | $trace | (accepts bool for backwards compatibility only). |
void |
Reimplemented in enrol_self_plugin.
enrol_plugin::fill_enrol_custom_fields | ( | array | $enrolmentdata, |
int | $courseid ) |
Fill custom fields data for a given enrolment plugin.
For example: resolve linked entities from the idnumbers (cohort, role, group, etc.) Also fill the default values that are not specified.
array | $enrolmentdata | enrolment data received in CSV file in tool_uploadcourse |
int | $courseid | Course ID. |
array | Updated enrolment data with custom fields info. |
Reimplemented in enrol_cohort_plugin, enrol_guest_plugin, enrol_manual_plugin, enrol_meta_plugin, and enrol_self_plugin.
enrol_plugin::find_instance | ( | array | $enrolmentdata, |
int | $courseid ) |
Finds matching instances for a given course.
array | $enrolmentdata | enrolment data. |
int | $courseid | Course ID. |
stdClass|null | Matching instance |
Reimplemented in enrol_cohort_plugin, enrol_guest_plugin, enrol_manual_plugin, enrol_meta_plugin, and enrol_self_plugin.
enrol_plugin::get_action_icons | ( | stdClass | $instance | ) |
Returns edit icons for the page with list of instances.
stdClass | $instance |
array |
Reimplemented in enrol_manual_plugin.
enrol_plugin::get_bulk_operations | ( | course_enrolment_manager | $manager | ) |
Return an array of enrol_bulk_enrolment_operation objects that define the bulk actions that can be performed on user enrolments by the plugin.
course_enrolment_manager | $manager |
array |
Reimplemented in enrol_manual_plugin, and enrol_self_plugin.
enrol_plugin::get_config | ( | $name, | |
$default = NULL ) |
Returns plugin config value.
string | $name | |
string | $default | value if config does not exist yet |
string | value or default |
enrol_plugin::get_description_text | ( | $instance | ) |
Returns optional enrolment instance description text.
This is used in detailed course information.
object | $instance |
string | short html text |
Reimplemented in enrol_fee_plugin.
enrol_plugin::get_enrol_info | ( | stdClass | $instance | ) |
Return information for enrolment instance containing list of parameters required for enrolment, name of enrolment plugin etc.
stdClass | $instance | enrolment instance |
stdClass|null | instance info. |
Reimplemented in enrol_guest_plugin, and enrol_self_plugin.
|
protected |
Returns the user who is responsible for enrolments for given instance.
Override if plugin knows anybody better than admin.
int | $instanceid | enrolment instance id |
stdClass | user record |
Reimplemented in enrol_flatfile_plugin, enrol_manual_plugin, and enrol_self_plugin.
|
protected |
Generate subject and body messages for enrolment expiration notification.
stdClass | $user | An object representing the user. |
stdClass | $ue | An object containing enrolment data. |
string | $name | Name of this enrol plugin. |
stdClass | $enroller | The user who is responsible for enrolments. |
context | $context | The context object. |
string | Return the body message. |
Reimplemented in enrol_self_plugin.
enrol_plugin::get_info_icons | ( | array | $instances | ) |
Returns optional enrolment information icons.
This is used in course list for quick overview of enrolment options.
We are not using single instance parameter because sometimes we might want to prevent icon repetition when multiple instances of one type exist. One instance may also produce several icons.
array | $instances | all enrol instances of this type in one course |
array | of pix_icon |
Reimplemented in enrol_fee_plugin, enrol_guest_plugin, enrol_paypal_plugin, and enrol_self_plugin.
enrol_plugin::get_instance_defaults | ( | ) |
Returns defaults for new instances.
array |
Reimplemented in enrol_guest_plugin, enrol_manual_plugin, and enrol_self_plugin.
enrol_plugin::get_instance_name | ( | $instance | ) |
Returns localised name of enrol instance.
object | $instance | (null is accepted too) |
string |
Reimplemented in enrol_cohort_plugin, enrol_meta_plugin, enrol_mnet_plugin, and enrol_self_plugin.
enrol_plugin::get_manual_enrol_button | ( | course_enrolment_manager | $manager | ) |
Returns an enrol_user_button that takes the user to a page where they are able to enrol users into the managers course through this plugin.
Optional: If the plugin supports manual enrolments it can choose to override this otherwise it shouldn't
course_enrolment_manager | $manager |
enrol_user_button|false |
Reimplemented in enrol_manual_plugin.
enrol_plugin::get_manual_enrol_link | ( | $instance | ) |
Returns link to manual enrol UI if exists.
Does the access control tests automatically.
object | $instance |
?moodle_url |
Reimplemented in enrol_manual_plugin.
enrol_plugin::get_name | ( | ) |
Returns name of this enrol plugin.
string |
enrol_plugin::get_newinstance_link | ( | $courseid | ) |
Returns link to page which may be used to add new instance of enrolment plugin in course.
int | $courseid |
?moodle_url | page url |
Reimplemented in enrol_category_plugin.
enrol_plugin::get_unenrolself_link | ( | $instance | ) |
Returns list of unenrol links for all enrol instances in course.
stdClass | $instance |
?moodle_url | or NULL if self unenrolment not supported |
enrol_plugin::get_user_enrolment_actions | ( | course_enrolment_manager | $manager, |
$ue ) |
Gets an array of the user enrolment actions.
course_enrolment_manager | $manager | |
stdClass | $ue |
array | An array of user_enrolment_actions |
enrol_plugin::get_welcome_message_contact | ( | int | $sendoption, |
context | $context ) |
Get the "from" contact which the message will be sent from.
int | $sendoption | send email from constant ENROL_SEND_EMAIL_FROM_* |
context | $context | where the user will be fetched from. |
null|stdClass | the contact user object. |
enrol_plugin::has_bulk_operations | ( | course_enrolment_manager | $manager | ) |
Returns true if the plugin has one or more bulk operations that can be performed on user enrolments.
course_enrolment_manager | $manager |
bool |
enrol_plugin::instance_deleteable | ( | $instance | ) |
enrol_plugin::is_cron_required | ( | ) |
Reads version.php and determines if it is necessary to execute the cron job now.
bool |
enrol_plugin::is_csv_upload_supported | ( | ) |
Check if enrolment plugin is supported in csv course upload.
If supported, plugins are also encouraged to override methods: {
bool |
Reimplemented in enrol_cohort_plugin, enrol_guest_plugin, enrol_manual_plugin, enrol_meta_plugin, and enrol_self_plugin.
enrol_plugin::is_self_enrol_available | ( | stdClass | $instance | ) |
Does this plugin support some way to self enrol? This function doesn't check user capabilities.
Use can_self_enrol to check capabilities.
stdClass | $instance | enrolment instance |
bool | - true means "Enrol me in this course" link could be available. |
Reimplemented in enrol_self_plugin.
|
protected |
Makes sure config is loaded and cached.
void |
|
protected |
Notify user about incoming expiration of their enrolment, it is called only if notification of enrolled users (aka students) is enabled in course.
This is executed only once for each expiring enrolment right at the start of the expiration threshold.
stdClass | $user | |
stdClass | $ue | |
progress_trace | $trace |
|
protected |
Notify person responsible for enrolments that some user enrolments will be expired soon, it is called only if notification of enrollers (aka teachers) is enabled in course.
This is called repeatedly every day for each course if there are any pending expiration in the expiration threshold.
int | $eid | |
array | $users | |
progress_trace | $trace |
enrol_plugin::process_expirations | ( | progress_trace | $trace, |
$courseid = null ) |
Do any enrolments need expiration processing.
Plugins that want to call this functionality must implement 'expiredaction' config setting.
progress_trace | $trace | |
int | $courseid | one course, empty mean all |
bool | true if any data processed, false if not |
enrol_plugin::restore_group_member | ( | $instance, | |
$groupid, | |||
$userid ) |
Restore user group membership.
stdClass | $instance | |
int | $groupid | |
int | $userid |
Reimplemented in enrol_cohort_plugin, enrol_manual_plugin, and enrol_meta_plugin.
enrol_plugin::restore_instance | ( | restore_enrolments_structure_step | $step, |
stdClass | $data, | ||
$course, | |||
$oldid ) |
Restore instance and map settings.
restore_enrolments_structure_step | $step | |
stdClass | $data | |
stdClass | $course | |
int | $oldid |
Reimplemented in enrol_cohort_plugin, enrol_database_plugin, enrol_fee_plugin, enrol_flatfile_plugin, enrol_guest_plugin, enrol_ldap_plugin, enrol_lti_plugin, enrol_manual_plugin, enrol_meta_plugin, enrol_paypal_plugin, and enrol_self_plugin.
enrol_plugin::restore_role_assignment | ( | $instance, | |
$roleid, | |||
$userid, | |||
$contextid ) |
Restore role assignment.
stdClass | $instance | |
int | $roleid | |
int | $userid | |
int | $contextid |
Reimplemented in enrol_database_plugin, enrol_flatfile_plugin, enrol_ldap_plugin, enrol_manual_plugin, and enrol_self_plugin.
enrol_plugin::restore_sync_course | ( | $course | ) |
Automatic enrol sync executed during restore.
Useful for automatic sync by course->idnumber or course category.
stdClass | $course | course record |
Reimplemented in enrol_category_plugin, enrol_database_plugin, and enrol_ldap_plugin.
enrol_plugin::restore_user_enrolment | ( | restore_enrolments_structure_step | $step, |
$data, | |||
$instance, | |||
$userid, | |||
$oldinstancestatus ) |
Restore user enrolment.
restore_enrolments_structure_step | $step | |
stdClass | $data | |
stdClass | $instance | |
int | $oldinstancestatus | |
int | $userid |
Reimplemented in enrol_cohort_plugin, enrol_database_plugin, enrol_fee_plugin, enrol_flatfile_plugin, enrol_ldap_plugin, enrol_manual_plugin, enrol_meta_plugin, enrol_paypal_plugin, and enrol_self_plugin.
enrol_plugin::roles_protected | ( | ) |
Does this plugin assign protected roles are can they be manually removed?
bool | - false means anybody may tweak roles, it does not use itemid and component when assigning roles |
Reimplemented in enrol_fee_plugin, enrol_flatfile_plugin, enrol_manual_plugin, enrol_paypal_plugin, and enrol_self_plugin.
enrol_plugin::send_course_welcome_message_to_user | ( | stdClass | $instance, |
int | $userid, | ||
int | $sendoption, | ||
?string | $message = '' ) |
Send course welcome message to user.
stdClass | $instance | Enrol instance. |
int | $userid | User ID. |
int | $sendoption | Send email from constant ENROL_SEND_EMAIL_FROM_* |
null | string | $message | Message to send to the user. |
enrol_plugin::send_expiry_notifications | ( | $trace | ) |
Send expiry notifications.
Plugin that wants to have expiry notification MUST implement following:
progress_trace | $trace | (accepts bool for backwards compatibility only) |
enrol_plugin::set_config | ( | $name, | |
$value ) |
Sets plugin config value.
string | $name | name of config |
string | $value | string config value, null means delete |
enrol_plugin::show_enrolme_link | ( | stdClass | $instance | ) |
Does this plugin support some way to user to self enrol?
stdClass | $instance | course enrol instance |
bool | - true means show "Enrol me in this course" link in course UI |
Reimplemented in enrol_fee_plugin, enrol_paypal_plugin, and enrol_self_plugin.
enrol_plugin::sync_user_enrolments | ( | $user | ) |
Forces synchronisation of user enrolments.
This is important especially for external enrol plugins, this function is called for all enabled enrol plugins right after every user login.
object | $user | user record |
void |
Reimplemented in enrol_database_plugin, and enrol_ldap_plugin.
enrol_plugin::try_autoenrol | ( | stdClass | $instance | ) |
Attempt to automatically enrol current user in course without any interaction, calling code has to make sure the plugin and instance are active.
This should return either a timestamp in the future or false.
stdClass | $instance | course enrol instance |
bool|int | false means not enrolled, integer means timeend |
enrol_plugin::try_guestaccess | ( | stdClass | $instance | ) |
Attempt to automatically gain temporary guest access to course, calling code has to make sure the plugin and instance are active.
This should return either a timestamp in the future or false.
stdClass | $instance | course enrol instance |
bool|int | false means no guest access, integer means timeend |
Reimplemented in enrol_guest_plugin.
enrol_plugin::unenrol_user | ( | stdClass | $instance, |
$userid ) |
Unenrol user from course, the last unenrolment removes all remaining roles.
stdClass | $instance | |
int | $userid |
void |
Reimplemented in enrol_guest_plugin, and enrol_lti_plugin.
enrol_plugin::update_communication | ( | int | $enrolmentinstanceid, |
string | $action, | ||
stdClass | $course ) |
Update instance members.
Update communication room membership for an instance action being performed.
int | $enrolmentinstanceid | ID of the enrolment instance |
string | $action | The update action being performed |
stdClass | $course | The course object |
void |
enrol_plugin::update_enrol_plugin_data | ( | int | $courseid, |
array | $enrolmentdata, | ||
stdClass | $instance ) |
Updates enrol plugin instance with provided data.
int | $courseid | Course ID. |
array | $enrolmentdata | enrolment data. |
stdClass | $instance | Instance to update. |
stdClass | updated instance |
Reimplemented in enrol_guest_plugin, and enrol_self_plugin.
enrol_plugin::update_instance | ( | $instance, | |
$data ) |
Update instance of enrol plugin.
stdClass | $instance | |
stdClass | $data | modified instance fields |
boolean |
Reimplemented in enrol_cohort_plugin, enrol_fee_plugin, enrol_lti_plugin, enrol_manual_plugin, enrol_meta_plugin, enrol_paypal_plugin, and enrol_self_plugin.
enrol_plugin::update_status | ( | $instance, | |
$newstatus ) |
Update instance status.
Override when plugin needs to do some action when enabled or disabled.
stdClass | $instance | |
int | $newstatus | ENROL_INSTANCE_ENABLED, ENROL_INSTANCE_DISABLED |
void |
Reimplemented in enrol_cohort_plugin, and enrol_meta_plugin.
enrol_plugin::update_user_enrol | ( | stdClass | $instance, |
$userid, | |||
$status = NULL, | |||
$timestart = NULL, | |||
$timeend = NULL ) |
Store user_enrolments changes and trigger event.
stdClass | $instance | |
int | $userid | |
int | $status | |
int | $timestart | |
int | $timeend |
void |
enrol_plugin::use_standard_editing_ui | ( | ) |
This returns false for backwards compatibility, but it is really recommended.
boolean |
Reimplemented in enrol_cohort_plugin, enrol_fee_plugin, enrol_guest_plugin, enrol_lti_plugin, enrol_manual_plugin, enrol_meta_plugin, enrol_mnet_plugin, enrol_paypal_plugin, and enrol_self_plugin.
enrol_plugin::user_delete | ( | $user | ) |
Called when user is about to be deleted.
object | $user |
void |
enrol_plugin::validate_enrol_plugin_data | ( | array | $enrolmentdata, |
?int | $courseid = null ) |
Check if data is valid for a given enrolment plugin.
array | $enrolmentdata | enrolment data to validate. |
int | null | $courseid | Course ID. |
array | Errors |
Reimplemented in enrol_cohort_plugin, enrol_guest_plugin, enrol_meta_plugin, and enrol_self_plugin.
enrol_plugin::validate_param_types | ( | $data, | |
$rules ) |
Validate a list of parameter names and types.
array | $data | array of ("fieldname"=>value) of submitted data |
array | $rules | array of ("fieldname"=>PARAM_X types - or "fieldname"=>array( list of valid options ) |
array | of "element_name"=>"error_description" if there are errors, or an empty array if everything is OK. |
enrol_plugin::validate_plugin_data_context | ( | array | $enrolmentdata, |
?int | $courseid = null ) |
Check if plugin custom data is allowed in relevant context.
This is called from the tool_uploadcourse if the plugin supports instance creation in upload course ({
Override it if plugin can validate provided data in relevant context.
array | $enrolmentdata | enrolment data to validate. |
int | null | $courseid | Course ID. |
lang_string|null | Error |
Reimplemented in enrol_cohort_plugin.