Changeset 8202
- Timestamp:
- 03/29/2014 01:00:36 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/deprecated/2.0.php
r8073 r8202 24 24 _deprecated_function( __FUNCTION__, '2.0', 'bp_blogs_catch_transition_post_status()' ); 25 25 } 26 27 /** 28 * @deprecated BuddyPress (2.0.0) 29 */ 30 function bp_messages_screen_inbox_mark_notifications() { 31 _deprecated_function( __FUNCTION__, '2.0', 'bp_messages_screen_conversation_mark_notifications()' ); 32 } -
trunk/bp-messages/bp-messages-notifications.php
r8099 r8202 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' ), 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'; … … 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 * … … 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' ); 189 } 190 } 191 add_action( 'messages_screen_conversation', 'bp_messages_screen_inbox_mark_notifications', 10 ); 182 global $thread_template; 183 184 // get unread PM notifications for the user 185 $new_pm_notifications = BP_Notifications_Notification::get( array( 186 'user_id' => bp_loggedin_user_id(), 187 'component_name' => buddypress()->messages->id, 188 'component_action' => 'new_message', 189 'is_new' => 1, 190 ) ); 191 $unread_message_ids = wp_list_pluck( $new_pm_notifications, 'item_id' ); 192 193 // no unread PMs, so stop! 194 if ( empty( $unread_message_ids ) ) { 195 return; 196 } 197 198 // get the unread message ids for this thread only 199 $message_ids = array_intersect( $unread_message_ids, wp_list_pluck( $thread_template->thread->messages, 'id' ) ); 200 201 // mark each notification for each PM message as read 202 foreach ( $message_ids as $message_id ) { 203 bp_notifications_mark_notifications_by_item_id( bp_loggedin_user_id(), (int) $message_id, buddypress()->messages->id, 'new_message' ); 204 } 205 } 206 } 207 add_action( 'thread_loop_start', 'bp_messages_screen_conversation_mark_notifications', 10 ); 192 208 193 209 /** -
trunk/bp-messages/bp-messages-template.php
r8070 r8202 307 307 } 308 308 309 function bp_message_thread_view_link() { 310 echo bp_get_message_thread_view_link(); 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 ) ); 309 function bp_message_thread_view_link( $thread_id = 0 ) { 310 echo bp_get_message_thread_view_link( $thread_id ); 311 } 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
Note: See TracChangeset
for help on using the changeset viewer.