| 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 =& XoopsDatabaseFactory::getDatabaseConnection() ; | 
|---|
| 25 |         $mid = $module->getVar('mid') ; | 
|---|
| 26 |          | 
|---|
| 27 |         $xp_prefix = preg_replace('/wordpress/','wp',$mydirname); | 
|---|
| 28 |          | 
|---|
| 29 |         $xoops_prefix = $db->prefix(); | 
|---|
| 30 |  | 
|---|
| 31 |         if (empty($xoops_prefix) || empty($xp_prefix)) { | 
|---|
| 32 |                 $ret[] = '<span style="color:#ff0000;">ERROR: Empty Prefix.</span><br />'; | 
|---|
| 33 |                 return false; | 
|---|
| 34 |         } | 
|---|
| 35 |          | 
|---|
| 36 |         $prefix_mod = $xoops_prefix  . '_' . $xp_prefix; | 
|---|
| 37 |         $sql = "SHOW TABLES LIKE '$prefix_mod%'"; | 
|---|
| 38 |         if ($result = $db->query($sql)) { | 
|---|
| 39 |                 while ($table = $db->fetchRow($result)){ | 
|---|
| 40 |                         $drop_sql = 'DROP TABLE '. $table[0] ; | 
|---|
| 41 |                         if (!$db->queryF($drop_sql)) { | 
|---|
| 42 |                                 $ret[] = '<span style="color:#ff0000;">ERROR: Could not drop table <b>'.htmlspecialchars($table[0]).'<b>.</span><br />'; | 
|---|
| 43 |                         } else { | 
|---|
| 44 |                                 $ret[] = 'Table <b>'.htmlspecialchars($table[0]).'</b> dropped.<br />'; | 
|---|
| 45 |                         } | 
|---|
| 46 |                 } | 
|---|
| 47 |         } else { | 
|---|
| 48 |                 $ret[] = '<span style="color:#ff0000;">ERROR: Table not found of prefix <b>'.htmlspecialchars($prefix_mod).'<b> .</span><br />'; | 
|---|
| 49 |                 return false; | 
|---|
| 50 |         } | 
|---|
| 51 |  | 
|---|
| 52 |  | 
|---|
| 53 |         // TEMPLATES (Not necessary because modulesadmin removes all templates) | 
|---|
| 54 |         /* $tplfile_handler =& xoops_gethandler( 'tplfile' ) ; | 
|---|
| 55 |         $templates =& $tplfile_handler->find( null , 'module' , $mid ) ; | 
|---|
| 56 |         $tcount = count( $templates ) ; | 
|---|
| 57 |         if( $tcount > 0 ) { | 
|---|
| 58 |                 $ret[] = 'Deleting templates...' ; | 
|---|
| 59 |                 for( $i = 0 ; $i < $tcount ; $i ++ ) { | 
|---|
| 60 |                         if( ! $tplfile_handler->delete( $templates[$i] ) ) { | 
|---|
| 61 |                                 $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 />'; | 
|---|
| 62 |                         } else { | 
|---|
| 63 |                                 $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 />'; | 
|---|
| 64 |                         } | 
|---|
| 65 |                 } | 
|---|
| 66 |         } | 
|---|
| 67 |         unset($templates); */ | 
|---|
| 68 |  | 
|---|
| 69 |  | 
|---|
| 70 |         return true ; | 
|---|
| 71 | } | 
|---|
| 72 |  | 
|---|
| 73 | function xpress_message_append_onuninstall( &$module_obj , &$log ) | 
|---|
| 74 | { | 
|---|
| 75 |         if( is_array( @$GLOBALS['ret'] ) ) { | 
|---|
| 76 |                 foreach( $GLOBALS['ret'] as $message ) { | 
|---|
| 77 |                         $log->add( strip_tags( $message ) ) ; | 
|---|
| 78 |                 } | 
|---|
| 79 |         } | 
|---|
| 80 |  | 
|---|
| 81 |         // use mLog->addWarning() or mLog->addError() if necessary | 
|---|
| 82 | } | 
|---|
| 83 |  | 
|---|
| 84 | } | 
|---|
| 85 |  | 
|---|
| 86 | ?> | 
|---|