Skip to:
Content

BuddyPress.org

Ticket #3123: 3123-2.patch

File 3123-2.patch, 3.0 KB (added by boonebgorges, 13 years ago)
  • bp-forums/bp-forums-functions.php

    function bp_forums_total_topic_count() { 
    273273        if ( isset( $bbdb ) ) {
    274274                if ( bp_is_active( 'groups' ) ) {
    275275                        $groups_table_sql = groups_add_forum_tables_sql();
     276                        $groups_table_sql = preg_replace( '|^, |', '', $groups_table_sql );
    276277                        $groups_where_sql = groups_add_forum_where_sql( "t.topic_status = 0" );
    277278                } else {
    278279                        $groups_table_sql = '';
    279280                        $groups_where_sql = "t.topic_status = 0";
    280281                }
    281                 $count = $bbdb->get_results( $bbdb->prepare( "SELECT t.topic_id FROM {$bbdb->topics} AS t {$groups_table_sql} WHERE {$groups_where_sql}" ) );
     282                $count = $bbdb->get_results( $bbdb->prepare( "SELECT t.topic_id FROM {$groups_table_sql} WHERE {$groups_where_sql}" ) );
    282283                $count = count( (array)$count );
    283284        } else {
    284285                $count = 0;
  • bp-forums/bp-forums-screens.php

     
    33function bp_forums_directory_forums_setup() {
    44        global $bp;
    55
    6         if ( bp_is_forums_component() && !bp_current_action() && !bp_current_item() ) {
     6        if ( bp_is_forums_component() ) {
    77                if ( bp_forum_directory_is_disabled() )
    88                        return false;
    99
  • bp-groups/bp-groups-filters.php

    function groups_add_forum_privacy_sql() { 
    6868        add_filter( 'get_topics_fields',     'groups_add_forum_fields_sql' );
    6969        add_filter( 'get_topics_index_hint', 'groups_add_forum_tables_sql' );
    7070        add_filter( 'get_topics_where',      'groups_add_forum_where_sql'  );
     71        add_filter( 'bb_query',              'groups_remove_topic_table_declaration' );
    7172}
    7273add_filter( 'bbpress_init', 'groups_add_forum_privacy_sql' );
    7374
     75/**
     76 * Removes the redundant topic table declaration in the topics query. History's hackiest hack.
     77 *
     78 * @package BuddyPress
     79 *
     80 * @param obj $query The bbPress query object
     81 * @return obj @query The modified object
     82 */
     83function groups_remove_topic_table_declaration( $query ) {
     84        global $bbdb;
     85       
     86        $query->request = str_replace( 'FROM ' . $bbdb->topics . ' AS t ,', 'FROM ', $query->request );
     87        return $query;
     88}
    7489function groups_add_forum_fields_sql( $sql = '' ) {
    7590        return 't.*, g.id as object_id, g.name as object_name, g.slug as object_slug';
    7691}
    7792
    7893function groups_add_forum_tables_sql( $sql = '' ) {
    79         global $bp;
    80         return ', ' . $bp->groups->table_name . ' AS g LEFT JOIN ' . $bp->groups->table_name_groupmeta . ' AS gm ON g.id = gm.group_id ';
     94        global $bp, $bbdb;
     95       
     96        return ', ' . $bp->groups->table_name . ' AS g LEFT JOIN ' . $bp->groups->table_name_groupmeta . ' AS gm ON g.id = gm.group_id, ' . $bbdb->topics . ' AS t';
    8197}
    8298
    8399function groups_add_forum_where_sql( $sql = '' ) {