Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
enrol_database_plugin Class Reference

Database enrolment plugin implementation. More...

Inheritance diagram for enrol_database_plugin:
enrol_plugin

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? Yes, but only if user suspended...
 
 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_courses (progress_trace $trace)
 Performs a full sync with external database.
 
 sync_enrolments (progress_trace $trace, $onecourse=null)
 Forces synchronisation of all enrolments with external database.
 
 sync_user_enrolments ($user)
 Forces synchronisation of user enrolments with external database, does not create new courses.
 
 test_settings ()
 Test plugin settings, print info to output.
 
 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

 db_addslashes ($text)
 
 db_decode ($text)
 
 db_encode ($text)
 
 db_get_sql ($table, array $conditions, array $fields, $distinct=false, $sort="")
 
 db_init ()
 Tries to make connection to the external database.
 
 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
 

Detailed Description

Database enrolment plugin implementation.

Author
Petr Skoda - based on code by Martin Dougiamas, Martin Langhoff and others
License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ add_course_navigation()

enrol_plugin::add_course_navigation ( $instancesnode,
stdClass $instance )
inherited

Adds navigation links into course admin block.

By defaults looks for manage links only.

Parameters
navigation_node$instancesnode
stdClass$instance
Return values
void

◆ add_custom_instance()

enrol_plugin::add_custom_instance ( stdClass $course,
?array $fields = null )
inherited

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.

Parameters
stdClass$courseCourse object
array | null$fieldsinstance fields
Return values
int|nullid of new instance or null if not supported

Reimplemented in enrol_cohort_plugin, and enrol_meta_plugin.

◆ add_default_instance()

enrol_plugin::add_default_instance ( $course)
inherited

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.

Parameters
object$course
Return values
?intid of new instance or null if no default supported

Reimplemented in enrol_guest_plugin, enrol_manual_plugin, and enrol_self_plugin.

◆ add_instance()

enrol_plugin::add_instance ( $course,
array $fields = NULL )
inherited

Add new instance of enrol plugin.

Parameters
object$course
arrayinstance fields
Return values
intid 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.

◆ allow_enrol()

enrol_plugin::allow_enrol ( stdClass $instance)
inherited

Does this plugin allow manual enrolments?

Parameters
stdClass$instancecourse enrol instance All plugins allowing this must implement 'enrol/xxx:enrol' capability
Return values
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.

◆ allow_manage()

enrol_plugin::allow_manage ( stdClass $instance)
inherited

Does this plugin allow manual changes in user_enrolments table?

All plugins allowing this must implement 'enrol/xxx:manage' capability

Parameters
stdClass$instancecourse enrol instance
Return values
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.

◆ allow_unenrol()

enrol_plugin::allow_unenrol ( stdClass $instance)
inherited

Does this plugin allow manual unenrolment of all users? All plugins allowing this must implement 'enrol/xxx:unenrol' capability.

Parameters
stdClass$instancecourse enrol instance
Return values
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.

◆ allow_unenrol_user()

enrol_database_plugin::allow_unenrol_user ( stdClass $instance,
stdClass $ue )

Does this plugin allow manual unenrolment of a specific user? Yes, but only if user suspended...

Parameters
stdClass$instancecourse enrol instance
stdClass$uerecord from user_enrolments table
Return values
bool- true means user with 'enrol/xxx:unenrol' may unenrol this user, false means nobody may touch this user enrolment

Reimplemented from enrol_plugin.

◆ backup_annotate_custom_fields()

enrol_plugin::backup_annotate_custom_fields ( backup_enrolments_execution_step $step,
stdClass $enrol )
inherited

Backup execution step hook to annotate custom fields.

Parameters
backup_enrolments_execution_step$step
stdClass$enrol

◆ can_add_instance()

enrol_plugin::can_add_instance ( $courseid)
inherited

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.

Parameters
int$courseid
Return values
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.

◆ can_delete_instance()

enrol_database_plugin::can_delete_instance ( $instance)

Is it possible to delete enrol instance via standard UI?

Parameters
stdClass$instance
Return values
bool

Reimplemented from enrol_plugin.

◆ can_edit_instance()

enrol_plugin::can_edit_instance ( $instance)
inherited

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.

Parameters
stdClass$instance
Return values
boolean

◆ can_hide_show_instance()

