Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/21/2011 02:14:16 PM (15 years ago)
Author:
boonebgorges
Message:

Fixes sticky logic on group forum directories so that stickies always appear at the top of the order, without breaking pagination. Fixes #3059. Props sushkov for the inital patch. Introduces bp_forums_enable_global_directory_stickies() to allow easy modification of the default global forum directory behavior, which is to show group stickies in their normal freshness-based position.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-classes.php

    r4649 r4764  
    596596        return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 AND is_banned = 0", $group_id ) );
    597597    }
     598   
     599   
     600    /**
     601     * Get a total count of all topics of a given status, across groups/forums
     602     *
     603     * @package BuddyPress
     604     * @since 1.3
     605     *
     606     * @param str $status 'public', 'private', 'hidden', 'all' Which group types to count
     607     * @return int The topic count
     608     */
     609    function get_global_topic_count( $status = 'public' ) {
     610        global $bbdb, $wpdb, $bp;
     611       
     612        switch ( $status ) {
     613            case 'all' :
     614                $status_sql = '';
     615                break;
     616               
     617            case 'hidden' :
     618                $status_sql = $wpdb->prepare( "AND g.status = 'hidden'" );
     619                break;
     620               
     621            case 'private' :
     622                $status_sql = $wpdb->prepare( "AND g.status = 'private'" );
     623                break;
     624               
     625            case 'public' :
     626            default :
     627                $status_sql = $wpdb->prepare( "AND g.status = 'public'" );
     628                break;
     629        }
     630       
     631        return $wpdb->get_var( "SELECT COUNT(t.topic_id) FROM {$bbdb->topics} AS t INNER JOIN {$bp->groups->table_name_groupmeta} AS gm ON t.forum_id = gm.meta_value INNER JOIN {$bp->groups->table_name} AS g ON gm.group_id = g.id WHERE gm.meta_key = 'forum_id' {$status_sql} AND t.topic_status = '0' AND t.topic_sticky != '2' " );
     632    }
    598633}
    599634
Note: See TracChangeset for help on using the changeset viewer.