Moodle  2.2.1
http://www.collinsharper.com
enrol_plugin Class Reference
Inheritance diagram for enrol_plugin:

Public Member Functions

 get_name ()
 get_instance_name ($instance)
 get_info_icons (array $instances)
 get_description_text ($instance)
 get_config ($name, $default=NULL)
 set_config ($name, $value)
 roles_protected ()
 allow_enrol (stdClass $instance)
 allow_unenrol (stdClass $instance)
 allow_unenrol_user (stdClass $instance, stdClass $ue)
 allow_manage (stdClass $instance)
 show_enrolme_link (stdClass $instance)
 try_autoenrol (stdClass $instance)
 try_guestaccess (stdClass $instance)
 enrol_user (stdClass $instance, $userid, $roleid=NULL, $timestart=0, $timeend=0, $status=NULL)
 update_user_enrol (stdClass $instance, $userid, $status=NULL, $timestart=NULL, $timeend=NULL)
 unenrol_user (stdClass $instance, $userid)
 sync_user_enrolments ($user)
 get_newinstance_link ($courseid)
 instance_deleteable ($instance)
 get_manual_enrol_link ($instance)
 get_unenrolself_link ($instance)
 course_edit_form ($instance, MoodleQuickForm $mform, $data, $context)
 course_edit_validation ($instance, array $data, $context)
 course_updated ($inserted, $course, $data)
 add_instance ($course, array $fields=NULL)
 add_default_instance ($course)
 update_status ($instance, $newstatus)
 delete_instance ($instance)
 enrol_page_hook (stdClass $instance)
 add_course_navigation ($instancesnode, stdClass $instance)
 get_action_icons (stdClass $instance)
 is_cron_required ()
 cron ()
 user_delete ($user)
 get_manual_enrol_button (course_enrolment_manager $manager)
 get_user_enrolment_actions (course_enrolment_manager $manager, $ue)
 has_bulk_operations ()
 get_bulk_operations ()

Protected Member Functions

 load_config ()

Protected Attributes

 $config = null

Detailed Description

All enrol plugins should be based on this class, this is also the main source of documentation.

Definition at line 977 of file enrollib.php.


Member Function Documentation

add_course_navigation ( instancesnode,
stdClass $  instance 
)

Adds navigation links into course admin block.

By defaults looks for manage links only.

Parameters:
navigation_node$instancesnode
stdClass$instance
Returns:
void

Reimplemented in enrol_self_plugin, enrol_manual_plugin, and enrol_paypal_plugin.

Definition at line 1640 of file enrollib.php.

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.

Parameters:
object$course
Returns:
int id of new instance or null if no default supported

Reimplemented in enrol_guest_plugin, enrol_self_plugin, and enrol_manual_plugin.

Definition at line 1564 of file enrollib.php.

Here is the caller graph for this function:

add_instance ( course,
array fields = NULL 
)

Add new instance of enrol plugin.

Parameters:
object$course
arrayinstance fields
Returns:
int id of new instance, null if can not be created

Reimplemented in enrol_guest_plugin, and enrol_manual_plugin.

Definition at line 1527 of file enrollib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

allow_enrol ( stdClass $  instance)

Does this plugin allow manual enrolments?

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

Definition at line 1090 of file enrollib.php.

allow_manage ( stdClass $  instance)

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
Returns:
bool - true means it is possible to change enrol period and status in user_enrolments table

Reimplemented in enrol_self_plugin, enrol_paypal_plugin, and enrol_manual_plugin.

Definition at line 1129 of file enrollib.php.

allow_unenrol ( stdClass $  instance)

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

Parameters:
stdClass$instancecourse enrol instance
Returns:
bool - true means user with 'enrol/xxx:unenrol' may unenrol others freely, false means nobody may touch user_enrolments

Reimplemented in enrol_self_plugin, enrol_paypal_plugin, and enrol_manual_plugin.

Definition at line 1101 of file enrollib.php.

Here is the caller graph for this function:

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.

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

Reimplemented in enrol_meta_plugin.

Definition at line 1117 of file enrollib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

course_edit_form ( instance,
MoodleQuickForm mform,
data,
context 
)

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
Returns:
void

Reimplemented in enrol_guest_plugin.

Definition at line 1489 of file enrollib.php.

course_edit_validation ( instance,
array data,
context 
)

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
Returns:
array errors array

Reimplemented in enrol_guest_plugin.

Definition at line 1501 of file enrollib.php.

course_updated ( inserted,
course,
data 
)

Called after updating/inserting course.

Parameters:
bool$insertedtrue if course just inserted
object$course
object$dataform data
Returns:
void

Reimplemented in enrol_guest_plugin, enrol_cohort_plugin, enrol_meta_plugin, and enrol_category_plugin.

Definition at line 1513 of file enrollib.php.

Here is the call graph for this function:

cron ( )

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

Returns:
void

Reimplemented in enrol_self_plugin, enrol_meta_plugin, enrol_cohort_plugin, enrol_category_plugin, enrol_imsenterprise_plugin, and enrol_flatfile_plugin.

Definition at line 1680 of file enrollib.php.

delete_instance ( instance)

Delete course enrol plugin instance, unenrol all users.

Parameters:
object$instance
Returns:
void

Definition at line 1593 of file enrollib.php.

Here is the call graph for this function:

enrol_page_hook ( stdClass $  instance)

Creates course enrol form, checks if form submitted and enrols user if necessary. It can also redirect.

Parameters:
stdClass$instance
Returns:
string html text, usually a form in a text box

Reimplemented in enrol_self_plugin, enrol_paypal_plugin, and enrol_guest_plugin.

Definition at line 1627 of file enrollib.php.

