Moodle

When remotely enrolling, should be passed to the remote server all user settings affecting student's privacy and mails

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.8.2
  • Fix Version/s: 2.0
  • Component/s: MNet
  • Labels:
    None
  • Affected Branches:
    MOODLE_18_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE

Description

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 true; }
}
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 true; }
}
}

return false;
}

  1. mnetfields.diff
    12/Jan/10 1:24 PM
    3 kB
    Penny Leach
  2. mnetfields.diff
    12/Jan/10 11:45 AM
    3 kB
    Penny Leach

Issue Links

Activity

Hide
Penny Leach added a comment -

Hi, I think the attached patch is more generic. Can you give it a go?

Show
Penny Leach added a comment - Hi, I think the attached patch is more generic. Can you give it a go?
Hide
Penny Leach added a comment -

better patch

Show
Penny Leach added a comment - better patch
Hide
Penny Leach added a comment -

I have changed moodle in 2.0 to allow administrators to configure a list of profile fields to send and receive over MNET. This doesn't include custom profile fields, but it should solve your problem. I'm closing this bug now as it's being tracked in MDL-20660

Show
Penny Leach added a comment - I have changed moodle in 2.0 to allow administrators to configure a list of profile fields to send and receive over MNET. This doesn't include custom profile fields, but it should solve your problem. I'm closing this bug now as it's being tracked in MDL-20660

People

Vote (2)
Watch (4)

Dates

  • Created:
    Updated:
    Resolved: