original_string: public function req_enrol_user(stdclass $user, stdclass $remotecourse) {
          global $CFG, $DB;
          require_once($CFG->dirroot.'/mnet/xmlrpc/client.php');
  
          $peer = new mnet_peer();
          $peer->set_id($remotecourse->hostid);
  
          $request = new mnet_xmlrpc_client();
          $request->set_method('enrol/mnet/enrol.php/enrol_user');
          $request->add_param(mnet_strip_user((array)$user, mnet_fields_to_send($peer)));
          $request->add_param($remotecourse->remoteid);
  
          if ($request->send($peer) === true) {
              if ($request->response === true) {
                  // cache the enrolment information in our table
                  $enrolment                  = new stdclass();
                  $enrolment->hostid          = $peer->id;
                  $enrolment->userid          = $user->id;
                  $enrolment->remotecourseid  = $remotecourse->remoteid;
                  $enrolment->enroltype       = 'mnet';
                  // $enrolment->rolename not known now, must be re-fetched
                  // $enrolment->enroltime not known now, must be re-fetched
                  $DB->insert_record('mnetservice_enrol_enrolments', $enrolment);
                  return true;
  
              } else {
                  return serialize(array('invalid response: '.print_r($request->response, true)));
              }
  
          } else {
              return serialize($request->error);
          }
      }
code: public function req_enrol_user(stdclass $user, stdclass $remotecourse) {
          global $CFG, $DB;
          require_once($CFG->dirroot.'/mnet/xmlrpc/client.php');
  
          $peer = new mnet_peer();
          $peer->set_id($remotecourse->hostid);
  
          $request = new mnet_xmlrpc_client();
          $request->set_method('enrol/mnet/enrol.php/enrol_user');
          $request->add_param(mnet_strip_user((array)$user, mnet_fields_to_send($peer)));
          $request->add_param($remotecourse->remoteid);
  
          if ($request->send($peer) === true) {
              if ($request->response === true) {
                  // cache the enrolment information in our table
                  $enrolment                  = new stdclass();
                  $enrolment->hostid          = $peer->id;
                  $enrolment->userid          = $user->id;
                  $enrolment->remotecourseid  = $remotecourse->remoteid;
                  $enrolment->enroltype       = 'mnet';
                  // $enrolment->rolename not known now, must be re-fetched
                  // $enrolment->enroltime not known now, must be re-fetched
                  $DB->insert_record('mnetservice_enrol_enrolments', $enrolment);
                  return true;
  
              } else {
                  return serialize(array('invalid response: '.print_r($request->response, true)));
              }
  
          } else {
              return serialize($request->error);
          }
      }
code_tokens: public function req_enrol_user ( stdclass $ user , stdclass $ remotecourse ) { global $ CFG , $ DB ; require_once ( $ CFG -> dirroot . '/mnet/xmlrpc/client.php' ) ; $ peer = new mnet_peer ( ) ; $ peer -> set_id ( $ remotecourse -> hostid ) ; $ request = new mnet_xmlrpc_client ( ) ; $ request -> set_method ( 'enrol/mnet/enrol.php/enrol_user' ) ; $ request -> add_param ( mnet_strip_user ( ( array ) $ user , mnet_fields_to_send ( $ peer ) ) ) ; $ request -> add_param ( $ remotecourse -> remoteid ) ; if ( $ request -> send ( $ peer ) === true ) { if ( $ request -> response === true ) { // cache the enrolment information in our table $ enrolment = new stdclass ( ) ; $ enrolment -> hostid = $ peer -> id ; $ enrolment -> userid = $ user -> id ; $ enrolment -> remotecourseid = $ remotecourse -> remoteid ; $ enrolment -> enroltype = 'mnet' ; // $enrolment->rolename not known now, must be re-fetched // $enrolment->enroltime not known now, must be re-fetched $ DB -> insert_record ( 'mnetservice_enrol_enrolments' , $ enrolment ) ; return true ; } else { return serialize ( array ( 'invalid response: ' . print_r ( $ request -> response , true ) ) ) ; } } else { return serialize ( $ request -> error ) ; } }
docstring: Send request to enrol our user to the remote course
  
  Updates our remote enrolments cache if the enrolment was successful.
  
  @uses mnet_xmlrpc_client Invokes XML-RPC request
  @param object $user our user
  @param object $remotecourse record from mnetservice_enrol_courses table
  @return true|string true if success, error message from the remote host otherwise
docstring_tokens: Send request to enrol our user to the remote course