From: jerome <jerome> Date: Thu, 30 Oct 2008 04:24:46 +0000 (+0000) Subject: MDL-15352: check that the peer has been setup X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c4f2cf4a2042efef3b12f13911c34ac047fa92b0;p=moodle.git MDL-15352: check that the peer has been setup --- diff --git a/lang/en_utf8/repository_remotemoodle.php b/lang/en_utf8/repository_remotemoodle.php index 10981f53ff..8ee457cdca 100644 --- a/lang/en_utf8/repository_remotemoodle.php +++ b/lang/en_utf8/repository_remotemoodle.php @@ -13,3 +13,4 @@ $string['failtoretrievelist'] = 'List could not be retrieved or is empty'; $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 diff --git a/repository/remotemoodle/repository.class.php b/repository/remotemoodle/repository.class.php index a88093ebf2..abbcdc3ee4 100644 --- a/repository/remotemoodle/repository.class.php +++ b/repository/remotemoodle/repository.class.php @@ -159,7 +159,21 @@ class repository_remotemoodle extends repository { ///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();