Skip to:
Content

BuddyPress.org

Ticket #3041: 3041.patch

File 3041.patch, 6.4 KB (added by johnpbloch, 14 years ago)

This patch creates a function to return all available components (disabled and enabled); when disabling components, we need to check against a centralized list of components to know what should be disabled.

  • bp-core/admin/bp-core-admin.php

     
    232232        if ( isset( $_POST['bp-admin-component-submit'] ) && isset( $_POST['bp_components'] ) ) {
    233233                if ( !check_admin_referer('bp-admin-component-setup') )
    234234                        return false;
    235 
    236                 // Settings form submitted, now save the settings. First, set active components
    237                 foreach ( (array)$_POST['bp_components'] as $key => $value ) {
    238                         if ( !(int) $value )
    239                                 $disabled[$key] = 1;
     235               
     236                $optional_components = bp_core_admin_components_available('keys');
     237               
     238                $disabled = array();
     239                foreach( $optional_components as $component ){
     240                        if( !isset( $_POST['bp_components']["bp-{$component}.php"] ) )
     241                                $disabled["bp-{$component}.php"] = 1;
    240242                }
     243               
    241244                update_site_option( 'bp-deactivated-components', $disabled );
    242245               
    243246                // Then, update the directory pages
     
    297300       
    298301        $disabled_components = apply_filters( 'bp_deactivated_components', get_site_option( 'bp-deactivated-components' ) );
    299302       
    300         // An array of strings looped over to create component setup markup
    301         $optional_components = array(
    302                 'xprofile' => array(
    303                         'title'         => __( "Extended Profiles", 'buddypress' ),
    304                         'description'   => __( "Fully editable profile fields allow you to define the fields users can fill in to describe themselves. Tailor profile fields to suit your audience.", 'buddypress' )
    305                 ),
    306                 'friends' => array(
    307                         'title'         => __( "Friend Connections", 'buddypress' ),
    308                         'description'   => __( "Let your users make connections so they can track the activity of others, or filter on only those users they care about the most.", 'buddypress' )
    309                 ),
    310                 'messages' => array(
    311                         'title'         => __( "Private Messaging", 'buddypress' ),
    312                         'description'   => __( "Private messaging will allow your users to talk to each other directly, and in private. Not just limited to one on one discussions, your users can send messages to multiple recipients.", 'buddypress' )
    313                 ),
    314                 'activity' => array(
    315                         'title'         => __( "Activity Streams", 'buddypress' ),
    316                         'description'   => __( "Global, personal and group activity streams with threaded commenting, direct posting, favoriting and @mentions. All with full RSS feed and email notification support.", 'buddypress' )
    317                 ),
    318                 'groups' => array(
    319                         'title'         => __( "Extensible Groups", 'buddypress' ),
    320                         'description'   => __( "Powerful public, private or hidden groups allow your users to break the discussion down into specific topics with a separate activity stream and member listing.", 'buddypress' )
    321                 ),
    322                 'forums' => array(
    323                         'title'         => __( "Discussion Forums", 'buddypress' ),
    324                         'description'   => __( "Full powered discussion forums built directly into groups allow for more conventional in-depth conversations. NOTE: This will require an extra (but easy) setup step.", 'buddypress' )
    325                 )
    326         );
     303        // Get the array of strings looped over to create component setup markup
     304        $optional_components = bp_core_admin_components_available();
    327305       
    328         if ( is_multisite() ) {
    329                 $optional_components['blogs'] = array(
    330                         'title'         => __( "Blog Tracking", 'buddypress' ),
    331                         'description'   => __( "Track new blogs, new posts and new comments across your entire blog network.", 'buddypress' )
    332                 );
    333         }
    334        
    335306        ?>
    336307       
    337308        <?php /* The setup wizard uses different, more descriptive text here */ ?>
     
    370341}
    371342
    372343/**
     344 * Returns the available component options in the requested format
     345 *
     346 * @package BuddyPress Core
     347 * @since 1.3
     348 *
     349 * @param string $format The requested format; 'keys' will return just the keys available, anything else will return a multidimensional array with keys, title, and description.
     350 * @return array
     351 */
     352function bp_core_admin_components_available( $format = '' ){
     353        $format = 'keys' == $format ? 'keys' : 'full';
     354        if( $format == 'full' ){
     355       
     356                $optional_components = array(
     357                        'xprofile' => array(
     358                                'title'         => __( "Extended Profiles", 'buddypress' ),
     359                                'description'   => __( "Fully editable profile fields allow you to define the fields users can fill in to describe themselves. Tailor profile fields to suit your audience.", 'buddypress' )
     360                        ),
     361                        'friends' => array(
     362                                'title'         => __( "Friend Connections", 'buddypress' ),
     363                                'description'   => __( "Let your users make connections so they can track the activity of others, or filter on only those users they care about the most.", 'buddypress' )
     364                        ),
     365                        'messages' => array(
     366                                'title'         => __( "Private Messaging", 'buddypress' ),
     367                                'description'   => __( "Private messaging will allow your users to talk to each other directly, and in private. Not just limited to one on one discussions, your users can send messages to multiple recipients.", 'buddypress' )
     368                        ),
     369                        'activity' => array(
     370                                'title'         => __( "Activity Streams", 'buddypress' ),
     371                                'description'   => __( "Global, personal and group activity streams with threaded commenting, direct posting, favoriting and @mentions. All with full RSS feed and email notification support.", 'buddypress' )
     372                        ),
     373                        'groups' => array(
     374                                'title'         => __( "Extensible Groups", 'buddypress' ),
     375                                'description'   => __( "Powerful public, private or hidden groups allow your users to break the discussion down into specific topics with a separate activity stream and member listing.", 'buddypress' )
     376                        ),
     377                        'forums' => array(
     378                                'title'         => __( "Discussion Forums", 'buddypress' ),
     379                                'description'   => __( "Full powered discussion forums built directly into groups allow for more conventional in-depth conversations. NOTE: This will require an extra (but easy) setup step.", 'buddypress' )
     380                        )
     381                );
     382               
     383                if ( is_multisite() ) {
     384                        $optional_components['blogs'] = array(
     385                                'title'         => __( "Blog Tracking", 'buddypress' ),
     386                                'description'   => __( "Track new blogs, new posts and new comments across your entire blog network.", 'buddypress' )
     387                        );
     388                }
     389               
     390        } else {
     391       
     392                $optional_components = array(
     393                        'xprofile',
     394                        'friends',
     395                        'messages',
     396                        'activity',
     397                        'groups',
     398                        'forums'
     399                );
     400               
     401                if ( is_multisite() ) {
     402                        $optional_components[] = 'blogs';
     403                }
     404       
     405        }
     406       
     407        return apply_filters( 'bp_core_admin_components_available', $optional_components, $format );
     408       
     409}
     410
     411/**
    373412 * Creates reusable markup for page setup on the Components and Pages dashboard panel.
    374413 *
    375414 * This markup has been abstracted so that it can be used both during the setup wizard as well as