Changeset 11578
- Timestamp:
- 06/06/2017 05:46:21 PM (8 years ago)
- Location:
- trunk/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/bp-messages-actions.php
r11537 r11578 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 /** … … 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' ) ); … … 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' ) ); … … 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() . '/' ); -
trunk/src/bp-messages/bp-messages-cache.php
r10417 r11578 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 ) { … … 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 /** -
trunk/src/bp-messages/bp-messages-functions.php
r11562 r11578 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 … … 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 } -
trunk/src/bp-messages/bp-messages-notifications.php
r11022 r11578 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( -
trunk/src/bp-messages/bp-messages-star.php
r10417 r11578 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 … … 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 ) ); … … 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(); -
trunk/src/bp-messages/bp-messages-template.php
r11576 r11578 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. … … 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 … … 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 … … 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. … … 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. … … 697 697 /** 698 698 * Output the unread messages count for the current inbox. 699 */ 700 function bp_total_unread_messages_count() { 701 echo bp_get_total_unread_messages_count(); 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. 705 */ 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 707 */ 708 function bp_get_total_unread_messages_count() { 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. 717 */ 718 function bp_get_total_unread_messages_count( $user_id = 0 ) { 709 719 710 720 /** … … 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 … … 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 … … 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 … … 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 … … 1925 1935 * @param string $value Text indicating action being executed. 1926 1936 */ 1927 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' ) );1937 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' ) ); 1928 1938 } 1929 1939 -
trunk/src/bp-messages/classes/class-bp-messages-component.php
r11577 r11578 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( … … 253 253 254 254 // Unread message count. 255 $count = messages_get_unread_count( );255 $count = messages_get_unread_count( bp_loggedin_user_id() ); 256 256 if ( !empty( $count ) ) { 257 257 $title = sprintf( -
trunk/src/bp-messages/classes/class-bp-messages-thread.php
r11447 r11578 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 ) ); … … 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 /** … … 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 /** -
trunk/src/bp-templates/bp-legacy/buddypress/members/single/messages/messages-loop.php
r11166 r11578 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">
Note: See TracChangeset
for help on using the changeset viewer.