[828] | 1 | <?php |
---|
| 2 | $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ; |
---|
| 3 | |
---|
| 4 | eval( ' function xoops_module_uninstall_'.$mydirname.'( $module ) { return xpress_onuninstall_base( $module , "'.$mydirname.'" ) ; } ' ) ; |
---|
| 5 | |
---|
| 6 | |
---|
| 7 | if( ! function_exists( 'xpress_onuninstall_base' ) ) { |
---|
| 8 | |
---|
| 9 | function xpress_onuninstall_base( $module , $mydirname ) |
---|
| 10 | { |
---|
| 11 | // transations on module uninstall |
---|
| 12 | |
---|
| 13 | global $ret ; // TODO :-D |
---|
| 14 | |
---|
| 15 | // for Cube 2.1 |
---|
| 16 | if( defined( 'XOOPS_CUBE_LEGACY' ) ) { |
---|
| 17 | $root =& XCube_Root::getSingleton(); |
---|
| 18 | $root->mDelegateManager->add( 'Legacy.Admin.Event.ModuleUninstall.' . ucfirst($mydirname) . '.Success' , 'xpress_message_append_onuninstall' ) ; |
---|
| 19 | $ret = array() ; |
---|
| 20 | } else { |
---|
| 21 | if( ! is_array( $ret ) ) $ret = array() ; |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | $db =& Database::getInstance() ; |
---|
| 25 | $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 | } |
---|
| 41 | } |
---|
| 42 | } |
---|
| 43 | } |
---|
| 44 | */ |
---|
| 45 | // TEMPLATES (Not necessary because modulesadmin removes all templates) |
---|
| 46 | /* $tplfile_handler =& xoops_gethandler( 'tplfile' ) ; |
---|
| 47 | $templates =& $tplfile_handler->find( null , 'module' , $mid ) ; |
---|
| 48 | $tcount = count( $templates ) ; |
---|
| 49 | if( $tcount > 0 ) { |
---|
| 50 | $ret[] = 'Deleting templates...' ; |
---|
| 51 | for( $i = 0 ; $i < $tcount ; $i ++ ) { |
---|
| 52 | if( ! $tplfile_handler->delete( $templates[$i] ) ) { |
---|
| 53 | $ret[] = '<span style="color:#ff0000;">ERROR: Could not delete template '.$templates[$i]->getVar('tpl_file','s').' from the database. Template ID: <b>'.$templates[$i]->getVar('tpl_id','s').'</b></span><br />'; |
---|
| 54 | } else { |
---|
| 55 | $ret[] = 'Template <b>'.$templates[$i]->getVar('tpl_file','s').'</b> deleted from the database. Template ID: <b>'.$templates[$i]->getVar('tpl_id','s').'</b><br />'; |
---|
| 56 | } |
---|
| 57 | } |
---|
| 58 | } |
---|
| 59 | unset($templates); */ |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | return true ; |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | function xpress_message_append_onuninstall( &$module_obj , &$log ) |
---|
| 66 | { |
---|
| 67 | if( is_array( @$GLOBALS['ret'] ) ) { |
---|
| 68 | foreach( $GLOBALS['ret'] as $message ) { |
---|
| 69 | $log->add( strip_tags( $message ) ) ; |
---|
| 70 | } |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | // use mLog->addWarning() or mLog->addError() if necessary |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | ?> |
---|