} $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 $formdata->wwwroot = trim($formdata->wwwroot); $formdata->wwwroot = rtrim($formdata->wwwroot, '/'); // ensure the wwwroot starts with a http or https prefix if (strtolower(substr($formdata->wwwroot, 0, 4)) != 'http') { $formdata->wwwroot = 'http://' . $formdata->wwwroot; } $mnet_peer->set_applicationid($formdata->applicationid); $application = $DB->get_field('mnet_application', 'name', array('id' => $formdata->applicationid)); $mnet_peer->bootstrap($formdata->wwwroot, null, $application); // bootstrap the second form straight with the data from the first form $reviewform = new mnet_review_host_form(null, array('peer' => $mnet_peer)); // the second step (also the edit host form) $formdata->oldpublickey = $mnet_peer->public_key; // set this so we can confirm on form post without having to recreate the mnet_peer object $reviewform->set_data($mnet_peer); echo $OUTPUT->header(); echo $OUTPUT->box_start(); $reviewform->display(); echo $OUTPUT->box_end(); echo $OUTPUT->footer(); exit; } else {
} $fh = fopen($mfile, 'r'); $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 {