} else { // PARAM_URL requires a genuine TLD (I think) This breaks my testing $temp_wwwroot = clean_param($form->wwwroot, PARAM_URL); if ($temp_wwwroot !== $form->wwwroot) { trigger_error("We now parse the wwwroot with PARAM_URL. Your URL will need to have a valid TLD, etc."); print_error('invalidurl', 'mnet', 'peers.php'); exit; } unset($temp_wwwroot); $mnet_peer->set_applicationid($form->applicationid); $application = $DB->get_field('mnet_application', 'name', array('id' => $form->applicationid)); $mnet_peer->bootstrap($form->wwwroot, null, $application); } if (isset($form->name) && $form->name != $mnet_peer->name) { $form->name = clean_param($form->name, PARAM_NOTAGS); $mnet_peer->set_name($form->name); } if (isset($form->deleted) && ($form->deleted == '0' || $form->deleted == '1')) { $mnet_peer->deleted = $form->deleted; } if (isset($form->public_key)) { $form->public_key = clean_param($form->public_key, PARAM_PEM); if (empty($form->public_key)) { print_error("invalidpubkey", 'mnet', 'peers.php?step=update&hostid=' . $mnet_peer->id, ''); exit; } else { $oldkey = $mnet_peer->public_key; $mnet_peer->public_key = $form->public_key; $credentials = $mnet_peer->check_credentials($form->public_key); $mnet_peer->public_key_expires = $credentials['validTo_time_t']; if ($mnet_peer->public_key_expires == false) {
$maharawebroot = fread($fh, filesize($mfile)); fclose($fh); if (empty($maharawebroot)) { error('Step3 - could not find maharawebroot. Config failed.'); } $strheader = get_string('mahoodle', 'configmahoodle'); $navlinks = array(); $navlinks[] = array('name' => $strheader, 'link' => null, 'type' => 'misc'); $navigation = build_navigation($navlinks); print_header($strheader, $strheader, $navigation, ""); //now set up pubkey stuff in Moodle $mnet_peer = new mnet_peer(); $application = get_record('mnet_application', 'name', 'mahara'); $mnet_peer->set_applicationid($application->id); $mnet_peer->bootstrap($maharawebroot, null, $application->name); $mnet_peer->set_name('localmahara'); $mnet_peer->commit(); //now configure Networking in Moodle. //first get hostid. $hostid = get_field('mnet_host', 'id', 'name', 'localmahara'); $host2service = new stdClass(); $host2service->hostid = $hostid; $host2service->serviceid = get_field('mnet_service', 'id', 'name', 'sso_idp'); $host2service->publish = 1; $host2service->subscribe = 0; if ($hostrec = get_record('mnet_host2service', 'hostid', $hostid, 'serviceid', $host2service->serviceid)) { $host2service->id = $hostrec->id; update_record('mnet_host2service', $host2service); } else { insert_record('mnet_host2service', $host2service); }