Skip to:
Content

BuddyPress.org

Changeset 6581


Ignore:
Timestamp:
12/10/2012 08:25:00 AM (12 years ago)
Author:
johnjamesjacoby
Message:

Legacy Group Forums:

  • Retire bbPress 1.1 group forums component.
  • Creates new "Retired" components group, where old components go to die.
  • Deprecate "Forums" settings tab; use Legacy Forums Setting instead.
  • Remove associated code for old forums admin UI.
  • See #4493.
  • Fixes #3598.
Location:
trunk
Files:
1 added
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/admin/bp-core-components.php

    r6558 r6581  
    5050function bp_core_admin_components_options() {
    5151
    52     // Load core functions, if needed
    53     if ( !function_exists( 'bp_get_option' ) )
    54         require( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' );
    55 
    5652    // Declare local variables
    5753    $deactivated_components = array();
     
    7874    );
    7975
     76    // Retired components
     77    $retired_components['forums'] = array(
     78        'title'       => __( 'Group Forums', 'buddypress' ),
     79        'description' => sprintf( __( 'BuddyPress Forums are retired. Use %s.', 'buddypress' ), '<a href="http://bbpress.org">bbPress</a>' )
     80    );
     81
    8082    // Optional core components
    8183    $optional_components = array(
     
    105107        ),
    106108        'forums'   => array(
    107             'title'       => __( 'Discussion Forums', 'buddypress' ),
    108             'description' => __( 'Site-wide and Group forums allow for focused, bulletin-board style conversations. Powered by bbPress.', 'buddypress' )
     109            'title'       => __( 'Group Forums (Legacy)', 'buddypress' ),
     110            'description' => __( 'Group forums allow for focused, bulletin-board style conversations.', 'buddypress' )
    109111        ),
    110112        'blogs'    => array(
     
    114116    );
    115117
     118    // Don't show Forums component in optional components if it's disabled
     119    if ( ! bp_is_active( 'forums' ) ) {
     120        unset( $optional_components['forums'] );
     121    }
     122   
    116123    // Add blogs tracking if multisite
    117124    if ( is_multisite() ) {
     
    130137            // Trim off namespace and filename
    131138            $trimmed = array();
    132             foreach ( (array) $deactivated_components as $component => $value ) {
     139            foreach ( array_keys( (array) $deactivated_components ) as $component ) {
    133140                $trimmed[] = str_replace( '.php', '', str_replace( 'bp-', '', $component ) );
    134141            }
    135142
    136143            // Loop through the optional components to create an active component array
    137             foreach ( (array) $optional_components as $ocomponent => $ovalue ) {
     144            foreach ( array_keys( (array) $optional_components ) as $ocomponent ) {
    138145                if ( !in_array( $ocomponent, $trimmed ) ) {
    139146                    $active_components[$ocomponent] = 1;
     
    176183            $current_components = $required_components;
    177184            break;
     185        case 'retired' :
     186            $current_components = $retired_components;
     187            break;
    178188    } ?>
    179189
     
    182192        <li><a href="<?php echo add_query_arg( array( 'page' => 'bp-components', 'action' => 'active'   ), bp_get_admin_url( $page ) ); ?>" <?php if ( $action === 'active'   ) : ?>class="current"<?php endif; ?>><?php printf( _n(  'Active <span class="count">(%s)</span>',   'Active <span class="count">(%s)</span>',   count( $active_components   ), 'buddypress' ), number_format_i18n( count( $active_components   ) ) ); ?></a> | </li>
    183193        <li><a href="<?php echo add_query_arg( array( 'page' => 'bp-components', 'action' => 'inactive' ), bp_get_admin_url( $page ) ); ?>" <?php if ( $action === 'inactive' ) : ?>class="current"<?php endif; ?>><?php printf( _n(  'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', count( $inactive_components ), 'buddypress' ), number_format_i18n( count( $inactive_components ) ) ); ?></a> | </li>
    184         <li><a href="<?php echo add_query_arg( array( 'page' => 'bp-components', 'action' => 'mustuse'  ), bp_get_admin_url( $page ) ); ?>" <?php if ( $action === 'mustuse'  ) : ?>class="current"<?php endif; ?>><?php printf( _n(  'Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', count( $required_components ), 'buddypress' ), number_format_i18n( count( $required_components ) ) ); ?></a></li>
     194        <li><a href="<?php echo add_query_arg( array( 'page' => 'bp-components', 'action' => 'mustuse'  ), bp_get_admin_url( $page ) ); ?>" <?php if ( $action === 'mustuse'  ) : ?>class="current"<?php endif; ?>><?php printf( _n(  'Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', count( $required_components ), 'buddypress' ), number_format_i18n( count( $required_components ) ) ); ?></a> | </li>
     195        <li><a href="<?php echo add_query_arg( array( 'page' => 'bp-components', 'action' => 'retired'  ), bp_get_admin_url( $page ) ); ?>" <?php if ( $action === 'retired'  ) : ?>class="current"<?php endif; ?>><?php printf( _n(  'Retired <span class="count">(%s)</span>',  'Retired <span class="count">(%s)</span>',  count( $retired_components ),  'buddypress' ), number_format_i18n( count( $retired_components  ) ) ); ?></a></li>
    185196    </ul>
    186197
     
    214225                    endif; ?>
    215226
    216                     <tr id="<?php echo $name; ?>" class="<?php echo $name . ' ' . $class; ?>">
     227                    <tr id="<?php echo esc_attr( $name ); ?>" class="<?php echo esc_attr( $name ) . ' ' . esc_attr( $class ); ?>">
    217228                        <th scope="row">
    218229
     
    265276 *
    266277 * @since BuddyPress (1.6)
    267  * @todo Use settings API
    268  * @global BuddyPress $bp
    269  * @return false On failure
     278 * @todo Use settings API when it supports saving network settings
     279 * @return If not time to save settings
    270280 */
    271281function bp_core_admin_components_settings_handler() {
    272     global $bp;
    273 
    274     if ( isset( $_POST['bp-admin-component-submit'] ) ) {
    275         if ( !check_admin_referer('bp-admin-component-setup') )
    276             return false;
    277 
    278         // Settings form submitted, now save the settings. First, set active components
    279         if ( isset( $_POST['bp_components'] ) ) {
    280             // Save settings and upgrade schema
    281             require_once( BP_PLUGIN_DIR . '/bp-core/admin/bp-core-schema.php' );
    282             $bp->active_components = stripslashes_deep( $_POST['bp_components'] );
    283             bp_core_install( $bp->active_components );
    284 
    285             bp_update_option( 'bp-active-components', $bp->active_components );
    286         }
    287 
    288         $base_url = bp_get_admin_url(  add_query_arg( array( 'page' => 'bp-components', 'updated' => 'true' ), 'admin.php' ) );
    289 
    290         wp_redirect( $base_url );
    291     }
     282   
     283    // Bail if not saving settings
     284    if ( ! isset( $_POST['bp-admin-component-submit'] ) )
     285        return;
     286
     287    // Bail if nonce fails
     288    if ( ! check_admin_referer( 'bp-admin-component-setup' ) )
     289        return;
     290
     291    // Settings form submitted, now save the settings. First, set active components
     292    if ( isset( $_POST['bp_components'] ) ) {
     293
     294        // Load up BuddyPress
     295        $bp = buddypress();
     296
     297        // Save settings and upgrade schema
     298        require_once( BP_PLUGIN_DIR . '/bp-core/admin/bp-core-schema.php' );
     299
     300        $bp->active_components = stripslashes_deep( $_POST['bp_components'] );
     301
     302        bp_core_install( $bp->active_components );
     303
     304        bp_update_option( 'bp-active-components', $bp->active_components );
     305    }
     306
     307    // Where are we redirecting to?
     308    $base_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components', 'updated' => 'true' ), 'admin.php' ) );
     309
     310    // Redirect
     311    wp_redirect( $base_url );
    292312}
    293313add_action( 'bp_admin_init', 'bp_core_admin_components_settings_handler' );
  • trunk/bp-core/admin/bp-core-functions.php

    r6579 r6581  
    225225    );
    226226
    227     // If forums component is active, add additional tab
    228     if ( bp_is_active( 'forums' ) ) {
    229         $tabs['3'] = array(
    230             'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bb-forums-setup'  ), 'admin.php' ) ),
    231             'name' => __( 'Forums', 'buddypress' )
    232         );
    233     }
    234 
    235227    // Loop through tabs and build navigation
    236     foreach( $tabs as $tab_id => $tab_data ) {
     228    foreach( array_values( $tabs ) as $tab_data ) {
    237229        $is_current = (bool) ( $tab_data['name'] == $active_tab );
    238230        $tab_class  = $is_current ? $active_class : $idle_class;
  • trunk/bp-core/bp-core-admin.php

    r6579 r6581  
    5050    public $js_url = '';
    5151
    52 
    5352    /** Methods ***************************************************************/
    5453
     
    7574     */
    7675    private function setup_globals() {
    77         $bp               = buddypress();
     76        $bp = buddypress();
     77
     78        // Paths and URLs
    7879        $this->admin_dir  = trailingslashit( $bp->plugin_dir  . 'bp-core/admin' ); // Admin path
    7980        $this->admin_url  = trailingslashit( $bp->plugin_url  . 'bp-core/admin' ); // Admin url
     
    8182        $this->css_url    = trailingslashit( $this->admin_url . 'css'           ); // Admin css URL
    8283        $this->js_url     = trailingslashit( $this->admin_url . 'js'            ); // Admin css URL
     84
     85        // Main settings page
     86        $this->settings_page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php';
    8387    }
    8488
     
    164168
    165169        $hooks = array();
    166         $page  = bp_core_do_network_admin()  ? 'settings.php' : 'options-general.php';
    167170
    168171        // Changed in BP 1.6 . See bp_core_admin_backpat_menu()
     
    187190        // Add the option pages
    188191        $hooks[] = add_submenu_page(
    189             $page,
     192            $this->settings_page,
    190193            __( 'BuddyPress Components', 'buddypress' ),
    191194            __( 'BuddyPress', 'buddypress' ),
     
    196199
    197200        $hooks[] = add_submenu_page(
    198             $page,
     201            $this->settings_page,
    199202            __( 'BuddyPress Pages', 'buddypress' ),
    200203            __( 'BuddyPress Pages', 'buddypress' ),
     
    205208
    206209        $hooks[] = add_submenu_page(
    207             $page,
     210            $this->settings_page,
    208211            __( 'BuddyPress Settings', 'buddypress' ),
    209212            __( 'BuddyPress Settings', 'buddypress' ),
     
    279282        /** Forums ************************************************************/
    280283
    281         if ( bp_is_active( 'forums' ) && bp_forums_is_installed_correctly() ) {
     284        if ( bp_is_active( 'forums' ) ) {
    282285
    283286            // Add the main section
    284             add_settings_section( 'bp_forums',        __( 'Forums Settings',       'buddypress' ), 'bp_admin_setting_callback_bbpress_section',       'buddypress'              );
     287            add_settings_section( 'bp_forums',        __( 'Legacy Group Forums',       'buddypress' ), 'bp_admin_setting_callback_bbpress_section',       'buddypress'              );
    285288
    286289            // Allow subscriptions setting
     
    323326            return $links;
    324327
    325         $page = 'bp-components';
    326         $text = __( 'Settings', 'buddypress' );
    327         $url  = bp_core_do_network_admin() ? network_admin_url( 'settings.php' ) : admin_url( 'options-general.php' );
    328 
    329328        // Add a few links to the existing links array
    330329        return array_merge( $links, array(
    331             'settings' => '<a href="' . add_query_arg( array( 'page' => $page      ), $url                      ) . '">' . $text                              . '</a>',
    332             'about'    => '<a href="' . add_query_arg( array( 'page' => 'bp-about' ), admin_url( 'index.php'  ) ) . '">' . esc_html__( 'About', 'buddypress' ) . '</a>'
     330            'settings' => '<a href="' . add_query_arg( array( 'page' => 'bp-components' ), bp_get_admin_url( $this->settings_page ) ) . '">' . esc_html__( 'Settings', 'buddypress' ) . '</a>',
     331            'about'    => '<a href="' . add_query_arg( array( 'page' => 'bp-about'      ), bp_get_admin_url( 'index.php'          ) ) . '">' . esc_html__( 'About',    'buddypress' ) . '</a>'
    333332        ) );
    334333    }
     
    340339     */
    341340    public function admin_head() {
    342         $settings_page  = bp_core_do_network_admin()  ? 'settings.php' : 'options-general.php';
    343341
    344342        // Settings pages
    345         remove_submenu_page( $settings_page, 'bb-forums-setup'  );
    346         remove_submenu_page( $settings_page, 'bp-page-settings' );
    347         remove_submenu_page( $settings_page, 'bp-settings'      );
     343        remove_submenu_page( $this->settings_page, 'bp-page-settings' );
     344        remove_submenu_page( $this->settings_page, 'bp-settings'      );
    348345
    349346        // About and Credits pages
     
    374371     */
    375372    public function about_screen() {
    376 
    377         // Switch page to use for settings
    378         $settings_page = bp_is_network_activated() ? 'settings.php' : 'options-general.php';
    379373
    380374        list( $display_version ) = explode( '-', bp_get_version() ); ?>
     
    462456     */
    463457    public function credits_screen() {
    464 
    465         // Switch page to use for settings
    466         $settings_page = bp_is_network_activated() ? 'settings.php' : 'options-general.php';
    467458
    468459        list( $display_version ) = explode( '-', bp_get_version() ); ?>
     
    578569
    579570            <div class="return-to-dashboard">
    580                 <a href="<?php echo esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), $settings_page ) ) ); ?>"><?php _e( 'Go to Community Settings' ); ?></a>
     571                <a href="<?php echo esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), $this->settings_page ) ) ); ?>"><?php _e( 'Go to Community Settings' ); ?></a>
    581572            </div>
    582573
  • trunk/bp-core/bp-core-update.php

    r6579 r6581  
    144144 */
    145145function bp_version_bump() {
    146     $db_version = bp_get_db_version();
    147     bp_update_option( '_bp_db_version', $db_version );
     146    bp_update_option( '_bp_db_version', bp_get_db_version() );
    148147}
    149148
  • trunk/bp-forums/bp-forums-loader.php

    r6342 r6581  
    3535     *
    3636     * @since BuddyPress (1.5)
    37      * @global BuddyPress $bp The one true BuddyPress instance
    3837     */
    3938    function setup_globals() {
    40         global $bp;
     39        $bp = buddypress();
    4140
    4241        // Define the parent forum ID
     
    8079        );
    8180
    82         // Admin area
    83         if ( is_admin() )
    84             $includes[] = 'admin';
    85 
    8681        // bbPress stand-alone
    8782        if ( !defined( 'BB_PATH' ) )
     
    9388    /**
    9489     * Setup BuddyBar navigation
    95      *
    96      * @global BuddyPress $bp The one true BuddyPress instance
    9790     */
    9891    function setup_nav() {
    99         global $bp;
    10092
    10193        // Stop if forums haven't been set up yet
     
    151143        );
    152144
    153         // Favorite forums items. Disabled until future release.
    154         /*
    155         $sub_nav[] = array(
    156             'name'            => __( 'Favorites', 'buddypress' ),
    157             'slug'            => 'favorites',
    158             'parent_url'      => $forums_link,
    159             'parent_slug'     => $this->slug,
    160             'screen_function' => 'bp_member_forums_screen_favorites',
    161             'position'        => 60,
    162             'item_css_id'     => 'favorites'
    163         );
    164         */
    165 
    166145        parent::setup_nav( $main_nav, $sub_nav );
    167146    }
     
    169148    /**
    170149     * Set up the Toolbar
    171      *
    172      * @global BuddyPress $bp The one true BuddyPress instance
    173150     */
    174151    function setup_admin_bar() {
    175         global $bp;
    176152
    177153        // Prevent debug notices
     
    186162            // Add the "My Account" sub menus
    187163            $wp_admin_nav[] = array(
    188                 'parent' => $bp->my_account_menu_id,
     164                'parent' => buddypress()->my_account_menu_id,
    189165                'id'     => 'my-account-' . $this->id,
    190166                'title'  => __( 'Forums', 'buddypress' ),
     
    222198    /**
    223199     * Sets up the title for pages and <title>
    224      *
    225      * @global BuddyPress $bp The one true BuddyPress instance
    226200     */
    227201    function setup_title() {
    228         global $bp;
     202        $bp = buddypress();
    229203
    230204        // Adjust title based on view
     
    247221
    248222function bp_setup_forums() {
    249     global $bp;
    250 
    251     $bp->forums = new BP_Forums_Component();
     223    buddypress()->forums = new BP_Forums_Component();
    252224}
    253225add_action( 'bp_setup_components', 'bp_setup_forums', 6 );
  • trunk/bp-forums/deprecated/1.6.php

    r6342 r6581  
    66 * This file contains all the deprecated functions for BuddyPress forums since
    77 * version 1.6. This was a major update for the forums component, moving from
    8  * bbPress 1.1 to bbPress 2.1.
     8 * bbPress 1.x to bbPress 2.x.
    99 *
    1010 * @package BuddyPress
     
    4242        else : ?>
    4343
    44             <div style="width: 45%; float: left; margin-top: 20px;">
     44            <div>
    4545                <h3><?php _e( 'Forums for Groups', 'buddypress' ) ?></h3>
    4646
     
    5858                <div>
    5959                    <a class="button button-primary" href="<?php echo $action ?>"><?php _e( 'Reinstall Group Forums', 'buddypress' ) ?></a> &nbsp;
    60                 </div>
    61             </div>
    62 
    63             <div style="width: 45%; float: left; margin: 20px 0 20px 20px; padding: 0 20px 20px 20px; border: 1px solid #ddd; background-color: #fff;">
    64                 <h3><?php _e( 'New! Site Wide Forums', 'buddypress' ) ?></h3>
    65                 <p><?php _e( 'Your site will have central forums that are not isolated to any specific group. Choose this if you\'d like to have a central forum area for your members.', 'buddypress' ) ?></p>
    66                 <p class="description"><?php _e( 'You may activate both Group and Site Wide forums, but this may create a poor experience for your members.', 'buddypress' ) ?></p>
    67 
    68                 <h4 style="margin-bottom: 10px;"><?php _e( 'Features', 'buddypress' ); ?></h4>
    69                 <ul class="description" style="list-style: square; margin-left: 30px;">
    70                     <li><?php _e( 'Central Discussion Area',     'buddypress' ); ?></p></li>
    71                     <li><?php _e( 'Forum Plugins Available',     'buddypress' ); ?></p></li>
    72                     <li><?php _e( 'Activity Stream Integration', 'buddypress' ); ?></p></li>
    73                     <li><?php _e( '@ Mention Integration',       'buddypress' ); ?></p></li>
    74                 </ul>
    75                 <div>
    76                     <a class="button thickbox button-primary" href="<?php bp_admin_url( add_query_arg( array( 'tab' => 'plugin-information', 'plugin' => 'bbpress', 'TB_iframe' => 'true', 'width' => '640', 'height' => '500' ), 'plugin-install.php' ) ); ?>"><?php _e( 'Install Site Wide Forums', 'buddypress' ) ?></a> &nbsp;
    7760                </div>
    7861            </div>
     
    159142            ?>
    160143
    161                 <div style="width: 45%; float: left;  margin-top: 20px;">
     144                <div>
    162145                    <h3><?php _e( 'Forums for Groups', 'buddypress' ) ?></h3>
    163146
     
    179162                </div>
    180163
    181                 <div style="width: 45%; float: left; margin: 20px 0 20px 20px; padding: 0 20px 20px 20px; border: 1px solid #ddd; background-color: #fff;">
    182                     <h3><?php _e( 'New! Site Wide Forums', 'buddypress' ) ?></h3>
    183                     <p><?php _e( 'Your site will have central forums that are not isolated to any specific group. Choose this if you\'d like to have a central forum area for your members.', 'buddypress' ) ?></p>
    184                     <p class="description"><?php _e( 'You may activate both Group and Site Wide forums, but this may create a poor experience for your members.', 'buddypress' ) ?></p>
    185 
    186                     <h4 style="margin-bottom: 10px;"><?php _e( 'Features', 'buddypress' ); ?></h4>
    187                     <ul class="description" style="list-style: square; margin-left: 30px;">
    188                         <li><?php _e( 'Central Discussion Area',     'buddypress' ); ?></p></li>
    189                         <li><?php _e( 'Forum Plugins Available',     'buddypress' ); ?></p></li>
    190                         <li><?php _e( 'Activity Stream Integration', 'buddypress' ); ?></p></li>
    191                         <li><?php _e( '@ Mention Integration',       'buddypress' ); ?></p></li>
    192                     </ul>
    193                     <div>
    194                         <a class="button thickbox button-primary" href="<?php bp_admin_url( add_query_arg( array( 'tab' => 'plugin-information', 'plugin' => 'bbpress', 'TB_iframe' => 'true', 'width' => '640', 'height' => '500' ), 'plugin-install.php' ) ); ?>"><?php _e( 'Install Site Wide Forums', 'buddypress' ) ?></a> &nbsp;
    195                     </div>
    196                 </div>
    197 
    198164            <?php }
    199165        break;
Note: See TracChangeset for help on using the changeset viewer.