public function req_unenrol_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/unenrol_user');
        $request->add_param($user->username);
        $request->add_param($remotecourse->remoteid);

        if ($request->send($peer) === true) {
            if ($request->response === true) {
                // clear the cached information
                $DB->delete_records('mnetservice_enrol_enrolments',
                    array('hostid'=>$peer->id, 'userid'=>$user->id, 'remotecourseid'=>$remotecourse->remoteid, 'enroltype'=>'mnet'));
                return true;

            } else {
                return serialize(array('invalid response: '.print_r($request->response, true)));
            }

        } else {
            return serialize($request->error);
        }
    }
public function req_unenrol_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/unenrol_user');
        $request->add_param($user->username);
        $request->add_param($remotecourse->remoteid);

        if ($request->send($peer) === true) {
            if ($request->response === true) {
                // clear the cached information
                $DB->delete_records('mnetservice_enrol_enrolments',
                    array('hostid'=>$peer->id, 'userid'=>$user->id, 'remotecourseid'=>$remotecourse->remoteid, 'enroltype'=>'mnet'));
                return true;

            } else {
                return serialize(array('invalid response: '.print_r($request->response, true)));
            }

        } else {
            return serialize($request->error);
        }
    }
public function req_unenrol_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/unenrol_user' ) ; $ request -> add_param ( $ user -> username ) ; $ request -> add_param ( $ remotecourse -> remoteid ) ; if ( $ request -> send ( $ peer ) === true ) { if ( $ request -> response === true ) { // clear the cached information $ DB -> delete_records ( 'mnetservice_enrol_enrolments' , array ( 'hostid' => $ peer -> id , 'userid' => $ user -> id , 'remotecourseid' => $ remotecourse -> remoteid , 'enroltype' => 'mnet' ) ) ; return true ; } else { return serialize ( array ( 'invalid response: ' . print_r ( $ request -> response , true ) ) ) ; } } else { return serialize ( $ request -> error ) ; } }
Send request to unenrol our user from the remote course

Updates our remote enrolments cache if the unenrolment 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
Send request to unenrol our user from the remote course