Ticket #5273: 5273.single_new_message_notification.patch
File 5273.single_new_message_notification.patch, 4.2 KB (added by , 11 years ago) |
---|
-
bp-messages/bp-messages-notifications.php
function messages_format_notifications( $action, $item_id, $secondary_item_id, $ 120 120 $text = sprintf( __('You have %d new messages', 'buddypress' ), (int) $total_items ); 121 121 $filter = 'bp_messages_multiple_new_message_notification'; 122 122 } else { 123 if ( !empty( $secondary_item_id ) ) { 124 $text = sprintf( __('You have %d new message from %s', 'buddypress' ), (int) $total_items, bp_core_get_user_displayname( $secondary_item_id ) ); 123 // get message thread ID 124 $message = new BP_Messages_Message( $item_id ); 125 $thread_id = $message->thread_id; 126 127 $link = bp_get_message_thread_view_link( $thread_id ); 128 129 if ( ! empty( $secondary_item_id ) ) { 130 $text = sprintf( __( '%2$s sent you a new private message', 'buddypress' ), (int) $total_items, bp_core_get_user_displayname( $secondary_item_id ) ); 125 131 } else { 126 $text = sprintf( __( 'You have %d new message','buddypress' ), (int) $total_items );132 $text = sprintf( __( 'buddypress' ), (int) $total_items ); 127 133 } 128 134 $filter = 'bp_messages_single_new_message_notification'; 129 135 } … … function bp_messages_message_sent_add_notification( $message ) { 167 173 add_action( 'messages_message_sent', 'bp_messages_message_sent_add_notification', 10 ); 168 174 169 175 /** 170 * Mark new message notifications when member views their inbox.171 *172 * @since BuddyPress (1.9.0)173 */174 function bp_messages_screen_inbox_mark_notifications() {175 if ( bp_is_active( 'notifications' ) ) {176 bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->messages->id, 'new_message' );177 }178 }179 add_action( 'messages_screen_inbox', 'bp_messages_screen_inbox_mark_notifications', 10 );180 181 /**182 176 * Mark new message notification when member reads a message thread directly. 183 177 * 184 178 * @since BuddyPress (1.9.0) 185 179 */ 186 180 function bp_messages_screen_conversation_mark_notifications() { 187 181 if ( bp_is_active( 'notifications' ) ) { 188 bp_notifications_mark_notifications_by_item_id( bp_loggedin_user_id(), (int) bp_action_variable( 0 ), buddypress()->messages->id, 'new_message' ); 182 global $thread_template; 183 184 // get all message ids from message thread 185 $message_ids = wp_list_pluck( $thread_template->thread->messages, 'id' ); 186 187 // mark each notification for each PM message as read in a loop 188 foreach ( $message_ids as $message_id ) { 189 bp_notifications_mark_notifications_by_item_id( bp_loggedin_user_id(), (int) $message_id, buddypress()->messages->id, 'new_message' ); 190 } 189 191 } 190 192 } 191 add_action( ' messages_screen_conversation', 'bp_messages_screen_inbox_mark_notifications', 10 );193 add_action( '_mark_notifications', 10 ); -
bp-messages/bp-messages-template.php
function bp_message_thread_to() { 252 252 return apply_filters( 'bp_message_thread_to', BP_Messages_Thread::get_recipient_links($messages_template->thread->recipients ) ); 253 253 } 254 254 255 function bp_message_thread_view_link( ) {256 echo bp_get_message_thread_view_link( );255 function bp_message_thread_view_link() { 256 echo bp_get_message_thread_view_link(); 257 257 } 258 function bp_get_message_thread_view_link() { 259 global $messages_template, $bp; 260 return apply_filters( 'bp_get_message_thread_view_link', trailingslashit( bp_loggedin_user_domain() . $bp->messages->slug . '/view/' . $messages_template->thread->thread_id ) ); 258 function bp_get_message_thread_view_link( $thread_id = 0 ) { 259 global $messages_template; 260 261 if ( empty( $messages_template ) && (int) $thread_id > 0 ) { 262 $thread_id = (int) $thread_id; 263 } else { 264 $thread_id = $messages_template->thread->thread_id; 265 } 266 267 return apply_filters( 'bp_get_message_thread_view_link', trailingslashit( bp_loggedin_user_domain() . buddypress()->messages->slug . '/view/' . $thread_id ) ); 261 268 } 262 269 263 270 function bp_message_thread_delete_link() {