Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

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

Manual enrolment plugin main library file.

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

Defines 1 class


Class: enrol_manual_plugin  - X-Ref

roles_protected()   X-Ref
No description

allow_enrol(stdClass $instance)   X-Ref
No description

allow_unenrol(stdClass $instance)   X-Ref
No description

allow_manage(stdClass $instance)   X-Ref
No description

get_manual_enrol_link($instance)   X-Ref
Returns link to manual enrol UI if exists.
Does the access control tests automatically.

return: moodle_url
param: stdClass $instance

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

return: boolean
param: int $courseid

get_action_icons(stdClass $instance)   X-Ref
Returns edit icons for the page with list of instances.

return: array
param: stdClass $instance

add_default_instance($course)   X-Ref
Add new instance of enrol plugin with default settings.

return: int id of new instance, null if can not be created
param: stdClass $course

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

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

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

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

get_manual_enrol_button(course_enrolment_manager $manager)   X-Ref
Returns a button to manually enrol users through the manual enrolment plugin.

By default the first manual enrolment plugin instance available in the course is used.
If no manual enrolment instances exist within the course then false is returned.

This function also adds a quickenrolment JS ui to the page so that users can be enrolled
via AJAX.

return: enrol_user_button
param: course_enrolment_manager $manager

sync(progress_trace $trace, $courseid = null)   X-Ref
Sync all meta course links.

return: int 0 means ok, 1 means error, 2 means plugin disabled
param: progress_trace $trace
param: int $courseid one course, empty mean all

get_enroller($instanceid)   X-Ref
Returns the user who is responsible for manual enrolments in given instance.

Usually it is the first editing teacher - the person with "highest authority"
as defined by sort_by_roleassignment_authority() having 'enrol/manual:manage'
capability.

return: stdClass user record
param: int $instanceid enrolment instance id

get_bulk_operations(course_enrolment_manager $manager)   X-Ref
The manual plugin has several bulk operations that can be performed.

return: array
param: course_enrolment_manager $manager

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

restore_role_assignment($instance, $roleid, $userid, $contextid)   X-Ref
Restore role assignment.

param: stdClass $instance
param: int $roleid
param: int $userid
param: int $contextid

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

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

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

return: bool
param: object $instance

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

return: bool
param: stdClass $instance

enrol_cohort(stdClass $instance, $cohortid, $roleid = null, $timestart = 0, $timeend = 0, $status = null, $recovergrades = null)   X-Ref
Enrol all not enrolled cohort members into course via enrol instance.

return: int The number of enrolled cohort users
param: stdClass $instance
param: int $cohortid
param: int $roleid optional role id
param: int $timestart 0 means unknown
param: int $timeend 0 means forever
param: int $status default to ENROL_USER_ACTIVE for new enrolments, no change by default in updates
param: bool $recovergrades restore grade history

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

return: boolean

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.

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

get_expirynotify_options()   X-Ref
Return an array of valid options for the expirynotify.

return: array

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

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

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

return: array of "element_name"=>"error_description" if there are errors,
return: void
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

enrol_manual_output_fragment_enrol_users_form($args)   X-Ref
Serve the manual enrol users form as a fragment.

return: string
param: array $args List of named arguments for the fragment loader.