enrol_database_plugin::can_hide_show_instance ( $instance)

Is it possible to hide/show enrol instance via standard UI?

Parameters
stdClass$instance
Return values
bool

Reimplemented from enrol_plugin.

◆ can_self_enrol()

enrol_plugin::can_self_enrol ( stdClass $instance,
$checkuserenrolment = true )
inherited

Checks if user can self enrol.

Parameters
stdClass$instanceenrolment instance
bool$checkuserenrolmentif true will check if user enrolment is inactive. used by navigation to improve performance.
Return values
bool|stringtrue if successful, else error message or false

Reimplemented in enrol_self_plugin.

◆ course_edit_form()

enrol_plugin::course_edit_form ( $instance,
MoodleQuickForm $mform,
$data,
$context )
inherited

Adds enrol instance UI to course edit form.

Parameters
object$instanceenrol instance or null if does not exist yet
MoodleQuickForm$mform
object$data
object$contextcontext of existing course or parent category if course does not exist
Return values
void

◆ course_edit_validation()

enrol_plugin::course_edit_validation ( $instance,
array $data,
$context )
inherited

Validates course edit form data.

Parameters
object$instanceenrol instance or null if does not exist yet
array$data
object$contextcontext of existing course or parent category if course does not exist
Return values
arrayerrors array

◆ course_updated()

enrol_plugin::course_updated ( $inserted,
$course,
$data )
inherited

Called after updating/inserting course.

Parameters
bool$insertedtrue if course just inserted
object$course
object$dataform data
Return values
void

Reimplemented in enrol_category_plugin, enrol_cohort_plugin, enrol_guest_plugin, and enrol_meta_plugin.

◆ cron()

enrol_plugin::cron ( )
inherited

Called for all enabled enrol plugins that returned true from is_cron_required().

Return values
void

Reimplemented in enrol_imsenterprise_plugin.

◆ db_init()

enrol_database_plugin::db_init ( )
protected

Tries to make connection to the external database.

Return values
null|ADONewConnection

◆ delete_instance()

enrol_plugin::delete_instance ( $instance)
inherited

Delete course enrol plugin instance, unenrol all users.

Parameters
object$instance
Return values
void

Reimplemented in enrol_lti_plugin.

◆ edit_instance_form()

enrol_plugin::edit_instance_form ( $instance,
MoodleQuickForm $mform,
$context )
inherited

Adds form elements to add/edit instance form.

Since
Moodle 3.1
Parameters
object$instanceenrol instance or null if does not exist yet
MoodleQuickForm$mform
context$context
Return values
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.

◆ edit_instance_validation()

enrol_plugin::edit_instance_validation ( $data,
$files,
$instance,
$context )
inherited

Perform custom validation of the data used to edit the instance.

Since
Moodle 3.1
Parameters
array$dataarray of ("fieldname"=>value) of submitted data
array$filesarray of uploaded files "element_name"=>tmp_file_path
object$instanceThe instance data loaded from the DB.
context$contextThe context of the instance we are editing
Return values
arrayof "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_page_hook()

enrol_plugin::enrol_page_hook ( stdClass $instance)
inherited

Creates course enrol form, checks if form submitted and enrols user if necessary.

It can also redirect.

Parameters
stdClass$instance
Return values
stringhtml text, usually a form in a text box

Reimplemented in enrol_fee_plugin, enrol_guest_plugin, enrol_paypal_plugin, and enrol_self_plugin.

◆ enrol_user()

enrol_plugin::enrol_user ( stdClass $instance,
$userid,
$roleid = null,
$timestart = 0,
$timeend = 0,
$status = null,
$recovergrades = null )
inherited

Enrol user into course via enrol instance.

Parameters
stdClass$instance
int$userid
int$roleidoptional role id
int$timestart0 means unknown
int$timeend0 means forever
int$statusdefault to ENROL_USER_ACTIVE for new enrolments, no change by default in updates
bool$recovergradesrestore grade history
Return values
void

Reimplemented in enrol_flatfile_plugin, and enrol_guest_plugin.

◆ fetch_users_and_notify_expiry()

enrol_plugin::fetch_users_and_notify_expiry ( int $timenow,
string $name,
progress_trace $trace )
protectedinherited

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.

Parameters
int$timenowCurrent time.
string$nameName of this enrol plugin.
progress_trace$trace(accepts bool for backwards compatibility only).
Return values
void

