Changeset 5129
- Timestamp:
- 09/09/2011 03:06:13 PM (13 years ago)
- Location:
- trunk/bp-forums
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-forums/bp-forums-filters.php
r5093 r5129 201 201 $sql .= $wpdb->prepare( " AND p.poster_id = %s ", bp_displayed_user_id() ); 202 202 203 // Remove any topic_author information 204 $sql = str_replace( " AND t.topic_poster = '" . bp_displayed_user_id() . "'", '', $sql ); 205 203 206 return $sql; 204 207 } -
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 { -
trunk/bp-forums/bp-forums-template.php
r5112 r5129 137 137 $this->total_topic_count = 0; 138 138 } else { 139 // Get a total topic count, for use in pagination. This value will differ 140 // depending on scope 139 141 if ( !empty( $forum_id ) ) { 142 // Group forums 140 143 $topic_count = bp_forums_get_forum( $forum_id ); 141 144 $topic_count = (int)$topic_count->topics; 142 145 } else if ( !empty( $bp->groups->current_group ) ) { 143 146 $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() ); 147 } else if ( bp_is_user_forums_started() || ( bp_is_directory() && $user_id ) ) { 148 // This covers the case of Profile > Forums > Topics Started, as 149 // well as Forum Directory > My Topics 150 $topic_count = bp_forums_total_topic_count_for_user( bp_displayed_user_id(), $type ); 146 151 } else if ( bp_is_user_forums_replied_to() ) { 147 $topic_count = bp_forums_total_replied_count_for_user( bp_displayed_user_id() ); 152 // Profile > Forums > Replied To 153 $topic_count = bp_forums_total_replied_count_for_user( bp_displayed_user_id(), $type ); 148 154 } else { 149 // For forum directories , get a true count155 // For forum directories (All Topics), get a true count 150 156 $status = is_super_admin() ? 'all' : 'public'; // todo: member-of 151 157 $topic_count = (int)groups_total_forum_topic_count( $status, $search_terms );
Note: See TracChangeset
for help on using the changeset viewer.