When remotely enrolling a student, RPC should pass to the remote server all flags affecting the student's privacy (maildisplay) and how Moodle send mails (emailstop, mailformat, maildigest).
These settings affect the user in the course even before his first log-in, when all user data are passed.
I attach the two modified functions in enrol/mnet/enrol.php
(modifications commented with [nicus] tag)
---8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<---
function enrol_user($user, $courseid) {
global $MNET, $MNET_REMOTE_CLIENT;
$userrecord = get_record('user','username',addslashes($user['username']), 'mnethostid',$MNET_REMOTE_CLIENT->id);
if ($userrecord == false) {
$userrecord = new stdClass();
$userrecord->username = addslashes($user['username']);
$userrecord->email = addslashes($user['email']);
$userrecord->firstname = addslashes($user['firstname']);
$userrecord->lastname = addslashes($user['lastname']);
// [nicus] added emailstop, mailformat, maildigest, maildisplay, lang, trackforums fields
$userrecord->emailstop = addslashes($user['emailstop']);
$userrecord->mailformat = addslashes($user['mailformat']);
$userrecord->maildigest = addslashes($user['maildigest']);
$userrecord->maildisplay = addslashes($user['maildisplay']);
$userrecord->lang = addslashes($user['lang']);
$userrecord->trackforums = addslashes($user['trackforums']);
$userrecord->mnethostid = $MNET_REMOTE_CLIENT->id;
if ($userrecord->id = insert_record('user', $userrecord))
{ $userrecord = get_record('user','id', $userrecord->id); }else
{ // TODO: Error out return false; }}
if (! $course = get_record('course', 'id', $courseid) )
{ // TODO: Error out return false; }$courses = $this->available_courses();
if (!empty($courses[$courseid])) {
if (enrol_into_course($course, $userrecord, 'mnet'))
}
return false;
}
---8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<---
function req_enrol_user($userid, $courseid) {
global $CFG;
global $USER;
global $MNET;
require_once $CFG->dirroot . '/mnet/xmlrpc/client.php';
// Prepare a basic user record
// in case the remote host doesn't have it
// [nicus] added emailstop, mailformat, maildigest, maildisplay, lang, trackforums fieldS
$user = get_record('user', 'id', $userid, '','','','', 'username, email, firstname, lastname, emailstop, mailformat, maildigest, maildisplay, lang, trackforums');
$user = (array)$user;
$course = get_record('mnet_enrol_course', 'id', $courseid);
// get the Service Provider info
$mnet_sp = new mnet_peer();
$mnet_sp->set_id($course->hostid);
// set up the RPC request
$mnetrequest = new mnet_xmlrpc_client();
$mnetrequest->set_method('enrol/mnet/enrol.php/enrol_user');
$mnetrequest->add_param($user);
$mnetrequest->add_param($course->remoteid);
// Thunderbirds are go! Do RPC call and store response
if ($mnetrequest->send($mnet_sp) === true) {
if ($mnetrequest->response == true) {
// now store it in the mnet_enrol_assignments table
$assignment = new StdClass;
$assignment->userid = $userid;
$assignment->hostid = $course->hostid;
$assignment->courseid = $course->id;
$assignment->enroltype = 'mnet';
// TODO: other fields
if (insert_record('mnet_enrol_assignments', $assignment))
}
}
return false;
}
- has a non-specific relationship to
-
MDL-17782 Unable to edit profile on networked site
- Closed
-
MDL-21327 enrol/mnet creates users regardless of the auto create settings in auth/mnet
- Closed
- has been marked as being related by
-
MDL-20660 Pass student ID over MNET from Moodle
- Closed
- will help resolve
-
MDL-21259 Low hanging fruit - simple feature requests
- Closed