Merged Donal's changes to MNET to allow moodle to also network with mahara.
changelog follows
[MNET-manual] added version.php, install.xml and upgrade.php patches
Route remote users back to their home server without going through jump.php and land.php
Display app-specific strings in the user view
Display the application icon in the Remote Host block
Hide the 'logs' tab if the application under review is not Moodle
Hide the 'logs' tab if the application under review is not Moodle
Update user record to note that picture == 1 once a picture has been
transferred.
Change 2 to uri - is this fluid?
Add application paramter to bootstrap function
Find the application
Workaround for PHP5.2.2 bug: http://bugs.php.net/bug.php?id=41293
$HTTP_RAW_POST_DATA was not being populated
Ensure we get an application for our Peer
Update the URI to use for MNET
The default 'wantsurl' should be empty
Use the appropriate 'land' url for the remote application
Add hidden form elements for 'application'
Add awareness of new Application concept
Add awareness of new Application concept
Add awareness of new Application concept
Add awareness of new Application concept
Add awareness of new Application concept
Add awareness of new Application concept
Add awareness of new Application concept
This commit is contained in:
@@ -10,7 +10,9 @@ admin_externalpage_print_header();
|
||||
if (isset($mnet_peer->id) && $mnet_peer->id > 0) {
|
||||
$tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
|
||||
$tabs[] = new tabobject('mnetservices', 'mnet_services.php?step=list&hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false);
|
||||
$tabs[] = new tabobject('mnetlog', $logurl, $strmnetlog, $strmnetlog, false);
|
||||
if ($mnet_peer->application->name == 'moodle') {
|
||||
$tabs[] = new tabobject('mnetlog', $logurl, $strmnetlog, $strmnetlog, false);
|
||||
}
|
||||
} else {
|
||||
$tabs[] = new tabobject('mnetdetails', '#', $strmnetedithost, $strmnetedithost, false);
|
||||
}
|
||||
@@ -24,6 +26,8 @@ print_simple_box_start("center", "");
|
||||
<input type="hidden" name="step" value="commit" />
|
||||
<input type="hidden" name="last_connect_time" value="<?php echo $mnet_peer->last_connect_time; ?>" />
|
||||
<input type="hidden" name="id" value="<?php echo isset($mnet_peer->id)? $mnet_peer->id : '0' ; ?>" />
|
||||
<input type="hidden" name="applicationid" value="<?php echo isset($mnet_peer->applicationid)? $mnet_peer->applicationid : '0' ; ?>" />
|
||||
<input type="hidden" name="applicationname" value="<?php echo isset($mnet_peer->application->name)? $mnet_peer->application->name : '' ; ?>" />
|
||||
<table cellpadding="9" cellspacing="0" width="635">
|
||||
|
||||
<tr>
|
||||
@@ -48,7 +52,7 @@ if (empty($mnet_peer->public_key)) $mnet_peer->public_key = '';
|
||||
|
||||
|
||||
if (isset($mnet_peer->deleted) && $mnet_peer->deleted > 0) {
|
||||
$key = mnet_get_public_key($mnet_peer->wwwroot);
|
||||
$key = mnet_get_public_key($mnet_peer->wwwroot, $mnet_peer->application->xmlrpc_server_url);
|
||||
$mnet_peer->public_key = clean_param($key, PARAM_PEM);
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -9,7 +9,9 @@ $logurl = $CFG->wwwroot.
|
||||
|
||||
$tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
|
||||
$tabs[] = new tabobject('mnetservices', 'mnet_services.php?step=list&hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false);
|
||||
if ($mnet_peer->id != $CFG->mnet_all_hosts_id) $tabs[] = new tabobject('mnetlog', $logurl, $strmnetlog, $strmnetlog, false);
|
||||
if ($mnet_peer->id != $CFG->mnet_all_hosts_id && $mnet_peer->application->name == 'moodle') {
|
||||
$tabs[] = new tabobject('mnetlog', $logurl, $strmnetlog, $strmnetlog, false);
|
||||
}
|
||||
print_tabs(array($tabs), 'mnetservices');
|
||||
print_simple_box_start("center", "");
|
||||
|
||||
|
||||
@@ -78,7 +78,15 @@ if (empty($CFG->mnet_dispatcher_mode) || $CFG->mnet_dispatcher_mode !== 'strict'
|
||||
<tr>
|
||||
<td class="cell c0"></td>
|
||||
<td class="cell c1"><input type="text" name="wwwroot" value="" /></td>
|
||||
<td class="cell c2"></td>
|
||||
<td class="cell c2">
|
||||
<select name="applicationid">
|
||||
<?php
|
||||
foreach($applications as $application) {
|
||||
echo ' <option value="'.$application->id.'">'.$application->display_name."</option>\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
<td class="cell c3"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
+29
-4
@@ -80,9 +80,11 @@ if (($form = data_submitted()) && confirm_sesskey()) {
|
||||
exit;
|
||||
}
|
||||
unset($temp_wwwroot);
|
||||
$mnet_peer->bootstrap($form->wwwroot);
|
||||
$mnet_peer->set_applicationid($form->applicationid);
|
||||
$application = get_field('mnet_application', 'name', '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);
|
||||
@@ -134,7 +136,7 @@ if (($form = data_submitted()) && confirm_sesskey()) {
|
||||
} elseif (is_int($hostid)) {
|
||||
$mnet_peer = new mnet_peer();
|
||||
$mnet_peer->set_id($hostid);
|
||||
$currentkey = mnet_get_public_key($mnet_peer->wwwroot);
|
||||
$currentkey = mnet_get_public_key($mnet_peer->wwwroot, $mnet_peer->application);
|
||||
if($currentkey == $mnet_peer->public_key) unset($currentkey);
|
||||
$form = new stdClass();
|
||||
if ($hostid != $CFG->mnet_all_hosts_id) {
|
||||
@@ -143,8 +145,31 @@ if (($form = data_submitted()) && confirm_sesskey()) {
|
||||
include('./mnet_review_allhosts.html');
|
||||
}
|
||||
} else {
|
||||
$hosts = get_records_select('mnet_host', " id != '{$CFG->mnet_localhost_id}' AND deleted = '0' ",'wwwroot ASC' );
|
||||
$hosts = get_records_sql(' SELECT
|
||||
h.id,
|
||||
h.wwwroot,
|
||||
h.ip_address,
|
||||
h.name,
|
||||
h.public_key,
|
||||
h.public_key_expires,
|
||||
h.transport,
|
||||
h.portno,
|
||||
h.last_connect_time,
|
||||
h.last_log_id,
|
||||
h.applicationid,
|
||||
a.name as app_name,
|
||||
a.display_name as app_display_name,
|
||||
a.xmlrpc_server_url
|
||||
FROM
|
||||
'.$CFG->prefix.'mnet_host h,
|
||||
'.$CFG->prefix.'mnet_application a
|
||||
WHERE
|
||||
h.id != \''.$CFG->mnet_localhost_id.'\' AND
|
||||
h.deleted = \'0\' AND
|
||||
h.applicationid=a.id');
|
||||
|
||||
if (empty($hosts)) $hosts = array();
|
||||
$applications = get_records('mnet_application');
|
||||
include('./peers.html');
|
||||
}
|
||||
?>
|
||||
|
||||
+2
-1
@@ -225,7 +225,7 @@ class auth_plugin_mnet extends auth_plugin_base {
|
||||
// construct the redirection URL
|
||||
//$transport = mnet_get_protocol($mnet_peer->transport);
|
||||
$wantsurl = urlencode($wantsurl);
|
||||
$url = "{$mnet_peer->wwwroot}/auth/mnet/land.php?token={$mnet_session->token}&idp={$MNET->wwwroot}&wantsurl={$wantsurl}";
|
||||
$url = "{$mnet_peer->wwwroot}{$mnet_peer->application->sso_land_url}?token={$mnet_session->token}&idp={$MNET->wwwroot}&wantsurl={$wantsurl}";
|
||||
|
||||
return $url;
|
||||
}
|
||||
@@ -338,6 +338,7 @@ class auth_plugin_mnet extends auth_plugin_base {
|
||||
if (strlen($fetchrequest->response['f1']) > 0) {
|
||||
$imagecontents = base64_decode($fetchrequest->response['f1']);
|
||||
file_put_contents($filename, $imagecontents);
|
||||
$localuser->picture = 1;
|
||||
}
|
||||
if (strlen($fetchrequest->response['f2']) > 0) {
|
||||
$imagecontents = base64_decode($fetchrequest->response['f2']);
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ if (!is_enabled_auth('mnet')) {
|
||||
// grab the GET params - wantsurl could be anything - take it
|
||||
// with PARAM_RAW
|
||||
$hostid = required_param('hostid', PARAM_INT);
|
||||
$wantsurl = optional_param('wantsurl', '/', PARAM_RAW);
|
||||
$wantsurl = optional_param('wantsurl', '', PARAM_RAW);
|
||||
|
||||
// start the mnet session and redirect browser to remote URL
|
||||
$mnetauth = get_auth_plugin('mnet');
|
||||
|
||||
@@ -40,9 +40,13 @@ class block_mnet_hosts extends block_list {
|
||||
$sql = "
|
||||
SELECT DISTINCT
|
||||
h.id,
|
||||
h.name
|
||||
h.name,
|
||||
h.wwwroot,
|
||||
a.name as application,
|
||||
a.display_name
|
||||
FROM
|
||||
{$CFG->prefix}mnet_host h,
|
||||
{$CFG->prefix}mnet_application a,
|
||||
{$CFG->prefix}mnet_host2service h2s_IDP,
|
||||
{$CFG->prefix}mnet_service s_IDP,
|
||||
{$CFG->prefix}mnet_host2service h2s_SP,
|
||||
@@ -50,13 +54,17 @@ class block_mnet_hosts extends block_list {
|
||||
WHERE
|
||||
h.id != '{$CFG->mnet_localhost_id}' AND
|
||||
h.id = h2s_IDP.hostid AND
|
||||
h.applicationid = a.id AND
|
||||
h2s_IDP.serviceid = s_IDP.id AND
|
||||
s_IDP.name = 'sso_idp' AND
|
||||
h2s_IDP.publish = '1' AND
|
||||
h.id = h2s_SP.hostid AND
|
||||
h2s_SP.serviceid = s_SP.id AND
|
||||
s_SP.name = 'sso_idp' AND
|
||||
h2s_SP.publish = '1'";
|
||||
h2s_SP.publish = '1'
|
||||
ORDER BY
|
||||
a.display_name,
|
||||
h.name";
|
||||
|
||||
$hosts = get_records_sql($sql);
|
||||
|
||||
@@ -65,14 +73,19 @@ class block_mnet_hosts extends block_list {
|
||||
$this->content->icons = array();
|
||||
$this->content->footer = '';
|
||||
|
||||
$icon = "<img src=\"$CFG->pixpath/i/mnethost.gif\"".
|
||||
" class=\"icon\" alt=\"".get_string('server', 'block_mnet_hosts')."\" />";
|
||||
|
||||
if ($hosts) {
|
||||
foreach ($hosts as $host) {
|
||||
$icon = '<img src="'.$CFG->pixpath.'/i/'.$host->application.'_host.gif"'.
|
||||
' class="icon" alt="'.get_string('server', 'block_mnet_hosts').'" />';
|
||||
|
||||
$this->content->icons[]=$icon;
|
||||
$this->content->items[]="<a title=\"" .s($host->name).
|
||||
"\" href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$host->id}\">" . s($host->name) ."</a>";
|
||||
if ($host->id == $USER->mnethostid) {
|
||||
$this->content->items[]="<a title=\"" .s($host->name).
|
||||
"\" href=\"{$host->wwwroot}\">". s($host->name) ."</a>";
|
||||
} else {
|
||||
$this->content->items[]="<a title=\"" .s($host->name).
|
||||
"\" href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$host->id}\">" . s($host->name) ."</a>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+21
-2
@@ -1071,7 +1071,8 @@
|
||||
<FIELD NAME="transport" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="public_key_expires" NEXT="portno"/>
|
||||
<FIELD NAME="portno" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="transport" NEXT="last_connect_time"/>
|
||||
<FIELD NAME="last_connect_time" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="portno" NEXT="last_log_id"/>
|
||||
<FIELD NAME="last_log_id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="last_connect_time"/>
|
||||
<FIELD NAME="last_log_id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="last_connect_time" NEXT="applicationid"/>
|
||||
<FIELD NAME="applicationid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="last_log_id"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the mnet_host table"/>
|
||||
@@ -1564,9 +1565,27 @@
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="mnet_application" COMMENT="mnet_application table retrofitted from MySQL" PREVIOUS="grade_import_newitem">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="display_name"/>
|
||||
<FIELD NAME="display_name" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="xmlrpc_server_url"/>
|
||||
<FIELD NAME="xmlrpc_server_url" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="display_name" NEXT="sso_land_url"/>
|
||||
<FIELD NAME="sso_land_url" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="xmlrpc_server_url"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for mnet_application"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
<STATEMENTS>
|
||||
<STATEMENT NAME="insert log_display" TYPE="insert" TABLE="log_display" COMMENT="Initial insert of records on table log_display">
|
||||
<STATEMENT NAME="insert mnet_application" TYPE="insert" TABLE="mnet_application" COMMENT="Initial insert of records on table mnet_application" NEXT="insert log_display">
|
||||
<SENTENCES>
|
||||
<SENTENCE TEXT="(name, display_name, xmlrpc_server_url, sso_land_url) VALUES ('moodle','Moodle','/mnet/xmlrpc/server.php', '/auth/mnet/land.php')" />
|
||||
<SENTENCE TEXT="(name, display_name, xmlrpc_server_url, sso_land_url) VALUES ('mahara','Mahara','/api/xmlrpc/server.php', '/auth/xmlrpc/land.php')" />
|
||||
</SENTENCES>
|
||||
</STATEMENT>
|
||||
<STATEMENT NAME="insert log_display" TYPE="insert" TABLE="log_display" COMMENT="Initial insert of records on table log_display" PREVIOUS="insert mnet_application">
|
||||
<SENTENCES>
|
||||
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('user', 'view', 'user', 'CONCAT(firstname," ",lastname)')" />
|
||||
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('course', 'user report', 'user', 'CONCAT(firstname," ",lastname)')" />
|
||||
|
||||
@@ -1445,6 +1445,61 @@ function xmldb_main_upgrade($oldversion=0) {
|
||||
/// Launch rename field rawgrade
|
||||
$result = $result && rename_field($table, $field, 'finalgrade');
|
||||
}
|
||||
|
||||
if ($result && $oldversion < 2007071400) {
|
||||
$table = new XMLDBTable('mnet_host');
|
||||
$field = new XMLDBField('applicationid');
|
||||
$field->setAttributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '1', 'last_log_id');
|
||||
|
||||
$result = $result && add_field($table, $field);
|
||||
|
||||
/**
|
||||
** mnet application table
|
||||
**/
|
||||
$table = new XMLDBTable('mnet_application');
|
||||
$table->comment = 'Information about applications on remote hosts';
|
||||
$f = $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', false,
|
||||
XMLDB_NOTNULL,XMLDB_SEQUENCE, null, null, null);
|
||||
$f = $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '50', null,
|
||||
XMLDB_NOTNULL, NULL, null, null, null);
|
||||
$f = $table->addFieldInfo('display_name', XMLDB_TYPE_CHAR, '50', null,
|
||||
XMLDB_NOTNULL, NULL, null, null, null);
|
||||
$f = $table->addFieldInfo('xmlrpc_server_url', XMLDB_TYPE_CHAR, '255', null,
|
||||
XMLDB_NOTNULL, NULL, null, null, null);
|
||||
$f = $table->addFieldInfo('sso_land_url', XMLDB_TYPE_CHAR, '255', null,
|
||||
XMLDB_NOTNULL, NULL, null, null, null);
|
||||
|
||||
// PK and indexes
|
||||
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
// Create the table
|
||||
$result = $result && create_table($table);
|
||||
|
||||
$table = new XMLDBTable('mnet_host');
|
||||
$field = new XMLDBField('applicationid');
|
||||
$field->setAttributes(XMLDB_TYPE_INTEGER, '255', null, XMLDB_NOTNULL, null, null, null, '', 'xmlrpc_server_url');
|
||||
$result = $result && add_field($table, $field);
|
||||
|
||||
$application = new stdClass();
|
||||
$application->name = 'moodle';
|
||||
$application->display_name = 'Moodle';
|
||||
$application->xmlrpc_server_url = '/mnet/xmlrpc/server.php';
|
||||
$application->sso_land_url = '/auth/mnet/land.php';
|
||||
if ($result) {
|
||||
$newid = insert_record('mnet_application', $application, false);
|
||||
$result = set_field('mnet_host', 'applicationid', $newid);
|
||||
}
|
||||
|
||||
$application = new stdClass();
|
||||
$application->name = 'mahara';
|
||||
$application->display_name = 'Mahara';
|
||||
$application->xmlrpc_server_url = '/api/xmlrpc/server.php';
|
||||
$application->sso_land_url = '/auth/xmlrpc/land.php';
|
||||
$result = $result && insert_record('mnet_application', $application, false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
?>
|
||||
|
||||
+7
-3
@@ -45,7 +45,7 @@ function mnet_get_hostname_from_uri($uri = null) {
|
||||
* its http:// or https:// prefix
|
||||
* @return string A PEM formatted SSL Certificate.
|
||||
*/
|
||||
function mnet_get_public_key($uri) {
|
||||
function mnet_get_public_key($uri, $application=null) {
|
||||
global $CFG, $MNET;
|
||||
// The key may be cached in the mnet_set_public_key function...
|
||||
// check this first
|
||||
@@ -54,8 +54,12 @@ function mnet_get_public_key($uri) {
|
||||
return $key;
|
||||
}
|
||||
|
||||
$rq = xmlrpc_encode_request('system/keyswap', array($CFG->wwwroot, $MNET->public_key), array("encoding" => "utf-8"));
|
||||
$ch = curl_init($uri.'/mnet/xmlrpc/server.php');
|
||||
if (empty($application)) {
|
||||
$application = get_record('mnet_application', 'name', 'moodle');
|
||||
}
|
||||
|
||||
$rq = xmlrpc_encode_request('system/keyswap', array($CFG->wwwroot, $MNET->public_key, $application->name), array("encoding" => "utf-8"));
|
||||
$ch = curl_init($uri . $application->xmlrpc_server_url);
|
||||
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
+22
-2
@@ -18,6 +18,7 @@ class mnet_peer {
|
||||
var $public_key_expires = 0;
|
||||
var $last_connect_time = 0;
|
||||
var $last_log_id = 0;
|
||||
var $applicationid = 1; // Default of 1 == Moodle
|
||||
var $keypair = array();
|
||||
var $error = array();
|
||||
|
||||
@@ -25,7 +26,7 @@ class mnet_peer {
|
||||
return true;
|
||||
}
|
||||
|
||||
function bootstrap($wwwroot, $pubkey = null) {
|
||||
function bootstrap($wwwroot, $pubkey = null, $application) {
|
||||
|
||||
if (substr($wwwroot, -1, 1) == '/') {
|
||||
$wwwroot = substr($wwwroot, 0, -1);
|
||||
@@ -59,8 +60,16 @@ class mnet_peer {
|
||||
$this->wwwroot = $wwwroot;
|
||||
$this->ip_address = $ip_address;
|
||||
$this->deleted = 0;
|
||||
|
||||
$this->application = get_record('mnet_application', 'name', $application);
|
||||
if (empty($this->application)) {
|
||||
$this->application = get_record('mnet_application', 'name', 'moodle');
|
||||
}
|
||||
|
||||
$this->applicationid = $this->application->id;
|
||||
|
||||
if(empty($pubkey)) {
|
||||
$this->public_key = clean_param(mnet_get_public_key($this->wwwroot), PARAM_PEM);
|
||||
$this->public_key = clean_param(mnet_get_public_key($this->wwwroot, $this->application), PARAM_PEM);
|
||||
} else {
|
||||
$this->public_key = clean_param($pubkey, PARAM_PEM);
|
||||
}
|
||||
@@ -155,6 +164,7 @@ class mnet_peer {
|
||||
$obj->deleted = $this->deleted;
|
||||
$obj->last_connect_time = $this->last_connect_time;
|
||||
$obj->last_log_id = $this->last_log_id;
|
||||
$obj->applicationid = $this->applicationid;
|
||||
|
||||
if (isset($this->id) && $this->id > 0) {
|
||||
$obj->id = $this->id;
|
||||
@@ -178,6 +188,14 @@ class mnet_peer {
|
||||
return false;
|
||||
}
|
||||
|
||||
function set_applicationid($applicationid) {
|
||||
if (is_numeric($applicationid) && $applicationid == intval($applicationid)) {
|
||||
$this->applicationid = $applicationid;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function set_wwwroot($wwwroot) {
|
||||
global $CFG;
|
||||
|
||||
@@ -231,6 +249,8 @@ class mnet_peer {
|
||||
$this->public_key_expires = $hostinfo->public_key_expires;
|
||||
$this->last_connect_time = $hostinfo->last_connect_time;
|
||||
$this->last_log_id = $hostinfo->last_log_id;
|
||||
$this->applicationid = $hostinfo->applicationid;
|
||||
$this->application = get_record('mnet_application', 'id', $this->applicationid);
|
||||
}
|
||||
|
||||
function get_public_key() {
|
||||
|
||||
@@ -124,8 +124,7 @@ class mnet_xmlrpc_client {
|
||||
function send($mnet_peer) {
|
||||
global $CFG, $MNET;
|
||||
|
||||
$this->uri = $mnet_peer->wwwroot.
|
||||
'/mnet/xmlrpc/server.php';
|
||||
$this->uri = $mnet_peer->wwwroot.$mnet_peer->application->xmlrpc_server_url;
|
||||
|
||||
// Initialize with the target URL
|
||||
$ch = curl_init($this->uri);
|
||||
|
||||
+14
-7
@@ -21,6 +21,12 @@ require_once $CFG->dirroot.'/mnet/remote_client.php';
|
||||
// Content type for output is not html:
|
||||
header('Content-type: text/xml; charset=utf-8');
|
||||
|
||||
// PHP 5.2.2: $HTTP_RAW_POST_DATA not populated bug:
|
||||
// http://bugs.php.net/bug.php?id=41293
|
||||
if (empty($HTTP_RAW_POST_DATA)) {
|
||||
$HTTP_RAW_POST_DATA = file_get_contents('php://input');
|
||||
}
|
||||
|
||||
if (!empty($CFG->mnet_rpcdebug)) {
|
||||
trigger_error("HTTP_RAW_POST_DATA");
|
||||
trigger_error($HTTP_RAW_POST_DATA);
|
||||
@@ -205,7 +211,7 @@ function mnet_server_strip_wrappers($HTTP_RAW_POST_DATA) {
|
||||
$MNET_REMOTE_CLIENT->touch();
|
||||
// Parse the XML
|
||||
} elseif ($signature_verified == 0) {
|
||||
$currkey = mnet_get_public_key($MNET_REMOTE_CLIENT->wwwroot);
|
||||
$currkey = mnet_get_public_key($MNET_REMOTE_CLIENT->wwwroot, $MNET_REMOTE_CLIENT->application->xmlrpc_server_url);
|
||||
if($currkey != $certificate) {
|
||||
// Has the server updated its certificate since our last
|
||||
// handshake?
|
||||
@@ -270,11 +276,11 @@ function mnet_server_fault_xml($code, $text) {
|
||||
<member>
|
||||
<name>faultString</name>
|
||||
<value><string>'.$text.'</string></value>
|
||||
</member>
|
||||
</struct>
|
||||
</value>
|
||||
</fault>
|
||||
</methodResponse>');
|
||||
</member>
|
||||
</struct>
|
||||
</value>
|
||||
</fault>
|
||||
</methodResponse>');
|
||||
|
||||
if (!empty($CFG->mnet_rpcdebug)) {
|
||||
trigger_error("XMLRPC Error Response");
|
||||
@@ -727,7 +733,8 @@ function mnet_keyswap($function, $params) {
|
||||
|
||||
if (!empty($CFG->mnet_register_allhosts)) {
|
||||
$mnet_peer = new mnet_peer();
|
||||
$keyok = $mnet_peer->bootstrap($params[0], $params[1]);
|
||||
@list($wwwroot, $pubkey, $application) = each($params);
|
||||
$keyok = $mnet_peer->bootstrap($wwwroot, $pubkey, $application);
|
||||
if ($keyok) {
|
||||
$mnet_peer->commit();
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 923 B |
Binary file not shown.
|
After Width: | Height: | Size: 608 B |
+24
-3
@@ -178,9 +178,30 @@
|
||||
include('tabs.php');
|
||||
|
||||
if (is_mnet_remote_user($user)) {
|
||||
echo "<p class=\"errorboxcontent\">This profile is for a remote user from another Moodle system. <br />\n";
|
||||
$remotehost = get_record('mnet_host', 'id', $user->mnethostid);
|
||||
echo "Remote Moodle: <a href=\"{$remotehost->wwwroot}/user/edit.php\">{$remotehost->name}</a> (click here to edit your profile on the remote server) </p>\n";
|
||||
$sql = "
|
||||
SELECT DISTINCT
|
||||
h.id,
|
||||
h.name,
|
||||
a.name as application,
|
||||
a.display_name
|
||||
FROM
|
||||
{$CFG->prefix}mnet_host h,
|
||||
{$CFG->prefix}mnet_application a
|
||||
WHERE
|
||||
h.id = '{$user->mnethostid}' AND
|
||||
h.applicationid = a.id
|
||||
ORDER BY
|
||||
a.display_name,
|
||||
h.name";
|
||||
|
||||
$remotehost = get_record_sql($sql);
|
||||
|
||||
echo '<p class="errorboxcontent">'.get_string('remote'.$remotehost->application.'user')." <br />\n";
|
||||
if ($remotehost->application =='moodle') {
|
||||
echo "Remote {$remotehost->display_name}: <a href=\"{$remotehost->wwwroot}/user/edit.php\">{$remotehost->name}</a> ".get_string('editremoteprofile')." </p>\n";
|
||||
} else {
|
||||
echo "Remote {$remotehost->display_name}: <a href=\"{$remotehost->wwwroot}/\">{$remotehost->name}</a> ".get_string('gotoyourserver')." </p>\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo '<table width="80%" class="userinfobox" summary="">';
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
// This is compared against the values stored in the database to determine
|
||||
// whether upgrades should be performed (see lib/db/*.php)
|
||||
|
||||
$version = 2007071300; // YYYYMMDD = date
|
||||
$version = 2007071400; // YYYYMMDD = date
|
||||
// XY = increments within a single day
|
||||
|
||||
$release = '1.9 dev'; // Human-friendly version name
|
||||
|
||||
Reference in New Issue
Block a user