Changeset 4367
- Timestamp:
- 05/15/2011 10:40:03 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-filters.php
r4305 r4367 113 113 * @param string $content The activity content 114 114 */ 115 function bp_activity_at_name_filter( $content ) { 115 function bp_activity_at_name_filter( $activity ) { 116 // Only run this function once for a given activity item 117 remove_filter( 'bp_activity_after_save', 'bp_activity_at_name_filter' ); 118 119 $content = $activity->content; 120 116 121 $usernames = bp_activity_find_mentions( $content ); 117 122 … … 126 131 127 132 // Increase the number of new @ mentions for the user 128 $new_mention_count = (int)get_user_meta( $user_id, 'bp_new_mention_count', true ); 129 update_user_meta( $user_id, 'bp_new_mention_count', $new_mention_count + 1 ); 133 bp_activity_adjust_mention_count( $activity->id, 'add' ); 130 134 131 135 $content = preg_replace( '/(@' . $username . '\b)/', "<a href='" . bp_core_get_user_domain( $user_id ) . "' rel='nofollow'>@$username</a>", $content ); 132 136 } 133 137 134 return $content; 138 // Resave the activity item with the linked usernames 139 $activity->content = $content; 140 $activity->save(); 135 141 } 136 add_filter( 'bp_activity_new_update_content', 'bp_activity_at_name_filter' ); 137 add_filter( 'groups_activity_new_update_content', 'bp_activity_at_name_filter' ); 138 add_filter( 'pre_comment_content', 'bp_activity_at_name_filter' ); 139 add_filter( 'group_forum_topic_text_before_save', 'bp_activity_at_name_filter' ); 140 add_filter( 'group_forum_post_text_before_save', 'bp_activity_at_name_filter' ); 141 add_filter( 'bp_activity_comment_content', 'bp_activity_at_name_filter' ); 142 add_filter( 'bp_activity_after_save', 'bp_activity_at_name_filter' ); 142 143 143 144 function bp_activity_make_nofollow_filter( $text ) { -
trunk/bp-activity/bp-activity-functions.php
r4277 r4367 16 16 * @since 1.3 17 17 * 18 * @param $content The content of the activity, usually found in $activity->content18 * @param str $content The content of the activity, usually found in $activity->content 19 19 * @return array $usernames Array of the found usernames that match existing users 20 20 */ … … 31 31 32 32 /** 33 * Re duces new mention count for mentioned users when activity items are deleted33 * Resets a user's unread mentions list and count 34 34 * 35 35 * @package BuddyPress Activity 36 36 * @since 1.3 37 37 * 38 * @param $activity_id The unique id for the activity item 39 */ 40 function bp_activity_reduce_mention_count( $activity_id ) { 38 * @param int $user_id The id of the user whose unread mentions are being reset 39 */ 40 function bp_activity_clear_new_mentions( $user_id ) { 41 delete_user_meta( $user_id, 'bp_new_mention_count' ); 42 delete_user_meta( $user_id, 'bp_new_mentions' ); 43 } 44 45 /** 46 * Adjusts new mention count for mentioned users when activity items are deleted or created 47 * 48 * @package BuddyPress Activity 49 * @since 1.3 50 * 51 * @param int $activity_id The unique id for the activity item 52 */ 53 function bp_activity_adjust_mention_count( $activity_id, $action = 'add' ) { 41 54 $activity = new BP_Activity_Activity( $activity_id ); 42 55 … … 51 64 continue; 52 65 53 // Decrease the number of new @ mentions for the user66 // Adjust the mention list and count for the member 54 67 $new_mention_count = (int)get_user_meta( $user_id, 'bp_new_mention_count', true ); 55 update_user_meta( $user_id, 'bp_new_mention_count', $new_mention_count - 1 ); 68 if ( !$new_mentions = get_user_meta( $user_id, 'bp_new_mentions', true ) ) 69 $new_mentions = array(); 70 71 switch ( $action ) { 72 case 'delete' : 73 $key = array_search( $activity_id, $new_mentions ); 74 if ( $key !== false ) { 75 var_dump( $new_mentions ); 76 var_dump( $activity_id ); 77 unset( $new_mentions[$key] ); 78 } 79 break; 80 81 case 'add' : 82 default : 83 if ( !in_array( $activity_id, $new_mentions ) ) { 84 $new_mentions[] = (int)$activity_id; 85 } 86 break; 87 } 88 89 // Get an updated mention count 90 $new_mention_count = count( $new_mentions ); 91 92 // Resave the user_meta 93 update_user_meta( $user_id, 'bp_new_mention_count', $new_mention_count ); 94 update_user_meta( $user_id, 'bp_new_mentions', $new_mentions ); 56 95 } 57 96 } 58 97 } 59 add_action( 'bp_activity_action_delete_activity', 'bp_activity_reduce_mention_count' );60 98 61 99 /** … … 758 796 $args = wp_parse_args( $args, $defaults ); 759 797 798 // Adjust the new mention count of any mentioned member 799 bp_activity_adjust_mention_count( $args['id'], 'delete' ); 800 760 801 if ( !$activity_ids_deleted = BP_Activity_Activity::delete( $args ) ) 761 802 return false; -
trunk/bp-activity/bp-activity-screens.php
r4287 r4367 68 68 add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications' ); 69 69 add_action( 'bp_activity_screen_mentions', 'bp_activity_remove_screen_notifications' ); 70 71 /** 72 * Reset the logged-in user's new mentions data when he visits his mentions screen 73 * 74 * @package BuddyPress Activity 75 * @since 1.3 76 * @uses bp_activity_clear_new_mentions() 77 * @uses bp_is_my_profile() 78 */ 79 function bp_activity_reset_my_new_mentions() { 80 if ( bp_is_my_profile() ) 81 bp_activity_clear_new_mentions( bp_loggedin_user_id() ); 82 } 83 add_action( 'bp_activity_screen_mentions', 'bp_activity_reset_my_new_mentions' ); 70 84 71 85 function bp_activity_screen_single_activity_permalink() { -
trunk/bp-themes/bp-default/_inc/ajax.php
r4354 r4367 113 113 case 'mentions': 114 114 $feed_url = $bp->loggedin_user->domain . bp_get_activity_slug() . '/mentions/feed/'; 115 delete_user_meta( $bp->loggedin_user->id, 'bp_new_mention_count');115 bp_activity_clear_new_mentions( $bp->loggedin_user->id ); 116 116 break; 117 117 default:
Note: See TracChangeset
for help on using the changeset viewer.