Changeset 5047
- Timestamp:
- 08/29/2011 10:43:45 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-template.php
r5030 r5047 1135 1135 } 1136 1136 1137 /** 1138 * Is this a user's forums page? 1139 * 1140 * @package BuddyPress 1141 * 1142 * @return bool 1143 */ 1137 1144 function bp_is_user_forums() { 1138 global $bp;1139 1140 1145 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 */ 1159 function 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 */ 1174 function bp_is_user_forums_replied_to() { 1175 if ( bp_is_current_component( 'forums' ) && bp_is_current_action( 'replies' ) ) 1141 1176 return true; 1142 1177 -
trunk/bp-forums/bp-forums-functions.php
r4920 r5047 310 310 } 311 311 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 */ 323 function 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 312 352 function bp_forums_get_topic_extras( $topics ) { 313 353 global $bp, $wpdb, $bbdb; -
trunk/bp-forums/bp-forums-template.php
r5030 r5047 142 142 } else if ( !empty( $bp->groups->current_group ) ) { 143 143 $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() ); 144 148 } else { 145 149 // For forum directories, get a true count -
trunk/bp-themes/bp-default/forums/index.php
r4994 r5047 8 8 */ 9 9 10 ?> 10 ?>htnshtsn 11 11 12 12 <?php get_header( 'buddypress' ); ?> … … 151 151 <?php endif; ?> 152 152 </div><!-- #new-topic-post --> 153 153 154 154 <?php do_action( 'bp_after_new_topic_form' ); ?> 155 155 156 156 <?php do_action( 'bp_after_directory_forums_content' ); ?> 157 157 -
trunk/bp-themes/bp-default/members/single/forums.php
r4452 r5047 37 37 do_action( 'bp_before_member_forums_content' ); ?> 38 38 39 <div class=" groups mygroups">39 <div class="forums myforums"> 40 40 41 41 <?php locate_template( array( 'forums/forums-loop.php' ), true ); ?>
Note: See TracChangeset
for help on using the changeset viewer.