]> git.mjollnir.org Git - moodle.git/commitdiff
Merged Donal's changes to MNET to allow moodle to also network with mahara.
authormjollnir_ <mjollnir_>
Sat, 14 Jul 2007 03:00:12 +0000 (03:00 +0000)
committermjollnir_ <mjollnir_>
Sat, 14 Jul 2007 03:00:12 +0000 (03:00 +0000)
    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

17 files changed:
admin/mnet/mnet_review.html
admin/mnet/mnet_services.html
admin/mnet/peers.html
admin/mnet/peers.php
auth/mnet/auth.php
auth/mnet/jump.php
blocks/mnet_hosts/block_mnet_hosts.php
lib/db/install.xml
lib/db/upgrade.php
mnet/lib.php
mnet/peer.php
mnet/xmlrpc/client.php
mnet/xmlrpc/server.php
pix/i/mahara_host.gif [new file with mode: 0644]
pix/i/moodle_host.gif [new file with mode: 0644]
user/view.php
version.php

index 88392f3d95d3bb8f89cc638fb013981d9b7e23a1..8f43791cdf07febbd33cacf095839b4addd47849 100644 (file)
@@ -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&amp;hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
     $tabs[] = new tabobject('mnetservices', 'mnet_services.php?step=list&amp;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);
 }
 ?>
index 10c99e69a69423a9b0de21fa83211a4ba4a0ffe8..e020aae589f421f7f54ef66f93fa2f80f8d5254d 100644 (file)
@@ -9,7 +9,9 @@ $logurl = $CFG->wwwroot.
 
 $tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&amp;hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false);
 $tabs[] = new tabobject('mnetservices', 'mnet_services.php?step=list&amp;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", "");
 
index 138be56b187042ffef7ddf8aed4dd9cc8b90cc50..1f48fb7abd10f9c3e9529149ce13f50e7e4d1143 100644 (file)
@@ -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>
index b6e8cdd213e89903a12f9dc1d1141ecd49b4f7ce..2fdf215dcfd01c7d1a02142135440062fb4820dd 100644 (file)
@@ -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');
 }
 ?>
index 30fa1c71e807f002407e8938ccb233cd363dfb76..c01e46ab672502cd29ea544320c984a80cb99faf 100644 (file)
@@ -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']);
index 0dcc271c63e864551da4714f8fcb87c3c4e199c9..f05d7152fdd84107ab3e8eb98c001f6e221ab4a2 100644 (file)
@@ -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');
index cb628b39a0942a251254bfa5f885602e26ab203f..6ddf1e601e705a58c7bc41db1b8e978e234ca813 100644 (file)
@@ -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>";
+                }
             }
         }
 
index 9e1bc9c9e5fb7ffbd8ac4df56b0d14f2375b1e56..44aeb4e19177a204e74f19ba5283ec52aa99cd69 100644 (file)
         <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"/>
         <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,&quot; &quot;,lastname)')" />
         <SENTENCE TEXT="(module, action, mtable, field) VALUES ('course', 'user report', 'user', 'CONCAT(firstname,&quot; &quot;,lastname)')" />
index 037674748a6de68e0e335d64034d8dff0a9867b7..b2a53a4d60cf27f8789dde0822891e5eb310360a 100644 (file)
@@ -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;
 }
 ?>
index 9b73d88b07fb8bfa2cba3cdadc3a609522d696a1..ef714e49d1d5fe27854b5dd05c5b27ab5fc65aad 100644 (file)
@@ -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);
index 3058116e89367aaa9dbcd2b01c8356f38d15a976..da09ed03457386a94c2396dbcdf22e4d2ff72e3b 100644 (file)
@@ -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() {
index deef29fa848e04e5e8c85f2e95da227de03d0edd..98f1831c11b6660acae7192b753c2eeca32b990a 100644 (file)
@@ -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);
index 0f6bb7187ece5ffeb848f6b243156ba8b0e9111c..630ec789f93c107feea0aabb51c10afbc1971c56 100644 (file)
@@ -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();
         }
diff --git a/pix/i/mahara_host.gif b/pix/i/mahara_host.gif
new file mode 100644 (file)
index 0000000..25711e4
Binary files /dev/null and b/pix/i/mahara_host.gif differ
diff --git a/pix/i/moodle_host.gif b/pix/i/moodle_host.gif
new file mode 100644 (file)
index 0000000..a6eb2c3
Binary files /dev/null and b/pix/i/moodle_host.gif differ
index a6e01d6ddf3874ba8ce958301dd855317a307c8f..86836ee4e3ed18a8a0655121b3e825e7f9250f26 100644 (file)
     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="">';
index 6c6224fa08f5ddd19377b1877ed7ec689af47312..c7446091d466e9a003d3d99061db1b6baeb3d5bc 100644 (file)
@@ -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