diff --git a/admin/mnet/adminlib.php b/admin/mnet/adminlib.php index 399069997a1..2a6b7b94523 100644 --- a/admin/mnet/adminlib.php +++ b/admin/mnet/adminlib.php @@ -57,8 +57,8 @@ function upgrade_plugin_mnet_functions($component) { // Disable functions that don't exist (any more) in the source // Should these be deleted? What about their permissions records? - foreach ($DB->get_records('mnet_rpc', array('pluginname'=>$plugin, 'plugintype'=>$type), 'function_name ASC ') as $rpc) { - if (!array_key_exists($rpc->function_name, $methodservices)) { + foreach ($DB->get_records('mnet_rpc', array('pluginname'=>$plugin, 'plugintype'=>$type), 'functionname ASC ') as $rpc) { + if (!array_key_exists($rpc->functionname, $methodservices)) { $DB->set_field('mnet_rpc', 'enabled', 0, array('id' => $rpc->id)); } } @@ -77,57 +77,57 @@ function upgrade_plugin_mnet_functions($component) { $dataobject->filename = $f; if (is_string($method)) { - $dataobject->function_name = $method; + $dataobject->functionname = $method; } else if (is_array($method)) { // wants to override file or class - $dataobject->function_name = $method['method']; + $dataobject->functionname = $method['method']; $dataobject->classname = $method['classname']; $dataobject->filename = $method['filename']; } - $dataobject->xmlrpc_path = $type.'/'.$plugin.'/'.$dataobject->filename.'/'.$method; + $dataobject->xmlrpcpath = $type.'/'.$plugin.'/'.$dataobject->filename.'/'.$method; $dataobject->static = false; require_once($path . '/' . $dataobject->filename); $functionreflect = null; // slightly different ways to get this depending on whether it's a class method or a function if (!empty($dataobject->classname)) { if (!class_exists($dataobject->classname)) { - throw new moodle_exception('installnosuchmethod', 'mnet', '', (object)array('method' => $dataobject->function_name, 'class' => $dataobject->classname)); + throw new moodle_exception('installnosuchmethod', 'mnet', '', (object)array('method' => $dataobject->functionname, 'class' => $dataobject->classname)); } $key = $dataobject->filename . '|' . $dataobject->classname; if (!array_key_exists($key, $cachedclasses)) { // look to see if we've already got a reflection object try { $cachedclasses[$key] = Zend_Server_Reflection::reflectClass($dataobject->classname); } catch (Zend_Server_Reflection_Exception $e) { // catch these and rethrow them to something more helpful - throw new moodle_exception('installreflectionclasserror', 'mnet', '', (object)array('method' => $dataobject->function_name, 'class' => $dataobject->classname, 'error' => $e->getMessage())); + throw new moodle_exception('installreflectionclasserror', 'mnet', '', (object)array('method' => $dataobject->functionname, 'class' => $dataobject->classname, 'error' => $e->getMessage())); } } $r =& $cachedclasses[$key]; - if (!$r->hasMethod($dataobject->function_name)) { - throw new moodle_exception('installnosuchmethod', 'mnet', '', (object)array('method' => $dataobject->function_name, 'class' => $dataobject->classname)); + if (!$r->hasMethod($dataobject->functionname)) { + throw new moodle_exception('installnosuchmethod', 'mnet', '', (object)array('method' => $dataobject->functionname, 'class' => $dataobject->classname)); } // stupid workaround for zend not having a getMethod($name) function $ms = $r->getMethods(); foreach ($ms as $m) { - if ($m->getName() == $dataobject->function_name) { + if ($m->getName() == $dataobject->functionname) { $functionreflect = $m; break; } } $dataobject->static = (int)$functionreflect->isStatic(); } else { - if (!function_exists($dataobject->function_name)) { - throw new moodle_exception('installnosuchfunction', 'mnet', '', (object)array('method' => $dataobject->function_name, 'file' => $dataobject->filename)); + if (!function_exists($dataobject->functionname)) { + throw new moodle_exception('installnosuchfunction', 'mnet', '', (object)array('method' => $dataobject->functionname, 'file' => $dataobject->filename)); } try { - $functionreflect = Zend_Server_Reflection::reflectFunction($dataobject->function_name); + $functionreflect = Zend_Server_Reflection::reflectFunction($dataobject->functionname); } catch (Zend_Server_Reflection_Exception $e) { // catch these and rethrow them to something more helpful - throw new moodle_exception('installreflectionfunctionerror', 'mnet', '', (object)array('method' => $dataobject->function_name, '' => $dataobject->filename, 'error' => $e->getMessage())); + throw new moodle_exception('installreflectionfunctionerror', 'mnet', '', (object)array('method' => $dataobject->functionname, '' => $dataobject->filename, 'error' => $e->getMessage())); } } $dataobject->profile = serialize(admin_mnet_method_profile($functionreflect)); $dataobject->help = $functionreflect->getDescription(); - if ($record_exists = $DB->get_record('mnet_rpc', array('xmlrpc_path'=>$dataobject->xmlrpc_path))) { + if ($record_exists = $DB->get_record('mnet_rpc', array('xmlrpcpath'=>$dataobject->xmlrpcpath))) { $dataobject->id = $record_exists->id; $dataobject->enabled = $record_exists->enabled; $DB->update_record('mnet_rpc', $dataobject); @@ -136,7 +136,7 @@ function upgrade_plugin_mnet_functions($component) { } } - foreach ($methodservices[$dataobject->function_name] as $service) { + foreach ($methodservices[$dataobject->functionname] as $service) { if ($serviceobj = $DB->get_record('mnet_service', array('name'=>$service['servicename']))) { $serviceobj->apiversion = $service['apiversion']; $DB->update_record('mnet_service', $serviceobj); diff --git a/lib/db/install.xml b/lib/db/install.xml index 015872b8aed..6e21b656a31 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1,5 +1,5 @@ - @@ -1320,12 +1320,12 @@ - +
- - - - + + + + @@ -1338,10 +1338,20 @@ - +
- +
+ + + + + + + + +
+ @@ -1353,7 +1363,7 @@
- +
@@ -1366,7 +1376,20 @@
- +
+ + + + + + + + + + + +
+ @@ -2365,4 +2388,4 @@
-
\ No newline at end of file + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index c8576f7c8b3..a7a6faf1782 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -2903,6 +2903,64 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL"); upgrade_main_savepoint($result, 2010012600); } + if ($result && $oldversion < 2010012900) { + + /// Define table mnet_remote_rpc to be created + $table = new xmldb_table('mnet_remote_rpc'); + + /// Adding fields to table mnet_remote_rpc + $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); + $table->add_field('functionname', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, null, null); + $table->add_field('xmlrpcpath', XMLDB_TYPE_CHAR, '80', null, XMLDB_NOTNULL, null, null); + + /// Adding keys to table mnet_remote_rpc + $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + + /// Conditionally launch create table for mnet_remote_rpc + if (!$dbman->table_exists($table)) { + $dbman->create_table($table); + } + + + /// Define table mnet_remote_service2rpc to be created + $table = new xmldb_table('mnet_remote_service2rpc'); + + /// Adding fields to table mnet_remote_service2rpc + $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); + $table->add_field('serviceid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); + $table->add_field('rpcid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); + + /// Adding keys to table mnet_remote_service2rpc + $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + + /// Adding indexes to table mnet_remote_service2rpc + $table->add_index('rpcid_serviceid', XMLDB_INDEX_UNIQUE, array('rpcid', 'serviceid')); + + /// Conditionally launch create table for mnet_remote_service2rpc + if (!$dbman->table_exists($table)) { + $dbman->create_table($table); + } + + + /// Rename field function_name on table mnet_rpc to functionname + $table = new xmldb_table('mnet_rpc'); + $field = new xmldb_field('function_name', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, null, null, 'id'); + + /// Launch rename field function_name + $dbman->rename_field($table, $field, 'functionname'); + + + /// Rename field xmlrpc_path on table mnet_rpc to xmlrpcpath + $table = new xmldb_table('mnet_rpc'); + $field = new xmldb_field('xmlrpc_path', XMLDB_TYPE_CHAR, '80', null, XMLDB_NOTNULL, null, null, 'function_name'); + + /// Launch rename field xmlrpc_path + $dbman->rename_field($table, $field, 'xmlrpcpath'); + + + /// Main savepoint reached + upgrade_main_savepoint($result, 2010012900); + } return $result; } diff --git a/mnet/xmlrpc/client.php b/mnet/xmlrpc/client.php index 81918d0aaf8..14c6154b35c 100644 --- a/mnet/xmlrpc/client.php +++ b/mnet/xmlrpc/client.php @@ -318,7 +318,7 @@ class mnet_xmlrpc_client { {mnet_service2rpc} s2r, {mnet_host2service} h2s WHERE - r.xmlrpc_path = ? AND + r.xmlrpcpath = ? AND s2r.rpcid = r.id AND s2r.serviceid = h2s.serviceid AND h2s.subscribe = '1' AND diff --git a/mnet/xmlrpc/serverlib.php b/mnet/xmlrpc/serverlib.php index be0cef5194e..fb9c077f4b4 100644 --- a/mnet/xmlrpc/serverlib.php +++ b/mnet/xmlrpc/serverlib.php @@ -314,7 +314,7 @@ function mnet_server_dispatch($payload) { //////////////////////////////////// NORMAL PLUGIN DISPATCHER } else { // anything else comes from some sort of plugin - if ($rpcrecord = $DB->get_record('mnet_rpc', array('xmlrpc_path' => $method))) { + if ($rpcrecord = $DB->get_record('mnet_rpc', array('xmlrpcpath' => $method))) { $response = mnet_server_invoke_plugin_method($method, $callstack, $rpcrecord, $payload); $response = mnet_server_prepare_response($response); echo $response; @@ -366,8 +366,8 @@ function mnet_system($method, $params, $hostinfo) { if ('system.listMethods' == $method || 'system/listMethods' == $method) { $query = ' SELECT DISTINCT - rpc.function_name, - rpc.xmlrpc_path + rpc.functionname, + rpc.xmlrpcpath FROM {mnet_host2service} h2s JOIN {mnet_service2rpc} s2r ON h2s.serviceid = s2r.serviceid @@ -378,19 +378,19 @@ function mnet_system($method, $params, $hostinfo) { h2s.publish = 1 AND rpc.enabled = 1 ' . ((count($params) > 0) ? 'AND svc.name = ? ' : '') . ' ORDER BY - rpc.xmlrpc_path ASC'; + rpc.xmlrpcpath ASC'; if (count($params) > 0) { $params = array($params[0]); } $methods = array(); foreach ($DB->get_records_sql($query, $params) as $result) { - $methods[] = $result->xmlrpc_path; + $methods[] = $result->xmlrpcpath; } return $methods; } elseif (in_array($method, array('system.methodSignature', 'system/methodSignature', 'system.methodHelp', 'system/methodHelp'))) { $query = ' SELECT DISTINCT - rpc.function_name, + rpc.functionname, rpc.help, rpc.profile FROM @@ -398,7 +398,7 @@ function mnet_system($method, $params, $hostinfo) { {mnet_service2rpc} s2r, {mnet_rpc} rpc WHERE - rpc.xmlrpc_path = ? AND + rpc.xmlrpcpath = ? AND s2r.rpcid = rpc.id AND h2s.publish = 1 AND rpc.enabled = 1 AND h2s.serviceid = s2r.serviceid AND @@ -605,12 +605,12 @@ function mnet_setup_dummy_method($method, $callstack, $rpcrecord) { } catch (Exception $e) { throw new mnet_server_exception(709, "classerror"); } - if (!is_callable(array($object, $rpcrecord->function_name))) { + if (!is_callable(array($object, $rpcrecord->functionname))) { throw new mnet_server_exception(706, "nosuchfunction"); } $MNET_REMOTE_CLIENT->object_to_call($object); } else { - if (!is_callable(array($rpcrecord->classname, $rpcrecord->function_name))) { + if (!is_callable(array($rpcrecord->classname, $rpcrecord->functionname))) { throw new mnet_server_exception(706, "nosuchfunction"); } $MNET_REMOTE_CLIENT->static_location($rpcrecord->classname); diff --git a/version.php b/version.php index 91fd9f6735a..2cf23187678 100644 --- a/version.php +++ b/version.php @@ -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 = 2010012600; // YYYYMMDD = date of the last version bump + $version = 2010012900; // YYYYMMDD = date of the last version bump // XX = daily increments $release = '2.0 dev (Build: 20100128)'; // Human-friendly version name