Ticket #3123: 3123-2.patch
File 3123-2.patch, 3.0 KB (added by , 13 years ago) |
---|
-
bp-forums/bp-forums-functions.php
function bp_forums_total_topic_count() { 273 273 if ( isset( $bbdb ) ) { 274 274 if ( bp_is_active( 'groups' ) ) { 275 275 $groups_table_sql = groups_add_forum_tables_sql(); 276 $groups_table_sql = preg_replace( '|^, |', '', $groups_table_sql ); 276 277 $groups_where_sql = groups_add_forum_where_sql( "t.topic_status = 0" ); 277 278 } else { 278 279 $groups_table_sql = ''; 279 280 $groups_where_sql = "t.topic_status = 0"; 280 281 } 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}" ) ); 282 283 $count = count( (array)$count ); 283 284 } else { 284 285 $count = 0; -
bp-forums/bp-forums-screens.php
3 3 function bp_forums_directory_forums_setup() { 4 4 global $bp; 5 5 6 if ( bp_is_forums_component() && !bp_current_action() && !bp_current_item()) {6 if ( bp_is_forums_component() ) { 7 7 if ( bp_forum_directory_is_disabled() ) 8 8 return false; 9 9 -
bp-groups/bp-groups-filters.php
function groups_add_forum_privacy_sql() { 68 68 add_filter( 'get_topics_fields', 'groups_add_forum_fields_sql' ); 69 69 add_filter( 'get_topics_index_hint', 'groups_add_forum_tables_sql' ); 70 70 add_filter( 'get_topics_where', 'groups_add_forum_where_sql' ); 71 add_filter( 'bb_query', 'groups_remove_topic_table_declaration' ); 71 72 } 72 73 add_filter( 'bbpress_init', 'groups_add_forum_privacy_sql' ); 73 74 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 */ 83 function 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 } 74 89 function groups_add_forum_fields_sql( $sql = '' ) { 75 90 return 't.*, g.id as object_id, g.name as object_name, g.slug as object_slug'; 76 91 } 77 92 78 93 function 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'; 81 97 } 82 98 83 99 function groups_add_forum_where_sql( $sql = '' ) {