Reimplemented in enrol_self_plugin.

◆ fill_enrol_custom_fields()

enrol_plugin::fill_enrol_custom_fields ( array $enrolmentdata,
int $courseid )
inherited

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.

Parameters
array$enrolmentdataenrolment data received in CSV file in tool_uploadcourse
int$courseidCourse ID.
Return values
arrayUpdated enrolment data with custom fields info.

Reimplemented in enrol_cohort_plugin, enrol_guest_plugin, enrol_manual_plugin, enrol_meta_plugin, and enrol_self_plugin.

◆ find_instance()

enrol_plugin::find_instance ( array $enrolmentdata,
int $courseid )
inherited

Finds matching instances for a given course.

Parameters
array$enrolmentdataenrolment data.
int$courseidCourse ID.
Return values
stdClass|nullMatching instance

Reimplemented in enrol_cohort_plugin, enrol_guest_plugin, enrol_manual_plugin, enrol_meta_plugin, and enrol_self_plugin.

◆ get_action_icons()

enrol_plugin::get_action_icons ( stdClass $instance)
inherited

Returns edit icons for the page with list of instances.

Parameters
stdClass$instance
Return values
array

Reimplemented in enrol_manual_plugin.

◆ get_bulk_operations()

enrol_plugin::get_bulk_operations ( course_enrolment_manager $manager)
inherited

Return an array of enrol_bulk_enrolment_operation objects that define the bulk actions that can be performed on user enrolments by the plugin.

Parameters
course_enrolment_manager$manager
Return values
array

Reimplemented in enrol_manual_plugin, and enrol_self_plugin.

◆ get_config()

enrol_plugin::get_config ( $name,
$default = NULL )
inherited

Returns plugin config value.

Parameters
string$name
string$defaultvalue if config does not exist yet
Return values
stringvalue or default

◆ get_description_text()

enrol_plugin::get_description_text ( $instance)
inherited

Returns optional enrolment instance description text.

This is used in detailed course information.

Parameters
object$instance
Return values
stringshort html text

Reimplemented in enrol_fee_plugin.

◆ get_enrol_info()

enrol_plugin::get_enrol_info ( stdClass $instance)
inherited

Return information for enrolment instance containing list of parameters required for enrolment, name of enrolment plugin etc.

Parameters
stdClass$instanceenrolment instance
Return values
stdClass|nullinstance info.

Reimplemented in enrol_guest_plugin, and enrol_self_plugin.

◆ get_enroller()

enrol_plugin::get_enroller ( $instanceid)
protectedinherited

Returns the user who is responsible for enrolments for given instance.

Override if plugin knows anybody better than admin.

Parameters
int$instanceidenrolment instance id
Return values
stdClassuser record

Reimplemented in enrol_flatfile_plugin, enrol_manual_plugin, and enrol_self_plugin.

◆ get_expiry_message_body()

enrol_plugin::get_expiry_message_body ( stdClass $user,
stdClass $ue,
string $name,
stdClass $enroller,
context $context )
protectedinherited

Generate subject and body messages for enrolment expiration notification.

Parameters
stdClass$userAn object representing the user.
stdClass$ueAn object containing enrolment data.
string$nameName of this enrol plugin.
stdClass$enrollerThe user who is responsible for enrolments.
context$contextThe context object.
Return values
stringReturn the body message.

Reimplemented in enrol_self_plugin.

◆ get_info_icons()

enrol_plugin::get_info_icons ( array $instances)
inherited

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.

Parameters
array$instancesall enrol instances of this type in one course
Return values
arrayof pix_icon

Reimplemented in enrol_fee_plugin, enrol_guest_plugin, enrol_paypal_plugin, and enrol_self_plugin.

◆ get_instance_defaults()

enrol_plugin::get_instance_defaults ( )
inherited

Returns defaults for new instances.

Since
Moodle 3.1
Return values
array

Reimplemented in enrol_guest_plugin, enrol_manual_plugin, and enrol_self_plugin.

◆ get_instance_name()

enrol_plugin::get_instance_name ( $instance)
inherited

Returns localised name of enrol instance.

Parameters
object$instance(null is accepted too)
Return values
string

Reimplemented in enrol_cohort_plugin, enrol_meta_plugin, enrol_mnet_plugin, and enrol_self_plugin.

