Skip to content

Commit

Permalink
mnet MDL-21261 mnet overhaul - adding and removing files I missed in …
Browse files Browse the repository at this point in the history
…the last big commit
  • Loading branch information
Penny Leach committed Jan 28, 2010
1 parent 64d187a commit d2ac37c
Show file tree
Hide file tree
Showing 9 changed files with 1,044 additions and 222 deletions.
195 changes: 195 additions & 0 deletions admin/mnet/testclient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
<?php
/**
* A service browser for remote Moodles
*
* This script 'remotely' executes the reflection methods on a remote Moodle,
* and publishes the details of the available services
*
* @author Donal McMullan donal@catalyst.net.nz
* @version 0.0.1
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package mnet
*/
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
require_once $CFG->dirroot.'/mnet/xmlrpc/client.php';
require_once($CFG->libdir.'/adminlib.php');
include_once($CFG->dirroot.'/mnet/lib.php');

if ($CFG->mnet_dispatcher_mode === 'off') {
print_error('mnetdisabled', 'mnet');
}

require_login();
admin_externalpage_setup('mnettestclient');

$context = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/site:config', $context);

error_reporting(E_ALL);

admin_externalpage_print_header();
if (!extension_loaded('openssl')) {
print_error('requiresopenssl', 'mnet', '', NULL, true);
}

// optional drilling down parameters
$hostid = optional_param('hostid', 0, PARAM_INT);
$servicename = optional_param('servicename', '', PARAM_SAFEDIR);
$methodid = optional_param('method', 0, PARAM_INT);

$hosts = $DB->get_records('mnet_host');
$moodleapplicationid = $DB->get_field('mnet_application', 'id', array('name' => 'moodle'));

$url = new moodle_url('/admin/mnet/testclient.php');
$PAGE->set_url($url);

echo $OUTPUT->heading(get_string('hostlist', 'mnet'));
foreach ($hosts as $id => $host) {
if (empty($host->wwwroot) || $host->wwwroot == $CFG->wwwroot) {
continue;
}
$newurl = new moodle_url($url, array('hostid' => $host->id));
echo '<p>' . $OUTPUT->link($newurl, $host->wwwroot) . '</p>';
}

