Changeset 5129 for trunk/bp-forums/bp-forums-functions.php
- Timestamp:
- 09/09/2011 03:06:13 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-forums/bp-forums-functions.php
r5112 r5129 291 291 } 292 292 293 function bp_forums_total_topic_count_for_user( $user_id = 0 ) { 293 /** 294 * Get a total "Topics Started" count for a given user 295 * 296 * @package BuddyPress 297 * 298 * @param int $user_id ID of the user being queried. Falls back on displayed user, then loggedin 299 * @param str $type The current filter/sort type. 'active', 'popular', 'unreplied' 300 * @return int $count The topic count 301 */ 302 function bp_forums_total_topic_count_for_user( $user_id = 0, $type = 'active' ) { 294 303 global $bp; 295 304 … … 300 309 301 310 if ( class_exists( 'BB_Query' ) ) { 302 $query = new BB_Query( 'topic', array( 'topic_author_id' => $user_id, 'page' => 1, 'per_page' => -1, 'count' => true ) ); 311 $args = array( 312 'topic_author_id' => $user_id, 313 'page' => 1, 314 'per_page' => -1, 315 'count' => true 316 ); 317 318 if ( 'unreplied' == $type ) 319 $args['post_count'] = 1; 320 321 $query = new BB_Query( 'topic', $args ); 303 322 $count = $query->count; 304 323 $query = null; … … 321 340 * @return int $count 322 341 */ 323 function bp_forums_total_replied_count_for_user( $user_id = 0 ) {342 function bp_forums_total_replied_count_for_user( $user_id = 0, $type = 'active' ) { 324 343 global $bp; 325 344 … … 341 360 $topics[] = $result->topic_id; 342 361 } 343 $count = count( $topics ); 362 363 // Even more unfortunate. If this is filtered by 'unreplied', we have to requery 364 if ( 'unreplied' == $type ) { 365 $topic_ids = implode( ',', $topics ); 366 $topics_query = new BB_Query( 'topic', array( 'topic_id' => $topic_ids, 'page' => 1, 'per_page' => -1, 'post_count' => 1 ) ); 367 $count = count( $topics_query->results ); 368 } else { 369 $count = count( $topics ); 370 } 344 371 $query = null; 345 372 } else {
Note: See TracChangeset
for help on using the changeset viewer.