◆ get_manual_enrol_button()

enrol_plugin::get_manual_enrol_button ( course_enrolment_manager $manager)
inherited

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

Parameters
course_enrolment_manager$manager
Return values
enrol_user_button|false

Reimplemented in enrol_manual_plugin.

◆ get_manual_enrol_link()

enrol_plugin::get_manual_enrol_link ( $instance)
inherited

Returns link to manual enrol UI if exists.

Does the access control tests automatically.

Parameters
object$instance
Return values
?moodle_url

Reimplemented in enrol_manual_plugin.

◆ get_name()

enrol_plugin::get_name ( )
inherited

Returns name of this enrol plugin.

Return values
string

◆ get_newinstance_link()

enrol_plugin::get_newinstance_link ( $courseid)
inherited

Returns link to page which may be used to add new instance of enrolment plugin in course.

Parameters
int$courseid
Return values
?moodle_urlpage url

Reimplemented in enrol_category_plugin.

◆ get_unenrolself_link()

enrol_plugin::get_unenrolself_link ( $instance)
inherited

Returns list of unenrol links for all enrol instances in course.

Parameters
stdClass$instance
Return values
?moodle_urlor NULL if self unenrolment not supported

◆ get_user_enrolment_actions()

enrol_plugin::get_user_enrolment_actions ( course_enrolment_manager $manager,
$ue )
inherited

Gets an array of the user enrolment actions.

Parameters
course_enrolment_manager$manager
stdClass$ue
Return values
arrayAn array of user_enrolment_actions

◆ get_welcome_message_contact()

enrol_plugin::get_welcome_message_contact ( int $sendoption,
context $context )
inherited

Get the "from" contact which the message will be sent from.

Parameters
int$sendoptionsend email from constant ENROL_SEND_EMAIL_FROM_*
context$contextwhere the user will be fetched from.
Return values
null|stdClassthe contact user object.

◆ has_bulk_operations()

enrol_plugin::has_bulk_operations ( course_enrolment_manager $manager)
inherited

Returns true if the plugin has one or more bulk operations that can be performed on user enrolments.

Parameters
course_enrolment_manager$manager
Return values
bool

◆ instance_deleteable()

enrol_plugin::instance_deleteable ( $instance)
inherited
Deprecated
since Moodle 2.8 MDL-35864 - please use can_delete_instance() instead.

◆ is_cron_required()

enrol_plugin::is_cron_required ( )
inherited

Reads version.php and determines if it is necessary to execute the cron job now.

Return values
bool

◆ is_csv_upload_supported()

enrol_plugin::is_csv_upload_supported ( )
inherited

Check if enrolment plugin is supported in csv course upload.

If supported, plugins are also encouraged to override methods: {

See also
self\fill_enrol_custom_fields()}, {
self\validate_plugin_data_context()}
Return values
bool

Reimplemented in enrol_cohort_plugin, enrol_guest_plugin, enrol_manual_plugin, enrol_meta_plugin, and enrol_self_plugin.

◆ is_self_enrol_available()

enrol_plugin::is_self_enrol_available ( stdClass $instance)
inherited

Does this plugin support some way to self enrol? This function doesn't check user capabilities.

Use can_self_enrol to check capabilities.

Parameters
stdClass$instanceenrolment instance
Return values
bool- true means "Enrol me in this course" link could be available.

Reimplemented in enrol_self_plugin.

◆ load_config()

enrol_plugin::load_config ( )
protectedinherited

Makes sure config is loaded and cached.

Return values
void

◆ notify_expiry_enrolled()

enrol_plugin::notify_expiry_enrolled ( $user,
$ue,
progress_trace $trace )
protectedinherited

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.

Parameters
stdClass$user
stdClass$ue
progress_trace$trace

◆ notify_expiry_enroller()

enrol_plugin::notify_expiry_enroller ( $eid,
$users,
progress_trace $trace )
protectedinherited

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.

Parameters
int$eid
array$users
progress_trace$trace

◆ process_expirations()

enrol_plugin::process_expirations ( progress_trace $trace,
$courseid = null )
inherited

Do any enrolments need expiration processing.

Plugins that want to call this functionality must implement 'expiredaction' config setting.

Parameters
progress_trace$trace
int$courseidone course, empty mean all
Return values
booltrue if any data processed, false if not

