Skip to:
Content

BuddyPress.org

Ticket #5289: 5289.diff

File 5289.diff, 4.5 KB (added by imath, 10 years ago)
  • bp-activity/bp-activity-notifications.php

     
    351351add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications' );
    352352add_action( 'bp_activity_screen_mentions',                  'bp_activity_remove_screen_notifications' );
    353353
     354
     355function bp_activity_at_mention_delete_notification( $args = 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( $args['id'] ) ) {
     359                bp_notifications_delete_all_notifications_by_type( $args['id'], buddypress()->activity->id );
     360        }
     361}
     362add_action( 'bp_activity_delete', 'bp_activity_at_mention_delete_notification', 10, 1 );
  • bp-friends/bp-friends-notifications.php

     
    293293                bp_notifications_delete_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, buddypress()->friends->id, 'friendship_request' );
    294294        }
    295295}
    296 add_action( 'friends_friendship_withdrawn', 'bp_friends_mark_friendship_withdrawn_notifications_by_item_id', 10, 2 );
     296add_action( 'friends_friendship_whithdrawn', 'bp_friends_mark_friendship_withdrawn_notifications_by_item_id', 10, 2 );
    297297
    298298/**
    299299 * Remove friendship requests FROM user, used primarily when a user is deleted
  • bp-groups/bp-groups-notifications.php

     
    554554add_action( 'groups_delete_group', 'bp_groups_delete_group_delete_all_notifications', 10 );
    555555
    556556/**
     557 * Remove promoted notifications for any demoted member
     558 *
     559 * @since BuddyPress (?)
     560 */
     561function 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
     568add_action( 'groups_demoted_member', 'bp_groups_delete_group_delete_promoted_notifications', 10, 2 );
     569
     570/**
    557571 * Mark notifications read when a member accepts a group invitation
    558572 *
    559573 * @since BuddyPress (1.9.0)
  • bp-messages/bp-messages-classes.php

     
    127127                $recipients = $wpdb->get_results( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d AND is_deleted = 0", $thread_id ) );
    128128
    129129                if ( empty( $recipients ) ) {
     130                        // Get the massage id in order to delete notification
     131                        $message_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages} WHERE thread_id = %d", $thread_id ) );
     132
    130133                        // Delete all the messages
    131134                        $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_messages} WHERE thread_id = %d", $thread_id ) );
    132135
    133136                        // Delete all the recipients
    134137                        $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d", $thread_id ) );
     138
     139                        do_action_ref_array( 'messages_thread_deleted_thread', array( $message_id ) );
    135140                }
    136141
    137142                return true;
  • bp-messages/bp-messages-notifications.php

     
    189189        }
    190190}
    191191add_action( 'messages_screen_conversation', 'bp_messages_screen_inbox_mark_notifications', 10 );
     192
     193
     194function bp_messages_message_delete_notification( $message_id = 0 ) {
     195        if ( bp_is_active( 'notifications' ) && !empty( $message_id ) ) {
     196                bp_notifications_delete_all_notifications_by_type( $message_id, buddypress()->messages->id );
     197        }
     198}
     199
     200add_action( 'messages_thread_deleted_thread', 'bp_messages_message_delete_notification', 10, 1 );
     201