/** * Export module base and related tables * @access private */ function export_Tables($moduleInstance) { $_exportedTables = array(); $modulename = $moduleInstance->name; $this->openNode('tables'); if ($moduleInstance->isentitytype) { $focus = CRMEntity::getInstance($modulename); // Setup required module variables which is need for vtlib API's vtlib_setup_modulevars($modulename, $focus); $tables = array($focus->table_name); if (!empty($focus->groupTable)) { $tables[] = $focus->groupTable[0]; } if (!empty($focus->customFieldTable)) { $tables[] = $focus->customFieldTable[0]; } foreach ($tables as $table) { $this->openNode('table'); $this->outputNode($table, 'name'); $this->outputNode('<![CDATA[' . Vtiger_Utils::CreateTableSql($table) . ']]>', 'sql'); $this->closeNode('table'); $_exportedTables[] = $table; } } // Now export table information recorded in schema file if (file_exists("modules/{$modulename}/schema.xml")) { $schema = simplexml_load_file("modules/{$modulename}/schema.xml"); if (!empty($schema->tables) && !empty($schema->tables->table)) { foreach ($schema->tables->table as $tablenode) { $table = trim($tablenode->name); if (!in_array($table, $_exportedTables)) { $this->openNode('table'); $this->outputNode($table, 'name'); $this->outputNode('<![CDATA[' . Vtiger_Utils::CreateTableSql($table) . ']]>', 'sql'); $this->closeNode('table'); $_exportedTables[] = $table; } } } } $this->closeNode('tables'); }