Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/15/2011 10:40:03 PM (13 years ago)
Author:
boonebgorges
Message:

Reconfigures the way that new activity mentions are stored and incremented, so that counts more accurately reflect new and deleted activity items. Fixes #2082

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-filters.php

    r4305 r4367  
    113113 * @param string $content The activity content
    114114 */
    115 function bp_activity_at_name_filter( $content ) {
     115function 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
    116121    $usernames = bp_activity_find_mentions( $content );
    117122
     
    126131
    127132        // 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' );
    130134
    131135        $content = preg_replace( '/(@' . $username . '\b)/', "<a href='" . bp_core_get_user_domain( $user_id ) . "' rel='nofollow'>@$username</a>", $content );
    132136    }
    133137
    134     return $content;
     138    // Resave the activity item with the linked usernames
     139    $activity->content = $content;
     140    $activity->save();
    135141}
    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' );
     142add_filter( 'bp_activity_after_save', 'bp_activity_at_name_filter' );
    142143
    143144function bp_activity_make_nofollow_filter( $text ) {
Note: See TracChangeset for help on using the changeset viewer.