Ticket #5479: 5479.01.patch
File 5479.01.patch, 4.7 KB (added by , 11 years ago) |
---|
-
bp-messages/bp-messages-notifications.php
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( __( 'You have %d new private messages', 'buddypress' ), (int) $total_items ); 127 133 } 128 134 $filter = 'bp_messages_single_new_message_notification'; 129 135 } … … 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( 'thread_loop_start', 'bp_messages_screen_conversation_mark_notifications', 10 ); 192 194 193 195 /** 194 196 * When a message is deleted, delete corresponding notifications. -
bp-messages/bp-messages-template.php
306 306 return apply_filters( 'bp_message_thread_to', BP_Messages_Thread::get_recipient_links($messages_template->thread->recipients ) ); 307 307 } 308 308 309 function bp_message_thread_view_link( ) {310 echo bp_get_message_thread_view_link( );309 function bp_message_thread_view_link( $thread_id = 0 ) { 310 echo bp_get_message_thread_view_link( $thread_id ); 311 311 } 312 function bp_get_message_thread_view_link() { 313 global $messages_template, $bp; 314 return apply_filters( 'bp_get_message_thread_view_link', trailingslashit( bp_loggedin_user_domain() . $bp->messages->slug . '/view/' . $messages_template->thread->thread_id ) ); 312 function bp_get_message_thread_view_link( $thread_id = 0 ) { 313 global $messages_template; 314 315 if ( empty( $messages_template ) && (int) $thread_id > 0 ) { 316 $thread_id = (int) $thread_id; 317 } else { 318 $thread_id = $messages_template->thread->thread_id; 319 } 320 321 return apply_filters( 'bp_get_message_thread_view_link', trailingslashit( bp_loggedin_user_domain() . buddypress()->messages->slug . '/view/' . $thread_id ) ); 315 322 } 316 323 317 324 function bp_message_thread_delete_link() { -
bp-notifications/bp-notifications-classes.php
663 663 $update = self::get_query_clauses( $update_args ); 664 664 $where = self::get_query_clauses( $where_args ); 665 665 666 // make sure we delete the notification cache for the user on update 667 if ( ! empty( $where_args['user_id'] ) ) { 668 wp_cache_delete( 'all_for_user_' . $where_args['user_id'], 'bp_notifications' ); 669 } 670 666 671 return self::_update( $update['data'], $where['data'], $update['format'], $where['format'] ); 667 672 } 668 673