Commit e1c80084 authored by Donal McMullan's avatar Donal McMullan

WIP

parent 2e827204
......@@ -84,6 +84,8 @@ function networkingform_fail(Pieform $form) {
function networkingform_submit(Pieform $form, $values) {
$reply = get_string('networkingunchanged','admin');
if (get_config('enablenetworking') != $values['enablenetworking']) {
if (!set_config('enablenetworking', $values['enablenetworking'])) {
networkingform_fail($form);
......
......@@ -137,6 +137,7 @@ function auth_config_submit(Pieform $form, $values) {
// TODO: move to lib if people want this:
function execute_javascript_and_close($js='') {
echo 'EXECUTE JS AND CLOSE';
echo '<html>
<head>
<title>You may close this window</title>
......
......@@ -469,14 +469,7 @@ class PluginAuthXmlrpc extends PluginAuth {
$authinstance = new stdClass();
$peer = new Peer();
if (false == $peer->findByWwwroot($values['wwwroot'])) {
try {
$peer->bootstrap($values['wwwroot'], null);
} catch (RemoteServerException $e) {
$form->set_error('wwwroot',get_string('cantretrievekey', 'auth').'<br>'.$e->getMessage());
throw new RemoteServerException($e->getMessage(), $e->getCode());
}
}
//TODO: test values and set appropriate errors on form
}
public static function save_config_options($values, $form) {
......@@ -507,7 +500,7 @@ class PluginAuthXmlrpc extends PluginAuth {
if (false == $peer->findByWwwroot($values['wwwroot'])) {
try {
$peer->bootstrap($values['wwwroot'], null);
$peer->bootstrap($values['wwwroot'], null, $values['appname'], $values['institution']);
} catch (RemoteServerException $e) {
$form->set_error('wwwroot',get_string('cantretrievekey', 'auth'));
throw new RemoteServerException($e->getMessage(), $e->getCode());
......@@ -529,7 +522,7 @@ class PluginAuthXmlrpc extends PluginAuth {
*/
$peer->commit();
$authinstance->instancename = $values['instancename'];
$authinstance->institution = $values['institution'];
$authinstance->authname = $values['authname'];
......
......@@ -72,6 +72,7 @@ class Peer {
if (!array_key_exists($name, $this->members)) {
throw new ParamOutOfRangeException(addslashes($name) .' is not a member of Peer.');
}
if ($value != $this->members[$name]) {
if ($name == 'appname') {
$this->application = Application::findByName($value);
......@@ -147,18 +148,21 @@ class Peer {
if ($this->initialized == self::INITIALIZED) {
$this->initialized = self::PERSISTENT;
return insert_record('host',$host);
} elseif ($this->initialized == self::PERSISTENT) {
try {
return update_record('host',$host,array('wwwroot' => $host->wwwroot));
} catch (Exception $e) {
throw new SQLException();
$exists = get_record('host', 'wwwroot', $host->wwwroot);
if (false == $exists) {
return insert_record('host',$host);
}
return true;
}
try {
return update_record('host',$host,array('wwwroot' => $host->wwwroot));
} catch (Exception $e) {
throw new SQLException();
}
return false;
}
public function bootstrap($wwwroot, $pubkey, $appname = 'moodle') {
public function bootstrap($wwwroot, $pubkey, $appname = 'moodle', $institution = null) {
global $CFG;
$wwwroot = dropslash($wwwroot);
......@@ -200,17 +204,19 @@ class Peer {
require_once($CFG->docroot .'/include/eLearning/institution.php');
$institution = new Institution;
$iname = preg_replace('/\s+/', '', $this->name);
if (false == $institution->findByName($iname)) {
if (null == $institution) {
$institution = new Institution;
$iname = preg_replace('/\s+/', '', $this->name);
$institution->name = preg_replace('/\s+/', '', $this->name);
$institution->displayname = $this->name;
$institution->commit();
$this->institution = $institution->name;
} else {
$this->institution = $institution;
}
$this->institution = $institution->name;
if(empty($pubkey)) {
try {
$somekey = get_public_key($this->wwwroot, $this->appname);
......
......@@ -123,9 +123,10 @@ $string['enablenetworkingdescription'] = 'Allow your Mahara server to communicat
$string['enablenetworking'] = 'Enable networking';
$string['networkingenabled'] = 'Networking has been enabled';
$string['networkingdisabled'] = 'Networking has been disabled';
$string['networkingunchanged'] = 'Network settings were not changed';
$string['promiscuousmode'] = 'Auto-register all hosts';
$string['promiscuousmodedisabled'] = 'Networking has been disabled';
$string['promiscuousmodeenabled'] = 'Networking has been disabled';
$string['promiscuousmodedisabled'] = 'Auto-register has been disabled';
$string['promiscuousmodeenabled'] = 'Auto-register has been enabled';
$string['promiscuousmodedescription'] = 'Create an institution record for any host that connects to you, and allow its users to log on to Mahara';
// Admin menu editor
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment