$string['usernotfound'] = 'The user $a is not registered into the remote Moodle';
$string['usercannotaccess'] = 'You ($a) cannot access to this file';
$string['nopeer'] = '<div style=\"font-size:0.8em\">Please setup some <a href=\"http://docs.moodle.org/en/admin/mnet/peers#Peer_to_Peer_Network\">Moodle peers</a> for your Moodle site. </div>';
+$string['hostnotfound'] = 'Cannot find the remote Moodle into the database - contact your system administrator';
\ No newline at end of file
///the method will not be returned by the system method system/listMethods)
require_once($CFG->dirroot . '/mnet/xmlrpc/client.php');
$this->ensure_environment();
+
+ ///check that the peer has been setup
+ if (!array_key_exists('peer',$this->options)) {
+ echo json_encode(array('e'=>get_string('error').' 9010: '.get_string('hostnotfound','repository_remotemoodle')));
+ exit;
+ }
+
$host = $DB->get_record('mnet_host',array('id' => $this->options['peer'])); //need to retrieve the host url
+
+ ///check that the peer host exists into the database
+ if (empty($host)) {
+ echo json_encode(array('e'=>get_string('error').' 9011: '.get_string('hostnotfound','repository_remotemoodle')));
+ exit;
+ }
+
$mnet_peer = new mnet_peer();
$mnet_peer->set_wwwroot($host->wwwroot);
$client = new mnet_xmlrpc_client();