]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15352: check that the peer has been setup
authorjerome <jerome>
Thu, 30 Oct 2008 04:24:46 +0000 (04:24 +0000)
committerjerome <jerome>
Thu, 30 Oct 2008 04:24:46 +0000 (04:24 +0000)
lang/en_utf8/repository_remotemoodle.php
repository/remotemoodle/repository.class.php

index 10981f53ff73361a4b67006d024acfd177e08e2f..8ee457cdca9920f909da5b940895a8faa94ff5f5 100644 (file)
@@ -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
index a88093ebf25a098143ec4dfcfb77b7c47bd61bf3..abbcdc3ee4d64fededb15c21568b20d98a52a11c 100644 (file)
@@ -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();