Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/06/2017 05:46:21 PM (7 years ago)
Author:
dcavins
Message:

Show displayed user's messages on messages screens.

When a site administrator visits another user’s messages, she is shown
her own messages because the display logic for messages refers to the
logged-in user rather than the displayed user. This changeset updates
the logic to allow the site admin to view and interact with another
user’s messages.

Fixes #7096.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-messages/bp-messages-template.php

    r11576 r11578  
    5959    // User ID
    6060    // @todo displayed user for moderators that get this far?
    61     $user_id = bp_loggedin_user_id();
     61    $user_id = bp_displayed_user_id();
    6262
    6363    // Search Terms.
     
    305305         * @param int    $thread_id ID of the thread.
    306306         */
    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 );
    308308    }
    309309
     
    330330         * @param string $value Text indicating action being executed.
    331331         */
    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' ) );
    333333    }
    334334
     
    362362
    363363        // 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' );
    365365
    366366        // Add the args to the URL.
     
    409409
    410410        // 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' );
    412412
    413413        // Add the args to the URL.
     
    697697/**
    698698 * 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 */
     706function bp_total_unread_messages_count( $user_id = 0 ) {
     707    echo bp_get_total_unread_messages_count( $user_id );
    702708}
    703709    /**
    704710     * Get the unread messages count for the current inbox.
    705711     *
    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 ) {
    709719
    710720        /**
     
    715725         * @param int $value Unread messages count for the current inbox.
    716726         */
    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 ) );
    718728    }
    719729
     
    825835         * @param string $value The form action.
    826836         */
    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 ) ) );
    828838    }
    829839
     
    11541164         * @param string $value Text indicating action being executed.
    11551165         */
    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' ) );
    11571167    }
    11581168
     
    11721182
    11731183        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' );
    11751185        } 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' );
    11771187        }
    11781188
     
    19251935         * @param string $value Text indicating action being executed.
    19261936         */
    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' ) );
    19281938    }
    19291939
Note: See TracChangeset for help on using the changeset viewer.