Ticket #5289: 5289.03.diff
File 5289.03.diff, 4.2 KB (added by , 11 years ago) |
---|
-
bp-activity/bp-activity-notifications.php
351 351 add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications' ); 352 352 add_action( 'bp_activity_screen_mentions', 'bp_activity_remove_screen_notifications' ); 353 353 354 355 function bp_activity_at_mention_delete_notification( $activity_ids_deleted = array() ) { 356 // Let's delete all without checking if content contains any mentions 357 // to avoid a query to get the activity 358 if ( bp_is_active( 'notifications' ) && !empty( $activity_ids_deleted ) ) { 359 foreach( $activity_ids_deleted as $activity_id ) { 360 bp_notifications_delete_all_notifications_by_type( $activity_id, buddypress()->activity->id ); 361 } 362 } 363 } 364 add_action( 'bp_activity_deleted_activities', 'bp_activity_at_mention_delete_notification', 10, 1 ); -
bp-groups/bp-groups-notifications.php
554 554 add_action( 'groups_delete_group', 'bp_groups_delete_group_delete_all_notifications', 10 ); 555 555 556 556 /** 557 * Remove promoted notifications for any demoted member 558 * 559 * @since BuddyPress (?) 560 */ 561 function bp_groups_delete_group_delete_promoted_notifications( $user_id = 0, $group_id = 0 ) { 562 if ( bp_is_active( 'notifications' ) && !empty( $group_id ) && !empty( $user_id ) ) { 563 bp_notifications_delete_notifications_by_item_id( $user_id, $group_id, buddypress()->groups->id, 'member_promoted_to_admin' ); 564 bp_notifications_delete_notifications_by_item_id( $user_id, $group_id, buddypress()->groups->id, 'member_promoted_to_mod' ); 565 } 566 } 567 568 add_action( 'groups_demoted_member', 'bp_groups_delete_group_delete_promoted_notifications', 10, 2 ); 569 570 /** 557 571 * Mark notifications read when a member accepts a group invitation 558 572 * 559 573 * @since BuddyPress (1.9.0) -
bp-messages/bp-messages-classes.php
121 121 122 122 // Mark messages as deleted 123 123 $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET is_deleted = 1 WHERE thread_id = %d AND user_id = %d", $thread_id, bp_loggedin_user_id() ) ); 124 125 // Get the massage id in order to delete notification 126 $message_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages} WHERE thread_id = %d", $thread_id ) ); 124 127 125 128 // Check to see if any more recipients remain for this message 126 129 // if not, then delete the message from the database. 127 130 $recipients = $wpdb->get_results( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d AND is_deleted = 0", $thread_id ) ); 128 131 129 132 if ( empty( $recipients ) ) { 133 130 134 // Delete all the messages 131 135 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_messages} WHERE thread_id = %d", $thread_id ) ); 132 136 133 137 // Delete all the recipients 134 138 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d", $thread_id ) ); 139 135 140 } 136 141 142 do_action_ref_array( 'messages_thread_deleted_thread', array( $message_id ) ); 143 137 144 return true; 138 145 } 139 146 -
bp-messages/bp-messages-notifications.php
189 189 } 190 190 } 191 191 add_action( 'messages_screen_conversation', 'bp_messages_screen_inbox_mark_notifications', 10 ); 192 193 194 function bp_messages_message_delete_notification( $message_id = 0 ) { 195 if ( bp_is_active( 'notifications' ) && !empty( $message_id ) ) { 196 bp_notifications_delete_notifications_by_item_id( bp_loggedin_user_id(), (int) $message_id, buddypress()->messages->id, 'new_message' ); 197 } 198 } 199 200 add_action( 'messages_thread_deleted_thread', 'bp_messages_message_delete_notification', 10, 1 ); 201