Skip to:
Content

BuddyPress.org

Changeset 462


Ignore:
Timestamp:
10/30/2008 12:18:36 AM (17 years ago)
Author:
apeatling
Message:

Added message email notifications.

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-friends.php

    r449 r462  
    118118function friends_screen_requests() {
    119119    global $bp;
    120    
    121     // Remove any notifications of new friend requests as we are viewing the
    122     // friend request page
    123     bp_core_delete_notifications_for_user_by_type( $bp['loggedin_userid'], 'friends', 'friendship_request' );
    124        
     120           
    125121    if ( isset($bp['action_variables']) && in_array( 'accept', $bp['action_variables'] ) && is_numeric($bp['action_variables'][1]) ) {
    126122       
    127123        if ( friends_accept_friendship( $bp['action_variables'][1] ) ) {
     124            //bp_core_delete_notification( $bp['loggedin_userid'], 'friends', 'friendship_request' );
     125           
    128126            $bp['message'] = __('Friendship accepted', 'buddypress');
    129127            $bp['message_type'] = 'success';
  • trunk/bp-messages.php

    r449 r462  
    1010include_once( 'bp-messages/bp-messages-admin.php' );
    1111include_once( 'bp-messages/bp-messages-templatetags.php' );
     12include_once( 'bp-messages/bp-messages-notifications.php' );
    1213
    1314/**************************************************************************
     
    346347}
    347348
    348 
    349 /**************************************************************************
    350  messages_format_activity()
    351  
    352  Selects and formats recorded messages component activity.
    353  **************************************************************************/
    354 
    355 function messages_format_activity( $friendship_id, $action, $for_secondary_user = false  ) {
    356     global $bp;
    357    
    358     switch( $action ) {
    359         // no actions set yet.
    360     }
    361    
    362     return false;
    363 }
    364 
    365349function messages_format_notifications( $action, $item_id, $total_items ) {
    366350    global $bp;
     
    512496                    // Send notices to the recipients
    513497                    for ( $i = 0; $i < count($pmessage->recipients); $i++ ) {
    514                         if ( $pmessage->recipients[$i] != $bp['loggedin_userid'] )
     498                        if ( $pmessage->recipients[$i] != $bp['loggedin_userid'] ) {
    515499                            bp_core_add_notification( $pmessage->id, $pmessage->recipients[$i], 'messages', 'new_message' );   
     500                        }
    516501                    }
    517502                   
    518                     do_action( 'bp_messages_message_sent', array( 'item_id' => $pmessage->id, 'recipient_ids' => $pmessage->recipients, 'component_name' => 'messages', 'component_action' => 'message_sent', 'is_private' => 1 ) );
     503                    do_action( 'bp_messages_message_sent', array( 'item_id' => $pmessage->id, 'recipient_ids' => $pmessage->recipients, 'thread_id' => $pmessage->thread_id, 'component_name' => 'messages', 'component_action' => 'message_sent', 'is_private' => 1 ) );
    519504           
    520505                    if ( $from_ajax ) {
     
    582567        $notice->is_active = 1;
    583568        $notice->save(); // send it.
     569       
     570        do_action( 'bp_messages_notice_sent', $subject, $message );
    584571    }
    585572       
  • trunk/bp-messages/bp-messages-classes.php

    r391 r462  
    284284   
    285285    var $thread_id;
    286     var $recipients;
     286    var $recipients = false;
    287287
    288288    function bp_messages_message( $id = null ) {
     
    318318
    319319        // First insert the message into the messages table
    320         $sql = $wpdb->prepare( "INSERT INTO " . $bp['messages']['table_name_messages'] . " ( sender_id, subject, message, date_sent, message_order, sender_is_group ) VALUES ( %d, %s, %s, FROM_UNIXTIME(%d), %d, %d )", $userdata->ID, $this->subject, $this->message, $this->date_sent, $this->message_order, $this->sender_is_group );
    321 
    322         if ( $wpdb->query($sql) === false )
    323             return false;
    324 
     320        if ( !$wpdb->query( $wpdb->prepare( "INSERT INTO " . $bp['messages']['table_name_messages'] . " ( sender_id, subject, message, date_sent, message_order, sender_is_group ) VALUES ( %d, %s, %s, FROM_UNIXTIME(%d), %d, %d )", $userdata->ID, $this->subject, $this->message, $this->date_sent, $this->message_order, $this->sender_is_group ) ) )
     321            return false;
     322           
    325323        // Next, if thread_id is set, we are adding to an existing thread, if not, start a new one.
    326324        if ( $this->thread_id ) {
     
    331329            $message_ids = serialize($message_ids);
    332330           
     331            // We need this so we can return the new message ID.
     332            $message_id = $wpdb->insert_id;
     333           
    333334            // Update the sender ids for the thread
    334335            $sender_ids = unserialize($the_ids->sender_ids);
     
    345346           
    346347            // Find the recipients and update the unread counts for each
    347             $recipients = $wpdb->get_results( $wpdb->prepare( "SELECT user_id FROM " . $bp['messages']['table_name_recipients'] . " WHERE thread_id = %d", $this->thread_id ) );
    348            
    349             for ( $i = 0; $i < count($recipients); $i++ ) {
    350                 if ( $recipients[$i]->user_id != $userdata->ID )
    351                     $wpdb->query( $wpdb->prepare( "UPDATE " . $bp['messages']['table_name_recipients'] . " SET unread_count = unread_count + 1, sender_only = 0 WHERE thread_id = %d AND user_id = %d", $this->thread_id, $recipients[$i]->user_id ) );
     348            if ( !$this->recipients )
     349                $this->recipients = $this->get_recipients();
     350           
     351            for ( $i = 0; $i < count($this->recipients); $i++ ) {
     352                if ( $this->recipients[$i]->user_id != $userdata->ID )
     353                    $wpdb->query( $wpdb->prepare( "UPDATE " . $bp['messages']['table_name_recipients'] . " SET unread_count = unread_count + 1, sender_only = 0 WHERE thread_id = %d AND user_id = %d", $this->thread_id, $this->recipients[$i]->user_id ) );
    352354            }
    353355        } else {
     
    374376            }
    375377        }
    376         update_usermeta( $userdata->ID, 'last_activity', date( 'Y-m-d H:i:s' ) );
     378       
     379        $this->id = $message_id;
    377380       
    378381        return true;
     382    }
     383   
     384    function get_recipients() {
     385        global $bp, $wpdb;
     386       
     387        return $wpdb->get_results( $wpdb->prepare( "SELECT user_id FROM " . $bp['messages']['table_name_recipients'] . " WHERE thread_id = %d", $this->thread_id ) );
    379388    }
    380389   
  • trunk/bp-xprofile.php

    r454 r462  
    338338
    339339---------------------
    340 ', 'buddypress' ), $poster_name, $wire_post->content, $wire_link );
     340', 'buddypress' ), $poster_name, stripslashes($wire_post->content), $wire_link );
    341341
    342342            $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
Note: See TracChangeset for help on using the changeset viewer.