Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/24/2011 05:12:13 PM (15 years ago)
Author:
boonebgorges
Message:

Ensures that upgrades from BP 1.2.x are recognized as upgrades, and previous component settings are saved. Fixes #3153. Props cnorris23

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-loader.php

    r4488 r4556  
    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', );
     58
     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 );
    5864
    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
     
    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
     
    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
Note: See TracChangeset for help on using the changeset viewer.