[1] | 1 | <?php |
---|
| 2 | $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ; |
---|
| 3 | |
---|
| 4 | eval( ' function xoops_module_update_'.$mydirname.'( $module ) { return xpress_onupdate_base( $module , "'.$mydirname.'" ) ; } ' ) ; |
---|
| 5 | |
---|
| 6 | |
---|
| 7 | if( ! function_exists( 'xpress_onupdate_base' ) ) : |
---|
| 8 | function xpress_onupdate_base( $module , $mydirname ) |
---|
| 9 | { |
---|
| 10 | // transations on module update |
---|
| 11 | |
---|
[128] | 12 | global $msgs ; // TODO :-D |
---|
[1] | 13 | // for Cube 2.1 |
---|
| 14 | if( defined( 'XOOPS_CUBE_LEGACY' ) ) { |
---|
| 15 | $root =& XCube_Root::getSingleton(); |
---|
| 16 | $root->mDelegateManager->add( 'Legacy.Admin.Event.ModuleUpdate.' . ucfirst($mydirname) . '.Success', 'xpress_message_append_onupdate' ) ; |
---|
[128] | 17 | $msgs = array() ; |
---|
[1] | 18 | } else { |
---|
[128] | 19 | if( ! is_array( $msgs ) ) $msgs = array() ; |
---|
[1] | 20 | } |
---|
| 21 | |
---|
| 22 | $db =& Database::getInstance() ; |
---|
| 23 | $mid = $module->getVar('mid') ; |
---|
| 24 | |
---|
[208] | 25 | //XPressME Update |
---|
| 26 | global $wpdb,$wp_rewrite, $wp_queries, $table_prefix, $wp_db_version, $wp_roles,$wp_query; |
---|
[252] | 27 | global $xoops_db; |
---|
[208] | 28 | $mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname; |
---|
| 29 | $path = $mydirpath . '/'; |
---|
| 30 | |
---|
[277] | 31 | //Site_url and home of an optional table are repaired. |
---|
| 32 | $site_url= XOOPS_URL."/modules/".$mydirname; |
---|
| 33 | xpress_put_siteurl($mydirname,$site_url); |
---|
| 34 | xpress_put_home($mydirname,$site_url); |
---|
[208] | 35 | |
---|
| 36 | // XPressME orignal table update |
---|
[277] | 37 | $t_mess = xpress_table_make($module , $mydirname); |
---|
| 38 | $msgs = array_merge($msgs,$t_mess); |
---|
[1] | 39 | |
---|
[187] | 40 | // make templates |
---|
[102] | 41 | include_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/xpress_templates_make.php' ; |
---|
| 42 | $t_mess = xpress_templates_make($mid,$mydirname); |
---|
[151] | 43 | |
---|
[128] | 44 | $msgs = array_merge($msgs,$t_mess); |
---|
[187] | 45 | |
---|
[277] | 46 | // The activation processing of the XPressME plugin is omitted. |
---|
| 47 | // Because the XPressME plugin is done with wp-config in activation |
---|
[187] | 48 | |
---|
| 49 | /* activate the xpressme plugin */ |
---|
[277] | 50 | // require_once dirname( __FILE__ ).'/xpress_active_plugin.php'; |
---|
| 51 | // if (xpress_pulugin_activation('xpressme/xpressme.php')){ |
---|
| 52 | // $msgs[] = 'The xpressme plug-in was activated.'; |
---|
| 53 | // } |
---|
[187] | 54 | |
---|
[1] | 55 | return true ; |
---|
| 56 | } |
---|
| 57 | endif; |
---|
| 58 | |
---|
[187] | 59 | if( ! function_exists( 'xpress_put_siteurl' ) ) : |
---|
| 60 | function xpress_put_siteurl($mydirname,$url){ |
---|
| 61 | global $xoopsModule; |
---|
| 62 | $wp_prefix = $mydirname; |
---|
| 63 | if ($wp_prefix == 'wordpress'){ |
---|
| 64 | $wp_prefix = 'wp'; |
---|
| 65 | } |
---|
| 66 | $xoopsDB =& Database::getInstance(); |
---|
| 67 | $db_xpress_option = $xoopsDB->prefix($wp_prefix . '_options'); |
---|
| 68 | |
---|
| 69 | $sql = "UPDATE $db_xpress_option SET option_value = '$url' WHERE option_name = 'siteurl'"; |
---|
| 70 | $res = $xoopsDB->queryF($sql, 0, 0); |
---|
| 71 | } |
---|
| 72 | endif; |
---|
| 73 | |
---|
[277] | 74 | if( ! function_exists( 'xpress_put_home' ) ) : |
---|
| 75 | function xpress_put_home($mydirname,$url){ |
---|
| 76 | global $xoopsModule; |
---|
| 77 | $wp_prefix = $mydirname; |
---|
| 78 | if ($wp_prefix == 'wordpress'){ |
---|
| 79 | $wp_prefix = 'wp'; |
---|
| 80 | } |
---|
| 81 | $xoopsDB =& Database::getInstance(); |
---|
| 82 | $db_xpress_option = $xoopsDB->prefix($wp_prefix . '_options'); |
---|
| 83 | |
---|
| 84 | $sql = "UPDATE $db_xpress_option SET option_value = '$url' WHERE option_name = 'home'"; |
---|
| 85 | $res = $xoopsDB->queryF($sql, 0, 0); |
---|
| 86 | } |
---|
| 87 | endif; |
---|
| 88 | |
---|
| 89 | |
---|
[1] | 90 | if( ! function_exists( 'xpress_message_append_onupdate' ) ) : |
---|
| 91 | function xpress_message_append_onupdate( &$module_obj , &$log ) |
---|
| 92 | { |
---|
| 93 | if( is_array( @$GLOBALS['msgs'] ) ) { |
---|
| 94 | foreach( $GLOBALS['msgs'] as $message ) { |
---|
| 95 | $log->add( strip_tags( $message ) ) ; |
---|
| 96 | } |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | // use mLog->addWarning() or mLog->addError() if necessary |
---|
| 100 | } |
---|
| 101 | endif; |
---|
| 102 | |
---|
| 103 | if( ! function_exists( 'get_db_version' ) ) : |
---|
| 104 | function get_db_version($mydirname){ |
---|
| 105 | global $xoopsModule; |
---|
| 106 | $wp_prefix = $mydirname; |
---|
| 107 | if ($wp_prefix == 'wordpress'){ |
---|
| 108 | $wp_prefix = 'wp'; |
---|
| 109 | } |
---|
| 110 | $xoopsDB =& Database::getInstance(); |
---|
| 111 | $db_xpress_option = $xoopsDB->prefix($wp_prefix . '_options'); |
---|
| 112 | |
---|
| 113 | $sql = "SELECT option_value FROM $db_xpress_option WHERE option_name = 'db_version'"; |
---|
| 114 | $res = $xoopsDB->query($sql, 0, 0); |
---|
| 115 | if ($res === false){ |
---|
| 116 | return false; |
---|
| 117 | } else { |
---|
| 118 | $row = $xoopsDB->fetchArray($res); |
---|
| 119 | return $row['option_value']; |
---|
| 120 | } |
---|
| 121 | } |
---|
| 122 | endif; |
---|
| 123 | |
---|
[277] | 124 | if( ! function_exists( 'xpress_block_check' ) ) : |
---|
| 125 | function xpress_block_check($mydirname){ |
---|
| 126 | include_once(dirname(dirname(__FILE__)) . '/class/check_blocks_class.php'); |
---|
[1] | 127 | |
---|
[277] | 128 | $xoops_block_check =& xoops_block_check::getInstance(); |
---|
| 129 | |
---|
| 130 | if ( !$xoops_block_check->is_admin() ) |
---|
| 131 | { |
---|
| 132 | $cont = 'Block Check Pass'; |
---|
| 133 | return cont; |
---|
| 134 | } |
---|
| 135 | |
---|
| 136 | switch ( $xoops_block_check->get_op() ) |
---|
| 137 | { |
---|
| 138 | case "remove_block": |
---|
| 139 | $cont = $xoops_block_check->remove_block(); |
---|
| 140 | break; |
---|
| 141 | |
---|
| 142 | default: |
---|
| 143 | $cont = $xoops_block_check->check_blocks($mydirname); |
---|
| 144 | break; |
---|
| 145 | } |
---|
| 146 | return $cont; |
---|
| 147 | } |
---|
| 148 | endif; |
---|
| 149 | |
---|
| 150 | if( ! function_exists( 'xpress_table_make' ) ) : |
---|
| 151 | function xpress_table_make($module, $mydirname) |
---|
| 152 | { |
---|
| 153 | $xp_prefix = $mydirname; |
---|
| 154 | if ($xp_prefix == 'wordpress'){ |
---|
| 155 | $xp_prefix = 'wp'; |
---|
| 156 | } |
---|
| 157 | $db =& Database::getInstance() ; |
---|
| 158 | $mid = $module->getVar('mid') ; |
---|
| 159 | |
---|
| 160 | // XPressME orignal table update |
---|
| 161 | $xp_prefix = $mydirname; |
---|
| 162 | if ($xp_prefix == 'wordpress'){ |
---|
| 163 | $xp_prefix = 'wp'; |
---|
| 164 | } |
---|
| 165 | $msgs = array(); |
---|
| 166 | |
---|
| 167 | if (! enhanced_table_check($mydirname,'views')){ |
---|
| 168 | $views_table = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_views' ; |
---|
| 169 | $queries ="CREATE TABLE $views_table ( |
---|
| 170 | post_id bigint(20) unsigned NOT NULL default '0', |
---|
| 171 | post_views bigint(20) unsigned NOT NULL default '0', |
---|
| 172 | KEY post_id (post_id) |
---|
| 173 | ) TYPE=MyISAM"; |
---|
| 174 | $db->queryF( $queries ) ; |
---|
| 175 | $msgs[] = "$views_table table of XPressME was made."; |
---|
| 176 | } |
---|
| 177 | |
---|
| 178 | if (! enhanced_table_check($mydirname,'d3forum_link')){ |
---|
| 179 | $d3forum_link = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_d3forum_link' ; |
---|
| 180 | $queries ="CREATE TABLE $d3forum_link ( |
---|
| 181 | comment_ID bigint(20) unsigned NOT NULL default '0', |
---|
| 182 | post_id int(10) unsigned NOT NULL default '0' , |
---|
| 183 | wp_post_ID bigint(20) unsigned NOT NULL default '0', |
---|
| 184 | KEY post_id (post_id) |
---|
| 185 | )TYPE=MyISAM"; |
---|
| 186 | $db->queryF( $queries ) ; |
---|
| 187 | $msgs[] = "$d3forum_link table of XPressME was made."; |
---|
| 188 | } |
---|
| 189 | |
---|
| 190 | if (! enhanced_table_check($mydirname,'group_role')){ |
---|
| 191 | $group_role = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_group_role' ; |
---|
| 192 | $queries ="CREATE TABLE $group_role ( |
---|
| 193 | groupid smallint(5) unsigned NOT NULL default '0', |
---|
| 194 | name varchar(50) NOT NULL default '' , |
---|
| 195 | description text NOT NULL default '', |
---|
| 196 | group_type varchar(50) NOT NULL default '' , |
---|
| 197 | role varchar(20) NOT NULL default '' , |
---|
| 198 | login_all smallint(5) unsigned NOT NULL default '0' , |
---|
| 199 | KEY groupid (groupid) |
---|
| 200 | )TYPE=MyISAM"; |
---|
| 201 | $db->queryF( $queries ) ; |
---|
| 202 | $sql = "INSERT INTO $group_role (groupid, role) VALUES (1, 'administrator')"; |
---|
| 203 | $db->queryF( $sql ) ; |
---|
| 204 | $msgs[] = "$group_role table of XPressME was made."; |
---|
| 205 | } |
---|
| 206 | |
---|
| 207 | return $msgs; |
---|
| 208 | } |
---|
| 209 | endif; |
---|
| 210 | |
---|
[1] | 211 | if( ! function_exists( 'enhanced_table_check' ) ) : |
---|
| 212 | function enhanced_table_check($mydirname,$table_name){ |
---|
| 213 | global $xoopsModule; |
---|
| 214 | |
---|
| 215 | $xoopsDB =& Database::getInstance(); |
---|
| 216 | if ($mydirname == 'wordpress'){ |
---|
| 217 | $xpress_prefix= $xoopsDB->prefix('wp_'); |
---|
| 218 | } else { |
---|
| 219 | $xpress_prefix= $xoopsDB->prefix($mydirname . '_'); |
---|
| 220 | } |
---|
| 221 | $db_enhanced = $xpress_prefix . $table_name; |
---|
| 222 | |
---|
| 223 | $sql = "show tables like '$db_enhanced'"; |
---|
| 224 | $res = $xoopsDB->query($sql, 0, 0); |
---|
| 225 | if ($res === false){ |
---|
| 226 | return false; |
---|
| 227 | } else { |
---|
| 228 | if ($xoopsDB->getRowsNum($res) > 0) |
---|
| 229 | return true; |
---|
| 230 | else |
---|
| 231 | return false; |
---|
| 232 | } |
---|
| 233 | } |
---|
| 234 | endif; |
---|
| 235 | |
---|
[151] | 236 | |
---|
| 237 | |
---|
[1] | 238 | ?> |
---|