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.

Differences Between: [Versions 310 and 311] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

Fee enrolment plugin. This plugin allows you to set up paid courses.

Copyright: 2019 Shamim Rezaie <shamim@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 435 lines (16 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: enrol_fee_plugin  - X-Ref

Fee enrolment plugin implementation.

get_possible_currencies()   X-Ref
Returns the list of currencies that the payment subsystem supports and therefore we can work with.

return: array[currencycode => currencyname]

get_info_icons(array $instances)   X-Ref
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.

param: array $instances all enrol instances of this type in one course
return: array of pix_icon

roles_protected()   X-Ref
No description

allow_unenrol(stdClass $instance)   X-Ref
No description

allow_manage(stdClass $instance)   X-Ref
No description

show_enrolme_link(stdClass $instance)   X-Ref
No description

can_add_instance($courseid)   X-Ref
Returns true if the user can add a new instance in this course.

param: int $courseid
return: boolean

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

return: boolean

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 new 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

enrol_page_hook(stdClass $instance)   X-Ref
Creates course enrol form, checks if form submitted
and enrols user if necessary. It can also redirect.

param: stdClass $instance
return: string html text, usually a form in a text box

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 $oldinstancestatus
param: int $userid

get_status_options()   X-Ref
Return an array of valid options for the status.

return: array

get_roleid_options($instance, $context)   X-Ref
Return an array of valid options for the roleid.

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

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

param: stdClass $instance
param: MoodleQuickForm $mform
param: context $context
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

sync(progress_trace $trace)   X-Ref
Execute synchronisation.

param: progress_trace $trace
return: int exit code, 0 means ok

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