Ticket #3153: 3153.002.diff
| File 3153.002.diff, 6.7 KB (added by , 15 years ago) |
|---|
-
bp-core/admin/bp-core-update.php
14 14 } 15 15 16 16 function __construct() { 17 // Look for current DB version 18 if ( !$this->database_version = get_site_option( 'bp-db-version' ) ) { 19 if ( $this->database_version = get_option( 'bp-db-version' ) ) { 20 $this->is_network_activate = true; 21 } else { 22 if ( !$this->current_step() ) { 23 setcookie( 'bp-wizard-step', 0, time() + 60 * 60 * 24, COOKIEPATH ); 24 $_COOKIE['bp-wizard-step'] = 0; 25 } 17 global $bp; 18 19 // Get current DB version 20 $this->database_version = !empty( $bp->database_version ) ? $bp->database_version : ''; 21 22 if ( !empty( $bp->is_network_activate ) ) { 23 $this->is_network_activate = $bp->is_network_activate; 24 } else { 25 if ( !$this->current_step() ) { 26 setcookie( 'bp-wizard-step', 0, time() + 60 * 60 * 24, COOKIEPATH ); 27 $_COOKIE['bp-wizard-step'] = 0; 26 28 } 27 29 } 28 30 29 31 $this->new_version = constant( 'BP_DB_VERSION' ); 30 $this->setup_type = ( empty( $this->database_version ) && !(int)get_site_option( 'bp-core-db-version' ) ) ? 'install' : 'update';32 $this->setup_type = !empty( $bp->maintenance_mode ) ? $bp->maintenance_mode : ''; 31 33 $this->current_step = $this->current_step(); 32 34 33 35 // Call the save method that will save data and modify $current_step … … 74 76 if ( $this->database_version < $this->new_version ) 75 77 $steps[] = __( 'Database Update', 'buddypress' ); 76 78 77 if ( $this->database_version < 1225|| !bp_core_get_page_meta() )79 if ( (int) $this->database_version < 1801 || !bp_core_get_page_meta() ) 78 80 $steps[] = __( 'Pages', 'buddypress' ); 79 81 80 82 $steps[] = __( 'Finish', 'buddypress' ); … … 262 264 $blogs_slug = constant( 'BP_BLOGS_SLUG' ); 263 265 else 264 266 $blogs_slug = 'blogs'; 265 266 // Call up old bp-pages to see if a page has been previously linked to Blogs 267 268 // Call up old bp-pages to see if a page has been previously linked to Blogs 267 269 $page_blog_id = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG; 268 270 $existing_pages_data = get_blog_option( $page_blog_id, 'bp-pages' ); 269 271 $existing_pages = $existing_pages_data[$page_blog_id]; … … 364 366 $existing_pages = bp_core_update_get_page_meta(); 365 367 366 368 // Get active components 367 $active_components = apply_filters( 'bp_active_components', get_site_option( 'bp-active-components' ) ); 369 if ( !empty( $bp->active_components ) ) 370 $active_components = $bp->active_components; 371 else 372 $active_components = apply_filters( 'bp_active_components', get_site_option( 'bp-active-components' ) ); 368 373 369 374 // Check for defined slugs 370 375 $members_slug = !empty( $bp->members->slug ) ? $bp->members->slug : __( 'members', 'buddypress' ); … … 736 741 // Run the schema install to update tables 737 742 bp_core_install(); 738 743 739 if ( $this->database_version < 1225)744 if ( (int) $this->database_version < 1801 ) 740 745 $this->update_1_3(); 741 746 742 747 return true; … … 751 756 if ( isset( $_POST['submit'] ) ) { 752 757 check_admin_referer( 'bpwizard_ms_update' ); 753 758 754 if ( !$active_components = get_ option( 'bp-active-components' ) )759 if ( !$active_components = get_site_option( 'bp-active-components' ) ) 755 760 $active_components = array(); 756 761 757 762 // Transfer important settings from blog options to site options … … 773 778 $page_blog_id = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG; 774 779 $existing_pages_data = get_blog_option( $page_blog_id, 'bp-pages' ); 775 780 $existing_pages = $existing_pages_data[$page_blog_id]; 776 781 777 782 $bp_pages = $this->setup_pages( (array)$_POST['bp_pages'] ); 778 783 $bp_pages = array_merge( (array)$existing_pages, (array)$bp_pages ); 779 784 780 785 $existing_pages_data[$page_blog_id] = $bp_pages; 781 786 782 787 update_site_option( 'bp-pages', $existing_pages_data ); … … 1000 1005 check_admin_referer( 'bpwizard_finish' ); 1001 1006 1002 1007 // Update the DB version in the database 1003 update_site_option( 'bp-db-version', constant( 'BP_DB_VERSION' ));1008 update_site_option( 'bp-db-version', $this->new_version ); 1004 1009 delete_site_option( 'bp-core-db-version' ); 1005 1010 1006 1011 // Delete the setup cookie 1007 1012 @setcookie( 'bp-wizard-step', '', time() - 3600, COOKIEPATH ); 1008 1013 1009 // Load BP, so that the redirect is successful 1014 // Load BP, so that the redirect is successful 1010 1015 require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/bp-core-loader.php' ); 1011 1016 1012 1017 // Redirect to the BuddyPress dashboard … … 1070 1075 $active_components = apply_filters( 'bp_active_components', get_site_option( 'bp-active-components' ) ); 1071 1076 1072 1077 require_once( dirname( __FILE__ ) . '/bp-core-schema.php' ); 1073 1078 1074 1079 // Core DB Tables 1075 1080 bp_core_install_notifications(); 1076 1081 … … 1211 1216 * @uses add_submenu_page() WP function to add a submenu item 1212 1217 */ 1213 1218 function bp_core_update_add_admin_menu() { 1214 global $bp , $bp_wizard;1219 global $bp_wizard; 1215 1220 1216 1221 // Only load this version of the menu if this is an upgrade or a new installation 1217 if ( empty( $bp ->maintenence_mode ) )1222 if ( empty( $bp_wizard->setup_type ) ) 1218 1223 return false; 1219 1224 1220 1225 if ( !current_user_can( 'activate_plugins' ) ) 1221 1226 return false; 1222 1227 1223 if ( ' ' == get_site_option( 'bp-db-version' ) && !(int)get_site_option( 'bp-core-db-version' ) && !$bp_wizard->is_network_activate )1228 if ( 'install' == $bp_wizard->setup_type ) 1224 1229 $status = __( 'Setup', 'buddypress' ); 1225 1230 else 1226 1231 $status = __( 'Update', 'buddypress' ); … … 1283 1288 */ 1284 1289 function bp_core_update_get_page_meta() { 1285 1290 $page_ids = get_site_option( 'bp-pages' ); 1286 1291 1287 1292 $is_enable_multiblog = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? true : false; 1288 1293 1289 1294 $page_blog_id = $is_enable_multiblog ? get_current_blog_id() : BP_ROOT_BLOG; 1290 1295 1291 1296 $blog_page_ids = !empty( $page_ids[$page_blog_id] ) ? $page_ids[$page_blog_id] : false; 1292 1297 1293 1298 return apply_filters( 'bp_core_update_get_page_meta', $blog_page_ids ); 1294 1299 } 1295 1300 … … 1301 1306 * @global $pagenow The current admin page 1302 1307 */ 1303 1308 function bp_core_update_nag() { 1304 global $bp , $pagenow;1309 global $bp_wizard, $pagenow; 1305 1310 1311 if ( empty( $bp_wizard->setup_type ) ) 1312 return; 1313 1306 1314 if ( !is_super_admin() ) 1307 1315 return; 1308 1316 … … 1311 1319 1312 1320 $url = is_multisite() ? network_admin_url( 'admin.php?page=bp-wizard' ) : admin_url( 'admin.php?page=bp-wizard' ); 1313 1321 1314 switch( $bp ->maintenence_mode ) {1322 switch( $bp_wizard->setup_type ) { 1315 1323 case 'update': 1316 1324 $msg = sprintf( __( 'BuddyPress has been updated! Please run the <a href="%s">update wizard</a>.', 'buddypress' ), $url ); 1317 1325 break;