dirroot.'/mnet/xmlrpc/client.php'; // Site admins only, thanks. $context = get_context_instance(CONTEXT_SYSTEM); require_capability('moodle/site:config', $context); error_reporting(E_ALL); // Some HTML sugar echo ''; ?> Moodle MNET Test Client

Hosts

$host) { // Skip the 'all hosts' option if(empty($host->wwwroot)) continue; // Skip localhost if($host->wwwroot == $CFG->wwwroot) continue; // Skip non-moodle hosts if($host->applicationid != 1 && $host->applicationid != 2) continue; //TODO: get rid of magic numbers. echo '

'.$host->wwwroot."

\n"; } if (!empty($_GET['hostid']) && array_key_exists($_GET['hostid'], $hosts)) { $host = $hosts[$_GET['hostid']]; $mnet_peer = new mnet_peer(); $mnet_peer->set_wwwroot($host->wwwroot); $mnet_request = new mnet_xmlrpc_client(); // Tell it the path to the method that we want to execute $mnet_request->set_method('system/listServices'); $mnet_request->send($mnet_peer); $services = $mnet_request->response; $yesno = array('No', 'Yes'); $servicenames = array(); echo '

Services available on host: '.$host->wwwroot .'

'; foreach ($services as $id => $service) { $sql = 'select c.id, c.parent_type, c.parent from '.$CFG->prefix.'mnet_service2rpc a,'.$CFG->prefix.'mnet_service b, '.$CFG->prefix.'mnet_rpc c where a.serviceid = b.id and b.name=\''.addslashes($service['name']).'\' and c.id = a.rpcid '; echo ''; if ($detail = get_record_sql($sql)) { $service['humanname'] = get_string($service['name'].'_name', $detail->parent_type.'_'.$detail->parent); echo ''; } else { $service['humanname'] = $service['name']; echo ''; } echo ' '."\n"; $servicenames[$service['name']] = $service; } echo '
  Service ID    Service    Version    They Publish    They Subscribe  
'.$service['name'].''.$service['humanname'].' unknown '.$service['apiversion'].' '.$yesno[$service['publish']].' '.$yesno[$service['subscribe']].' List methods
'; if (isset($_GET['service']) && array_key_exists($_GET['service'], $servicenames)) { $service = $servicenames[$_GET['service']]; // Tell it the path to the method that we want to execute $mnet_request->set_method('system/listMethods'); $mnet_request->add_param($service['name'], 'string'); $mnet_request->send($mnet_peer); $methods = $mnet_request->response; echo '

Methods in the '.$service['humanname'] .' service

'; foreach ($methods as $id => $method) { echo ''."\n"; } echo '
MethodOptions
'.$method.' Inspect
'; } else { // Tell it the path to the method that we want to execute $mnet_request->set_method('system/listMethods'); $mnet_request->send($mnet_peer); $methods = $mnet_request->response; echo '

Methods '.$host->wwwroot .'

'; foreach ($methods as $id => $method) { echo ''."\n"; } echo '
MethodOptions
'.$method.' Inspect
'; } if (isset($_GET['method']) && array_key_exists($_GET['method'], $methods)) { $method = $methods[$_GET['method']]; $mnet_request = new mnet_xmlrpc_client(); // Tell it the path to the method that we want to execute $mnet_request->set_method('system/methodSignature'); $mnet_request->add_param($method, 'string'); $mnet_request->send($mnet_peer); $signature = $mnet_request->response; echo '

Method signature for '.$method.':

'; $params = array_pop($signature); foreach ($params as $pos => $details) { echo ''; } echo '
PositionTypeDescription
'.$pos.''.$details['type'].''.$details['description'].'
'; // Tell it the path to the method that we want to execute $mnet_request->set_method('system/methodHelp'); $mnet_request->add_param($method, 'string'); $mnet_request->send($mnet_peer); $help = $mnet_request->response; echo '

Help details from docblock for '.$method.':

'; echo(str_replace('\n', '
',$help)); echo ''; } } ?>