Moodle  2.2.1
http://www.collinsharper.com
mnetservice_enrol Class Reference

Public Member Functions

 is_available ()
 get_remote_subscribers ()
 get_remote_publishers ()
 get_remote_courses ($mnethostid, $usecache=true)
 req_course_enrolments ($mnethostid, $remotecourseid)
 req_enrol_user (stdclass $user, stdclass $remotecourse)
 req_unenrol_user (stdclass $user, stdclass $remotecourse)
 format_error_message ($errormsg)

Static Public Member Functions

static get_instance ()

Protected Member Functions

 __construct ()

Protected Attributes

 $cachesubscribers = null
 $cachepublishers = null

Static Protected Attributes

static $singleton

Detailed Description

Singleton providing various functionality usable by plugin(s) implementing this MNet service

Definition at line 37 of file locallib.php.


Constructor & Destructor Documentation

__construct ( ) [protected]

This is singleton, use mnetservice_enrol::get_instance()

Definition at line 51 of file locallib.php.


Member Function Documentation

format_error_message ( errormsg)

Prepares error messages returned by our XML-RPC requests to be send as debug info to print_error()

MNet client-side methods in this class return request error as serialized array.

Parameters:
string$errorserialized array
Returns:
string

Definition at line 446 of file locallib.php.

static get_instance ( ) [static]
Returns:
mnetservice_enrol singleton instance

Definition at line 57 of file locallib.php.

Here is the caller graph for this function:

get_remote_courses ( mnethostid,
usecache = true 
)

Fetches the information about the courses available on remote host for our students

The information about remote courses available for us is cached in {mnetservice_enrol_courses}. This method either returns the cached information (typically when displaying the list to students) or fetch fresh data via new XML-RPC request (which updates the local cache, too). The lifetime of the cache is 1 day, so even if $usecache is set to true, the cache will be re-populated if we did not fetch from any server (not only the currently requested one) for some time.

Parameters:
id$mnethostidMNet remote host id
bool$usecacheuse cached data or invoke new XML-RPC? mnet_xmlrpc_client Invokes XML-RPC request if the cache is not used
Returns:
array|string returned list or serialized array of mnet error messages

Definition at line 156 of file locallib.php.

Here is the call graph for this function:

Returns a list of remote servers that offer their courses for our users

We must subscribe MNet service 'mnet_enrol' for the peers to allow our users to enrol into their courses.

Todo:

once the MNet core is refactored this may be part of a parent class

the name of the service should be changed to the name of this plugin

Returns:
array

Definition at line 122 of file locallib.php.

Returns a list of remote servers that can enrol their users into our courses

We must publish MNet service 'mnet_enrol' for the peers to allow them to enrol their users into our courses.

Todo:

once the MNet core is refactored this may be part of a parent class

the name of the service should be changed to the name of this plugin

Returns:
array

Definition at line 93 of file locallib.php.

Is this service enabled?

Currently, this checks if whole MNet is available. In the future, additional checks can be done. Probably the field 'offer' should be checked but it does not seem to be used so far.

Todo:
move this to some parent class once we have such
Returns:
bool

Definition at line 74 of file locallib.php.

req_course_enrolments ( mnethostid,
remotecourseid 
)

Updates local cache about enrolments of our users in remote courses

The remote course must allow enrolments via our Remote enrolment service client. Because of legacy design of data structure returned by XML-RPC code, only one user enrolment per course is returned by 1.9 MNet servers. This may be an issue if the user is enrolled multiple times by various enrolment plugins. MNet 2.0 servers do not use user name as array keys - they do not need to due to side effect of MDL-19219.

Parameters:
id$mnethostidMNet remote host id
int$remotecourseidID of the course at the remote host
bool$usecacheuse cached data or invoke new XML-RPC? mnet_xmlrpc_client Invokes XML-RPC request
Returns:
bool|string true if success or serialized array of mnet error messages

Definition at line 257 of file locallib.php.

Here is the call graph for this function:

req_enrol_user ( stdclass $  user,
stdclass $  remotecourse 
)

Send request to enrol our user to the remote course

Updates our remote enrolments cache if the enrolment was successful.

mnet_xmlrpc_client Invokes XML-RPC request

Parameters:
object$userour user
object$remotecourserecord from mnetservice_enrol_courses table
Returns:
true|string true if success, error message from the remote host otherwise

Definition at line 366 of file locallib.php.

Here is the call graph for this function:

req_unenrol_user ( stdclass $  user,
stdclass $  remotecourse 
)

Send request to unenrol our user from the remote course

Updates our remote enrolments cache if the unenrolment was successful.

mnet_xmlrpc_client Invokes XML-RPC request

Parameters:
object$userour user
object$remotecourserecord from mnetservice_enrol_courses table
Returns:
true|string true if success, error message from the remote host otherwise

Definition at line 410 of file locallib.php.


Field Documentation

$cachepublishers = null [protected]

Definition at line 46 of file locallib.php.

$cachesubscribers = null [protected]

Definition at line 43 of file locallib.php.

$singleton [static, protected]

Definition at line 40 of file locallib.php.


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