Skip to:
Content

BuddyPress.org

Changeset 5047


Ignore:
Timestamp:
08/29/2011 10:43:45 PM (15 years ago)
Author:
boonebgorges
Message:

Fixes total found topic count for Started Topics and Replied To tabs on user profiles. Adds template tags to check whether you're looking at Started Topics or Replied To. Fixes class name in members/single/forums.php so that AJAX pagination works correctly. Fixes #3431

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-template.php

    r5030 r5047  
    11351135}
    11361136
     1137/**
     1138 * Is this a user's forums page?
     1139 *
     1140 * @package BuddyPress
     1141 *
     1142 * @return bool
     1143 */
    11371144function bp_is_user_forums() {
    1138         global $bp;
    1139 
    11401145        if ( bp_is_current_component( 'forums' ) )
     1146                return true;
     1147
     1148        return false;
     1149}
     1150
     1151/**
     1152 * Is this a user's "Topics Started" page?
     1153 *
     1154 * @package BuddyPress
     1155 * @since 1.5
     1156 *
     1157 * @return bool
     1158 */
     1159function bp_is_user_forums_started() {
     1160        if ( bp_is_current_component( 'forums' ) && bp_is_current_action( 'topics' ) )
     1161                return true;
     1162
     1163        return false;
     1164}
     1165
     1166/**
     1167 * Is this a user's "Replied To" page?
     1168 *
     1169 * @package BuddyPress
     1170 * @since 1.5
     1171 *
     1172 * @return bool
     1173 */
     1174function bp_is_user_forums_replied_to() {
     1175        if ( bp_is_current_component( 'forums' ) && bp_is_current_action( 'replies' ) )
    11411176                return true;
    11421177
  • trunk/bp-forums/bp-forums-functions.php

    r4920 r5047  
    310310}
    311311
     312/**
     313 * Return the total number of topics replied to by a given user
     314 *
     315 * Uses an unfortunate technique to count unique topics, due to limitations in BB_Query.
     316 *
     317 * @package BuddyPress
     318 * @since 1.5
     319 *
     320 * @param int $user_id Defaults to displayed user, then to logged-in user
     321 * @return int $count
     322 */
     323function bp_forums_total_replied_count_for_user( $user_id = 0 ) {
     324        global $bp;
     325
     326        do_action( 'bbpress_init' );
     327
     328        if ( !$user_id )
     329                $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
     330
     331        if ( !$user_id )
     332                return 0;
     333
     334        if ( class_exists( 'BB_Query' ) ) {
     335                $query = new BB_Query( 'post', array( 'post_author_id' => $user_id, 'page' => 1, 'per_page' => -1, 'count' => true ) );
     336
     337                // Count the unique topics. No better way to do this in the bbPress query API
     338                $topics = array();
     339                foreach( $query->results as $result ) {
     340                        if ( !in_array( $result->topic_id, $topics ) )
     341                                $topics[] = $result->topic_id;
     342                }
     343                $count = count( $topics );
     344                $query = null;
     345        } else {
     346                $count = 0;
     347        }
     348
     349        return apply_filters( 'bp_forums_total_replied_count_for_user', $count, $user_id );
     350}
     351
    312352function bp_forums_get_topic_extras( $topics ) {
    313353        global $bp, $wpdb, $bbdb;
  • trunk/bp-forums/bp-forums-template.php

    r5030 r5047  
    142142                        } else if ( !empty( $bp->groups->current_group ) ) {
    143143                                $topic_count = (int)groups_total_public_forum_topic_count( $type );
     144                        } else if ( bp_is_user_forums_started() ) {
     145                                $topic_count = bp_forums_total_topic_count_for_user( bp_displayed_user_id() );
     146                        } else if ( bp_is_user_forums_replied_to() ) {
     147                                $topic_count = bp_forums_total_replied_count_for_user( bp_displayed_user_id() );
    144148                        } else {
    145149                                // For forum directories, get a true count
  • trunk/bp-themes/bp-default/forums/index.php

    r4994 r5047  
    88 */
    99
    10 ?>
     10?>htnshtsn
    1111
    1212<?php get_header( 'buddypress' ); ?>
     
    151151                                <?php endif; ?>
    152152                        </div><!-- #new-topic-post -->
    153                        
     153
    154154                        <?php do_action( 'bp_after_new_topic_form' ); ?>
    155                        
     155
    156156                        <?php do_action( 'bp_after_directory_forums_content' ); ?>
    157157
  • trunk/bp-themes/bp-default/members/single/forums.php

    r4452 r5047  
    3737        do_action( 'bp_before_member_forums_content' ); ?>
    3838
    39         <div class="groups mygroups">
     39        <div class="forums myforums">
    4040
    4141                <?php locate_template( array( 'forums/forums-loop.php' ), true ); ?>
Note: See TracChangeset for help on using the changeset viewer.