diff --git a/admin/mnet/peer_forms.php b/admin/mnet/peer_forms.php index 26b6626cbb2..722e3a3d07f 100644 --- a/admin/mnet/peer_forms.php +++ b/admin/mnet/peer_forms.php @@ -15,15 +15,17 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . - /** * This file contains two forms for adding/editing mnet hosts, used by peers.php * - * @package moodlecore + * @package core + * @subpackage mnet * @copyright 2010 Penny Leach * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +defined('MOODLE_INTERNAL') || die(); + require_once($CFG->libdir . '/formslib.php'); /** @@ -33,12 +35,15 @@ require_once($CFG->libdir . '/formslib.php'); class mnet_simple_host_form extends moodleform { function definition() { global $DB; - $mform =& $this->_form; - $mform->addElement('text', 'wwwroot', get_string('hostname', 'mnet')); - $mform->addElement('select', 'applicationid', get_string('applicationtype', 'mnet'), $DB->get_records_menu('mnet_application', array(), 'id,display_name')); + $mform = $this->_form; + + $mform->addElement('text', 'wwwroot', get_string('hostname', 'mnet')); $mform->setType('wwwroot', PARAM_URL); $mform->addRule('wwwroot', null, 'required', null, 'client'); + + $mform->addElement('select', 'applicationid', get_string('applicationtype', 'mnet'), + $DB->get_records_menu('mnet_application', array(), 'id,display_name')); $mform->addRule('applicationid', null, 'required', null, 'client'); $this->add_action_buttons(false, get_string('addhost', 'mnet')); @@ -46,6 +51,7 @@ class mnet_simple_host_form extends moodleform { function validation($data) { global $DB; + $wwwroot = $data['wwwroot']; // ensure the wwwroot starts with a http or https prefix if (strtolower(substr($wwwroot, 0, 4)) != 'http') { @@ -66,7 +72,8 @@ class mnet_simple_host_form extends moodleform { class mnet_review_host_form extends moodleform { function definition() { global $OUTPUT; - $mform =& $this->_form; + + $mform = $this->_form; $mnet_peer = $this->_customdata['peer']; $mform->addElement('hidden', 'last_connect_time'); @@ -76,15 +83,16 @@ class mnet_review_host_form extends moodleform { $mform->addElement('text', 'name', get_string('site')); $mform->setType('name', PARAM_NOTAGS); + $mform->addElement('text', 'wwwroot', get_string('hostname', 'mnet')); $mform->setType('wwwroot', PARAM_URL); $mform->addElement('textarea', 'public_key', get_string('publickey', 'mnet'), array('rows' => 17, 'cols' => 100, 'class' => 'smalltext')); $mform->setType('public_key', PARAM_PEM); if ($mnet_peer && !empty($mnet_peer->deleted)) { - $radioarray=array(); - $radioarray[] = &MoodleQuickForm::createElement('radio', 'deleted', '', get_string('yes'), 1); - $radioarray[] = &MoodleQuickForm::createElement('radio', 'deleted', '', get_string('no'), 0); + $radioarray = array(); + $radioarray[] = MoodleQuickForm::createElement('radio', 'deleted', '', get_string('yes'), 1); + $radioarray[] = MoodleQuickForm::createElement('radio', 'deleted', '', get_string('no'), 0); $mform->addGroup($radioarray, 'radioar', get_string('deleted'), array(' '), false); } else { $mform->addElement('hidden', 'deleted'); diff --git a/admin/mnet/peers.php b/admin/mnet/peers.php index c799159347d..15655399940 100644 --- a/admin/mnet/peers.php +++ b/admin/mnet/peers.php @@ -36,7 +36,6 @@ require_login(); $context = get_context_instance(CONTEXT_SYSTEM); require_capability('moodle/site:config', $context, $USER->id, true, 'nopermissions'); - /// Initialize variables. $hostid = optional_param('hostid', 0, PARAM_INT); $updra = optional_param('updateregisterall', 0, PARAM_INT); @@ -71,12 +70,10 @@ if (!isset($CFG->mnet_dispatcher_mode)) { set_config('mnet_dispatcher_mode', 'off'); } - $mnet_peer = new mnet_peer(); $simpleform = new mnet_simple_host_form(); // the one that goes on the bottom of the main page $reviewform = null; // set up later in different code branches, so mnet_peer can be passed to the constructor - // if the first form has been submitted, bootstrap the peer and load up the review form if ($formdata = $simpleform->get_data()) { // ensure we remove trailing slashes @@ -168,7 +165,6 @@ if ($formdata = $reviewform->get_data()) { $mnet_peer->public_key_expires = $mnet_peer->check_common_name($formdata->public_key); $mnet_peer->updateparams->public_key_expires = $mnet_peer->check_common_name($formdata->public_key); - $credentials = $mnet_peer->check_credentials($mnet_peer->public_key); $mnet_peer->public_key_expires = $credentials['validTo_time_t'];