Skip to:
Content

bbPress.org


Ignore:
Timestamp:
01/14/2011 07:22:08 PM (16 years ago)
Author:
johnjamesjacoby
Message:

Adjust topic and reply counts up the subforum tree. Fixes #1320. Props GautamGupta

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-forum-template.php

    r2795 r2806  
    4141
    4242        // Don't show private forums to normal users
    43         if ( !current_user_can( 'read_private_forums' ) && empty( $r['meta_key'] ) && empty( $r['meta_value'] ) && empty( $r['meta_compare'] ) ) {
    44                 $r['meta_key']     = '_bbp_forum_visibility';
    45                 $r['meta_value']   = 'public';
    46                 $r['meta_compare'] = '==';
     43        if ( !current_user_can( 'read_private_forums' ) && empty( $r['meta_key'] ) && empty( $r['meta_value'] ) ) {
     44                $r['meta_key']   = '_bbp_forum_visibility';
     45                $r['meta_value'] = 'public';
    4746        }
    4847
     
    435434
    436435        // Don't show private forums to normal users
    437         if ( !current_user_can( 'read_private_forums' ) && empty( $r['meta_key'] ) && empty( $r['meta_value'] ) && empty( $r['meta_compare'] ) ) {
    438                 $r['meta_key']     = '_bbp_forum_visibility';
    439                 $r['meta_value']   = 'public';
    440                 $r['meta_compare'] = '==';
     436        if ( !current_user_can( 'read_private_forums' ) && empty( $r['meta_key'] ) && empty( $r['meta_value'] ) ) {
     437                $r['meta_key']   = '_bbp_forum_visibility';
     438                $r['meta_value'] = 'public';
    441439        }
    442440
     
    505503                                $topic_count = ' (' . bbp_get_forum_topic_count( $sub_forum->ID ) . ')';
    506504
    507                         //if ( !empty( $show_reply_count ) && !bbp_is_forum_category( $sub_forum->ID ) )
    508                         //      $reply_count = ' (' . bbp_get_forum_reply_count( $sub_forum->ID ) . ')';
     505                        if ( !empty( $show_reply_count ) && !bbp_is_forum_category( $sub_forum->ID ) )
     506                                $reply_count = ' (' . bbp_get_forum_reply_count( $sub_forum->ID ) . ')';
    509507
    510508                        $output .= $link_before . '<a href="' . $permalink . '" class="bbp-forum-link">' . $title . $topic_count . $reply_count . '</a>' . $show_sep . $link_after;
     
    904902 *
    905903 * @param int $forum_id Optional. Forum id
     904 * @param bool $total_count Optional. To get the total count or normal count?
    906905 * @uses bbp_get_forum_topic_count() To get the forum topic count
    907906 */
    908 function bbp_forum_topic_count( $forum_id = 0 ) {
     907function bbp_forum_topic_count( $forum_id = 0, $total_count = true ) {
    909908        echo bbp_get_forum_topic_count( $forum_id );
    910909}
     
    915914         *
    916915         * @param int $forum_id Optional. Forum id
     916         * @param bool $total_count Optional. To get the total count or normal
     917         *                           count?
    917918         * @uses bbp_get_forum_id() To get the forum id
    918919         * @uses get_post_meta() To get the forum topic count
     
    923924         * @return int Forum topic count
    924925         */
    925         function bbp_get_forum_topic_count( $forum_id = 0 ) {
    926                 $forum_id = bbp_get_forum_id( $forum_id );
    927                 $topics   = get_post_meta( $forum_id, '_bbp_forum_topic_count', true );
     926        function bbp_get_forum_topic_count( $forum_id = 0, $total_count = true ) {
     927                $forum_id = bbp_get_forum_id( $forum_id );
     928                $topics  = get_post_meta( $forum_id, empty( $total_count ) ? '_bbp_forum_topic_count' : '_bbp_forum_total_topic_count', true );
    928929
    929930                if ( '' === $topics )
    930                         $topics = bbp_update_forum_topic_count( $forum_id );
     931                        $topics = bbp_update_forum_topic_count( $forum_id, $total_count );
    931932
    932933                return apply_filters( 'bbp_get_forum_topic_count', (int) $topics, $forum_id );
     
    939940 *
    940941 * @param int $forum_id Optional. Forum id
     942 * @param bool $total_count Optional. To get the total count or normal count?
    941943 * @uses bbp_get_forum_reply_count() To get the forum reply count
    942944 */
    943 function bbp_forum_reply_count( $forum_id = 0 ) {
    944         echo bbp_get_forum_reply_count( $forum_id );
     945function bbp_forum_reply_count( $forum_id = 0, $total_count = true ) {
     946        echo bbp_get_forum_reply_count( $forum_id, $total_count );
    945947}
    946948        /**
     
    950952         *
    951953         * @param int $forum_id Optional. Forum id
     954         * @param bool $total_count Optional. To get the total count or normal
     955         *                           count?
    952956         * @uses bbp_get_forum_id() To get the forum id
    953957         * @uses get_post_meta() To get the forum reply count
     
    958962         * @return int Forum reply count
    959963         */
    960         function bbp_get_forum_reply_count( $forum_id = 0 ) {
    961                 $forum_id = bbp_get_forum_id( $forum_id );
    962                 $replies  = get_post_meta( $forum_id, '_bbp_forum_reply_count', true );
     964        function bbp_get_forum_reply_count( $forum_id = 0, $total_count = true ) {
     965                $forum_id = bbp_get_forum_id( $forum_id );
     966                $replies  = get_post_meta( $forum_id, empty( $total_count ) ? '_bbp_forum_reply_count' : '_bbp_forum_total_reply_count', true );
    963967
    964968                if ( '' === $replies )
    965                         $replies = bbp_update_forum_reply_count( $forum_id );
     969                        $replies = bbp_update_forum_reply_count( $forum_id, $total_count );
    966970
    967971                return apply_filters( 'bbp_get_forum_reply_count', (int) $replies, $forum_id );
Note: See TracChangeset for help on using the changeset viewer.