Skip to:
Content

BuddyPress.org

Ticket #3026: 3026.patch

File 3026.patch, 5.1 KB (added by boonebgorges, 13 years ago)
  • bp-core/admin/bp-core-admin.php

    function bp_core_admin_settings() { 
    113113                <?php if ( isset( $_POST['bp-admin'] ) ) : ?>
    114114
    115115                        <div id="message" class="updated fade">
    116                                 <p><?php _e( 'Settings Saved', 'buddypress' ); ?></p>
     116                                <p><?php _e( 'Settings saved.', 'buddypress' ); ?></p>
    117117                        </div>
    118118
    119119                <?php endif; ?>
    function bp_core_admin_settings() { 
    203203<?php
    204204}
    205205
     206/**
     207 * Saves settings data submitted from the Components panel
     208 *
     209 * @package BuddyPress Core
     210 * @since 1.3
     211 * @uses bp_core_update_page_meta() To save bp_pages data
     212 */
    206213function bp_core_admin_component_setup_handler() {
    207214        global $wpdb, $bp;
    208215
    function bp_core_admin_component_setup_handler() { 
    210217                if ( !check_admin_referer('bp-admin-component-setup') )
    211218                        return false;
    212219
    213                 // Settings form submitted, now save the settings. First, set active components
     220                // Check to see which components have just been disabled or enabled
     221                // We do this first so we'll still have access to old component settings data
     222                $previous_components    = get_site_option( 'bp-active-components' ) ? get_site_option( 'bp-active-components' ) : array();
     223                $new_components         = isset( $_POST['bp_components'] ) ? $_POST['bp_components'] : array();
     224
     225                $activated      = array_diff_assoc( $new_components, $previous_components );
     226                $deactivated    = array_diff_assoc( $previous_components, $new_components );
     227
     228                // Create the query arguments.
     229                // Translated component names are available now only for deactivated components
     230                $deactivated_names = array();
     231                foreach ( $deactivated as $component_id => $a ) {
     232                        if ( !empty( $bp->{$component_id}->name ) )
     233                                $deactivated_names[] = $bp->{$component_id}->name;
     234                }
     235                $deactivated_qs = urlencode( implode( ',', $deactivated_names ) );
     236               
     237                // We'll get the activated component names after the redirect
     238                $activated_qs   = urlencode( implode( ',', array_keys( $activated ) ) );
     239
     240                // Now save the settings. First, set active components
    214241                if ( isset( $_POST['bp_components'] ) ) {
    215242                        $bp->active_components = stripslashes_deep( $_POST['bp_components'] );
    216243                        update_site_option( 'bp-active-components', $bp->active_components );
    function bp_core_admin_component_setup_handler() { 
    227254                        bp_core_update_page_meta( $directory_pages );
    228255                }
    229256
    230                 wp_redirect( network_admin_url( add_query_arg( array( 'page' => 'bp-general-settings', 'updated' => 'true' ), 'admin.php' ) ) );
     257                $redirect = network_admin_url( add_query_arg( array( 'page' => 'bp-general-settings', 'updated' => 'true' ), 'admin.php' ) );
     258
     259                if ( $activated_qs )
     260                        $redirect = add_query_arg( array( 'activated' => $activated_qs ), $redirect );
     261               
     262                if ( $deactivated_qs )
     263                        $redirect = add_query_arg( array( 'deactivated' => $deactivated_qs ), $redirect );
     264
     265                wp_redirect( $redirect );
    231266        }
    232267}
    233268add_action( 'admin_init', 'bp_core_admin_component_setup_handler' );
    234269
    235270/**
    236  * Renders the Component Setup admin panel.
     271 * Renders the Components admin panel.
    237272 *
    238273 * @package BuddyPress Core
    239274 * @since {@internal Unknown}}
    240275 * @uses bp_core_admin_component_options()
    241276 */
    242277function bp_core_admin_component_setup() {
     278        global $bp;
     279       
     280        if ( isset( $_GET['activated'] ) ) {
     281                $activated_component_ids = explode( ',', urldecode( $_GET['activated'] ) );
     282               
     283                // Translated component names for activated components are only available now,
     284                // after activation
     285                $activated_components = array();
     286                foreach ( $activated_component_ids as $component_id ) {
     287                        if ( !empty( $bp->{$component_id}->name ) )
     288                                $activated_components[] = $bp->{$component_id}->name;
     289                }
     290        }
     291
     292        if ( isset( $_GET['deactivated'] ) ) {
     293                // Deactivated component names have already come through the query string
     294                $deactivated_components = explode( ',', urldecode( $_GET['deactivated'] ) );
     295        }
    243296?>
    244297
    245298        <div class="wrap">
    function bp_core_admin_component_setup() { 
    252305
    253306                        <div id="message" class="updated fade">
    254307
    255                                 <p><?php _e( 'Settings Saved', 'buddypress' ); ?></p>
     308                                <p><?php _e( 'Settings saved.', 'buddypress' ); ?></p>
     309                               
     310                                <?php if ( !empty( $activated_components ) ) : ?>
     311                                        <p><?php printf( __( '<strong>Newly activated components:</strong> You have just activated the following components: <em>%1$s</em>. Finish setting them up under Directory Pages below. Note: you may need to <a href="%2$s">create a page for each newly activated component</a>, and then return to this screen to complete setup.', 'buddypress' ), implode( ', ', $activated_components ), admin_url( 'post-new.php?post_type=page' ) ) ?></p>
     312                                <?php endif ?>
     313                               
     314                                <?php if ( !empty( $deactivated_components ) ) : ?>
     315                                        <p><?php printf( __( '<strong>Newly deactivated components:</strong> You have just deactivated the following components: <em>%1$s</em>. You may want to <a href="%2$s">delete or unpublish the old, unused directory pages</a>, so that they don\'t clutter your navigation.', 'buddypress' ), implode( ', ', $deactivated_components ), admin_url( 'edit.php?post_type=page' ) ) ?></p>
     316                                <?php endif ?>
    256317
    257318                        </div>
    258319