Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
enrol_mnet_mnetservice_enrol Class Reference

MNet server-side methods that are part of mnetservice_enrol. More...

Public Member Functions

 available_courses ()
 Returns list of courses that we offer to the caller for remote enrolment of their users.
 
 course_enrolments ($courseid, $roles=null)
 Returns a list of users from the client server who are enrolled in our course.
 
 enrol_user (array $userdata, $courseid)
 Enrol remote user to our course.
 
 unenrol_user ($username, $courseid)
 Unenrol remote user from our course.
 
 user_enrolments ()
 This method has never been implemented in Moodle MNet API.
 

Detailed Description

MNet server-side methods that are part of mnetservice_enrol.

The weird name of the class tries to follow a pattern {plugintype}_{pluginnname}_mnetservice_{servicename}

Class methods are compatible with API 1 of the service used by Moodle 1.x and 2.0 peers. The API version might become a part of class name but it is not neccessary due to how xml-rcp methods are/will be mapped to php methods.

Member Function Documentation

◆ available_courses()

enrol_mnet_mnetservice_enrol::available_courses ( )

Returns list of courses that we offer to the caller for remote enrolment of their users.

Since Moodle 2.0, courses are made available for MNet peers by creating an instance of enrol_mnet plugin for the course. Hidden courses are not returned. If there are two instances - one specific for the host and one for 'All hosts', the setting of the specific one is used. The id of the peer is kept in customint1, no other custom fields are used.

@uses mnet_remote_client Callable via XML-RPC only

Return values
array

◆ course_enrolments()

enrol_mnet_mnetservice_enrol::course_enrolments ( $courseid,
$roles = null )

Returns a list of users from the client server who are enrolled in our course.

Suitable instance of enrol_mnet must be created in the course. This method will not return any information about the enrolments in courses that are not available for remote enrolment, even if their users are enrolled into them via other plugin (note the difference from self::user_enrolments()).

This method will return enrolment information for users from hosts regardless the enrolment plugin. It does not matter if the user was enrolled remotely by their admin or locally. Once the course is available for remote enrolments, we will tell them everything about their users.

In Moodle 1.x the returned array used to be indexed by username. The side effect of MDL-19219 fix is that we do not need to use such index and therefore we can return all enrolment records. MNet clients 1.x will only use the last record for the student, if she is enrolled via multiple plugins.

@uses mnet_remote_client Callable via XML-RPC only

Parameters
int$courseidID of our course
string | array$rolescomma separated list of role shortnames (or array of them)
Return values
array

◆ enrol_user()

enrol_mnet_mnetservice_enrol::enrol_user ( array $userdata,
$courseid )

Enrol remote user to our course.

If we do not have local record for the remote user in our database, it gets created here.

@uses mnet_remote_client Callable via XML-RPC only

Parameters
array$userdatauser details {
See also
mnet_fields_to_import()}
Parameters
int$courseidour local course id
Return values
booltrue if the enrolment has been successful, throws exception otherwise

◆ unenrol_user()

enrol_mnet_mnetservice_enrol::unenrol_user ( $username,
$courseid )

Unenrol remote user from our course.

Only users enrolled via enrol_mnet plugin can be unenrolled remotely. If the remote user is enrolled into the local course via some other enrol plugin (enrol_manual for example), the remote host can't touch such enrolment. Please do not report this behaviour as bug, it is a feature ;-)

@uses mnet_remote_client Callable via XML-RPC only

Parameters
string$usernameof the remote user
int$courseidof our local course
Return values
booltrue if the unenrolment has been successful, throws exception otherwise

◆ user_enrolments()

enrol_mnet_mnetservice_enrol::user_enrolments ( )

This method has never been implemented in Moodle MNet API.

@uses mnet_remote_client Callable via XML-RPC only

Return values
arrayempty array

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