◆ restore_group_member()

enrol_plugin::restore_group_member ( $instance,
$groupid,
$userid )
inherited

Restore user group membership.

Parameters
stdClass$instance
int$groupid
int$userid

Reimplemented in enrol_cohort_plugin, enrol_manual_plugin, and enrol_meta_plugin.

◆ restore_instance()

enrol_database_plugin::restore_instance ( restore_enrolments_structure_step $step,
stdClass $data,
$course,
$oldid )

Restore instance and map settings.

Parameters
restore_enrolments_structure_step$step
stdClass$data
stdClass$course
int$oldid

Reimplemented from enrol_plugin.

◆ restore_role_assignment()

enrol_database_plugin::restore_role_assignment ( $instance,
$roleid,
$userid,
$contextid )

Restore role assignment.

Parameters
stdClass$instance
int$roleid
int$userid
int$contextid

Reimplemented from enrol_plugin.

◆ restore_sync_course()

enrol_database_plugin::restore_sync_course ( $course)

Automatic enrol sync executed during restore.

Parameters
stdClass$coursecourse record

Reimplemented from enrol_plugin.

◆ restore_user_enrolment()

enrol_database_plugin::restore_user_enrolment ( restore_enrolments_structure_step $step,
$data,
$instance,
$userid,
$oldinstancestatus )

Restore user enrolment.

Parameters
restore_enrolments_structure_step$step
stdClass$data
stdClass$instance
int$oldinstancestatus
int$userid

Reimplemented from enrol_plugin.

◆ roles_protected()

enrol_plugin::roles_protected ( )
inherited

Does this plugin assign protected roles are can they be manually removed?

Return values
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.

◆ send_course_welcome_message_to_user()

enrol_plugin::send_course_welcome_message_to_user ( stdClass $instance,
int $userid,
int $sendoption,
?string $message = '' )
inherited

Send course welcome message to user.

Parameters
stdClass$instanceEnrol instance.
int$useridUser ID.
int$sendoptionSend email from constant ENROL_SEND_EMAIL_FROM_*
null | string$messageMessage to send to the user.

◆ send_expiry_notifications()

enrol_plugin::send_expiry_notifications ( $trace)
inherited

Send expiry notifications.

Plugin that wants to have expiry notification MUST implement following:

  • expirynotifyhour plugin setting,
  • configuration options in instance edit form (expirynotify, notifyall and expirythreshold),
  • notification strings (expirymessageenrollersubject, expirymessageenrollerbody, expirymessageenrolledsubject and expirymessageenrolledbody),
  • expiry_notification provider in db/messages.php,
  • upgrade code that sets default thresholds for existing courses (should be 1 day),
  • something that calls this method, such as cron.
Parameters
progress_trace$trace(accepts bool for backwards compatibility only)

◆ set_config()

enrol_plugin::set_config ( $name,
$value )
inherited

Sets plugin config value.

Parameters
string$namename of config
string$valuestring config value, null means delete

◆ show_enrolme_link()

enrol_plugin::show_enrolme_link ( stdClass $instance)
inherited

Does this plugin support some way to user to self enrol?

Parameters
stdClass$instancecourse enrol instance
Return values
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.

◆ sync_courses()

enrol_database_plugin::sync_courses ( progress_trace $trace)

Performs a full sync with external database.

First it creates new courses if necessary, then enrols and unenrols users.

Parameters
progress_trace$trace
Return values
int0 means success, 1 db connect failure, 4 db read failure

◆ sync_enrolments()

enrol_database_plugin::sync_enrolments ( progress_trace $trace,
$onecourse = null )

Forces synchronisation of all enrolments with external database.

Parameters
progress_trace$trace
null | int$onecourselimit sync to one course only (used primarily in restore)
Return values
int0 means success, 1 db connect failure, 2 db read failure

◆ sync_user_enrolments()

enrol_database_plugin::sync_user_enrolments ( $user)

Forces synchronisation of user enrolments with external database, does not create new courses.

Parameters
stdClass$useruser record
Return values
void

Reimplemented from enrol_plugin.

◆ try_autoenrol()

enrol_plugin::try_autoenrol ( stdClass $instance)
inherited

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.

Parameters
stdClass$instancecourse enrol instance
Return values
bool|intfalse means not enrolled, integer means timeend

