Ticket #2084: 2084-1.diff
File 2084-1.diff, 4.9 KB (added by , 14 years ago) |
---|
-
bp-activity.php
524 524 } 525 525 526 526 /** 527 * bp_activity_total_mentions_for_user() 528 * 529 * Reduces new mention count for mentioned users when activity items are deleted 530 * 531 * @package BuddyPress Activity 532 * @since 1.3 533 * 534 * @param $activity_id The unique id for the activity item 535 */ 536 function bp_activity_total_mentions_for_user( $user_id = false ) { 537 global $bp; 538 539 if ( !$user_id ) 540 $user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id; 541 542 if ( !$count = wp_cache_get( 'bp_total_mentions_for_user_' . $user_id, 'bp' ) ) { 543 $count = BP_Activity_Activity::total_mention_count( $user_id ); 544 wp_cache_set( 'bp_total_mentions_for_user_' . $user_id, $count, 'bp' ); 545 } 546 547 return $count; 548 } 549 550 /** 527 551 * bp_activity_reduce_mention_count() 528 552 * 529 553 * Reduces new mention count for mentioned users when activity items are deleted -
bp-themes/bp-default/activity/index.php
47 47 48 48 <?php do_action( 'bp_before_activity_type_tab_mentions' ) ?> 49 49 50 <li id="activity-mentions"><a href="<?php echo bp_loggedin_user_domain() . BP_ACTIVITY_SLUG . '/mentions/' ?>" title="<?php _e( 'Activity that I have been mentioned in.', 'buddypress' ) ?>"><?php printf( __( '@%s Mentions', 'buddypress' ), bp_get_loggedin_user_username() ) ?><?php if ( bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) ) : ?> <strong><?php printf( __( '(%s new)', 'buddypress' ), bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) ) ?></strong><?php endif; ?></a></li> 51 50 <?php if ( bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) ) : ?> 51 <li id="activity-mentions"><a href="<?php echo bp_loggedin_user_domain() . BP_ACTIVITY_SLUG . '/mentions/' ?>" title="<?php _e( 'Activity that I have been mentioned in.', 'buddypress' ) ?>"><?php printf( __( '@%s Mentions', 'buddypress' ), bp_get_loggedin_user_username() ) ?><?php if ( bp_get_new_mention_count_for_user( bp_loggedin_user_id() ) ) : ?> <strong><?php printf( __( '(%s new)', 'buddypress' ), bp_get_new_mention_count_for_user( bp_loggedin_user_id() ) ) ?></strong><?php endif; ?></a></li> 52 <?php endif; ?> 52 53 <?php endif; ?> 53 54 54 55 <?php do_action( 'bp_activity_type_tabs' ) ?> -
bp-activity/bp-activity-templatetags.php
952 952 return apply_filters( 'bp_get_total_favorite_count_for_user', bp_activity_total_favorites_for_user( $user_id ) ); 953 953 } 954 954 955 function bp_new_mention_count_for_user( $user_id = false ) { 956 echo bp_get_new_favorite_count_for_user( $user_id ); 957 } 958 function bp_get_new_mention_count_for_user( $user_id = false ) { 959 return apply_filters( 'bp_get_new_mention_count_for_user', get_user_meta( $user_id, 'bp_new_mention_count', true ) ); 960 } 961 955 962 function bp_total_mention_count_for_user( $user_id = false ) { 956 963 echo bp_get_total_favorite_count_for_user( $user_id ); 957 964 } 958 965 function bp_get_total_mention_count_for_user( $user_id = false ) { 959 return apply_filters( 'bp_get_total_mention_count_for_user', get_user_meta( $user_id, 'bp_new_mention_count', true) );966 return apply_filters( 'bp_get_total_mention_count_for_user', bp_activity_total_mentions_for_user( $user_id ) ); 960 967 } 961 968 962 969 function bp_send_public_message_link() { -
bp-activity/bp-activity-classes.php
530 530 531 531 return count( maybe_unserialize( $favorite_activity_entries ) ); 532 532 } 533 534 function total_mention_count( $user_id ) { 535 global $bp, $wpdb; 536 537 $user_nicename = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->userdata->user_nicename : $bp->loggedin_user->userdata->user_nicename; 538 $user_login = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->userdata->user_login : $bp->loggedin_user->userdata->user_login; 539 $search_terms = '@' . bp_core_get_username( $user_id, $user_nicename, $user_login ) . '<'; // Start search at @ symbol and stop search at closing tag delimiter. 540 541 $search_terms = $wpdb->escape( $search_terms ); 542 $where_sql = "a.content LIKE '%%" . like_escape( $search_terms ) . "%%'"; 543 544 $total_mentions = $wpdb->get_var( $wpdb->prepare( "SELECT count(a.id) FROM {$bp->activity->table_name} a WHERE {$where_sql}" ) ); 545 546 return $total_mentions; 547 } 533 548 534 549 function check_exists_by_content( $content ) { 535 550 global $wpdb, $bp;