Changeset 277
- Timestamp:
- Jun 15, 2009, 11:43:27 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/xpressme_integration_kit/include/onupdate.php
r252 r277 23 23 $mid = $module->getVar('mid') ; 24 24 25 26 27 25 //XPressME Update 28 26 global $wpdb,$wp_rewrite, $wp_queries, $table_prefix, $wp_db_version, $wp_roles,$wp_query; 29 27 global $xoops_db; 30 define('WP_INSTALLING', true);31 28 $mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname; 32 29 $path = $mydirpath . '/'; 33 30 34 /* 35 * xpress_put_siteurl($mydirname,''); 36 * Call to a member function register() The on a non-object error is evaded. 37 * It happens by register_widget() that exists in wp-includes/widgets.php. 38 * The blog is not installed. It is cheating to function wp_maybe_load_widgets(). 39 * As a result, default-widgets.php is not loaded. 40 */ 41 xpress_put_siteurl($mydirname,''); // Site_url is temporarily deleted. 42 43 if (file_exists($path . 'wp-load.php')) { 44 require_once $path . 'wp-load.php'; 45 } else { 46 require_once $path . 'wp-config.php'; 47 } 48 // upgrade WordPress 49 50 $site_url= XOOPS_URL."/modules/".$mydirname; 51 xpress_put_siteurl($mydirname,$site_url); // Site_url is set again. 52 update_option("home", $site_url); 53 54 require_once($mydirpath . '/wp-admin/upgrade-functions.php'); 55 56 if ( get_db_version($mydirname) != $wp_db_version ){ 57 if( function_exists( 'wp_upgrade' ) ) { 58 wp_upgrade(); 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); 35 36 // XPressME orignal table update 37 $t_mess = xpress_table_make($module , $mydirname); 38 $msgs = array_merge($msgs,$t_mess); 39 40 // make templates 41 include_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/xpress_templates_make.php' ; 42 $t_mess = xpress_templates_make($mid,$mydirname); 43 44 $msgs = array_merge($msgs,$t_mess); 45 46 // The activation processing of the XPressME plugin is omitted. 47 // Because the XPressME plugin is done with wp-config in activation 48 49 /* activate the xpressme plugin */ 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 // } 54 55 // update_option("blog_charset", wp_blog_charset()); 56 return true ; 57 } 58 endif; 59 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 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 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; 59 118 } else { 60 wp_cache_flush(); 61 make_db_current_silent(); 62 upgrade_all(); 63 wp_cache_flush(); 64 } 65 $msgs[] = 'Upgrade Wordpress Database Ver.' . get_db_version($mydirname) .' to' . $wp_db_version; 66 } 119 $row = $xoopsDB->fetchArray($res); 120 return $row['option_value']; 121 } 122 } 123 endif; 124 125 if( ! function_exists( 'xpress_block_check' ) ) : 126 function xpress_block_check($mydirname){ 127 include_once(dirname(dirname(__FILE__)) . '/class/check_blocks_class.php'); 128 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') ; 67 160 68 161 // XPressME orignal table update 162 $xp_prefix = $mydirname; 163 if ($xp_prefix == 'wordpress'){ 164 $xp_prefix = 'wp'; 165 } 166 $msgs = array(); 167 69 168 if (! enhanced_table_check($mydirname,'views')){ 70 $xp_prefix = $mydirname;71 if ($xp_prefix == 'wordpress'){72 $xp_prefix = 'wp';73 }74 75 $charset_collate = '';76 if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) {77 if ( ! empty($wpdb->charset) )78 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";79 if ( ! empty($wpdb->collate) )80 $charset_collate .= " COLLATE $wpdb->collate";81 }82 169 $views_table = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_views' ; 83 $ views_queries ="CREATE TABLE $views_table (170 $queries ="CREATE TABLE $views_table ( 84 171 post_id bigint(20) unsigned NOT NULL default '0', 85 172 post_views bigint(20) unsigned NOT NULL default '0', 86 173 KEY post_id (post_id) 87 )$charset_collate;"; 88 89 dbDelta($views_queries); 174 ) TYPE=MyISAM"; 175 $db->queryF( $queries ) ; 90 176 $msgs[] = "$views_table table of XPressME was made."; 91 177 } 92 178 93 179 if (! enhanced_table_check($mydirname,'d3forum_link')){ 94 $xp_prefix = $mydirname;95 if ($xp_prefix == 'wordpress'){96 $xp_prefix = 'wp';97 }98 99 $charset_collate = '';100 if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) {101 if ( ! empty($wpdb->charset) )102 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";103 if ( ! empty($wpdb->collate) )104 $charset_collate .= " COLLATE $wpdb->collate";105 }106 107 180 $d3forum_link = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_d3forum_link' ; 108 181 $queries ="CREATE TABLE $d3forum_link ( … … 111 184 wp_post_ID bigint(20) unsigned NOT NULL default '0', 112 185 KEY post_id (post_id) 113 ) $charset_collate;";114 dbDelta($queries);186 )TYPE=MyISAM"; 187 $db->queryF( $queries ) ; 115 188 $msgs[] = "$d3forum_link table of XPressME was made."; 116 189 } 117 190 118 191 if (! enhanced_table_check($mydirname,'group_role')){ 119 $xp_prefix = $mydirname;120 if ($xp_prefix == 'wordpress'){121 $xp_prefix = 'wp';122 }123 124 $charset_collate = '';125 if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) {126 if ( ! empty($wpdb->charset) )127 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";128 if ( ! empty($wpdb->collate) )129 $charset_collate .= " COLLATE $wpdb->collate";130 }131 132 192 $group_role = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_group_role' ; 133 $ views_queries ="CREATE TABLE $group_role (193 $queries ="CREATE TABLE $group_role ( 134 194 groupid smallint(5) unsigned NOT NULL default '0', 135 195 name varchar(50) NOT NULL default '' , … … 139 199 login_all smallint(5) unsigned NOT NULL default '0' , 140 200 KEY groupid (groupid) 141 ) $charset_collate;";142 dbDelta($views_queries);201 )TYPE=MyISAM"; 202 $db->queryF( $queries ) ; 143 203 $sql = "INSERT INTO $group_role (groupid, role) VALUES (1, 'administrator')"; 144 $ wpdb->query($sql);204 $db->queryF( $sql ) ; 145 205 $msgs[] = "$group_role table of XPressME was made."; 146 206 } 147 if ( xpress_block_check($mydirname)) { 148 $msgs[] = '<span style="color:#ff0000;">Block Check OK</span>'; 149 } else { 150 $msgs[] = "Block Check NG. You need Repar Block on This Mobule 'Block Check' Menu"; 151 } 152 153 // make templates 154 include_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/xpress_templates_make.php' ; 155 $t_mess = xpress_templates_make($mid,$mydirname); 156 157 $msgs = array_merge($msgs,$t_mess); 158 159 160 /* activate the xpressme plugin */ 161 require_once dirname( __FILE__ ).'/xpress_active_plugin.php'; 162 if (xpress_pulugin_activation('xpressme/xpressme.php')){ 163 $msgs[] = 'The xpressme plug-in was activated.'; 164 } 165 166 // update_option("blog_charset", wp_blog_charset()); 167 $xpress_version = $module->modinfo['version']; 168 169 170 171 return true ; 172 } 173 endif; 174 175 if( ! function_exists( 'xpress_put_siteurl' ) ) : 176 function xpress_put_siteurl($mydirname,$url){ 177 global $xoopsModule; 178 $wp_prefix = $mydirname; 179 if ($wp_prefix == 'wordpress'){ 180 $wp_prefix = 'wp'; 181 } 182 $xoopsDB =& Database::getInstance(); 183 $db_xpress_option = $xoopsDB->prefix($wp_prefix . '_options'); 184 185 $sql = "UPDATE $db_xpress_option SET option_value = '$url' WHERE option_name = 'siteurl'"; 186 $res = $xoopsDB->queryF($sql, 0, 0); 187 } 188 endif; 189 190 if( ! function_exists( 'xpress_message_append_onupdate' ) ) : 191 function xpress_message_append_onupdate( &$module_obj , &$log ) 192 { 193 if( is_array( @$GLOBALS['msgs'] ) ) { 194 foreach( $GLOBALS['msgs'] as $message ) { 195 $log->add( strip_tags( $message ) ) ; 196 } 197 } 198 199 // use mLog->addWarning() or mLog->addError() if necessary 200 } 201 endif; 202 203 if( ! function_exists( 'get_db_version' ) ) : 204 function get_db_version($mydirname){ 205 global $xoopsModule; 206 $wp_prefix = $mydirname; 207 if ($wp_prefix == 'wordpress'){ 208 $wp_prefix = 'wp'; 209 } 210 $xoopsDB =& Database::getInstance(); 211 $db_xpress_option = $xoopsDB->prefix($wp_prefix . '_options'); 212 213 $sql = "SELECT option_value FROM $db_xpress_option WHERE option_name = 'db_version'"; 214 $res = $xoopsDB->query($sql, 0, 0); 215 if ($res === false){ 216 return false; 217 } else { 218 $row = $xoopsDB->fetchArray($res); 219 return $row['option_value']; 220 } 221 } 222 endif; 223 207 208 return $msgs; 209 } 210 endif; 224 211 225 212 if( ! function_exists( 'enhanced_table_check' ) ) : … … 248 235 endif; 249 236 250 if( ! function_exists( 'xpress_block_check' ) ) :251 function xpress_block_check($mydirname){252 include_once(dirname(dirname(__FILE__)) . '/class/check_blocks_class.php');253 254 $xoops_block_check =& xoops_block_check::getInstance();255 256 if ( !$xoops_block_check->is_admin() )257 {258 $cont = 'Block Check Pass';259 return cont;260 }261 262 switch ( $xoops_block_check->get_op() )263 {264 case "remove_block":265 $cont = $xoops_block_check->remove_block();266 break;267 268 default:269 $cont = $xoops_block_check->check_blocks($mydirname);270 break;271 }272 return $cont;273 }274 endif;275 237 276 238
Note: See TracChangeset
for help on using the changeset viewer.