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

0 comments on commit 3b8d8e1

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