Ticket #6412: 6412.2.diff
| File 6412.2.diff, 16.3 KB (added by , 11 years ago) |
|---|
-
src/bp-messages/bp-messages-functions.php
40 40 41 41 // Parse the default arguments 42 42 $r = bp_parse_args( $args, array( 43 'sender_id' => bp_ loggedin_user_id(),43 'sender_id' => bp_displayed_user_id(), 44 44 'thread_id' => false, // false for a new message, thread id for a reply to a thread. 45 45 'recipients' => array(), // Can be an array of usernames, user_ids or mixed. 46 46 'subject' => false, … … 263 263 */ 264 264 function messages_check_thread_access( $thread_id, $user_id = 0 ) { 265 265 if ( empty( $user_id ) ) { 266 $user_id = bp_ loggedin_user_id();266 $user_id = bp_displayed_user_id(); 267 267 } 268 268 269 269 return BP_Messages_Thread::check_access( $thread_id, $user_id ); … … 328 328 */ 329 329 function messages_get_unread_count( $user_id = 0 ) { 330 330 if ( empty( $user_id ) ) { 331 $user_id = bp_ loggedin_user_id();331 $user_id = bp_displayed_user_id(); 332 332 } 333 333 334 334 return BP_Messages_Thread::get_inbox_count( $user_id ); -
src/bp-messages/bp-messages-loader.php
143 143 'name' => $nav_name, 144 144 'slug' => $this->slug, 145 145 'position' => 50, 146 'show_for_displayed_user' => false,146 'show_for_displayed_user' => bp_core_can_edit_settings(), 147 147 'screen_function' => 'messages_screen_inbox', 148 148 'default_subnav_slug' => 'inbox', 149 149 'item_css_id' => $this->id -
src/bp-messages/bp-messages-screens.php
93 93 if ( isset( $_POST['send-notice'] ) ) { 94 94 if ( messages_send_notice( $_POST['subject'], $_POST['content'] ) ) { 95 95 bp_core_add_message( __( 'Notice sent successfully!', 'buddypress' ) ); 96 bp_core_redirect( bp_ loggedin_user_domain() . bp_get_messages_slug() . '/inbox/' );96 bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/inbox/' ); 97 97 } else { 98 98 bp_core_add_message( __( 'There was an error sending that notice. Please try again.', 'buddypress' ), 'error' ); 99 99 } … … 120 120 // Send the message 121 121 if ( ! empty( $thread_id ) ) { 122 122 bp_core_add_message( __( 'Message sent successfully!', 'buddypress' ) ); 123 bp_core_redirect( bp_ loggedin_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id . '/' );123 bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id . '/' ); 124 124 } else { 125 125 bp_core_add_message( __( 'There was an error sending that message. Please try again.', 'buddypress' ), 'error' ); 126 126 } … … 223 223 bp_core_add_message( __('Notice deleted.', 'buddypress') ); 224 224 } 225 225 } 226 bp_core_redirect( trailingslashit( bp_ loggedin_user_domain() . bp_get_messages_slug() . '/notices' ) );226 bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/notices' ) ); 227 227 } 228 228 229 229 if ( bp_action_variables() ) { -
src/bp-messages/bp-messages-star.php
36 36 */ 37 37 function bp_messages_is_message_starred( $mid = 0, $user_id = 0 ) { 38 38 if ( empty( $user_id ) ) { 39 $user_id = bp_ loggedin_user_id();39 $user_id = bp_displayed_user_id(); 40 40 } 41 41 42 42 if ( empty( $mid ) ) { … … 89 89 */ 90 90 function bp_get_the_message_star_action_link( $args = array() ) { 91 91 $r = bp_parse_args( $args, array( 92 'user_id' => bp_ loggedin_user_id(),92 'user_id' => bp_displayed_user_id(), 93 93 'thread_id' => 0, 94 94 'message_id' => (int) bp_get_the_thread_message_id(), 95 95 'url_only' => false, … … 110 110 // get user domain 111 111 if ( $r['user_id'] == bp_loggedin_user_id() ) { 112 112 $user_domain = bp_loggedin_user_domain(); 113 } elseif ( $r['user_id'] == bp_displayed_user_ domain() ) {113 } elseif ( $r['user_id'] == bp_displayed_user_id() ) { 114 114 $user_domain = bp_displayed_user_domain(); 115 115 } else { 116 116 $user_domain = bp_core_get_user_domain( $user_id ); … … 226 226 'action' => 'star', 227 227 'thread_id' => 0, 228 228 'message_id' => 0, 229 'user_id' => bp_ loggedin_user_id(),229 'user_id' => bp_displayed_user_id(), 230 230 'bulk' => false 231 231 ) ); 232 232 … … 330 330 $r['user_id'] = 0; 331 331 $r['meta_query'] = array( array( 332 332 'key' => 'starred_by_user', 333 'value' => bp_ loggedin_user_id()333 'value' => bp_displayed_user_id() 334 334 ) ); 335 335 336 336 return $r; … … 369 369 ) ); 370 370 371 371 // redirect back to previous screen 372 $redirect = wp_get_referer() ? wp_get_referer() : bp_ loggedin_user_domain() . bp_get_messages_slug();372 $redirect = wp_get_referer() ? wp_get_referer() : bp_displayed_user_domain() . bp_get_messages_slug(); 373 373 bp_core_redirect( $redirect ); 374 374 die(); 375 375 } -
src/bp-messages/bp-messages-template.php
144 144 'page_arg' => 'mpage', 145 145 'box' => 'inbox', 146 146 'type' => 'all', 147 'user_id' => bp_ loggedin_user_id(),147 'user_id' => bp_displayed_user_id(), 148 148 'max' => false, 149 149 'search_terms' => '', 150 150 'meta_query' => array(), … … 322 322 if ( count($this->thread->messages) > 1 ) { 323 323 if ( 'inbox' == $this->box ) { 324 324 foreach ( (array) $this->thread->messages as $key => $message ) { 325 if ( bp_ loggedin_user_id() != $message->sender_id ) {325 if ( bp_displayed_user_id() != $message->sender_id ) { 326 326 $last_message_index = $key; 327 327 break; 328 328 } … … 330 330 331 331 } elseif ( 'sentbox' == $this->box ) { 332 332 foreach ( (array) $this->thread->messages as $key => $message ) { 333 if ( bp_ loggedin_user_id() == $message->sender_id ) {333 if ( bp_displayed_user_id() == $message->sender_id ) { 334 334 $last_message_index = $key; 335 335 break; 336 336 } … … 400 400 401 401 // Parse the arguments 402 402 $r = bp_parse_args( $args, array( 403 'user_id' => bp_ loggedin_user_id(),403 'user_id' => bp_displayed_user_id(), 404 404 'box' => $default_box, 405 405 'per_page' => 10, 406 406 'max' => false, … … 641 641 * 642 642 * @param string $value permalink of a particular thread. 643 643 */ 644 return apply_filters( 'bp_get_message_thread_view_link', trailingslashit( bp_ loggedin_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id ) );644 return apply_filters( 'bp_get_message_thread_view_link', trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id ) ); 645 645 } 646 646 647 647 /** … … 666 666 * @param string $value URL for deleting the current thread. 667 667 * @param string $value Text indicating action being executed. 668 668 */ 669 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' ) );669 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' ) ); 670 670 } 671 671 672 672 /** … … 698 698 ); 699 699 700 700 // Base unread URL. 701 $url = trailingslashit( bp_ loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/unread' );701 $url = trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/unread' ); 702 702 703 703 // Add the args to the URL. 704 704 $url = add_query_arg( $args, $url ); … … 745 745 ); 746 746 747 747 // Base read URL. 748 $url = trailingslashit( bp_ loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/read' );748 $url = trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/read' ); 749 749 750 750 // Add the args to the URL. 751 751 $url = add_query_arg( $args, $url ); … … 1155 1155 * 1156 1156 * @param string The form action. 1157 1157 */ 1158 return apply_filters( 'bp_get_messages_form_action', trailingslashit( bp_ loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/' . bp_action_variable( 0 ) ) );1158 return apply_filters( 'bp_get_messages_form_action', trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/' . bp_action_variable( 0 ) ) ); 1159 1159 } 1160 1160 1161 1161 /** … … 1474 1474 * @param string $value URL for deleting the current notice. 1475 1475 * @param string $value Text indicating action being executed. 1476 1476 */ 1477 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' ) );1477 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' ) ); 1478 1478 } 1479 1479 1480 1480 /** … … 1492 1492 global $messages_template; 1493 1493 1494 1494 if ( 1 === (int) $messages_template->thread->is_active ) { 1495 $link = wp_nonce_url( trailingslashit( bp_ loggedin_user_domain() . bp_get_messages_slug() . '/notices/deactivate/' . $messages_template->thread->id ), 'messages_deactivate_notice' );1495 $link = wp_nonce_url( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/notices/deactivate/' . $messages_template->thread->id ), 'messages_deactivate_notice' ); 1496 1496 } else { 1497 $link = wp_nonce_url( trailingslashit( bp_ loggedin_user_domain() . bp_get_messages_slug() . '/notices/activate/' . $messages_template->thread->id ), 'messages_activate_notice' );1497 $link = wp_nonce_url( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/notices/activate/' . $messages_template->thread->id ), 'messages_activate_notice' ); 1498 1498 } 1499 1499 1500 1500 /** … … 1576 1576 return false; 1577 1577 } 1578 1578 1579 $closed_notices = bp_get_user_meta( bp_ loggedin_user_id(), 'closed_notices', true );1579 $closed_notices = bp_get_user_meta( bp_displayed_user_id(), 'closed_notices', true ); 1580 1580 1581 1581 if ( empty( $closed_notices ) ) { 1582 1582 $closed_notices = array(); … … 1621 1621 * 1622 1622 * @param string $value URL for the Private Message link in member profile headers. 1623 1623 */ 1624 return apply_filters( 'bp_get_send_private_message_link', wp_nonce_url( bp_ loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username( bp_displayed_user_id() ) ) );1624 return apply_filters( 'bp_get_send_private_message_link', wp_nonce_url( bp_displayed_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username( bp_displayed_user_id() ) ) ); 1625 1625 } 1626 1626 1627 1627 /** … … 2126 2126 $recipient_links = array(); 2127 2127 2128 2128 foreach( (array) $thread_template->thread->recipients as $recipient ) { 2129 if ( (int) $recipient->user_id !== bp_ loggedin_user_id() ) {2129 if ( (int) $recipient->user_id !== bp_displayed_user_id() ) { 2130 2130 $recipient_link = bp_core_get_userlink( $recipient->user_id ); 2131 2131 2132 2132 if ( empty( $recipient_link ) ) { … … 2206 2206 $classes[] = 'sent-by-' . intval( $thread_template->message->sender_id ); 2207 2207 2208 2208 // Whether the sender is the same as the logged-in user 2209 if ( bp_ loggedin_user_id() == $thread_template->message->sender_id ) {2209 if ( bp_displayed_user_id() == $thread_template->message->sender_id ) { 2210 2210 $classes[] = 'sent-by-me'; 2211 2211 } 2212 2212 … … 2405 2405 * @param string $value URL for deleting the current thread. 2406 2406 * @param string $value Text indicating action being executed. 2407 2407 */ 2408 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' ) );2408 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' ) ); 2409 2409 } 2410 2410 2411 2411 /** -
src/bp-messages/classes/class-bp_messages-thread.php
167 167 $this->recipients = $this->get_recipients(); 168 168 169 169 // Get the unread count for the logged in user 170 if ( isset( $this->recipients[bp_ loggedin_user_id()] ) ) {171 $this->unread_count = $this->recipients[bp_ loggedin_user_id()]->unread_count;170 if ( isset( $this->recipients[bp_displayed_user_id()] ) ) { 171 $this->unread_count = $this->recipients[bp_displayed_user_id()]->unread_count; 172 172 } 173 173 174 174 // Grab all message meta … … 318 318 // 319 319 // @todo the reliance on bp_loggedin_user_id() sucks for plugins 320 320 // refactor this method to accept a $user_id parameter 321 $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET is_deleted = 1 WHERE thread_id = %d AND user_id = %d", $thread_id, bp_ loggedin_user_id() ) );321 $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET is_deleted = 1 WHERE thread_id = %d AND user_id = %d", $thread_id, bp_displayed_user_id() ) ); 322 322 323 323 // Get the message ids in order to pass to the action 324 324 $message_ids = $wpdb->get_col( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages} WHERE thread_id = %d", $thread_id ) ); … … 555 555 global $wpdb; 556 556 557 557 $bp = buddypress(); 558 $sql = $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 );558 $sql = $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 0 WHERE user_id = %d AND thread_id = %d", bp_displayed_user_id(), $thread_id ); 559 559 $wpdb->query($sql); 560 560 561 561 wp_cache_delete( 'thread_recipients_' . $thread_id, 'bp_messages' ); 562 wp_cache_delete( bp_ loggedin_user_id(), 'bp_messages_unread_count' );562 wp_cache_delete( bp_displayed_user_id(), 'bp_messages_unread_count' ); 563 563 } 564 564 565 565 /** … … 573 573 global $wpdb; 574 574 575 575 $bp = buddypress(); 576 $sql = $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 );576 $sql = $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 1 WHERE user_id = %d AND thread_id = %d", bp_displayed_user_id(), $thread_id ); 577 577 $wpdb->query($sql); 578 578 579 579 wp_cache_delete( 'thread_recipients_' . $thread_id, 'bp_messages' ); 580 wp_cache_delete( bp_ loggedin_user_id(), 'bp_messages_unread_count' );580 wp_cache_delete( bp_displayed_user_id(), 'bp_messages_unread_count' ); 581 581 } 582 582 583 583 /** … … 663 663 global $wpdb; 664 664 665 665 if ( empty( $user_id ) ) { 666 $user_id = bp_ loggedin_user_id();666 $user_id = bp_displayed_user_id(); 667 667 } 668 668 669 669 $unread_count = wp_cache_get( $user_id, 'bp_messages_unread_count' ); … … 698 698 */ 699 699 public static function check_access( $thread_id, $user_id = 0 ) { 700 700 if ( empty( $user_id ) ) { 701 $user_id = bp_ loggedin_user_id();701 $user_id = bp_displayed_user_id(); 702 702 } 703 703 704 704 $recipients = self::get_recipients_for_thread( $thread_id ); -
src/bp-templates/bp-legacy/buddypress/members/single/messages/messages-loop.php
39 39 */ 40 40 do_action( 'bp_before_member_messages_threads' ); ?> 41 41 42 <form action="<?php echo bp_ loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() ?>/bulk-manage/" method="post" id="messages-bulk-management">42 <form action="<?php echo bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() ?>/bulk-manage/" method="post" id="messages-bulk-management"> 43 43 44 44 <table id="message-threads" class="messages-notices"> 45 45