Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/06/2017 05:46:21 PM (9 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-actions.php

    r11537 r11578  
    248248        }
    249249
    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        }
    252257
    253258        /**
     
    320325
    321326        // 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' ) ) {
    323328                messages_mark_thread_read( $id );
    324329                bp_core_add_message( __( 'Message marked as read.', 'buddypress' ) );
     
    361366
    362367        // 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' ) ) {
    364369                messages_mark_thread_unread( $id );
    365370                bp_core_add_message( __( 'Message marked unread.', 'buddypress' ) );
     
    405410        // Make sure the user has access to all notifications before managing them.
    406411        foreach ( $messages as $message ) {
    407                 if ( ! messages_check_thread_access( $message ) ) {
     412                if ( ! messages_check_thread_access( $message ) && ! bp_current_user_can( 'bp_moderate' ) ) {
    408413                        bp_core_add_message( __( 'There was a problem managing your messages.', 'buddypress' ), 'error' );
    409414                        bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/' );
Note: See TracChangeset for help on using the changeset viewer.