XPressME Integration Kit

Trac


Ignore:
Timestamp:
Apr 21, 2009, 12:51:44 PM (15 years ago)
Author:
toemon
Message:

#111 XPressMEモジュールをアンインストールしても、プラグインが作成したデータベーステーブルが残ってしまうバグ修正
xoops_version.php から $modversiontables?の記述を外し
onuninstall でdb_prefixからテーブルを見つけてDROPするようにした。
またxoops_version.php から $modversiontables?の記述を外したことにより、wordpressのテーブル構成が変わっても気にしないですむようになった。
但しXOOPSのモジュールインフォメーションにはSQLテーブルの情報がでない

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/onuninstall.php

    r1 r188  
    2424        $db =& Database::getInstance() ; 
    2525        $mid = $module->getVar('mid') ; 
    26 /* 
    27         // TABLES (loading mysql.sql) 
    28         $sql_file_path = dirname(__FILE__).'/sql/mysql.sql' ; 
    29         $prefix_mod = $db->prefix() . '_' . $mydirname ; 
    30         if( file_exists( $sql_file_path ) ) { 
    31                 $ret[] = "SQL file found at <b>".htmlspecialchars($sql_file_path)."</b>.<br  /> Deleting tables...<br />"; 
    32                 $sql_lines = file( $sql_file_path ) ; 
    33                 foreach( $sql_lines as $sql_line ) { 
    34                         if( preg_match( '/^CREATE TABLE \`?([a-zA-Z0-9_-]+)\`? /i' , $sql_line , $regs ) ) { 
    35                                 $sql = 'DROP TABLE '.$prefix_mod.'_'.$regs[1] ; 
    36                                 if (!$db->query($sql)) { 
    37                                         $ret[] = '<span style="color:#ff0000;">ERROR: Could not drop table <b>'.htmlspecialchars($prefix_mod.'_'.$regs[1]).'<b>.</span><br />'; 
    38                                 } else { 
    39                                         $ret[] = 'Table <b>'.htmlspecialchars($prefix_mod.'_'.$regs[1]).'</b> dropped.<br />'; 
    40                                 } 
     26         
     27        $xp_prefix = $mydirname; 
     28        if ($xp_prefix == 'wordpress'){ 
     29                $xp_prefix = 'wp'; 
     30        } 
     31         
     32        $xoops_prefix = $db->prefix(); 
     33 
     34        if (empty($xoops_prefix) || empty($xp_prefix)) { 
     35                $ret[] = '<span style="color:#ff0000;">ERROR: Empty Prefix.</span><br />'; 
     36                return false; 
     37        } 
     38         
     39        $prefix_mod = $xoops_prefix  . '_' . $xp_prefix; 
     40        $sql = "SHOW TABLES LIKE '$prefix_mod%'"; 
     41        if ($result = $db->query($sql)) { 
     42                while ($table = $db->fetchRow($result)){ 
     43                        $drop_sql = 'DROP TABLE '. $table[0] ; 
     44                        if (!$db->queryF($drop_sql)) { 
     45                                $ret[] = '<span style="color:#ff0000;">ERROR: Could not drop table <b>'.htmlspecialchars($table[0]).'<b>.</span><br />'; 
     46                        } else { 
     47                                $ret[] = 'Table <b>'.htmlspecialchars($table[0]).'</b> dropped.<br />'; 
    4148                        } 
    4249                } 
     50        } else { 
     51                $ret[] = '<span style="color:#ff0000;">ERROR: Table not found of prefix <b>'.htmlspecialchars($prefix_mod).'<b> .</span><br />'; 
     52                return false; 
    4353        } 
    44 */ 
     54 
     55 
    4556        // TEMPLATES (Not necessary because modulesadmin removes all templates) 
    4657        /* $tplfile_handler =& xoops_gethandler( 'tplfile' ) ; 
Note: See TracChangeset for help on using the changeset viewer.