diff --git src/bp-messages/bp-messages-actions.php src/bp-messages/bp-messages-actions.php
index e145f85..eb77706 100644
|
|
|
function messages_action_conversation() { |
| 247 | 247 | bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id . '/' ); |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | | // Mark message read. |
| 251 | | messages_mark_thread_read( $thread_id ); |
| | 250 | /* |
| | 251 | * Mark message read, but only run on the logged-in user's profile. |
| | 252 | * If an admin visits a thread, it shouldn't change the read status. |
| | 253 | */ |
| | 254 | if ( bp_is_my_profile() ) { |
| | 255 | messages_mark_thread_read( $thread_id ); |
| | 256 | } |
| 252 | 257 | |
| 253 | 258 | /** |
| 254 | 259 | * Fires after processing a view request for a single message thread. |
| … |
… |
function bp_messages_action_mark_read() { |
| 319 | 324 | } |
| 320 | 325 | |
| 321 | 326 | // Check access to the message and mark as read. |
| 322 | | if ( messages_check_thread_access( $id ) ) { |
| | 327 | if ( messages_check_thread_access( $id ) || bp_current_user_can( 'bp_moderate' ) ) { |
| 323 | 328 | messages_mark_thread_read( $id ); |
| 324 | 329 | bp_core_add_message( __( 'Message marked as read.', 'buddypress' ) ); |
| 325 | 330 | } else { |
| … |
… |
function bp_messages_action_mark_unread() { |
| 360 | 365 | } |
| 361 | 366 | |
| 362 | 367 | // Check access to the message and mark unread. |
| 363 | | if ( messages_check_thread_access( $id ) ) { |
| | 368 | if ( messages_check_thread_access( $id ) || bp_current_user_can( 'bp_moderate' ) ) { |
| 364 | 369 | messages_mark_thread_unread( $id ); |
| 365 | 370 | bp_core_add_message( __( 'Message marked unread.', 'buddypress' ) ); |
| 366 | 371 | } else { |
| … |
… |
function bp_messages_action_bulk_manage() { |
| 404 | 409 | |
| 405 | 410 | // Make sure the user has access to all notifications before managing them. |
| 406 | 411 | foreach ( $messages as $message ) { |
| 407 | | if ( ! messages_check_thread_access( $message ) ) { |
| | 412 | if ( ! messages_check_thread_access( $message ) && ! bp_current_user_can( 'bp_moderate' ) ) { |
| 408 | 413 | bp_core_add_message( __( 'There was a problem managing your messages.', 'buddypress' ), 'error' ); |
| 409 | 414 | bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/' ); |
| 410 | 415 | } |
diff --git src/bp-messages/bp-messages-cache.php src/bp-messages/bp-messages-cache.php
index 434c3a8..6883c96 100644
|
|
|
add_action( 'messages_message_after_save', 'bp_messages_clear_cache_on_message_s |
| 74 | 74 | * |
| 75 | 75 | * @param int|array $thread_ids If single thread, the thread ID. |
| 76 | 76 | * Otherwise, an array of thread IDs. |
| | 77 | * @param int $user_id ID of the user that the threads were deleted for. |
| 77 | 78 | */ |
| 78 | | function bp_messages_clear_cache_on_message_delete( $thread_ids ) { |
| | 79 | function bp_messages_clear_cache_on_message_delete( $thread_ids, $user_id ) { |
| 79 | 80 | // Delete thread and thread recipient cache. |
| 80 | 81 | foreach( (array) $thread_ids as $thread_id ) { |
| 81 | 82 | wp_cache_delete( $thread_id, 'bp_messages_threads' ); |
| … |
… |
function bp_messages_clear_cache_on_message_delete( $thread_ids ) { |
| 83 | 84 | } |
| 84 | 85 | |
| 85 | 86 | // Delete unread count for logged-in user. |
| 86 | | wp_cache_delete( bp_loggedin_user_id(), 'bp_messages_unread_count' ); |
| | 87 | wp_cache_delete( $user_id, 'bp_messages_unread_count' ); |
| 87 | 88 | } |
| 88 | | add_action( 'messages_delete_thread', 'bp_messages_clear_cache_on_message_delete' ); |
| | 89 | add_action( 'messages_delete_thread', 'bp_messages_clear_cache_on_message_delete', 10, 2 ); |
| 89 | 90 | |
| 90 | 91 | /** |
| 91 | 92 | * Invalidate cache for notices. |
diff --git src/bp-messages/bp-messages-functions.php src/bp-messages/bp-messages-functions.php
index 16e70b8..f78ddcf 100644
|
|
|
function messages_send_notice( $subject, $message ) { |
| 254 | 254 | function messages_delete_thread( $thread_ids, $user_id = 0 ) { |
| 255 | 255 | |
| 256 | 256 | if ( empty( $user_id ) ) { |
| 257 | | $user_id = bp_loggedin_user_id(); |
| | 257 | $user_id = |
| | 258 | bp_displayed_user_id() ? |
| | 259 | bp_displayed_user_id() : |
| | 260 | bp_loggedin_user_id(); |
| 258 | 261 | } |
| 259 | 262 | |
| 260 | 263 | /** |
| … |
… |
function messages_remove_callback_values() { |
| 380 | 383 | * @return int |
| 381 | 384 | */ |
| 382 | 385 | function messages_get_unread_count( $user_id = 0 ) { |
| 383 | | if ( empty( $user_id ) ) { |
| 384 | | $user_id = bp_loggedin_user_id(); |
| 385 | | } |
| 386 | | |
| 387 | 386 | return BP_Messages_Thread::get_inbox_count( $user_id ); |
| 388 | 387 | } |
| 389 | 388 | |
diff --git src/bp-messages/bp-messages-notifications.php src/bp-messages/bp-messages-notifications.php
index 4a6b025..f6d2284 100644
|
|
|
add_action( 'messages_message_sent', 'bp_messages_message_sent_add_notification' |
| 171 | 171 | function bp_messages_screen_conversation_mark_notifications() { |
| 172 | 172 | global $thread_template; |
| 173 | 173 | |
| | 174 | /* |
| | 175 | * Only run on the logged-in user's profile. |
| | 176 | * If an admin visits a thread, it shouldn't change the read status. |
| | 177 | */ |
| | 178 | if ( ! bp_is_my_profile() ) { |
| | 179 | return; |
| | 180 | } |
| | 181 | |
| 174 | 182 | // Get unread PM notifications for the user. |
| 175 | 183 | $new_pm_notifications = BP_Notifications_Notification::get( array( |
| 176 | 184 | 'user_id' => bp_loggedin_user_id(), |
diff --git src/bp-messages/bp-messages-star.php src/bp-messages/bp-messages-star.php
index 2b4e667..54e06c8 100644
|
|
|
function bp_get_messages_starred_slug() { |
| 41 | 41 | */ |
| 42 | 42 | function bp_messages_is_message_starred( $mid = 0, $user_id = 0 ) { |
| 43 | 43 | if ( empty( $user_id ) ) { |
| 44 | | $user_id = bp_loggedin_user_id(); |
| | 44 | $user_id = bp_displayed_user_id(); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | if ( empty( $mid ) ) { |
| … |
… |
function bp_messages_star_set_action( $args = array() ) { |
| 254 | 254 | 'action' => 'star', |
| 255 | 255 | 'thread_id' => 0, |
| 256 | 256 | 'message_id' => 0, |
| 257 | | 'user_id' => bp_loggedin_user_id(), |
| | 257 | 'user_id' => bp_displayed_user_id(), |
| 258 | 258 | 'bulk' => false |
| 259 | 259 | ) ); |
| 260 | 260 | |
| … |
… |
function bp_messages_star_action_handler() { |
| 397 | 397 | ) ); |
| 398 | 398 | |
| 399 | 399 | // Redirect back to previous screen. |
| 400 | | $redirect = wp_get_referer() ? wp_get_referer() : bp_loggedin_user_domain() . bp_get_messages_slug(); |
| | 400 | $redirect = wp_get_referer() ? wp_get_referer() : bp_displayed_user_domain() . bp_get_messages_slug(); |
| 401 | 401 | bp_core_redirect( $redirect ); |
| 402 | 402 | die(); |
| 403 | 403 | } |
diff --git src/bp-messages/bp-messages-template.php src/bp-messages/bp-messages-template.php
index c89d691..aa7de6e 100644
|
|
|
function bp_has_message_threads( $args = array() ) { |
| 58 | 58 | |
| 59 | 59 | // User ID |
| 60 | 60 | // @todo displayed user for moderators that get this far? |
| 61 | | $user_id = bp_loggedin_user_id(); |
| | 61 | $user_id = bp_displayed_user_id(); |
| 62 | 62 | |
| 63 | 63 | // Search Terms. |
| 64 | 64 | $search_terms = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : ''; |
| … |
… |
function bp_message_thread_view_link( $thread_id = 0 ) { |
| 304 | 304 | * @param string $value Permalink of a particular thread. |
| 305 | 305 | * @param int $thread_id ID of the thread. |
| 306 | 306 | */ |
| 307 | | return apply_filters( 'bp_get_message_thread_view_link', trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id ), $thread_id ); |
| | 307 | return apply_filters( 'bp_get_message_thread_view_link', trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id ), $thread_id ); |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | /** |
| … |
… |
function bp_message_thread_delete_link() { |
| 329 | 329 | * @param string $value URL for deleting the current thread. |
| 330 | 330 | * @param string $value Text indicating action being executed. |
| 331 | 331 | */ |
| 332 | | return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/delete/' . $messages_template->thread->thread_id ), 'messages_delete_thread' ) ); |
| | 332 | return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/delete/' . $messages_template->thread->thread_id ), 'messages_delete_thread' ) ); |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
| … |
… |
function bp_the_message_thread_mark_unread_url() { |
| 361 | 361 | ); |
| 362 | 362 | |
| 363 | 363 | // Base unread URL. |
| 364 | | $url = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/unread' ); |
| | 364 | $url = trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/unread' ); |
| 365 | 365 | |
| 366 | 366 | // Add the args to the URL. |
| 367 | 367 | $url = add_query_arg( $args, $url ); |
| … |
… |
function bp_the_message_thread_mark_read_url() { |
| 408 | 408 | ); |
| 409 | 409 | |
| 410 | 410 | // Base read URL. |
| 411 | | $url = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/read' ); |
| | 411 | $url = trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/read' ); |
| 412 | 412 | |
| 413 | 413 | // Add the args to the URL. |
| 414 | 414 | $url = add_query_arg( $args, $url ); |
| … |
… |
function bp_message_thread_avatar( $args = '' ) { |
| 696 | 696 | |
| 697 | 697 | /** |
| 698 | 698 | * Output the unread messages count for the current inbox. |
| | 699 | * |
| | 700 | * @since 2.6.x Added $user_id argument. |
| | 701 | * |
| | 702 | * @param int $user_id The user ID. |
| | 703 | * |
| | 704 | * @return int $unread_count Total inbox unread count for user. |
| 699 | 705 | */ |
| 700 | | function bp_total_unread_messages_count() { |
| 701 | | echo bp_get_total_unread_messages_count(); |
| | 706 | function bp_total_unread_messages_count( $user_id = 0 ) { |
| | 707 | echo bp_get_total_unread_messages_count( $user_id ); |
| 702 | 708 | } |
| 703 | 709 | /** |
| 704 | 710 | * Get the unread messages count for the current inbox. |
| 705 | 711 | * |
| 706 | | * @return int |
| | 712 | * @since 2.6.x Added $user_id argument. |
| | 713 | * |
| | 714 | * @param int $user_id The user ID. |
| | 715 | * |
| | 716 | * @return int $unread_count Total inbox unread count for user. |
| 707 | 717 | */ |
| 708 | | function bp_get_total_unread_messages_count() { |
| | 718 | function bp_get_total_unread_messages_count( $user_id = 0 ) { |
| 709 | 719 | |
| 710 | 720 | /** |
| 711 | 721 | * Filters the unread messages count for the current inbox. |
| … |
… |
function bp_total_unread_messages_count() { |
| 714 | 724 | * |
| 715 | 725 | * @param int $value Unread messages count for the current inbox. |
| 716 | 726 | */ |
| 717 | | return apply_filters( 'bp_get_total_unread_messages_count', BP_Messages_Thread::get_inbox_count() ); |
| | 727 | return apply_filters( 'bp_get_total_unread_messages_count', BP_Messages_Thread::get_inbox_count( $user_id ) ); |
| 718 | 728 | } |
| 719 | 729 | |
| 720 | 730 | /** |
| … |
… |
function bp_messages_form_action() { |
| 824 | 834 | * |
| 825 | 835 | * @param string $value The form action. |
| 826 | 836 | */ |
| 827 | | return apply_filters( 'bp_get_messages_form_action', trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/' . bp_action_variable( 0 ) ) ); |
| | 837 | return apply_filters( 'bp_get_messages_form_action', trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/' . bp_action_variable( 0 ) ) ); |
| 828 | 838 | } |
| 829 | 839 | |
| 830 | 840 | /** |
| … |
… |
function bp_message_notice_delete_link() { |
| 1153 | 1163 | * @param string $value URL for deleting the current notice. |
| 1154 | 1164 | * @param string $value Text indicating action being executed. |
| 1155 | 1165 | */ |
| 1156 | | return apply_filters( 'bp_get_message_notice_delete_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices/delete/' . $messages_template->thread->id, 'messages_delete_thread' ) ); |
| | 1166 | return apply_filters( 'bp_get_message_notice_delete_link', wp_nonce_url( bp_displayed_user_domain() . bp_get_messages_slug() . '/notices/delete/' . $messages_template->thread->id, 'messages_delete_thread' ) ); |
| 1157 | 1167 | } |
| 1158 | 1168 | |
| 1159 | 1169 | /** |
| … |
… |
function bp_message_activate_deactivate_link() { |
| 1171 | 1181 | global $messages_template; |
| 1172 | 1182 | |
| 1173 | 1183 | if ( 1 === (int) $messages_template->thread->is_active ) { |
| 1174 | | $link = wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices/deactivate/' . $messages_template->thread->id ), 'messages_deactivate_notice' ); |
| | 1184 | $link = wp_nonce_url( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/notices/deactivate/' . $messages_template->thread->id ), 'messages_deactivate_notice' ); |
| 1175 | 1185 | } else { |
| 1176 | | $link = wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices/activate/' . $messages_template->thread->id ), 'messages_activate_notice' ); |
| | 1186 | $link = wp_nonce_url( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/notices/activate/' . $messages_template->thread->id ), 'messages_activate_notice' ); |
| 1177 | 1187 | } |
| 1178 | 1188 | |
| 1179 | 1189 | /** |
| … |
… |
function bp_the_thread_recipients_list() { |
| 1634 | 1644 | } |
| 1635 | 1645 | |
| 1636 | 1646 | $recipient_links[] = $recipient_link; |
| | 1647 | } else { |
| | 1648 | $recipient_links[] = __( 'you', 'buddypress' ); |
| 1637 | 1649 | } |
| 1638 | 1650 | } |
| 1639 | 1651 | |
| | 1652 | // Convert to natural language. |
| | 1653 | $size = count( $recipient_links ); |
| | 1654 | $string = ''; |
| | 1655 | |
| | 1656 | $recipient_links[ $size - 1 ] = _x( 'and ', 'Joining word in a list of message recipients', 'buddypress' ) . $recipient_links[ $size - 1 ]; |
| | 1657 | |
| | 1658 | if ( $size >= 3 ) { |
| | 1659 | $recipient_links = implode( ', ', $recipient_links ); |
| | 1660 | } else { |
| | 1661 | $recipient_links = implode( ' ', $recipient_links ); |
| | 1662 | } |
| | 1663 | |
| 1640 | 1664 | /** |
| 1641 | 1665 | * Filters the HTML links to the profiles of recipients in the current thread. |
| 1642 | 1666 | * |
| … |
… |
function bp_the_thread_recipients_list() { |
| 1644 | 1668 | * |
| 1645 | 1669 | * @param string $value Comma-separated list of recipient HTML links for current thread. |
| 1646 | 1670 | */ |
| 1647 | | return apply_filters( 'bp_get_the_thread_recipients_list', implode( ', ', $recipient_links ) ); |
| | 1671 | return apply_filters( 'bp_get_the_thread_recipients_list', $recipient_links ); |
| 1648 | 1672 | } |
| 1649 | 1673 | |
| 1650 | 1674 | /** |
| … |
… |
function bp_the_thread_delete_link() { |
| 1919 | 1943 | * @param string $value URL for deleting the current thread. |
| 1920 | 1944 | * @param string $value Text indicating action being executed. |
| 1921 | 1945 | */ |
| 1922 | | return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/inbox/delete/' . bp_get_the_thread_id(), 'messages_delete_thread' ) ); |
| | 1946 | return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( bp_displayed_user_domain() . bp_get_messages_slug() . '/inbox/delete/' . bp_get_the_thread_id(), 'messages_delete_thread' ) ); |
| 1923 | 1947 | } |
| 1924 | 1948 | |
| 1925 | 1949 | /** |
diff --git src/bp-messages/classes/class-bp-messages-component.php src/bp-messages/classes/class-bp-messages-component.php
index baf5207..7049563 100644
|
|
|
class BP_Messages_Component extends BP_Component { |
| 145 | 145 | |
| 146 | 146 | // Only grab count if we're on a user page and current user has access. |
| 147 | 147 | if ( bp_is_user() && bp_user_has_access() ) { |
| 148 | | $count = bp_get_total_unread_messages_count(); |
| | 148 | $count = bp_get_total_unread_messages_count( bp_displayed_user_id() ); |
| 149 | 149 | $class = ( 0 === $count ) ? 'no-count' : 'count'; |
| 150 | 150 | $nav_name = sprintf( |
| 151 | 151 | /* translators: %s: Unread message count for the current user */ |
| … |
… |
class BP_Messages_Component extends BP_Component { |
| 204 | 204 | 'user_has_access' => $access |
| 205 | 205 | ); |
| 206 | 206 | |
| 207 | | $sub_nav[] = array( |
| 208 | | 'name' => __( 'Compose', 'buddypress' ), |
| 209 | | 'slug' => 'compose', |
| 210 | | 'parent_url' => $messages_link, |
| 211 | | 'parent_slug' => $slug, |
| 212 | | 'screen_function' => 'messages_screen_compose', |
| 213 | | 'position' => 30, |
| 214 | | 'user_has_access' => $access |
| 215 | | ); |
| | 207 | // Show certain screens only if the current user is the displayed user. |
| | 208 | if ( bp_is_my_profile() ) { |
| 216 | 209 | |
| 217 | | if ( bp_current_user_can( 'bp_moderate' ) ) { |
| | 210 | // Show "Compose" on the logged-in user's profile only. |
| 218 | 211 | $sub_nav[] = array( |
| 219 | | 'name' => __( 'Notices', 'buddypress' ), |
| 220 | | 'slug' => 'notices', |
| | 212 | 'name' => __( 'Compose', 'buddypress' ), |
| | 213 | 'slug' => 'compose', |
| 221 | 214 | 'parent_url' => $messages_link, |
| 222 | 215 | 'parent_slug' => $slug, |
| 223 | | 'screen_function' => 'messages_screen_notices', |
| 224 | | 'position' => 90, |
| 225 | | 'user_has_access' => true |
| | 216 | 'screen_function' => 'messages_screen_compose', |
| | 217 | 'position' => 30, |
| | 218 | 'user_has_access' => $access |
| 226 | 219 | ); |
| | 220 | |
| | 221 | /* |
| | 222 | * Show "Notices" on the logged-in user's profile only |
| | 223 | * and then only if the user can create notices. |
| | 224 | */ |
| | 225 | if ( bp_current_user_can( 'bp_moderate' ) ) { |
| | 226 | $sub_nav[] = array( |
| | 227 | 'name' => __( 'Notices', 'buddypress' ), |
| | 228 | 'slug' => 'notices', |
| | 229 | 'parent_url' => $messages_link, |
| | 230 | 'parent_slug' => $slug, |
| | 231 | 'screen_function' => 'messages_screen_notices', |
| | 232 | 'position' => 90, |
| | 233 | 'user_has_access' => true |
| | 234 | ); |
| | 235 | } |
| 227 | 236 | } |
| 228 | 237 | |
| 229 | 238 | parent::setup_nav( $main_nav, $sub_nav ); |
| … |
… |
class BP_Messages_Component extends BP_Component { |
| 243 | 252 | $messages_link = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() ); |
| 244 | 253 | |
| 245 | 254 | // Unread message count. |
| 246 | | $count = messages_get_unread_count(); |
| | 255 | $count = messages_get_unread_count( bp_loggedin_user_id() ); |
| 247 | 256 | if ( !empty( $count ) ) { |
| 248 | 257 | $title = sprintf( |
| 249 | 258 | /* translators: %s: Unread message count for the current user */ |
diff --git src/bp-messages/classes/class-bp-messages-thread.php src/bp-messages/classes/class-bp-messages-thread.php
index 7b5356d..c868d55 100644
|
|
|
class BP_Messages_Thread { |
| 144 | 144 | $order = 'ASC'; |
| 145 | 145 | } |
| 146 | 146 | |
| | 147 | $user_id = |
| | 148 | bp_displayed_user_id() ? |
| | 149 | bp_displayed_user_id() : |
| | 150 | bp_loggedin_user_id(); |
| | 151 | |
| 147 | 152 | // Merge $args with our defaults. |
| 148 | 153 | $r = wp_parse_args( $args, array( |
| 149 | | 'user_id' => bp_loggedin_user_id(), |
| | 154 | 'user_id' => $user_id, |
| 150 | 155 | 'update_meta_cache' => true |
| 151 | 156 | ) ); |
| 152 | 157 | |
| … |
… |
class BP_Messages_Thread { |
| 613 | 618 | public static function mark_as_read( $thread_id = 0 ) { |
| 614 | 619 | global $wpdb; |
| 615 | 620 | |
| | 621 | $user_id = |
| | 622 | bp_displayed_user_id() ? |
| | 623 | bp_displayed_user_id() : |
| | 624 | bp_loggedin_user_id(); |
| | 625 | |
| 616 | 626 | $bp = buddypress(); |
| 617 | | $retval = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 0 WHERE user_id = %d AND thread_id = %d", bp_loggedin_user_id(), $thread_id ) ); |
| | 627 | $retval = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 0 WHERE user_id = %d AND thread_id = %d", $user_id, $thread_id ) ); |
| 618 | 628 | |
| 619 | 629 | wp_cache_delete( 'thread_recipients_' . $thread_id, 'bp_messages' ); |
| 620 | | wp_cache_delete( bp_loggedin_user_id(), 'bp_messages_unread_count' ); |
| | 630 | wp_cache_delete( $user_id, 'bp_messages_unread_count' ); |
| 621 | 631 | |
| 622 | 632 | /** |
| 623 | 633 | * Fires when messages thread was marked as read. |
| … |
… |
class BP_Messages_Thread { |
| 643 | 653 | public static function mark_as_unread( $thread_id = 0 ) { |
| 644 | 654 | global $wpdb; |
| 645 | 655 | |
| | 656 | $user_id = |
| | 657 | bp_displayed_user_id() ? |
| | 658 | bp_displayed_user_id() : |
| | 659 | bp_loggedin_user_id(); |
| | 660 | |
| 646 | 661 | $bp = buddypress(); |
| 647 | | $retval = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 1 WHERE user_id = %d AND thread_id = %d", bp_loggedin_user_id(), $thread_id ) ); |
| | 662 | $retval = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 1 WHERE user_id = %d AND thread_id = %d", $user_id, $thread_id ) ); |
| 648 | 663 | |
| 649 | 664 | wp_cache_delete( 'thread_recipients_' . $thread_id, 'bp_messages' ); |
| 650 | | wp_cache_delete( bp_loggedin_user_id(), 'bp_messages_unread_count' ); |
| | 665 | wp_cache_delete( $user_id, 'bp_messages_unread_count' ); |
| 651 | 666 | |
| 652 | 667 | /** |
| 653 | 668 | * Fires when messages thread was marked as unread. |
diff --git src/bp-templates/bp-legacy/buddypress/members/single/messages/messages-loop.php src/bp-templates/bp-legacy/buddypress/members/single/messages/messages-loop.php
index 4b37ead..148d5f3 100644
|
|
|
do_action( 'bp_before_member_messages_loop' ); ?> |
| 50 | 50 | */ |
| 51 | 51 | do_action( 'bp_before_member_messages_threads' ); ?> |
| 52 | 52 | |
| 53 | | <form action="<?php echo bp_loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() ?>/bulk-manage/" method="post" id="messages-bulk-management"> |
| | 53 | <form action="<?php echo bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() ?>/bulk-manage/" method="post" id="messages-bulk-management"> |
| 54 | 54 | |
| 55 | 55 | <table id="message-threads" class="messages-notices"> |
| 56 | 56 | |
diff --git src/bp-templates/bp-legacy/buddypress/members/single/messages/single.php src/bp-templates/bp-legacy/buddypress/members/single/messages/single.php
index 1b31bbe..deae005 100644
|
|
|
|
| 35 | 35 | |
| 36 | 36 | <?php else : ?> |
| 37 | 37 | |
| 38 | | <?php printf( __( 'Conversation between %s and you.', 'buddypress' ), bp_get_thread_recipients_list() ); ?> |
| | 38 | <?php printf( __( 'Conversation between %s.', 'buddypress' ), bp_get_thread_recipients_list() ); ?> |
| 39 | 39 | |
| 40 | 40 | <?php endif; ?> |
| 41 | 41 | |