Changeset 4367 for trunk/bp-activity/bp-activity-functions.php
- Timestamp:
- 05/15/2011 10:40:03 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/bp-activity/bp-activity-functions.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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;
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)