Skip to:
Content

BuddyPress.org

Ticket #3153: 3153.002.diff

File 3153.002.diff, 6.7 KB (added by cnorris23, 15 years ago)
  • bp-core/admin/bp-core-update.php

     
    1414        }
    1515
    1616        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;
    2628                        }
    2729                }
    2830
    2931                $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 : '';
    3133                $this->current_step = $this->current_step();
    3234
    3335                // Call the save method that will save data and modify $current_step
     
    7476                        if ( $this->database_version < $this->new_version )
    7577                                $steps[] = __( 'Database Update', 'buddypress' );
    7678
    77                         if ( $this->database_version < 1225 || !bp_core_get_page_meta() )
     79                        if ( (int) $this->database_version < 1801 || !bp_core_get_page_meta() )
    7880                                $steps[] = __( 'Pages', 'buddypress' );
    7981
    8082                        $steps[] = __( 'Finish', 'buddypress' );
     
    262264                        $blogs_slug = constant( 'BP_BLOGS_SLUG' );
    263265                else
    264266                        $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
    267269                $page_blog_id           = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG;
    268270                $existing_pages_data    = get_blog_option( $page_blog_id, 'bp-pages' );
    269271                $existing_pages         = $existing_pages_data[$page_blog_id];
     
    364366                $existing_pages = bp_core_update_get_page_meta();
    365367
    366368                // 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' ) );
    368373
    369374                // Check for defined slugs
    370375                $members_slug    = !empty( $bp->members->slug    ) ? $bp->members->slug    : __( 'members',  'buddypress' );
     
    736741                        // Run the schema install to update tables
    737742                        bp_core_install();
    738743
    739                         if ( $this->database_version < 1225 )
     744                        if ( (int) $this->database_version < 1801 )
    740745                                $this->update_1_3();
    741746
    742747                        return true;
     
    751756                if ( isset( $_POST['submit'] ) ) {
    752757                        check_admin_referer( 'bpwizard_ms_update' );
    753758
    754                         if ( !$active_components = get_option( 'bp-active-components' ) )
     759                        if ( !$active_components = get_site_option( 'bp-active-components' ) )
    755760                                $active_components = array();
    756761
    757762                        // Transfer important settings from blog options to site options
     
    773778                                $page_blog_id           = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG;
    774779                                $existing_pages_data    = get_blog_option( $page_blog_id, 'bp-pages' );
    775780                                $existing_pages         = $existing_pages_data[$page_blog_id];
    776                                
     781
    777782                                $bp_pages               = $this->setup_pages( (array)$_POST['bp_pages'] );
    778783                                $bp_pages               = array_merge( (array)$existing_pages, (array)$bp_pages );
    779                                
     784
    780785                                $existing_pages_data[$page_blog_id] = $bp_pages;
    781786
    782787                                update_site_option( 'bp-pages', $existing_pages_data );
     
    10001005                        check_admin_referer( 'bpwizard_finish' );
    10011006
    10021007                        // 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 );
    10041009                        delete_site_option( 'bp-core-db-version' );
    10051010
    10061011                        // Delete the setup cookie
    10071012                        @setcookie( 'bp-wizard-step', '', time() - 3600, COOKIEPATH );
    10081013
    1009                         // Load BP, so that the redirect is successful                 
     1014                        // Load BP, so that the redirect is successful
    10101015                        require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/bp-core-loader.php' );
    10111016
    10121017                        // Redirect to the BuddyPress dashboard
     
    10701075                $active_components = apply_filters( 'bp_active_components', get_site_option( 'bp-active-components' ) );
    10711076
    10721077        require_once( dirname( __FILE__ ) . '/bp-core-schema.php' );
    1073        
     1078
    10741079        // Core DB Tables
    10751080        bp_core_install_notifications();
    10761081
     
    12111216 * @uses add_submenu_page() WP function to add a submenu item
    12121217 */
    12131218function bp_core_update_add_admin_menu() {
    1214         global $bp, $bp_wizard;
     1219        global $bp_wizard;
    12151220
    12161221        // 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 ) )
    12181223                return false;
    12191224
    12201225        if ( !current_user_can( 'activate_plugins' ) )
    12211226                return false;
    12221227
    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 )
    12241229                $status = __( 'Setup', 'buddypress' );
    12251230        else
    12261231                $status = __( 'Update', 'buddypress' );
     
    12831288 */
    12841289function bp_core_update_get_page_meta() {
    12851290        $page_ids = get_site_option( 'bp-pages' );
    1286        
     1291
    12871292        $is_enable_multiblog = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? true : false;
    12881293
    12891294        $page_blog_id = $is_enable_multiblog ? get_current_blog_id() : BP_ROOT_BLOG;
    1290        
     1295
    12911296        $blog_page_ids = !empty( $page_ids[$page_blog_id] ) ? $page_ids[$page_blog_id] : false;
    1292        
     1297
    12931298        return apply_filters( 'bp_core_update_get_page_meta', $blog_page_ids );
    12941299}
    12951300
     
    13011306 * @global $pagenow The current admin page
    13021307 */
    13031308function bp_core_update_nag() {
    1304         global $bp, $pagenow;
     1309        global $bp_wizard, $pagenow;
    13051310
     1311        if ( empty( $bp_wizard->setup_type ) )
     1312                return;
     1313
    13061314        if ( !is_super_admin() )
    13071315                return;
    13081316
     
    13111319
    13121320        $url = is_multisite() ? network_admin_url( 'admin.php?page=bp-wizard' ) : admin_url( 'admin.php?page=bp-wizard' );
    13131321
    1314         switch( $bp->maintenence_mode ) {
     1322        switch( $bp_wizard->setup_type ) {
    13151323                case 'update':
    13161324                        $msg = sprintf( __( 'BuddyPress has been updated! Please run the <a href="%s">update wizard</a>.', 'buddypress' ), $url );
    13171325                        break;