Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-31527 XMLDB Editor - make sure default tables are created with co…

…rrect plugin prefix
  • Loading branch information...
commit 1cdadf514074166a9877daab28fcf20c393fe1db 1 parent baa5cd8
Davo Smith authored February 07, 2012
22  admin/tool/xmldb/actions/create_xml_file/create_xml_file.class.php
@@ -68,6 +68,7 @@ function invoke() {
68 68
 
69 69
         // Get the dir containing the file
70 70
         $dirpath = required_param('dir', PARAM_PATH);
  71
+        $plugintype = $this->get_plugin_type($dirpath);
71 72
         $dirpath = $CFG->dirroot . $dirpath;
72 73
         $file = $dirpath . '/install.xml';
73 74
 
@@ -77,6 +78,9 @@ function invoke() {
77 78
         $xmlcomment = 'XMLDB file for Moodle ' . dirname($xmlpath);
78 79
 
79 80
         $xmltable = strtolower(basename(dirname($xmlpath)));
  81
+        if ($plugintype && $plugintype != 'mod') {
  82
+            $xmltable = $plugintype.'_'.$xmltable;
  83
+        }
80 84
 
81 85
         // Initial contents
82 86
         $c = '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
@@ -106,5 +110,23 @@ function invoke() {
106 110
         // Return ok if arrived here
107 111
         return $result;
108 112
     }
  113
+
  114
+    /**
  115
+     * From a given path, work out what type of plugin
  116
+     * this belongs to
  117
+     * @param string $dirpath Path to the db file for this plugin
  118
+     * @return string the type of the plugin or null if not found
  119
+     */
  120
+    function get_plugin_type($dirpath) {
  121
+        global $CFG;
  122
+        $dirpath = $CFG->dirroot.$dirpath;
  123
+        $plugintypes = get_plugin_types();
  124
+        foreach ($plugintypes as $plugintype => $pluginbasedir) {
  125
+            if (substr($dirpath, 0, strlen($pluginbasedir)) == $pluginbasedir) {
  126
+                return $plugintype;
  127
+            }
  128
+        }
  129
+        return null;
  130
+    }
109 131
 }
110 132
 

0 notes on commit 1cdadf5

Please sign in to comment.
Something went wrong with that request. Please try again.