Skip to:
Content

BuddyPress.org

Changeset 2020 for trunk/bp-messages.php


Ignore:
Timestamp:
09/30/2009 06:53:29 PM (16 years ago)
Author:
apeatling
Message:

Typecasting message arrays and checking to make sure duplicates do not slip through.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-messages.php

    r1995 r2020  
    440440
    441441        /* Strip the sender from the recipient list if they exist */
    442         if ( $key = array_search( $sender_id, $recipient_ids ) )
    443             unset( $recipient_ids[$key] ); 
    444 
     442        if ( $key = array_search( $sender_id, (array)$recipient_ids ) )
     443            unset( $recipient_ids[$key] );
     444
     445        /* Remove duplicates */
     446        $recipient_ids = array_unique( (array)$recipient_ids );
     447       
     448        if ( empty( $recipient_ids ) )
     449            return false;
     450       
    445451        $message->recipients = $recipient_ids;
    446452    }
     
    450456
    451457        // Send screen notifications to the recipients
    452         foreach ( $message->recipients as $recipient ) {
     458        foreach ( (array)$message->recipients as $recipient ) {
    453459            bp_core_add_notification( $message->id, $recipient, 'messages', 'new_message' );   
    454460        }
Note: See TracChangeset for help on using the changeset viewer.