if (!empty($hostid) && array_key_exists($hostid, $hosts)) {
$host = $hosts[$hostid];
if ($host->applicationid != $moodleapplicationid) {
echo $OUTPUT->notification(get_string('notmoodleapplication', 'mnet'));
}
$mnet_peer = new mnet_peer();
$mnet_peer->set_wwwroot($host->wwwroot);

$mnet_request = new mnet_xmlrpc_client();

$mnet_request->set_method('system/listServices');
$mnet_request->send($mnet_peer);
$services = $mnet_request->response;
$yesno = array('No', 'Yes');
$servicenames = array();

echo $OUTPUT->heading(get_string('servicesavailableonhost', 'mnet', $host->wwwroot));

$table = new html_table();
$table->head = array(
get_string('serviceid', 'mnet'),
get_string('service', 'mnet'),
get_string('version', 'mnet'),
get_string('theypublish', 'mnet'),
get_string('theysubscribe', 'mnet'),
get_string('options', 'mnet'),
);
$table->data = array();
$sql = 'SELECT s.name, min(r.plugintype) AS plugintype, min(r.pluginname) AS pluginname
FROM {mnet_service} s
JOIN {mnet_service2rpc} s2r ON s2r.serviceid = s.id
JOIN {mnet_rpc} r ON r.id = s2r.rpcid
GROUP BY s.name';

$yesno = array(get_string('no'), get_string('yes'));

$serviceinfo = $DB->get_records_sql($sql);
foreach ($services as $id => $servicedata) {
if (array_key_exists($servicedata['name'], $serviceinfo)) {
$service = $serviceinfo[$servicedata['name']];
$servicedata['humanname'] = get_string($servicedata['name'].'_name', $service->plugintype . '_' . $service->pluginname);
} else {
$servicedata['humanname'] = get_string('unknown', 'mnet');
}
$newurl = new moodle_url($url, array('hostid' => $host->id, 'servicename' => $servicedata['name']));
$table->data[] = array(
$servicedata['name'],
$servicedata['humanname'],
$servicedata['apiversion'],
$yesno[$servicedata['publish']],
$yesno[$servicedata['subscribe']],
$OUTPUT->link($newurl, get_string('listservices', 'mnet'))
);

}
echo $OUTPUT->table($table);


$mnet_request->set_method('system/listMethods');
if (isset($servicename) && array_key_exists($servicename, $serviceinfo)) {
echo $OUTPUT->heading(get_string('methodsavailableonhostinservice', 'mnet', array('host' => $host->wwwroot, 'service' => $servicename)));
$service = $serviceinfo[$servicename];
$mnet_request->add_param($servicename, 'string');
} else {
echo $OUTPUT->heading(get_string('methodsavailableonhost', 'mnet', $host->wwwroot));
}

$mnet_request->send($mnet_peer);
$methods = $mnet_request->response;


$table = new html_table();
$table->head = array(
get_string('method', 'mnet'),
get_string('options', 'mnet'),
);
$table->data = array();

foreach ($methods as $id => $method) {
$params = array('hostid' => $host->id, 'method' => $id);
if (isset($servicename)) {
$params['servicename'] = $servicename;
}
$newurl = new moodle_url($url, $params);
$table->data[] = array(
$method,
$OUTPUT->link($newurl, get_string('inspect', 'mnet'))
);
}
echo $OUTPUT->table($table);

if (isset($methodid) && array_key_exists($methodid, $methods)) {
$method = $methods[$methodid];

$mnet_request = new mnet_xmlrpc_client();
$mnet_request->set_method('system/methodSignature');
$mnet_request->add_param($method, 'string');
$mnet_request->send($mnet_peer);
$signature = $mnet_request->response;

echo $OUTPUT->heading(get_string('methodsignature', 'mnet', $method));

$table = new html_table();
$table->head = array(
get_string('position', 'mnet'),
get_string('name', 'mnet'),
get_string('type', 'mnet'),
get_string('description', 'mnet'),
);
$table->data = array();

$params = $signature['parameters'];
foreach ($params as $pos => $details) {
$table->data[] = array(
$pos,
$details['name'],
$details['type'],
$details['description'],
);
}
$table->data[] = array(
get_string('returnvalue', 'mnet'),
'',
$signature['return']['type'],
$signature['return']['description']
);

echo $OUTPUT->table($table);

$mnet_request->set_method('system/methodHelp');
$mnet_request->add_param($method, 'string');
$mnet_request->send($mnet_peer);
$help = $mnet_request->response;

echo $OUTPUT->heading(get_string('methodhelp', 'mnet', $method));
echo(str_replace('\n', '<br />',$help));
}
}

echo $OUTPUT->footer();
?>
52 changes: 52 additions & 0 deletions auth/mnet/db/mnet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.


/**
* This file contains the mnet services for the mnet authentication plugin
*
* @since 2.0
* @package moodlecore
* @subpackage auth
* @copyright 2010 Penny Leach
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$publishes = array(
'sso_idp' => array(
'apiversion' => 1,
'classname' => 'auth_plugin_mnet',
'filename' => 'auth.php',
'methods' => array(
'user_authorise',
'keepalive_server',
'kill_children',
'refresh_log',
'fetch_user_image',
'fetch_theme_info',
'update_enrolments',
),
),
'sso_sp' => array(
'apiversion' => 1,
'classname' => 'auth_plugin_mnet',
'filename' => 'auth.php',
'methods' => array(
'keepalive_client',
'kill_child'
)
)
);
41 changes: 41 additions & 0 deletions enrol/mnet/db/mnet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.


/**
* This file contains the mnet services for the mnet enrolment plugin
*
* @since 2.0
* @package moodlecore
* @subpackage enrolment
* @copyright 2010 Penny Leach
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$publishes = array(
'mnet_enrol' => array(
'apiversion' => 1,
'classname' => 'enrolment_plugin_mnet',
'filename' => 'enrol.php',
'methods' => array(
'available_courses',
'user_enrolments',
'enrol_user',
'unenrol_user',
'course_enrolments'
),
),
);
3 changes: 3 additions & 0 deletions enrol/mnet/version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

$plugin->version = 2010012600;
78 changes: 0 additions & 78 deletions mnet/rpclib.php

This file was deleted.

Loading

0 comments on commit d2ac37c

Please sign in to comment.