[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 | |
---|
| 55 | // update_option("blog_charset", wp_blog_charset()); |
---|
[1] | 56 | return true ; |
---|
| 57 | } |
---|
| 58 | endif; |
---|
| 59 | |
---|
[187] | 60 | if( ! function_exists( 'xpress_put_siteurl' ) ) : |
---|
| 61 | function xpress_put_siteurl($mydirname,$url){ |
---|
| 62 | global $xoopsModule; |
---|
| 63 | $wp_prefix = $mydirname; |
---|
| 64 | if ($wp_prefix == 'wordpress'){ |
---|
| 65 | $wp_prefix = 'wp'; |
---|
| 66 | } |
---|
| 67 | $xoopsDB =& Database::getInstance(); |
---|
| 68 | $db_xpress_option = $xoopsDB->prefix($wp_prefix . '_options'); |
---|
| 69 | |
---|
| 70 | $sql = "UPDATE $db_xpress_option SET option_value = '$url' WHERE option_name = 'siteurl'"; |
---|
| 71 | $res = $xoopsDB->queryF($sql, 0, 0); |
---|
| 72 | } |
---|
| 73 | endif; |
---|
| 74 | |
---|
[277] | 75 | if( ! function_exists( 'xpress_put_home' ) ) : |
---|
| 76 | function xpress_put_home($mydirname,$url){ |
---|
| 77 | global $xoopsModule; |
---|
| 78 | $wp_prefix = $mydirname; |
---|
| 79 | if ($wp_prefix == 'wordpress'){ |
---|
| 80 | $wp_prefix = 'wp'; |
---|
| 81 | } |
---|
| 82 | $xoopsDB =& Database::getInstance(); |
---|
| 83 | $db_xpress_option = $xoopsDB->prefix($wp_prefix . '_options'); |
---|
| 84 | |
---|
| 85 | $sql = "UPDATE $db_xpress_option SET option_value = '$url' WHERE option_name = 'home'"; |
---|
| 86 | $res = $xoopsDB->queryF($sql, 0, 0); |
---|
| 87 | } |
---|
| 88 | endif; |
---|
| 89 | |
---|
| 90 | |
---|
[1] | 91 | if( ! function_exists( 'xpress_message_append_onupdate' ) ) : |
---|
| 92 | function xpress_message_append_onupdate( &$module_obj , &$log ) |
---|
| 93 | { |
---|
| 94 | if( is_array( @$GLOBALS['msgs'] ) ) { |
---|
| 95 | foreach( $GLOBALS['msgs'] as $message ) { |
---|
| 96 | $log->add( strip_tags( $message ) ) ; |
---|
| 97 | } |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | // use mLog->addWarning() or mLog->addError() if necessary |
---|
| 101 | } |
---|
| 102 | endif; |
---|
| 103 | |
---|
| 104 | if( ! function_exists( 'get_db_version' ) ) : |
---|
| 105 | function get_db_version($mydirname){ |
---|
| 106 | global $xoopsModule; |
---|
| 107 | $wp_prefix = $mydirname; |
---|
| 108 | if ($wp_prefix == 'wordpress'){ |
---|
| 109 | $wp_prefix = 'wp'; |
---|
| 110 | } |
---|
| 111 | $xoopsDB =& Database::getInstance(); |
---|
| 112 | $db_xpress_option = $xoopsDB->prefix($wp_prefix . '_options'); |
---|
| 113 | |
---|
| 114 | $sql = "SELECT option_value FROM $db_xpress_option WHERE option_name = 'db_version'"; |
---|
| 115 | $res = $xoopsDB->query($sql, 0, 0); |
---|
| 116 | if ($res === false){ |
---|
| 117 | return false; |
---|
| 118 | } else { |
---|
| 119 | $row = $xoopsDB->fetchArray($res); |
---|
| 120 | return $row['option_value']; |
---|
| 121 | } |
---|
| 122 | } |
---|
| 123 | endif; |
---|
| 124 | |
---|
[277] | 125 | if( ! function_exists( 'xpress_block_check' ) ) : |
---|
| 126 | function xpress_block_check($mydirname){ |
---|
| 127 | include_once(dirname(dirname(__FILE__)) . '/class/check_blocks_class.php'); |
---|
[1] | 128 | |
---|
[277] | 129 | $xoops_block_check =& xoops_block_check::getInstance(); |
---|
| 130 | |
---|
| 131 | if ( !$xoops_block_check->is_admin() ) |
---|
| 132 | { |
---|
| 133 | $cont = 'Block Check Pass'; |
---|
| 134 | return cont; |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | switch ( $xoops_block_check->get_op() ) |
---|
| 138 | { |
---|
| 139 | case "remove_block": |
---|
| 140 | $cont = $xoops_block_check->remove_block(); |
---|
| 141 | break; |
---|
| 142 | |
---|
| 143 | default: |
---|
| 144 | $cont = $xoops_block_check->check_blocks($mydirname); |
---|
| 145 | break; |
---|
| 146 | } |
---|
| 147 | return $cont; |
---|
| 148 | } |
---|
| 149 | endif; |
---|
| 150 | |
---|
| 151 | if( ! function_exists( 'xpress_table_make' ) ) : |
---|
| 152 | function xpress_table_make($module, $mydirname) |
---|
| 153 | { |
---|
| 154 | $xp_prefix = $mydirname; |
---|
| 155 | if ($xp_prefix == 'wordpress'){ |
---|
| 156 | $xp_prefix = 'wp'; |
---|
| 157 | } |
---|
| 158 | $db =& Database::getInstance() ; |
---|
| 159 | $mid = $module->getVar('mid') ; |
---|
| 160 | |
---|
| 161 | // XPressME orignal table update |
---|
| 162 | $xp_prefix = $mydirname; |
---|
| 163 | if ($xp_prefix == 'wordpress'){ |
---|
| 164 | $xp_prefix = 'wp'; |
---|
| 165 | } |
---|
| 166 | $msgs = array(); |
---|
| 167 | |
---|
| 168 | if (! enhanced_table_check($mydirname,'views')){ |
---|
| 169 | $views_table = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_views' ; |
---|
| 170 | $queries ="CREATE TABLE $views_table ( |
---|
| 171 | post_id bigint(20) unsigned NOT NULL default '0', |
---|
| 172 | post_views bigint(20) unsigned NOT NULL default '0', |
---|
| 173 | KEY post_id (post_id) |
---|
| 174 | ) TYPE=MyISAM"; |
---|
| 175 | $db->queryF( $queries ) ; |
---|
| 176 | $msgs[] = "$views_table table of XPressME was made."; |
---|
| 177 | } |
---|
| 178 | |
---|
| 179 | if (! enhanced_table_check($mydirname,'d3forum_link')){ |
---|
| 180 | $d3forum_link = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_d3forum_link' ; |
---|
| 181 | $queries ="CREATE TABLE $d3forum_link ( |
---|
| 182 | comment_ID bigint(20) unsigned NOT NULL default '0', |
---|
| 183 | post_id int(10) unsigned NOT NULL default '0' , |
---|
| 184 | wp_post_ID bigint(20) unsigned NOT NULL default '0', |
---|
| 185 | KEY post_id (post_id) |
---|
| 186 | )TYPE=MyISAM"; |
---|
| 187 | $db->queryF( $queries ) ; |
---|
| 188 | $msgs[] = "$d3forum_link table of XPressME was made."; |
---|
| 189 | } |
---|
| 190 | |
---|
| 191 | if (! enhanced_table_check($mydirname,'group_role')){ |
---|
| 192 | $group_role = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_group_role' ; |
---|
| 193 | $queries ="CREATE TABLE $group_role ( |
---|
| 194 | groupid smallint(5) unsigned NOT NULL default '0', |
---|
| 195 | name varchar(50) NOT NULL default '' , |
---|
| 196 | description text NOT NULL default '', |
---|
| 197 | group_type varchar(50) NOT NULL default '' , |
---|
| 198 | role varchar(20) NOT NULL default '' , |
---|
| 199 | login_all smallint(5) unsigned NOT NULL default '0' , |
---|
| 200 | KEY groupid (groupid) |
---|
| 201 | )TYPE=MyISAM"; |
---|
| 202 | $db->queryF( $queries ) ; |
---|
| 203 | $sql = "INSERT INTO $group_role (groupid, role) VALUES (1, 'administrator')"; |
---|
| 204 | $db->queryF( $sql ) ; |
---|
| 205 | $msgs[] = "$group_role table of XPressME was made."; |
---|
| 206 | } |
---|
| 207 | |
---|
| 208 | return $msgs; |
---|
| 209 | } |
---|
| 210 | endif; |
---|
| 211 | |
---|
[1] | 212 | if( ! function_exists( 'enhanced_table_check' ) ) : |
---|
| 213 | function enhanced_table_check($mydirname,$table_name){ |
---|
| 214 | global $xoopsModule; |
---|
| 215 | |
---|
| 216 | $xoopsDB =& Database::getInstance(); |
---|
| 217 | if ($mydirname == 'wordpress'){ |
---|
| 218 | $xpress_prefix= $xoopsDB->prefix('wp_'); |
---|
| 219 | } else { |
---|
| 220 | $xpress_prefix= $xoopsDB->prefix($mydirname . '_'); |
---|
| 221 | } |
---|
| 222 | $db_enhanced = $xpress_prefix . $table_name; |
---|
| 223 | |
---|
| 224 | $sql = "show tables like '$db_enhanced'"; |
---|
| 225 | $res = $xoopsDB->query($sql, 0, 0); |
---|
| 226 | if ($res === false){ |
---|
| 227 | return false; |
---|
| 228 | } else { |
---|
| 229 | if ($xoopsDB->getRowsNum($res) > 0) |
---|
| 230 | return true; |
---|
| 231 | else |
---|
| 232 | return false; |
---|
| 233 | } |
---|
| 234 | } |
---|
| 235 | endif; |
---|
| 236 | |
---|
[151] | 237 | |
---|
| 238 | |
---|
[1] | 239 | ?> |
---|