◆ try_guestaccess()

enrol_plugin::try_guestaccess ( stdClass $instance)
inherited

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.

Parameters
stdClass$instancecourse enrol instance
Return values
bool|intfalse means no guest access, integer means timeend

Reimplemented in enrol_guest_plugin.

◆ unenrol_user()

enrol_plugin::unenrol_user ( stdClass $instance,
$userid )
inherited

Unenrol user from course, the last unenrolment removes all remaining roles.

Parameters
stdClass$instance
int$userid
Return values
void

Reimplemented in enrol_guest_plugin, and enrol_lti_plugin.

◆ update_communication()

enrol_plugin::update_communication ( int $enrolmentinstanceid,
string $action,
stdClass $course )
inherited

Update instance members.

Update communication room membership for an instance action being performed.

Parameters
int$enrolmentinstanceidID of the enrolment instance
string$actionThe update action being performed
stdClass$courseThe course object
Return values
void
Deprecated
Since Moodle 4.4.0.
See also
core_communication\hook_listener\update_communication_memberships_for_enrol_status_change()
Todo
MDL-80491 Final deprecation in Moodle 4.8.

◆ update_enrol_plugin_data()

enrol_plugin::update_enrol_plugin_data ( int $courseid,
array $enrolmentdata,
stdClass $instance )
inherited

Updates enrol plugin instance with provided data.

Parameters
int$courseidCourse ID.
array$enrolmentdataenrolment data.
stdClass$instanceInstance to update.
Return values
stdClassupdated instance

Reimplemented in enrol_guest_plugin, and enrol_self_plugin.

◆ update_instance()

enrol_plugin::update_instance ( $instance,
$data )
inherited

Update instance of enrol plugin.

Since
Moodle 3.1
Parameters
stdClass$instance
stdClass$datamodified instance fields
Return values
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.

◆ update_status()

enrol_plugin::update_status ( $instance,
$newstatus )
inherited

Update instance status.

Override when plugin needs to do some action when enabled or disabled.

Parameters
stdClass$instance
int$newstatusENROL_INSTANCE_ENABLED, ENROL_INSTANCE_DISABLED
Return values
void

Reimplemented in enrol_cohort_plugin, and enrol_meta_plugin.

◆ update_user_enrol()

enrol_plugin::update_user_enrol ( stdClass $instance,
$userid,
$status = NULL,
$timestart = NULL,
$timeend = NULL )
inherited

Store user_enrolments changes and trigger event.

Parameters
stdClass$instance
int$userid
int$status
int$timestart
int$timeend
Return values
void

◆ use_standard_editing_ui()

enrol_plugin::use_standard_editing_ui ( )
inherited

This returns false for backwards compatibility, but it is really recommended.

Since
Moodle 3.1
Return values
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.

◆ user_delete()

enrol_plugin::user_delete ( $user)
inherited

Called when user is about to be deleted.

Parameters
object$user
Return values
void

◆ validate_enrol_plugin_data()

enrol_plugin::validate_enrol_plugin_data ( array $enrolmentdata,
?int $courseid = null )
inherited

Check if data is valid for a given enrolment plugin.

Parameters
array$enrolmentdataenrolment data to validate.
int | null$courseidCourse ID.
Return values
arrayErrors

Reimplemented in enrol_cohort_plugin, enrol_guest_plugin, enrol_meta_plugin, and enrol_self_plugin.

◆ validate_param_types()

enrol_plugin::validate_param_types ( $data,
$rules )
inherited

Validate a list of parameter names and types.

Since
Moodle 3.1
Parameters
array$dataarray of ("fieldname"=>value) of submitted data
array$rulesarray of ("fieldname"=>PARAM_X types - or "fieldname"=>array( list of valid options )
Return values
arrayof "element_name"=>"error_description" if there are errors, or an empty array if everything is OK.

◆ validate_plugin_data_context()

enrol_plugin::validate_plugin_data_context ( array $enrolmentdata,
?int $courseid = null )
inherited

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 ({

See also
self\is_csv_upload_supported()})

Override it if plugin can validate provided data in relevant context.

Parameters
array$enrolmentdataenrolment data to validate.
int | null$courseidCourse ID.
Return values
lang_string|nullError

Reimplemented in enrol_cohort_plugin.


The documentation for this class was generated from the following file: