Skip to:
Content

BuddyPress.org

Ticket #3153: 3153.006.diff

File 3153.006.diff, 14.4 KB (added by cnorris23, 15 years ago)
  • bp-core/bp-core-loader.php

     
    5353
    5454                /** Components ********************************************************/
    5555
    56                 // Set the included and optional components
    57                 $bp->optional_components    = apply_filters( 'bp_optional_components',    array( 'activity', 'blogs', 'forums', 'friends', 'groups', 'messages', 'settings', 'xprofile', ) );
     56                // Set the included and optional components.
     57                $bp->optional_components = array( 'activity', 'forums', 'friends', 'groups', 'messages', 'settings', 'xprofile', );
    5858
     59                // Blogs component only available for multisite
     60                if ( is_multisite() )
     61                        $bp->optional_components[] = 'blogs';
     62
     63                $bp->optional_components    = apply_filters( 'bp_optional_components', $bp->optional_components );
     64
    5965                // Set the required components
    60                 $bp->required_components    = apply_filters( 'bp_required_components',    array( 'members', ) );
     66                $bp->required_components    = apply_filters( 'bp_required_components', array( 'members' ) );
    6167
    6268                // Get a list of activated components
    6369                if ( $active_components = get_site_option( 'bp-active-components' ) ) {
    64                         $bp->active_components      = apply_filters( 'bp_active_components',      $active_components );
     70                        $bp->active_components      = apply_filters( 'bp_active_components', $active_components );
    6571                        $bp->deactivated_components = apply_filters( 'bp_deactivated_components', array_values( array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_keys( $bp->active_components ) ) ) );
    6672
    6773                // Pre 1.3 Backwards compatibility
    6874                } elseif ( $deactivated_components = get_site_option( 'bp-deactivated-components' ) ) {
    6975                        // Trim off namespace and filename
    70                         foreach ( $deactivated_components as $component => $value )
     76                        foreach ( (array) $deactivated_components as $component => $value )
    7177                                $trimmed[] = str_replace( '.php', '', str_replace( 'bp-', '', $component ) );
    7278
    7379                        // Set globals
    7480                        $bp->deactivated_components = apply_filters( 'bp_deactivated_components', $trimmed );
    7581
    7682                        // Setup the active components
    77                         $active_components          = array_flip( array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_values( $bp->deactivated_components ) ) );
     83                        $active_components     = array_flip( array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_values( $bp->deactivated_components ) ) );
    7884
    7985                        // Loop through active components and set the values
    80                         foreach( $active_components as $component => $value )
    81                                 $bp->active_components[$component] = 1;
     86                        $bp->active_components = array_map( '__return_true', $active_components );
    8287
    8388                        // Set the active component global
    84                         $bp->active_components      = apply_filters( 'bp_active_components', $bp->active_components );
     89                        $bp->active_components = apply_filters( 'bp_active_components', $bp->active_components );
     90
     91                // Default to all components active
     92                } else {
     93                        // Set globals
     94                        $bp->deactivated_components = array();
     95
     96                        // Setup the active components
     97                        $active_components     = array_flip( array_values( array_merge( $bp->optional_components, $bp->required_components ) ) );
     98
     99                        // Loop through active components and set the values
     100                        $bp->active_components = array_map( '__return_true', $active_components );
     101
     102                        // Set the active component global
     103                        $bp->active_components = apply_filters( 'bp_active_components', $bp->active_components );
    85104                }
    86105
    87106                // Loop through optional components
     
    215234// Initialize the BuddyPress Core
    216235$bp->core = new BP_Core();
    217236
    218 ?>
     237?>
     238 No newline at end of file
  • bp-core/bp-core-functions.php

     
    307307                return;
    308308
    309309        // Don't show these messages during setup or upgrade
    310         if ( isset( $bp->maintenence_mode ) )
     310        if ( isset( $bp->maintenance_mode ) )
    311311                return;
    312312
    313313        /**
     
    11071107
    11081108        do_action( 'bp_do_404', $redirect );
    11091109
    1110         $wp_query->set_404();
    1111         status_header( 404 );
     1110        $wp_query->set_404();
     1111        status_header( 404 );
    11121112        nocache_headers();
    11131113
    11141114        if ( 'remove_canonical_direct' == $redirect )
  • 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                                 }
    26                         }
     17                global $bp;
     18
     19                // Get current DB version
     20                $this->database_version = !empty( $bp->database_version ) ? (int) $bp->database_version : 0;
     21
     22                if ( !empty( $bp->is_network_activate ) ) {
     23                        $this->is_network_activate = $bp->is_network_activate;
     24
     25                } elseif ( !$this->current_step() ) {
     26                        setcookie( 'bp-wizard-step', 0, time() + 60 * 60 * 24, COOKIEPATH );
     27                        $_COOKIE['bp-wizard-step'] = 0;
    2728                }
    2829
    2930                $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';
     31                $this->setup_type   = !empty( $bp->maintenance_mode ) ? $bp->maintenance_mode : '';
    3132                $this->current_step = $this->current_step();
    3233
     34                // Remove the admin menu while we update/install
     35                remove_action( bp_core_admin_hook(), 'bp_core_add_admin_menu', 9 );
     36
    3337                // Call the save method that will save data and modify $current_step
    3438                if ( isset( $_POST['save'] ) )
    3539                        $this->save( $_POST['save'] );
     
    7175                        if ( $this->is_network_activate )
    7276                                $steps[] = __( 'Multisite Update', 'buddypress' );
    7377
    74                         if ( $this->database_version < $this->new_version )
     78                        if ( $this->database_version < (int) $this->new_version )
    7579                                $steps[] = __( 'Database Update', 'buddypress' );
    7680
    77                         if ( $this->database_version < 1225 || !bp_core_get_page_meta() )
     81                        if ( $this->database_version < 1801 || !bp_core_get_page_meta() )
    7882                                $steps[] = __( 'Pages', 'buddypress' );
    7983
    8084                        $steps[] = __( 'Finish', 'buddypress' );
     
    264268                        $blogs_slug = 'blogs';
    265269
    266270                // Call up old bp-pages to see if a page has been previously linked to Blogs
    267                 $page_blog_id           = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG;
    268                 $existing_pages_data    = get_blog_option( $page_blog_id, 'bp-pages' );
    269                 $existing_pages         = $existing_pages_data[$page_blog_id];
     271                $page_blog_id        = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG;
     272                $existing_pages_data = get_blog_option( $page_blog_id, 'bp-pages' );
     273                $existing_pages      = $existing_pages_data[$page_blog_id];
    270274
    271275                if ( !empty( $existing_pages['blogs'] ) )
    272276                        $existing_blog_page = '&selected=' . $existing_pages['blogs'];
     
    718722        /** Save Step Methods *****************************************************/
    719723
    720724        function step_db_update_save() {
     725                global $bp;
     726
    721727                if ( isset( $_POST['submit'] ) ) {
    722728                        check_admin_referer( 'bpwizard_db_update' );
    723729
    724730                        // Run the schema install to update tables
    725731                        bp_core_install();
    726732
    727                         if ( $this->database_version < 1225 )
     733                        if ( $this->database_version < 1801 )
    728734                                $this->update_1_3();
    729735
     736                        // Update the active components option early if we're updating
     737                        if ( 'update' == $this->setup_type )
     738                                update_site_option( 'bp-active-components', $bp->active_components );
     739
    730740                        return true;
    731741                }
    732742
     
    739749                if ( isset( $_POST['submit'] ) ) {
    740750                        check_admin_referer( 'bpwizard_ms_update' );
    741751
    742                         if ( !$active_components = get_option( 'bp-active-components' ) )
     752                        if ( !$active_components = get_site_option( 'bp-active-components' ) )
    743753                                $active_components = array();
    744754
    745755                        // Transfer important settings from blog options to site options
    746756                        $options = array(
    747                                 'bp-db-version'         => $this->database_version,
    748                                 'bp-active-components'  => $active_components,
    749                                 'avatar-default'        => get_option( 'avatar-default' )
     757                                'bp-db-version'        => $this->database_version,
     758                                'bp-active-components' => $active_components,
     759                                'avatar-default'       => get_option( 'avatar-default' )
    750760                        );
    751761                        bp_core_activate_site_options( $options );
    752762
     
    758768                                        switch_to_blog( BP_ROOT_BLOG );
    759769
    760770                                // Move bp-pages data from the blog options table to site options
    761                                 $page_blog_id           = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG;
    762                                 $existing_pages_data    = get_blog_option( $page_blog_id, 'bp-pages' );
    763                                 $existing_pages         = $existing_pages_data[$page_blog_id];
     771                                $page_blog_id        = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG;
     772                                $existing_pages_data = get_blog_option( $page_blog_id, 'bp-pages' );
     773                                $existing_pages      = $existing_pages_data[$page_blog_id];
    764774
    765                                 $bp_pages               = $this->setup_pages( (array)$_POST['bp_pages'] );
    766                                 $bp_pages               = array_merge( (array)$existing_pages, (array)$bp_pages );
     775                                $bp_pages            = $this->setup_pages( (array)$_POST['bp_pages'] );
     776                                $bp_pages            = array_merge( (array)$existing_pages, (array)$bp_pages );
    767777
    768778                                $existing_pages_data[$page_blog_id] = $bp_pages;
    769779
     
    821831                        foreach ( (array)$existing_pages as $page_id )
    822832                                wp_delete_post( $page_id, true );
    823833
    824                         $blog_pages     = $this->setup_pages( (array)$_POST['bp_pages'] );
    825                         $page_blog_id   = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG;
    826                         $bp_pages       = array( $page_blog_id => $blog_pages );
     834                        $blog_pages   = $this->setup_pages( (array)$_POST['bp_pages'] );
     835                        $page_blog_id = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG;
     836                        $bp_pages     = array( $page_blog_id => $blog_pages );
    827837
    828838                        update_site_option( 'bp-pages', $bp_pages );
    829839
     
    9941004                        check_admin_referer( 'bpwizard_finish' );
    9951005
    9961006                        // Update the DB version in the database
    997                         update_site_option( 'bp-db-version', constant( 'BP_DB_VERSION' ) );
     1007                        update_site_option( 'bp-db-version', $this->new_version );
    9981008                        delete_site_option( 'bp-core-db-version' );
    9991009
    10001010                        // Delete the setup cookie
     
    11801190 * @uses add_submenu_page() WP function to add a submenu item
    11811191 */
    11821192function bp_core_update_add_admin_menu() {
    1183         global $bp, $bp_wizard;
     1193        global $bp_wizard;
    11841194
    11851195        // Only load this version of the menu if this is an upgrade or a new installation
    1186         if ( empty( $bp->maintenence_mode ) )
     1196        if ( empty( $bp_wizard->setup_type ) )
    11871197                return false;
    11881198
    11891199        if ( !current_user_can( 'activate_plugins' ) )
    11901200                return false;
    11911201
    1192         if ( '' == get_site_option( 'bp-db-version' ) && !(int)get_site_option( 'bp-core-db-version' ) && !$bp_wizard->is_network_activate )
     1202        if ( 'install' == $bp_wizard->setup_type )
    11931203                $status = __( 'Setup', 'buddypress' );
    11941204        else
    11951205                $status = __( 'Update', 'buddypress' );
     
    12561266
    12571267function bp_core_update_do_network_admin() {
    12581268        $do_network_admin = false;
    1259 
     1269
    12601270        if ( is_multisite() && ( !defined( 'BP_ENABLE_MULTIBLOG' ) || !BP_ENABLE_MULTIBLOG ) )
    12611271                $do_network_admin = true;
    1262 
     1272
    12631273        return apply_filters( 'bp_core_do_network_admin', $do_network_admin );
    12641274}
    12651275
    12661276function bp_core_update_admin_hook() {
    12671277        $hook = bp_core_update_do_network_admin() ? 'network_admin_menu' : 'admin_menu';
    1268 
     1278
    12691279        return apply_filters( 'bp_core_admin_hook', $hook );
    12701280}
    12711281
     
    12771287 * @global $pagenow The current admin page
    12781288 */
    12791289function bp_core_update_nag() {
    1280         global $bp, $pagenow;
     1290        global $bp_wizard, $pagenow;
    12811291
     1292        if ( empty( $bp_wizard->setup_type ) )
     1293                return;
     1294
    12821295        if ( !is_super_admin() )
    12831296                return;
    12841297
     
    12871300
    12881301        $url = bp_core_update_do_network_admin() ? network_admin_url( 'admin.php?page=bp-wizard' ) : admin_url( 'admin.php?page=bp-wizard' );
    12891302
    1290         switch( $bp->maintenence_mode ) {
     1303        switch( $bp_wizard->setup_type ) {
    12911304                case 'update':
    12921305                        $msg = sprintf( __( 'BuddyPress has been updated! Please run the <a href="%s">update wizard</a>.', 'buddypress' ), $url );
    12931306                        break;
  • bp-loader.php

     
    5959// Test to see whether this is a new installation or an upgraded version of BuddyPress
    6060if ( !$bp->database_version = get_site_option( 'bp-db-version' ) ) {
    6161        if ( $bp->database_version = get_option( 'bp-db-version' ) ) {
    62                 $bp->is_ms_activate = 1;
     62                $bp->is_network_activate = 1;
    6363        } else {
    6464                $bp->database_version = get_site_option( 'bp-core-db-version' );  // BP 1.2 option
    6565        }
     
    6767
    6868// This is a new installation.
    6969if ( empty( $bp->database_version ) ) {
    70         $bp->maintenence_mode = 'install';
     70        $bp->maintenance_mode = 'install';
    7171        require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-update.php' );
    7272
    7373// There is a previous installation
     
    7676        require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/bp-core-loader.php' );
    7777
    7878        // Check if an update is required
    79         if ( (int)$bp->database_version < (int)constant( 'BP_DB_VERSION' ) || isset( $bp->is_ms_activate ) ) {
    80                 $bp->maintenence_mode = 'update';
     79        if ( (int)$bp->database_version < (int)constant( 'BP_DB_VERSION' ) || isset( $bp->is_network_activate ) ) {
     80                $bp->maintenance_mode = 'update';
    8181                require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-update.php' );
    8282        }
    8383}
     
    8686
    8787if ( !function_exists( 'bp_loader_activate' ) ) :
    8888/**
    89  * Defines BP's activation routine.
    90  *
    91  * Most of BP's crucial setup is handled by the setup wizard. This function takes care of some
    92  * issues with incompatible legacy themes, and provides a hook for other functions to know that
    93  * BP has been activated.
    94  *
    95  * @package BuddyPress Core
    96 */
     89 * Defines BP's activation routine.
     90 *
     91 * Most of BP's crucial setup is handled by the setup wizard. This function takes care of some
     92 * issues with incompatible legacy themes, and provides a hook for other functions to know that
     93 * BP has been activated.
     94 *
     95 * @package BuddyPress Core
     96*/
    9797function bp_loader_activate() {
    9898        // Force refresh theme roots.
    9999        delete_site_transient( 'theme_roots' );