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/classes/class-bp-messages-thread.php

    r11447 r11578  
    145145        }
    146146
     147        $user_id =
     148            bp_displayed_user_id() ?
     149            bp_displayed_user_id() :
     150            bp_loggedin_user_id();
     151
    147152        // Merge $args with our defaults.
    148153        $r = wp_parse_args( $args, array(
    149             'user_id'           => bp_loggedin_user_id(),
     154            'user_id'           => $user_id,
    150155            'update_meta_cache' => true
    151156        ) );
     
    614619        global $wpdb;
    615620
     621        $user_id =
     622            bp_displayed_user_id() ?
     623            bp_displayed_user_id() :
     624            bp_loggedin_user_id();
     625
    616626        $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 ) );
    618628
    619629        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' );
    621631
    622632        /**
     
    644654        global $wpdb;
    645655
     656        $user_id =
     657            bp_displayed_user_id() ?
     658            bp_displayed_user_id() :
     659            bp_loggedin_user_id();
     660
    646661        $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 ) );
    648663
    649664        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' );
    651666
    652667        /**
Note: See TracChangeset for help on using the changeset viewer.