enrol_user ( stdClass $  instance,
userid,
roleid = NULL,
timestart = 0,
timeend = 0,
status = NULL 
)

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
Returns:
void

Reimplemented in enrol_guest_plugin.

Definition at line 1185 of file enrollib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

get_action_icons ( stdClass $  instance)

Returns edit icons for the page with list of instances

Parameters:
stdClass$instance
Returns:
array

Reimplemented in enrol_self_plugin, enrol_manual_plugin, and enrol_paypal_plugin.

Definition at line 1649 of file enrollib.php.

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

Returns:
array

Definition at line 1745 of file enrollib.php.

get_config ( name,
default = NULL 
)

Returns plugin config value

Parameters:
string$name
string$defaultvalue if config does not exist yet
Returns:
string value or default

Definition at line 1052 of file enrollib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

get_description_text ( instance)

Returns optional enrolment instance description text.

This is used in detailed course information.

Parameters:
object$instance
Returns:
string short html text

Definition at line 1031 of file enrollib.php.

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.

Parameters:
array$instancesall enrol instances of this type in one course
Returns:
array of pix_icon

Reimplemented in enrol_paypal_plugin, enrol_self_plugin, and enrol_guest_plugin.

Definition at line 1018 of file enrollib.php.

get_instance_name ( instance)

Returns localised name of enrol instance

Parameters:
object$instance(null is accepted too)
Returns:
string

Reimplemented in enrol_self_plugin, enrol_cohort_plugin, enrol_meta_plugin, and enrol_mnet_plugin.

Definition at line 996 of file enrollib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

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
Returns:
enrol_user_button|false

Reimplemented in enrol_manual_plugin, and enrol_cohort_plugin.

Definition at line 1714 of file enrollib.php.

get_manual_enrol_link ( instance)

Returns link to manual enrol UI if exists. Does the access control tests automatically.

Parameters:
object$instance
Returns:
moodle_url

Reimplemented in enrol_manual_plugin.

Definition at line 1433 of file enrollib.php.

get_name ( )

Returns name of this enrol plugin

Returns:
string

Definition at line 984 of file enrollib.php.

Here is the caller graph for this function:

get_newinstance_link ( courseid)

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

Parameters:
int$courseid
Returns:
moodle_url page url

Reimplemented in enrol_self_plugin, enrol_manual_plugin, enrol_paypal_plugin, enrol_guest_plugin, enrol_mnet_plugin, enrol_cohort_plugin, enrol_meta_plugin, and enrol_category_plugin.

Definition at line 1411 of file enrollib.php.

get_unenrolself_link ( instance)

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

Parameters:
int$instance
Returns:
moodle_url or NULL if self unenrolment not supported

Definition at line 1443 of file enrollib.php.

Here is the call graph for this function:

Gets an array of the user enrolment actions

Parameters:
course_enrolment_manager$manager
stdClass$ue
Returns:
array An array of user_enrolment_actions

Reimplemented in enrol_self_plugin, enrol_manual_plugin, and enrol_meta_plugin.

Definition at line 1725 of file enrollib.php.

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

Returns:
bool

Definition at line 1735 of file enrollib.php.

instance_deleteable ( instance)

Is it possible to delete enrol instance via standard UI?

Parameters:
object$instance
Returns:
bool

Reimplemented in enrol_ldap_plugin, enrol_category_plugin, and enrol_database_plugin.

Definition at line 1422 of file enrollib.php.

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

Returns:
bool

Definition at line 1658 of file enrollib.php.

Here is the call graph for this function:

load_config ( ) [protected]

Makes sure config is loaded and cached.

Returns:
void

Definition at line 1039 of file enrollib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Returns:
bool - false means anybody may tweak roles, it does not use itemid and component when assigning roles

Reimplemented in enrol_self_plugin, enrol_paypal_plugin, and enrol_manual_plugin.

Definition at line 1078 of file enrollib.php.

Here is the caller graph for this function:

set_config ( name,
value 
)

Sets plugin config value

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

Definition at line 1063 of file enrollib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

show_enrolme_link ( stdClass $  instance)

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

Parameters:
stdClass$instancecourse enrol instance
Returns:
bool - true means show "Enrol me in this course" link in course UI

Reimplemented in enrol_self_plugin, and enrol_paypal_plugin.

Definition at line 1140 of file enrollib.php.

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.

Parameters:
object$useruser record
Returns:
void

Reimplemented in enrol_ldap_plugin, and enrol_database_plugin.

Definition at line 1402 of file enrollib.php.

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.

Parameters:
stdClass$instancecourse enrol instance
Returns:
bool|int false means not enrolled, integer means timeend

Definition at line 1153 of file enrollib.php.

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.

Parameters:
stdClass$instancecourse enrol instance
Returns:
bool|int false means no guest access, integer means timeend

Reimplemented in enrol_guest_plugin.

Definition at line 1168 of file enrollib.php.

unenrol_user ( stdClass $  instance,
userid 
)

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

Parameters:
stdClass$instance
int$userid
Returns:
void

Reimplemented in enrol_guest_plugin.

Definition at line 1326 of file enrollib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

update_status ( instance,
newstatus 
)

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
Returns:
void

Reimplemented in enrol_meta_plugin.

Definition at line 1577 of file enrollib.php.

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

Store user_enrolments changes and trigger event.

Parameters:
stdClass$instance
int$userid
int$status
int$timestart
int$timeend
Returns:
void

Definition at line 1275 of file enrollib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

user_delete ( user)

Called when user is about to be deleted

Parameters:
object$user
Returns:
void

Definition at line 1688 of file enrollib.php.

Here is the call graph for this function:


Field Documentation

$config = null [protected]

Definition at line 978 of file enrollib.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations