if (function_exists($mnet_publishes)) {
(array)$publishes = $mnet_publishes();
}
+ } else if ('portfolio' == $type) {
+ $docname = 'lib.php';
+ $relname = '/portfolio/type/' . $parentname . '/'. $docname;
+ $filename = $CFG->dirroot . $relname;
+ require_once($CFG->libdir . '/portfoliolib.php');
+ $publishes = (array)portfolio_static_function($parentname, 'mnet_publishes');
} else {
// auth or enrol
$relname = '/'.$type.'/'.$parentname.'/'.$docname;
mnet_get_functions('enrol', $dir);
}
}
+
+ if ($plugins = get_list_of_plugins('portfolio/type')) {
+ foreach ($plugins as $p) {
+ mnet_get_functions('portfolio', $p);
+ }
+ }
}
?>
echo $breakstring;
?>
<input type="hidden" name="exists[<?php echo $version['serviceid']; ?>]" value="1" />
+<?php if ($name == 'pf_out') { // see MDL-16269 ?>
+ <input type="hidden" name="publish[<?php echo $version['serviceid']; ?>]" value="0" />
+<?php } else { ?>
<input type="checkbox" name="publish[<?php echo $version['serviceid']; ?>]" <?php echo (!empty($version['I_publish']))? 'checked="checked" ': '' ; ?>/>
<?php
print_string('publish','mnet');
print_string("enabled_for_all",'mnet',!empty($version['I_publish']));
}
echo '<br />';
-?>
+} ?>
<input type="checkbox" name="subscribe[<?php echo $version['serviceid']; ?>]" <?php echo (!empty($version['I_subscribe']))? 'checked="checked" ': '' ; ?>/>
<?php
print_string('subscribe','mnet');
}
}
+ if ($plugins = get_list_of_plugins('portfolio/type', 'db')) {
+ foreach ($plugins as $plugin) {
+ $dbdirs[] = $CFG->dirroot . '/portfolio/type/' . $plugin . '/db';
+ }
+ }
+
/// Local database changes, if the local folder exists.
if (file_exists($CFG->dirroot . '/local')) {
$dbdirs[] = $CFG->dirroot.'/local/db';
return RPC_NOSUCHCLASS;
}
- $object = new $class();
+ $object = false;
+ $static = false;
+
+ try {
+ // @todo set here whatever we can to ensure that errors cause exceptions :(
+ // see MDL-16175 - long term solution is teaching the dispatcher about:
+ // a: the difference between static and class methods
+ // b: object constructor arguments
+ $object = @new $class();
+ if (!method_exists($object, $functionname)) {
+ // Generate error response - unable to locate method
+ return RPC_NOSUCHMETHOD;
+ }
- if (!method_exists($object, $functionname)) {
- // Generate error response - unable to locate method
- return RPC_NOSUCHMETHOD;
- }
+ if (!method_exists($object, 'mnet_publishes')) {
+ // Generate error response - the class doesn't publish
+ // *any* methods, because it doesn't have an mnet_publishes
+ // method
+ return RPC_FORBIDDENMETHOD;
+ }
- if (!method_exists($object, 'mnet_publishes')) {
- // Generate error response - the class doesn't publish
- // *any* methods, because it doesn't have an mnet_publishes
- // method
- return RPC_FORBIDDENMETHOD;
+ // Get the list of published services - initialise method array
+ $servicelist = $object->mnet_publishes();
+ }
+ catch (Exception $e) {
+ if (method_exists($class, $functionname)) {
+ // static... don't try to instantiate it.
+ if (!method_exists($class, 'mnet_publishes')) {
+ return RPC_FORBIDDENMETHOD;
+ } else {
+ $servicelist = call_user_func(array($class, 'mnet_publishes'));
+ }
+ $static = $class;
+ }
}
- // Get the list of published services - initialise method array
- $servicelist = $object->mnet_publishes();
$methodapproved = false;
// If the method is in the list of approved methods, set the
// Stash the object so we can call the method on it later
$MNET_REMOTE_CLIENT->object_to_call($object);
+ $MNET_REMOTE_CLIENT->static_location($static);
+
// WE'RE LOOKING AT A FUNCTION
} else {
if (!function_exists($functionname)) {
// If the remote client is trying to execute a method on an object instead
// of just a function, we'll instantiate the proper class and store it in
- // this 'object_to_call' property.
+ // this 'object_to_call' property, or 'static_location' if it wants to be called statically
var $object_to_call = false;
+ var $static_location = false;
var $request_was_encrypted = false;
var $request_was_signed = false;
$this->object_to_call = $object;
}
+ function static_location($location) {
+ $this->static_location = $location;
+ }
+
function plaintext_is_ok() {
global $CFG;
function mnet_server_dummy_method($methodname, $argsarray, $functionname) {
global $MNET_REMOTE_CLIENT;
- if (!is_object($MNET_REMOTE_CLIENT->object_to_call)) {
- return @call_user_func_array($functionname, $argsarray);
- } else {
+ if (is_object($MNET_REMOTE_CLIENT->object_to_call)) {
return @call_user_method_array($functionname, $MNET_REMOTE_CLIENT->object_to_call, $argsarray);
+ } else if (!empty($MNET_REMOTE_CLIENT->static_location)) {
+ return @call_user_func_array(array($MNET_REMOTE_CLIENT->static_location, $functionname), $argsarray);
+ } else {
+ return @call_user_func_array($functionname, $argsarray);
}
}
exit(mnet_server_fault(703, 'nosuchfunction'));
}
+ } else if ($callstack[0] == 'portfolio') {
+ // Break out the callstack into its elements
+ list($base, $plugin, $filename, $methodname) = $callstack;
+
+ if ($filename == 'lib.php') {
+ $pluginclass = 'portfolio_plugin_' . $plugin;
+ $includefile = '/portfolio/type/'.$plugin.'/lib.php';
+ $response = mnet_server_invoke_method($includefile, $methodname, $method, $payload, $pluginclass);
+ $response = mnet_server_prepare_response($response);
+ echo $response;
+ } else {
+ // Generate error response - unable to locate function
+ exit(mnet_server_fault(7012, 'nosuchfunction'));
+ }
+
////////////////////////////////////// STRICT MOD/*
} elseif ($callstack[0] == 'mod' || 'dangerous' == $CFG->mnet_dispatcher_mode) {
list($base, $module, $filename, $functionname) = $callstack;