diff --git a/admin/mnet/adminlib.php b/admin/mnet/adminlib.php
index e4da39e..9ab7cf2 100644
--- a/admin/mnet/adminlib.php
+++ b/admin/mnet/adminlib.php
@@ -16,28 +16,28 @@
  * type/parentname/docname
  *
  * @param  string   $type           mod, auth or enrol
+ * @param  string   $dir            path to $parentname
  * @param  string   $parentname     Implementation of type, e.g. 'mnet' in the
  *                                  case of auth/mnet/auth.php
  * @return bool                     True on success, else false
  */
-function mnet_get_functions($type, $parentname) {
+function mnet_get_functions($type, $dir, $parentname) {
     global $CFG;
     $dataobject = new stdClass();
-    $docname = $type.'.php';
     $publishes = array();
-    if ('mod' == $type) {
+    $filename = $CFG->dirroot.'/'.$dir.'/'.$parentname;
+    if ($type == 'mod') {
         $docname = 'rpclib.php';
-        $relname  = '/mod/'.$parentname.'/'.$docname;
-        $filename = $CFG->dirroot.$relname;
+        $filename .= '/'.$docname;
         if (file_exists($filename)) include_once $filename;
-        $mnet_publishes = $parentname.'_mnet_publishes';
+        $prefix = str_replace('/', '_', substr($dir.'/', strlen('mod/')));
+        $mnet_publishes = $prefix.$parentname.'_mnet_publishes';
         if (function_exists($mnet_publishes)) {
             (array)$publishes = $mnet_publishes();
         }
-    } else {
-        // auth or enrol
-        $relname  = '/'.$type.'/'.$parentname.'/'.$docname;
-        $filename = $CFG->dirroot.$relname;
+    } else {  // auth || enrol
+        $docname = $type.'.php';
+        $filename .= '/'.$docname;
         if (file_exists($filename)) include_once $filename;
         $class = $type.($type=='enrol'? 'ment':'').'_plugin_'.$parentname;
         if (class_exists($class)) {
@@ -93,7 +93,7 @@ function mnet_get_functions($type, $parentname) {
         }
 
         $dataobject->function_name = $method;
-        $dataobject->xmlrpc_path   = $type.'/'.$parentname.'/'.$docname.'/'.$method;
+        $dataobject->xmlrpc_path   = $dir.'/'.$parentname.'/'.$docname.'/'.$method;
         $dataobject->parent_type   = $type;
         $dataobject->parent        = $parentname;
         $dataobject->enabled       = '0';
@@ -130,52 +130,30 @@ function mnet_get_functions($type, $parentname) {
 function upgrade_RPC_functions($returnurl) {
     global $CFG;
 
-    $basedir = $CFG->dirroot.'/mod';
-    if (file_exists($basedir) && filetype($basedir) == 'dir') {
-        $dirhandle = opendir($basedir);
-        while (false !== ($dir = readdir($dirhandle))) {
-            $firstchar = substr($dir, 0, 1);
-            if ($firstchar == '.' or $dir == 'CVS' or $dir == '_vti_cnf') {
-                continue;
+    $pathlist = array(
+        array('type' => 'mod', 'path' => 'mod'),
+        array('type' => 'mod', 'path' => 'mod/resource/type'),
+        array('type' => 'mod', 'path' => 'mod/assignment/type'),
+        array('type' => 'auth', 'path' => 'auth'),
+        array('type' => 'enrol', 'path' => 'enrol'),
+    );
+
+    foreach ($pathlist as $p) {
+        $basedir = $CFG->dirroot.'/'.$p['path'];
+
+        if (file_exists($basedir) && filetype($basedir) == 'dir') {
+            $dirhandle = opendir($basedir);
+            while (false !== ($dir = readdir($dirhandle))) {
+                $firstchar = substr($dir, 0, 1);
+                if ($firstchar == '.' or $dir == 'CVS' or $dir == '_vti_cnf') {
+                    continue;
+                }
+                if (filetype($basedir .'/'. $dir) != 'dir') {
+                    continue;
+                }
+
+                mnet_get_functions($p['type'], $p['path'], $dir);
             }
-            if (filetype($basedir .'/'. $dir) != 'dir') {
-                continue;
-            }
-
-            mnet_get_functions('mod', $dir);
-
-        }
-    }
-
-    $basedir = $CFG->dirroot.'/auth';
-    if (file_exists($basedir) && filetype($basedir) == 'dir') {
-        $dirhandle = opendir($basedir);
-        while (false !== ($dir = readdir($dirhandle))) {
-            $firstchar = substr($dir, 0, 1);
-            if ($firstchar == '.' or $dir == 'CVS' or $dir == '_vti_cnf') {
-                continue;
-            }
-            if (filetype($basedir .'/'. $dir) != 'dir') {
-                continue;
-            }
-
-            mnet_get_functions('auth', $dir);
-        }
-    }
-
-    $basedir = $CFG->dirroot.'/enrol';
-    if (file_exists($basedir) && filetype($basedir) == 'dir') {
-        $dirhandle = opendir($basedir);
-        while (false !== ($dir = readdir($dirhandle))) {
-            $firstchar = substr($dir, 0, 1);
-            if ($firstchar == '.' or $dir == 'CVS' or $dir == '_vti_cnf') {
-                continue;
-            }
-            if (filetype($basedir .'/'. $dir) != 'dir') {
-                continue;
-            }
-
-            mnet_get_functions('enrol', $dir);
         }
     }
 }
