Skip to:
Content

BuddyPress.org

Ticket #7096: 7096.01.diff

File 7096.01.diff, 8.4 KB (added by dcavins, 9 years ago)

Use the displayed user rather than the logged in user to build the messages loop.

  • src/bp-messages/bp-messages-template.php

    diff --git src/bp-messages/bp-messages-template.php src/bp-messages/bp-messages-template.php
    index c5b4f40..54dc747 100644
    function bp_has_message_threads( $args = array() ) { 
    6363
    6464        // User ID
    6565        // @todo displayed user for moderators that get this far?
    66         $user_id = bp_loggedin_user_id();
     66        $user_id = bp_displayed_user_id();
    6767
    6868        // Search Terms.
    6969        $search_terms = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
    function bp_message_thread_view_link( $thread_id = 0 ) { 
    309309                 * @param string $value     Permalink of a particular thread.
    310310                 * @param int    $thread_id ID of the thread.
    311311                 */
    312                 return apply_filters( 'bp_get_message_thread_view_link', trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id ), $thread_id );
     312                return apply_filters( 'bp_get_message_thread_view_link', trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id ), $thread_id );
    313313        }
    314314
    315315/**
    function bp_message_thread_delete_link() { 
    334334                 * @param string $value URL for deleting the current thread.
    335335                 * @param string $value Text indicating action being executed.
    336336                 */
    337                 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' ) );
     337                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' ) );
    338338        }
    339339
    340340/**
    function bp_the_message_thread_mark_unread_url() { 
    366366                );
    367367
    368368                // Base unread URL.
    369                 $url = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/unread' );
     369                $url = trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/unread' );
    370370
    371371                // Add the args to the URL.
    372372                $url = add_query_arg( $args, $url );
    function bp_the_message_thread_mark_read_url() { 
    413413                );
    414414
    415415                // Base read URL.
    416                 $url = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/read' );
     416                $url = trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/read' );
    417417
    418418                // Add the args to the URL.
    419419                $url = add_query_arg( $args, $url );
    function bp_message_thread_avatar( $args = '' ) { 
    700700
    701701/**
    702702 * Output the unread messages count for the current inbox.
     703 *
     704 * @since 2.6.x Added $user_id argument.
     705 *
     706 * @param int $user_id The user ID.
     707 *
     708 * @return int $unread_count Total inbox unread count for user.
    703709 */
    704 function bp_total_unread_messages_count() {
    705         echo bp_get_total_unread_messages_count();
     710function bp_total_unread_messages_count( $user_id = 0 ) {
     711        echo bp_get_total_unread_messages_count( $user_id );
    706712}
    707713        /**
    708714         * Get the unread messages count for the current inbox.
    709715         *
    710          * @return int
     716         * @since 2.6.x Added $user_id argument.
     717         *
     718         * @param int $user_id The user ID.
     719         *
     720         * @return int $unread_count Total inbox unread count for user.
    711721         */
    712         function bp_get_total_unread_messages_count() {
     722        function bp_get_total_unread_messages_count( $user_id = 0 ) {
    713723
    714724                /**
    715725                 * Filters the unread messages count for the current inbox.
    function bp_total_unread_messages_count() { 
    718728                 *
    719729                 * @param int $value Unread messages count for the current inbox.
    720730                 */
    721                 return apply_filters( 'bp_get_total_unread_messages_count', BP_Messages_Thread::get_inbox_count() );
     731                return apply_filters( 'bp_get_total_unread_messages_count', BP_Messages_Thread::get_inbox_count( $user_id ) );
    722732        }
    723733
    724734/**
    function bp_messages_form_action() { 
    825835                 *
    826836                 * @param string $value The form action.
    827837                 */
    828                 return apply_filters( 'bp_get_messages_form_action', trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/' . bp_action_variable( 0 ) ) );
     838                return apply_filters( 'bp_get_messages_form_action', trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/' . bp_action_variable( 0 ) ) );
    829839        }
    830840
    831841/**
    function bp_message_notice_delete_link() { 
    11501160                 * @param string $value URL for deleting the current notice.
    11511161                 * @param string $value Text indicating action being executed.
    11521162                 */
    1153                 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' ) );
     1163                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' ) );
    11541164        }
    11551165
    11561166/**
    function bp_message_activate_deactivate_link() { 
    11681178                global $messages_template;
    11691179
    11701180                if ( 1 === (int) $messages_template->thread->is_active ) {
    1171                         $link = wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices/deactivate/' . $messages_template->thread->id ), 'messages_deactivate_notice' );
     1181                        $link = wp_nonce_url( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/notices/deactivate/' . $messages_template->thread->id ), 'messages_deactivate_notice' );
    11721182                } else {
    1173                         $link = wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices/activate/' . $messages_template->thread->id ), 'messages_activate_notice' );
     1183                        $link = wp_nonce_url( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/notices/activate/' . $messages_template->thread->id ), 'messages_activate_notice' );
    11741184                }
    11751185
    11761186                /**
    function bp_the_thread_delete_link() { 
    19111921                 * @param string $value URL for deleting the current thread.
    19121922                 * @param string $value Text indicating action being executed.
    19131923                 */
    1914                 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' ) );
     1924                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' ) );
    19151925        }
    19161926
    19171927/**
  • src/bp-messages/classes/class-bp-messages-component.php

    diff --git src/bp-messages/classes/class-bp-messages-component.php src/bp-messages/classes/class-bp-messages-component.php
    index 334f90e..638077d 100644
    class BP_Messages_Component extends BP_Component { 
    147147
    148148                // Only grab count if we're on a user page and current user has access.
    149149                if ( bp_is_user() && bp_user_has_access() ) {
    150                         $count    = bp_get_total_unread_messages_count();
     150                        $count    = bp_get_total_unread_messages_count( bp_displayed_user_id() );
    151151                        $class    = ( 0 === $count ) ? 'no-count' : 'count';
    152152                        $nav_name = sprintf(
    153153                                /* translators: %s: Unread message count for the current user */
    class BP_Messages_Component extends BP_Component { 
    205205                        'position'        => 20,
    206206                        'user_has_access' => $access
    207207                );
    208 
     208                // @TODO: Should "compose" only be available if the current user is the displayed user?
    209209                $sub_nav[] = array(
    210210                        'name'            => __( 'Compose', 'buddypress' ),
    211211                        'slug'            => 'compose',
  • src/bp-templates/bp-legacy/buddypress/members/single/messages/messages-loop.php

    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 a99018f..976873c 100644
    do_action( 'bp_before_member_messages_loop' ); ?> 
    4545         */
    4646        do_action( 'bp_before_member_messages_threads' ); ?>
    4747
    48         <form action="<?php echo bp_loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() ?>/bulk-manage/" method="post" id="messages-bulk-management">
     48        <form action="<?php echo bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() ?>/bulk-manage/" method="post" id="messages-bulk-management">
    4949
    5050                <table id="message-threads" class="messages-notices">
    5151