Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/08/2017 12:22:09 AM (7 years ago)
Author:
djpaul
Message:

Retire Legacy Forums.

"Legacy Forums" is what we now call the bundled version of bbPress 1 that has shipped with BuddyPress for over nine years. The Legacy Forums codebase/features are many years stagnant, and it has been almost completely hidden from the UI for the past five years.

Legacy Forums were replaced by bbPress 2, which is its own plugin, and we've been promoting its integration with BuddyPress for a long time. Most significantly, bbPress 1 only runs on WordPress versions older than 4.7, because of a BackPress conflict (which is nested inside bbPress 1) with WordPress 4.7's WP_Taxonomy class.

If your site is still using Legacy Forums, you will need to migrate to bbPress 2 to run BuddyPress 3.0. See https://bpdevel.wordpress.com/2017/12/07/legacy-forums-support-will-be/ for more information.

Fixes #5351
See #7502

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-filters.php

    r11703 r11763  
    4545add_filter( 'bp_get_group_member_name',         'stripslashes' );
    4646add_filter( 'bp_get_group_member_link',         'stripslashes' );
    47 
    48 add_filter( 'groups_new_group_forum_desc', 'bp_create_excerpt' );
    4947
    5048add_filter( 'groups_group_name_before_save',        'force_balance_tags' );
     
    121119}
    122120
    123 /** Legacy group forums (bbPress 1.x) *****************************************/
    124 
    125 /**
    126  * Filter bbPress query SQL when on group pages or on forums directory.
    127  *
    128  * @since 1.1.0
    129  */
    130 function groups_add_forum_privacy_sql() {
    131     add_filter( 'get_topics_fields', 'groups_add_forum_fields_sql' );
    132     add_filter( 'get_topics_join',   'groups_add_forum_tables_sql' );
    133     add_filter( 'get_topics_where',  'groups_add_forum_where_sql'  );
    134 }
    135 add_filter( 'bbpress_init', 'groups_add_forum_privacy_sql' );
    136 
    137 /**
    138  * Add fields to bbPress query for group-specific data.
    139  *
    140  * @since 1.1.0
    141  *
    142  * @param string $sql SQL statement to amend.
    143  * @return string
    144  */
    145 function groups_add_forum_fields_sql( $sql = '' ) {
    146     $sql = 't.*, g.id as object_id, g.name as object_name, g.slug as object_slug';
    147     return $sql;
    148 }
    149 
    150 /**
    151  * Add JOINed tables to bbPress query for group-specific data.
    152  *
    153  * @since 1.1.0
    154  *
    155  * @param string $sql SQL statement to amend.
    156  * @return string
    157  */
    158 function groups_add_forum_tables_sql( $sql = '' ) {
    159     $bp = buddypress();
    160 
    161     $sql .= 'JOIN ' . $bp->groups->table_name . ' AS g LEFT JOIN ' . $bp->groups->table_name_groupmeta . ' AS gm ON g.id = gm.group_id ';
    162 
    163     return $sql;
    164 }
    165 
    166 /**
    167  * Add WHERE clauses to bbPress query for group-specific data and access protection.
    168  *
    169  * @since 1.1.0
    170  *
    171  * @param string $sql SQL Statement to amend.
    172  * @return string
    173  */
    174 function groups_add_forum_where_sql( $sql = '' ) {
    175 
    176     // Define locale variable.
    177     $parts = array();
    178 
    179     // Set this for groups.
    180     $parts['groups'] = "(gm.meta_key = 'forum_id' AND gm.meta_value = t.forum_id)";
    181 
    182     // Restrict to public...
    183     $parts['private'] = "g.status = 'public'";
    184 
    185     /**
    186      * ...but do some checks to possibly remove public restriction.
    187      *
    188      * Decide if private are visible
    189      */
    190 
    191     // Are we in our own profile?
    192     if ( bp_is_my_profile() )
    193         unset( $parts['private'] );
    194 
    195     // Are we a super admin?
    196     elseif ( bp_current_user_can( 'bp_moderate' ) )
    197         unset( $parts['private'] );
    198 
    199     // No need to filter on a single item.
    200     elseif ( bp_is_single_item() )
    201         unset( $parts['private'] );
    202 
    203     // Check the SQL filter that was passed.
    204     if ( !empty( $sql ) )
    205         $parts['passed'] = $sql;
    206 
    207     // Assemble Voltron.
    208     $parts_string = implode( ' AND ', $parts );
    209 
    210     $bp = buddypress();
    211 
    212     // Set it to the global filter.
    213     $bp->groups->filter_sql = $parts_string;
    214 
    215     // Return the global filter.
    216     return $bp->groups->filter_sql;
    217 }
    218 
    219 /**
    220  * Modify bbPress caps for bp-forums.
    221  *
    222  * @since 1.1.0
    223  *
    224  * @param bool   $value Original value for current_user_can check.
    225  * @param string $cap   Capability checked.
    226  * @param array  $args  Arguments for the caps.
    227  * @return bool
    228  */
    229 function groups_filter_bbpress_caps( $value, $cap, $args ) {
    230 
    231     if ( bp_current_user_can( 'bp_moderate' ) )
    232         return true;
    233 
    234     if ( 'add_tag_to' === $cap ) {
    235         $bp = buddypress();
    236 
    237         if ( $bp->groups->current_group->user_has_access ) {
    238             return true;
    239         }
    240     }
    241 
    242     if ( 'manage_forums' == $cap && is_user_logged_in() )
    243         return true;
    244 
    245     return $value;
    246 }
    247 add_filter( 'bb_current_user_can', 'groups_filter_bbpress_caps', 10, 3 );
    248 
    249 /**
    250  * Amends the forum directory's "last active" bbPress SQL query to stop it fetching information we aren't going to use.
    251  *
    252  * This speeds up the query.
    253  *
    254  * @since 1.5.0
    255  *
    256  * @see BB_Query::_filter_sql()
    257  *
    258  * @param string $sql SQL statement.
    259  * @return string
    260  */
    261 function groups_filter_forums_root_page_sql( $sql ) {
    262 
    263     /**
    264      * Filters the forum directory's "last active" bbPress SQL query.
    265      *
    266      * This filter is used to prevent fetching information that is not used.
    267      *
    268      * @since 1.5.0
    269      *
    270      * @param string $value SQL string to specify fetching just topic_id.
    271      */
    272     return apply_filters( 'groups_filter_bbpress_root_page_sql', 't.topic_id' );
    273 }
    274 add_filter( 'get_latest_topics_fields', 'groups_filter_forums_root_page_sql' );
    275 
    276121/**
    277122 * Should BuddyPress load the mentions scripts and related assets, including results to prime the
Note: See TracChangeset for help on using the changeset viewer.