Skip to:
Content

BuddyPress.org

Changeset 5595


Ignore:
Timestamp:
12/24/2011 03:37:55 PM (13 years ago)
Author:
boonebgorges
Message:

Don't send at-message notifications more than once for the same activity item. Fixes #3825

Location:
trunk
Files:
2 edited

Legend:

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

    r5296 r5595  
    4141function bp_activity_at_message_notification( $activity_id, $receiver_user_id ) {
    4242    global $bp;
     43   
     44    // Don't leave multiple notifications for the same activity item
     45    $notifications = BP_Core_Notification::get_all_for_user( $receiver_user_id, 'all' );
     46   
     47    foreach( $notifications as $notification ) {
     48        if ( $activity_id == $notification->item_id ) {
     49            return;
     50        }
     51    }
    4352
    4453    $activity = new BP_Activity_Activity( $activity_id );
  • trunk/bp-core/bp-core-classes.php

    r5479 r5595  
    746746     * @global wpdb $wpdb WordPress database object
    747747     * @param integer $user_id User ID
     748     * @param str $status 'is_new' or 'all'
    748749     * @return array Associative array
    749750     * @static
    750751     */
    751     function get_all_for_user( $user_id ) {
     752    function get_all_for_user( $user_id, $status = 'is_new' ) {
    752753        global $bp, $wpdb;
    753754
    754         return $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND is_new = 1", $user_id ) );
     755        $is_new = 'is_new' == $status ? ' AND is_new = 1 ' : '';
     756
     757        return $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE user_id = %d {$is_new}", $user_id ) );
    755758    }
    756759
Note: See TracChangeset for help on using the changeset viewer.