/** * Reads the install.xml files for Moodle core and modules and returns an array of * xmldb_structure object with xmldb_table from these files. * @return xmldb_structure schema from install.xml files */ public function get_install_xml_schema() { global $CFG; require_once $CFG->libdir . '/adminlib.php'; $schema = new xmldb_structure('export'); $schema->setVersion($CFG->version); $dbdirs = get_db_directories(); foreach ($dbdirs as $dbdir) { $xmldb_file = new xmldb_file($dbdir . '/install.xml'); if (!$xmldb_file->fileExists() or !$xmldb_file->loadXMLStructure()) { continue; } $structure = $xmldb_file->getStructure(); $tables = $structure->getTables(); foreach ($tables as $table) { $table->setPrevious(null); $table->setNext(null); $schema->addTable($table); } } return $schema; }