Skip to:
Content

BuddyPress.org

Changeset 5301


Ignore:
Timestamp:
11/08/2011 01:14:31 AM (8 years ago)
Author:
johnjamesjacoby
Message:

Use bp_displayed_user_id() rather than reference the $bp->displayed_user->id global var directly. First step at consolidating user ID checks to use WP_User class later. See #3738.

Location:
trunk
Files:
46 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-functions.php

    r5262 r5301  
    251251    // Fallback to logged in user if no user_id is passed
    252252    if ( empty( $user_id ) )
    253         $user_id = $bp->displayed_user->id;
     253        $user_id = bp_displayed_user_id();
    254254
    255255    // Get favorites for user
     
    431431    // Fallback on displayed user, and then logged in user
    432432    if ( empty( $user_id ) )
    433         $user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
     433        $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : $bp->loggedin_user->id;
    434434
    435435    return BP_Activity_Activity::total_favorite_count( $user_id );
  • trunk/bp-activity/bp-activity-loader.php

    r5300 r5301  
    124124
    125125        // Stop if there is no user displayed or logged in
    126         if ( !is_user_logged_in() && !isset( $bp->displayed_user->id ) )
     126        if ( !is_user_logged_in() && !bp_displayed_user_id() )
    127127            return;
    128128
     
    308308            } else {
    309309                $bp->bp_options_avatar = bp_core_fetch_avatar( array(
    310                     'item_id' => $bp->displayed_user->id,
     310                    'item_id' => bp_displayed_user_id(),
    311311                    'type'    => 'thumb'
    312312                ) );
  • trunk/bp-activity/bp-activity-screens.php

    r5259 r5301  
    268268    global $bp;
    269269
    270     if ( !$mention = bp_get_user_meta( $bp->displayed_user->id, 'notification_activity_new_mention', true ) )
     270    if ( !$mention = bp_get_user_meta( bp_displayed_user_id(), 'notification_activity_new_mention', true ) )
    271271        $mention = 'yes';
    272272
    273     if ( !$reply = bp_get_user_meta( $bp->displayed_user->id, 'notification_activity_new_reply', true ) )
     273    if ( !$reply = bp_get_user_meta( bp_displayed_user_id(), 'notification_activity_new_reply', true ) )
    274274        $reply = 'yes'; ?>
    275275
     
    287287            <tr id="activity-notification-settings-mentions">
    288288                <td>&nbsp;</td>
    289                 <td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( $bp->displayed_user->id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) ) ?></td>
     289                <td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( bp_displayed_user_id(), $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) ) ?></td>
    290290                <td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" value="yes" <?php checked( $mention, 'yes', true ) ?>/></td>
    291291                <td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" value="no" <?php checked( $mention, 'no', true ) ?>/></td>
  • trunk/bp-activity/bp-activity-template.php

    r5262 r5301  
    265265
    266266    // User filtering
    267     if ( !empty( $bp->displayed_user->id ) )
    268         $user_id = $bp->displayed_user->id;
     267    if ( bp_displayed_user_id() )
     268        $user_id = bp_displayed_user_id();
    269269
    270270    // Group filtering
     
    325325        // determine which user_id applies
    326326        if ( empty( $user_id ) )
    327             $user_id = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
     327            $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : $bp->loggedin_user->id;
    328328
    329329        // are we displaying user specific activity?
     
    361361                    break;
    362362                case 'mentions':
    363                     $user_nicename    = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->userdata->user_nicename : $bp->loggedin_user->userdata->user_nicename;
    364                     $user_login       = ( !empty( $bp->displayed_user->id ) ) ? $bp->displayed_user->userdata->user_login : $bp->loggedin_user->userdata->user_login;
     363                    $user_nicename    = ( bp_displayed_user_id() ) ? $bp->displayed_user->userdata->user_nicename : $bp->loggedin_user->userdata->user_nicename;
     364                    $user_login       = ( bp_displayed_user_id() ) ? $bp->displayed_user->userdata->user_login : $bp->loggedin_user->userdata->user_login;
    365365                    $search_terms     = '@' . bp_core_get_username( $user_id, $user_nicename, $user_login ) . '<'; // Start search at @ symbol and stop search at closing tag delimiter.
    366366                    $display_comments = 'stream';
     
    20442044
    20452045        if ( !$user_id )
    2046             $user_id = $bp->displayed_user->id;
     2046            $user_id = bp_displayed_user_id();
    20472047
    20482048        if ( bp_core_is_user_spammer( $user_id ) || bp_core_is_user_deleted( $user_id ) )
     
    23102310            return false;
    23112311
    2312         return apply_filters( 'bp_get_send_public_message_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_activity_slug() . '/?r=' . bp_core_get_username( $bp->displayed_user->id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) ) );
     2312        return apply_filters( 'bp_get_send_public_message_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_activity_slug() . '/?r=' . bp_core_get_username( bp_displayed_user_id(), $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) ) );
    23132313    }
    23142314
  • trunk/bp-activity/feeds/bp-activity-favorites-feed.php

    r5109 r5301  
    3636
    3737    <?php
    38         $favs = bp_activity_get_user_favorites( $bp->displayed_user->id );
     38        $favs = bp_activity_get_user_favorites( bp_displayed_user_id() );
    3939        $fav_ids = implode( ',', (array)$favs );
    4040    ?>
  • trunk/bp-activity/feeds/bp-activity-mentions-feed.php

    r5109 r5301  
    3434    <?php do_action('bp_activity_mentions_feed_head'); ?>
    3535
    36     <?php if ( bp_has_activities( 'max=50&display_comments=stream&search_terms=@' . bp_core_get_username( $bp->displayed_user->id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) ) ) : ?>
     36    <?php if ( bp_has_activities( 'max=50&display_comments=stream&search_terms=@' . bp_core_get_username( bp_displayed_user_id(), $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) ) ) : ?>
    3737        <?php while ( bp_activities() ) : bp_the_activity(); ?>
    3838            <item>
  • trunk/bp-activity/feeds/bp-activity-personal-feed.php

    r5109 r5301  
    3434    <?php do_action('bp_activity_personal_feed_head'); ?>
    3535
    36     <?php if ( bp_has_activities( 'user_id=' . $bp->displayed_user->id . '&max=50&display_comments=stream' ) ) : ?>
     36    <?php if ( bp_has_activities( 'user_id=' . bp_displayed_user_id() . '&max=50&display_comments=stream' ) ) : ?>
    3737        <?php while ( bp_activities() ) : bp_the_activity(); ?>
    3838            <item>
  • trunk/bp-blogs/bp-blogs-classes.php

    r4819 r5301  
    1515        global $bp, $wpdb;
    1616
    17         $user_id = $bp->displayed_user->id;
     17        $user_id = bp_displayed_user_id();
    1818
    1919        if ( $id ) {
     
    151151
    152152        if ( !$user_id )
    153             $user_id = $bp->displayed_user->id;
     153            $user_id = bp_displayed_user_id();
    154154
    155155        // Show logged in users their hidden blogs.
     
    177177
    178178        if ( !$user_id )
    179             $user_id = $bp->displayed_user->id;
     179            $user_id = bp_displayed_user_id();
    180180
    181181        return $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) );
     
    192192
    193193        if ( !$user_id )
    194             $user_id = $bp->displayed_user->id;
     194            $user_id = bp_displayed_user_id();
    195195
    196196        // If the user is logged in return the blog count including their hidden blogs.
  • trunk/bp-blogs/bp-blogs-functions.php

    r5248 r5301  
    411411
    412412    if ( !$user_id )
    413         $user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
     413        $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : $bp->loggedin_user->id;
    414414
    415415    if ( !$count = wp_cache_get( 'bp_total_blogs_for_user_' . $user_id, 'bp' ) ) {
  • trunk/bp-blogs/bp-blogs-loader.php

    r5300 r5301  
    182182            } else {
    183183                $bp->bp_options_avatar = bp_core_fetch_avatar( array(
    184                     'item_id' => $bp->displayed_user->id,
     184                    'item_id' => bp_displayed_user_id(),
    185185                    'type'    => 'thumb'
    186186                ) );
  • trunk/bp-blogs/bp-blogs-template.php

    r4961 r5301  
    204204
    205205    /* User filtering */
    206     if ( !empty( $bp->displayed_user->id ) )
    207         $user_id = $bp->displayed_user->id;
     206    if ( bp_displayed_user_id() )
     207        $user_id = bp_displayed_user_id();
    208208
    209209    $defaults = array(
  • trunk/bp-core/bp-core-avatars.php

    r5233 r5301  
    115115    if ( !$item_id ) {
    116116        if ( 'user' == $object )
    117             $item_id = $bp->displayed_user->id;
     117            $item_id = bp_displayed_user_id();
    118118        else if ( bp_is_active( 'groups' ) && 'group' == $object )
    119119            $item_id = $bp->groups->current_group->id;
     
    327327    if ( !$item_id ) {
    328328        if ( 'user' == $object )
    329             $item_id = $bp->displayed_user->id;
     329            $item_id = bp_displayed_user_id();
    330330        else if ( 'group' == $object )
    331331            $item_id = $bp->groups->current_group->id;
  • trunk/bp-core/bp-core-catchuri.php

    r5238 r5301  
    238238
    239239                // Switch the displayed_user based on compatbility mode
    240                 if ( bp_is_username_compatibility_mode() )
     240                if ( bp_is_username_compatibility_mode() ) {
    241241                    $bp->displayed_user->id = (int) bp_core_get_userid( urldecode( $bp_uri[$uri_offset + 1] ) );
    242                 else
     242                } else {
    243243                    $bp->displayed_user->id = (int) bp_core_get_userid_from_nicename( urldecode( $bp_uri[$uri_offset + 1] ) );
    244 
    245                 if ( empty( $bp->displayed_user->id ) ) {
     244                }
     245
     246                if ( !bp_displayed_user_id() ) {
     247
    246248                    // Prevent components from loading their templates
    247249                    $bp->current_component = '';
     
    253255                // If the displayed user is marked as a spammer, 404 (unless logged-
    254256                // in user is a super admin)
    255                 if ( !empty( $bp->displayed_user->id ) && bp_core_is_user_spammer( $bp->displayed_user->id ) ) {
     257                if ( bp_displayed_user_id() && bp_core_is_user_spammer( bp_displayed_user_id() ) ) {
    256258                    if ( is_super_admin() ) {
    257259                        bp_core_add_message( __( 'This user has been marked as a spammer. Only site admins can view this profile.', 'buddypress' ), 'error' );
  • trunk/bp-core/bp-core-template.php

    r5153 r5301  
    200200        $youtext = bp_core_ucfirst($youtext);
    201201
    202     if ( $bp->displayed_user->id == $bp->loggedin_user->id ) {
     202    if ( bp_displayed_user_id() == $bp->loggedin_user->id ) {
    203203        if ( $echo )
    204204            echo apply_filters( 'bp_word_or_name', $youtext );
     
    10831083    global $bp;
    10841084
    1085     if ( is_user_logged_in() && $bp->loggedin_user->id == $bp->displayed_user->id )
     1085    if ( is_user_logged_in() && $bp->loggedin_user->id == bp_displayed_user_id() )
    10861086        $my_profile = true;
    10871087    else
     
    10941094    global $bp;
    10951095
    1096     if ( !empty( $bp->displayed_user->id ) )
     1096    if ( bp_displayed_user_id() )
    10971097        return true;
    10981098
  • trunk/bp-core/deprecated/1.5.php

    r5296 r5301  
    130130    global $bp;
    131131
    132     $ud = get_userdata( $bp->displayed_user->id ); ?>
     132    $ud = get_userdata( bp_displayed_user_id() ); ?>
    133133
    134134<div class="bp-widget wp-profile">
  • trunk/bp-forums/bp-forums-functions.php

    r5245 r5301  
    316316
    317317    if ( !$user_id )
    318         $user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
     318        $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : $bp->loggedin_user->id;
    319319
    320320    if ( class_exists( 'BB_Query' ) ) {
  • trunk/bp-forums/bp-forums-loader.php

    r5300 r5301  
    104104
    105105        // Stop if there is no user displayed or logged in
    106         if ( !is_user_logged_in() && !isset( $bp->displayed_user->id ) )
     106        if ( !is_user_logged_in() && !bp_displayed_user_id() )
    107107            return;
    108108
     
    238238            } else {
    239239                $bp->bp_options_avatar = bp_core_fetch_avatar( array(
    240                     'item_id' => $bp->displayed_user->id,
     240                    'item_id' => bp_displayed_user_id(),
    241241                    'type'    => 'thumb'
    242242                ) );
  • trunk/bp-forums/bp-forums-template.php

    r5206 r5301  
    269269
    270270    // User filtering
    271     if ( !empty( $bp->displayed_user->id ) )
    272         $user_id = $bp->displayed_user->id;
     271    if ( bp_displayed_user_id() )
     272        $user_id = bp_displayed_user_id();
    273273
    274274    // "Replied" query must be manually modified
  • trunk/bp-friends/bp-friends-classes.php

    r4934 r5301  
    4242
    4343        // if running from ajax.
    44         if ( !$bp->displayed_user->id )
     44        if ( !bp_displayed_user_id() )
    4545            $bp->displayed_user->id = $creds['current_userid'];
    4646
    4747        if ( $this->populate_friend_details ) {
    48             if ( $this->friend_user_id == $bp->displayed_user->id ) {
     48            if ( $this->friend_user_id == bp_displayed_user_id() ) {
    4949                $this->friend = new BP_Core_User( $this->initiator_user_id );
    5050            } else {
     
    127127
    128128        if ( !$user_id )
    129             $user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
     129            $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : $bp->loggedin_user->id;
    130130
    131131        /* This is stored in 'total_friend_count' usermeta.
  • trunk/bp-friends/bp-friends-functions.php

    r4961 r5301  
    5858
    5959    // Remove the activity stream item for the user who canceled the friendship
    60     friends_delete_activity( array( 'item_id' => $friendship_id, 'type' => 'friendship_accepted', 'user_id' => $bp->displayed_user->id ) );
     60    friends_delete_activity( array( 'item_id' => $friendship_id, 'type' => 'friendship_accepted', 'user_id' => bp_displayed_user_id() ) );
    6161
    6262    do_action( 'friends_friendship_deleted', $friendship_id, $initiator_userid, $friend_userid );
     
    152152
    153153    if ( !$user_id )
    154         $user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
     154        $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : $bp->loggedin_user->id;
    155155
    156156    if ( !$count = wp_cache_get( 'bp_total_friend_count_' . $user_id, 'bp' ) ) {
  • trunk/bp-friends/bp-friends-loader.php

    r5300 r5301  
    197197            } else {
    198198                $bp->bp_options_avatar = bp_core_fetch_avatar( array(
    199                     'item_id' => $bp->displayed_user->id,
     199                    'item_id' => bp_displayed_user_id(),
    200200                    'type'    => 'thumb'
    201201                ) );
  • trunk/bp-friends/bp-friends-screens.php

    r4961 r5301  
    5555    global $bp;
    5656
    57     if ( !$send_requests = bp_get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_request', true ) )
     57    if ( !$send_requests = bp_get_user_meta( bp_displayed_user_id(), 'notification_friends_friendship_request', true ) )
    5858        $send_requests   = 'yes';
    5959
    60     if ( !$accept_requests = bp_get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_accepted', true ) )
     60    if ( !$accept_requests = bp_get_user_meta( bp_displayed_user_id(), 'notification_friends_friendship_accepted', true ) )
    6161        $accept_requests = 'yes';
    6262?>
  • trunk/bp-friends/bp-friends-template.php

    r4961 r5301  
    9393    global $bp;
    9494
    95     if ( !$friend_ids = wp_cache_get( 'friends_friend_ids_' . $bp->displayed_user->id, 'bp' ) ) {
    96         $friend_ids = BP_Friends_Friendship::get_random_friends( $bp->displayed_user->id );
    97         wp_cache_set( 'friends_friend_ids_' . $bp->displayed_user->id, $friend_ids, 'bp' );
     95    if ( !$friend_ids = wp_cache_get( 'friends_friend_ids_' . bp_displayed_user_id(), 'bp' ) ) {
     96        $friend_ids = BP_Friends_Friendship::get_random_friends( bp_displayed_user_id() );
     97        wp_cache_set( 'friends_friend_ids_' . bp_displayed_user_id(), $friend_ids, 'bp' );
    9898    } ?>
    9999
    100100    <div class="info-group">
    101         <h4><?php bp_word_or_name( __( "My Friends", 'buddypress' ), __( "%s's Friends", 'buddypress' ) ) ?>  (<?php echo BP_Friends_Friendship::total_friend_count( $bp->displayed_user->id ) ?>) <span><a href="<?php echo $bp->displayed_user->domain . bp_get_friends_slug() ?>"><?php _e('See All', 'buddypress') ?></a></span></h4>
     101        <h4><?php bp_word_or_name( __( "My Friends", 'buddypress' ), __( "%s's Friends", 'buddypress' ) ) ?>  (<?php echo BP_Friends_Friendship::total_friend_count( bp_displayed_user_id() ) ?>) <span><a href="<?php echo $bp->displayed_user->domain . bp_get_friends_slug() ?>"><?php _e('See All', 'buddypress') ?></a></span></h4>
    102102
    103103        <?php if ( $friend_ids ) { ?>
     
    208208            <?php wp_nonce_field( 'friends_search', '_wpnonce_friend_search' ) ?>
    209209
    210             <input type="hidden" name="initiator" id="initiator" value="<?php echo esc_attr( $bp->displayed_user->id ) ?>" />
     210            <input type="hidden" name="initiator" id="initiator" value="<?php echo esc_attr( bp_displayed_user_id() ) ?>" />
    211211
    212212        </form>
     
    268268            $user_id = $friends_template->friendship->friend->id;
    269269        else if ( empty( $user_id ) && !isset( $friends_template->friendship->friend ) )
    270             $user_id = $bp->displayed_user->id;
     270            $user_id = bp_displayed_user_id();
    271271
    272272        return apply_filters( 'bp_get_potential_friend_id', (int)$user_id );
     
    370370
    371371    if ( !$user_id )
    372         $user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
     372        $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : $bp->loggedin_user->id;
    373373
    374374    $friend_ids = friends_get_friend_user_ids( $user_id );
  • trunk/bp-groups/bp-groups-classes.php

    r5139 r5301  
    176176
    177177        if ( !$user_id )
    178             $user_id = $bp->displayed_user->id;
     178            $user_id = bp_displayed_user_id();
    179179
    180180        $filter = like_escape( $wpdb->escape( $filter ) );
     
    937937
    938938        if ( !$user_id )
    939             $user_id = $bp->displayed_user->id;
     939            $user_id = bp_displayed_user_id();
    940940
    941941        if ( $user_id != $bp->loggedin_user->id && !is_super_admin() ) {
  • trunk/bp-groups/bp-groups-functions.php

    r5140 r5301  
    398398
    399399    if ( !$user_id )
    400         $user_id = $bp->displayed_user->id;
     400        $user_id = bp_displayed_user_id();
    401401
    402402    return BP_Groups_Member::get_group_ids( $user_id, $pag_num, $pag_page );
     
    407407
    408408    if ( !$user_id )
    409         $user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
     409        $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : $bp->loggedin_user->id;
    410410
    411411    if ( !$count = wp_cache_get( 'bp_total_groups_for_user_' . $user_id, 'bp' ) ) {
  • trunk/bp-groups/bp-groups-loader.php

    r5300 r5301  
    448448
    449449                $bp->bp_options_avatar = bp_core_fetch_avatar( array(
    450                     'item_id' => $bp->displayed_user->id,
     450                    'item_id' => bp_displayed_user_id(),
    451451                    'type'    => 'thumb'
    452452                ) );
  • trunk/bp-groups/bp-groups-screens.php

    r5204 r5301  
    812812    global $bp;
    813813
    814     if ( !$group_invite = bp_get_user_meta( $bp->displayed_user->id, 'notification_groups_invite', true ) )
     814    if ( !$group_invite = bp_get_user_meta( bp_displayed_user_id(), 'notification_groups_invite', true ) )
    815815        $group_invite  = 'yes';
    816816
    817     if ( !$group_update = bp_get_user_meta( $bp->displayed_user->id, 'notification_groups_group_updated', true ) )
     817    if ( !$group_update = bp_get_user_meta( bp_displayed_user_id(), 'notification_groups_group_updated', true ) )
    818818        $group_update  = 'yes';
    819819
    820     if ( !$group_promo = bp_get_user_meta( $bp->displayed_user->id, 'notification_groups_admin_promotion', true ) )
     820    if ( !$group_promo = bp_get_user_meta( bp_displayed_user_id(), 'notification_groups_admin_promotion', true ) )
    821821        $group_promo   = 'yes';
    822822
    823     if ( !$group_request = bp_get_user_meta( $bp->displayed_user->id, 'notification_groups_membership_request', true ) )
     823    if ( !$group_request = bp_get_user_meta( bp_displayed_user_id(), 'notification_groups_membership_request', true ) )
    824824        $group_request = 'yes';
    825825?>
  • trunk/bp-groups/bp-groups-template.php

    r5189 r5301  
    238238
    239239    // User filtering
    240     if ( !empty( $bp->displayed_user->id ) )
    241         $user_id = $bp->displayed_user->id;
     240    if ( bp_displayed_user_id() )
     241        $user_id = bp_displayed_user_id();
    242242
    243243    // Type
     
    698698
    699699function bp_group_show_no_groups_message() {
    700     global $bp;
    701 
    702     if ( !groups_total_groups_for_user( $bp->displayed_user->id ) )
     700    if ( !groups_total_groups_for_user( bp_displayed_user_id() ) )
    703701        return true;
    704702
  • trunk/bp-members/bp-members-actions.php

    r4961 r5301  
    123123    global $bp;
    124124
    125     if ( !is_super_admin() || bp_is_my_profile() || !$bp->displayed_user->id )
     125    if ( !is_super_admin() || bp_is_my_profile() || !bp_displayed_user_id() )
    126126        return false;
    127127
     
    133133        do_action( 'bp_core_before_action_delete_user', $errors );
    134134
    135         if ( bp_core_delete_account( $bp->displayed_user->id ) ) {
     135        if ( bp_core_delete_account( bp_displayed_user_id() ) ) {
    136136            bp_core_add_message( sprintf( __( '%s has been deleted from the system.', 'buddypress' ), $bp->displayed_user->fullname ) );
    137137        } else {
  • trunk/bp-members/bp-members-adminbar.php

    r5289 r5301  
    109109    // User avatar
    110110    $avatar = bp_core_fetch_avatar( array(
    111         'item_id' => $bp->displayed_user->id,
     111        'item_id' => bp_displayed_user_id(),
    112112        'email'   => $bp->displayed_user->userdata->user_email,
    113113        'width'   => 16,
  • trunk/bp-members/bp-members-buddybar.php

    r4961 r5301  
    9292
    9393    // Only show if viewing a user
    94     if ( !$bp->displayed_user->id )
     94    if ( !bp_displayed_user_id() )
    9595        return false;
    9696
     
    112112            <li><a href="<?php bp_members_component_link( 'profile', 'change-avatar' ); ?>"><?php printf( __( "Edit %s's Avatar", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
    113113
    114             <?php if ( !bp_core_is_user_spammer( $bp->displayed_user->id ) ) : ?>
     114            <?php if ( !bp_core_is_user_spammer( bp_displayed_user_id() ) ) : ?>
    115115
    116116                <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/mark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php printf( __( "Mark as Spammer", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ); ?></a></li>
  • trunk/bp-members/bp-members-functions.php

    r5238 r5301  
    218218
    219219            // User ID matches displayed in user
    220             } elseif ( isset( $bp->displayed_user->id ) && $bp->displayed_user->id == $user_id ) {
     220            } elseif ( bp_displayed_user_id() == $user_id ) {
    221221                $userdata = &$bp->displayed_user->userdata;
    222222
     
    290290
    291291        // User ID matches displayed in user
    292         } elseif ( isset( $bp->displayed_user->id ) && $bp->displayed_user->id == $user_id ) {
     292        } elseif ( bp_displayed_user_id() == $user_id ) {
    293293            $userdata = &$bp->displayed_user->userdata;
    294294
     
    576576
    577577    if ( empty( $user_id ) )
    578         $user_id = $bp->displayed_user->id;
     578        $user_id = bp_displayed_user_id();
    579579
    580580    return apply_filters( 'bp_core_get_all_posts_for_user', $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d AND post_status = 'publish' AND post_type = 'post'", $user_id ) ) );
  • trunk/bp-members/bp-members-loader.php

    r5300 r5301  
    8989        /** Displayed user ****************************************************/
    9090
    91         // The user id of the user currently being viewed:
    92         // $bp->displayed_user->id is set in /bp-core/bp-core-catchuri.php
    93         if ( empty( $bp->displayed_user->id ) )
    94             $bp->displayed_user->id = 0;
    95 
    9691        // The domain for the user currently being displayed
    97         $bp->displayed_user->domain   = bp_core_get_user_domain( $bp->displayed_user->id );
     92        $bp->displayed_user->domain   = bp_core_get_user_domain( bp_displayed_user_id() );
    9893
    9994        // The core userdata of the user who is currently being displayed
    100         $bp->displayed_user->userdata = bp_core_get_core_userdata( $bp->displayed_user->id );
     95        $bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() );
    10196
    10297        // Fetch the full name displayed user
    103         $bp->displayed_user->fullname = bp_core_get_user_displayname( $bp->displayed_user->id );
     98        $bp->displayed_user->fullname = bp_core_get_user_displayname( bp_displayed_user_id() );
    10499
    105100        /** Profiles Fallback *************************************************/
     
    120115        }
    121116
    122         if ( !$bp->current_component && $bp->displayed_user->id )
     117        if ( !$bp->current_component && bp_displayed_user_id() )
    123118            $bp->current_component = $bp->default_component;
    124119    }
     
    178173        } elseif( bp_is_user() ) {
    179174            $bp->bp_options_avatar = bp_core_fetch_avatar( array(
    180                 'item_id' => $bp->displayed_user->id,
     175                'item_id' => bp_displayed_user_id(),
    181176                'type'    => 'thumb'
    182177            ) );
  • trunk/bp-members/bp-members-template.php

    r5271 r5301  
    282282
    283283    // User filtering
    284     if ( !empty( $bp->displayed_user->id ) )
    285         $user_id = $bp->displayed_user->id;
     284    if ( bp_displayed_user_id() )
     285        $user_id = bp_displayed_user_id();
    286286
    287287    // type: active ( default ) | random | newest | popular | online | alphabetical
     
    610610        if ( !empty( $members_template->member->id ) )
    611611            $user_id = $members_template->member->id;
    612         elseif ( !empty( $bp->displayed_user->id ) )
    613             $user_id = $bp->displayed_user->id;
     612        elseif ( bp_displayed_user_id() )
     613            $user_id = bp_displayed_user_id();
    614614
    615615        $defaults = array(
     
    716716           then check to see if the two users are friends. if they are, add a highlight CSS class
    717717           to the friends nav item if it exists. */
    718         if ( !bp_is_my_profile() && $bp->displayed_user->id ) {
     718        if ( !bp_is_my_profile() && bp_displayed_user_id() ) {
    719719            $selected = '';
    720720
    721721            if ( bp_is_active( 'friends' ) ) {
    722722                if ( $nav_item['css_id'] == $bp->friends->id ) {
    723                     if ( friends_check_friendship( $bp->loggedin_user->id, $bp->displayed_user->id ) )
     723                    if ( friends_check_friendship( $bp->loggedin_user->id, bp_displayed_user_id() ) )
    724724                        $selected = ' class="current selected"';
    725725                }
     
    804804        extract( $r, EXTR_SKIP );
    805805
    806         return apply_filters( 'bp_get_displayed_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html, 'alt' => $alt ) ) );
     806        return apply_filters( 'bp_get_displayed_user_avatar', bp_core_fetch_avatar( array( 'item_id' => bp_displayed_user_id(), 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html, 'alt' => $alt ) ) );
    807807    }
    808808
     
    829829
    830830        if ( empty( $user_id ) )
    831             $user_id = $bp->displayed_user->id;
     831            $user_id = bp_displayed_user_id();
    832832
    833833        $last_activity = bp_core_get_last_activity( bp_get_user_meta( $user_id, 'last_activity', true ), __('active %s', 'buddypress') );
     
    871871
    872872function bp_displayed_user_id() {
    873     global $bp;
    874     return apply_filters( 'bp_displayed_user_id', !empty( $bp->displayed_user->id ) ? $bp->displayed_user->id : 0 );
     873   
     874    static $id = 0;
     875   
     876    if ( empty( $id ) ) {
     877        global $bp;
     878        $id = !empty( $bp->displayed_user->id ) ? $bp->displayed_user->id : 0;
     879    }
     880
     881    return apply_filters( 'bp_displayed_user_id', $id );
    875882}
    876883    function bp_current_user_id() { return bp_displayed_user_id(); }
    877884
    878885function bp_loggedin_user_id() {
    879     global $bp;
    880     return apply_filters( 'bp_loggedin_user_id', !empty( $bp->loggedin_user->id ) ? $bp->loggedin_user->id : 0 );
     886
     887    static $id = 0;
     888   
     889    if ( empty( $id ) ) {
     890        global $bp;
     891        $id = !empty( $bp->loggedin_user->id ) ? $bp->loggedin_user->id : 0;
     892    }
     893
     894    return apply_filters( 'bp_loggedin_user_id', $id );
    881895}
    882896
     
    915929        global $bp;
    916930
    917         if ( !empty( $bp->displayed_user->id ) ) {
    918             $username = bp_core_get_username( $bp->displayed_user->id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login );
     931        if ( bp_displayed_user_id() ) {
     932            $username = bp_core_get_username( bp_displayed_user_id(), $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login );
    919933        } else {
    920934            $username = '';
     
    11711185
    11721186        // Must be displayed user
    1173         if ( empty( $bp->displayed_user->id ) )
     1187        if ( !bp_displayed_user_id() )
    11741188            return;
    11751189
  • trunk/bp-messages/bp-messages-loader.php

    r5300 r5301  
    242242            } else {
    243243                $bp->bp_options_avatar = bp_core_fetch_avatar( array(
    244                     'item_id' => $bp->displayed_user->id,
     244                    'item_id' => bp_displayed_user_id(),
    245245                    'type'    => 'thumb'
    246246                ) );
  • trunk/bp-messages/bp-messages-screens.php

    r4961 r5301  
    136136    }
    137137
    138     if ( !$new_messages = bp_get_user_meta( $bp->displayed_user->id, 'notification_messages_new_message', true ) )
     138    if ( !$new_messages = bp_get_user_meta( bp_displayed_user_id(), 'notification_messages_new_message', true ) )
    139139        $new_messages = 'yes';
    140140
    141     if ( !$new_notices = bp_get_user_meta( $bp->displayed_user->id, 'notification_messages_new_notice', true ) )
     141    if ( !$new_notices = bp_get_user_meta( bp_displayed_user_id(), 'notification_messages_new_notice', true ) )
    142142        $new_notices  = 'yes';
    143143?>
  • trunk/bp-messages/bp-messages-template.php

    r5072 r5301  
    171171
    172172    if ( 'notices' == $bp->current_action && !is_super_admin() ) {
    173         wp_redirect( $bp->displayed_user->id );
     173        wp_redirect( bp_displayed_user_id() );
    174174    } else {
    175175        if ( 'inbox' == $bp->current_action )
     
    562562            return false;
    563563
    564         return apply_filters( 'bp_get_send_private_message_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/compose/?r=' . bp_core_get_username( $bp->displayed_user->id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) ) );
     564        return apply_filters( 'bp_get_send_private_message_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/compose/?r=' . bp_core_get_username( bp_displayed_user_id(), $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) ) );
    565565    }
    566566
  • trunk/bp-settings/bp-settings-actions.php

    r5232 r5301  
    2222
    2323        // Validate the user again for the current password when making a big change
    24         if ( is_super_admin() || ( !empty( $_POST['pwd'] ) && $_POST['pwd'] != '' && wp_check_password( $_POST['pwd'], $bp->displayed_user->userdata->user_pass, $bp->displayed_user->id ) ) ) {
     24        if ( is_super_admin() || ( !empty( $_POST['pwd'] ) && $_POST['pwd'] != '' && wp_check_password( $_POST['pwd'], $bp->displayed_user->userdata->user_pass, bp_displayed_user_id() ) ) ) {
    2525
    26             $update_user = get_userdata( $bp->displayed_user->id );
     26            $update_user = get_userdata( bp_displayed_user_id() );
    2727
    2828            // Make sure changing an email address does not already exist
     
    8383            // Make sure these changes are in $bp for the current page load
    8484            if ( ( false === $email_error ) && ( false === $pass_error ) && ( wp_update_user( get_object_vars( $update_user ) ) ) ) {
    85                 $bp->displayed_user->userdata = bp_core_get_core_userdata( $bp->displayed_user->id );
     85                $bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() );
    8686                $bp_settings_updated = true;
    8787            }
     
    129129            foreach ( (array)$_POST['notifications'] as $key => $value ) {
    130130                if ( $meta_key = bp_get_user_meta_key( $key ) )
    131                     bp_update_user_meta( (int)$bp->displayed_user->id, $meta_key, $value );
     131                    bp_update_user_meta( (int)bp_displayed_user_id(), $meta_key, $value );
    132132            }
    133133        }
     
    156156
    157157        // delete the users account
    158         if ( bp_core_delete_account( $bp->displayed_user->id ) ) {
     158        if ( bp_core_delete_account( bp_displayed_user_id() ) ) {
    159159            bp_core_redirect( home_url() );
    160160        }
  • trunk/bp-themes/bp-default/_inc/ajax.php

    r5262 r5301  
    4040    if ( !empty( $_BP_COOKIE['bp-' . $object . '-scope'] ) ) {
    4141        if ( 'personal' == $_BP_COOKIE['bp-' . $object . '-scope'] ) {
    42             $user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
     42            $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : $bp->loggedin_user->id;
    4343            $qs[] = 'user_id=' . $user_id;
    4444        }
    45         if ( 'all' != $_BP_COOKIE['bp-' . $object . '-scope'] && empty( $bp->displayed_user->id ) && !$bp->is_single_item )
     45        if ( 'all' != $_BP_COOKIE['bp-' . $object . '-scope'] && !bp_displayed_user_id() && !$bp->is_single_item )
    4646            $qs[] = 'scope=' . $_BP_COOKIE['bp-' . $object . '-scope']; // Activity stream scope only on activity directory.
    4747    }
  • trunk/bp-xprofile/bp-xprofile-actions.php

    r5072 r5301  
    3333        return false;
    3434
    35     if ( bp_core_delete_existing_avatar( array( 'item_id' => $bp->displayed_user->id ) ) )
     35    if ( bp_core_delete_existing_avatar( array( 'item_id' => bp_displayed_user_id() ) ) )
    3636        bp_core_add_message( __( 'Your avatar was deleted successfully!', 'buddypress' ) );
    3737    else
  • trunk/bp-xprofile/bp-xprofile-activity.php

    r4961 r5301  
    120120        return false;
    121121
    122     $user_id = apply_filters( 'bp_xprofile_new_avatar_user_id', $bp->displayed_user->id );
     122    $user_id = apply_filters( 'bp_xprofile_new_avatar_user_id', bp_displayed_user_id() );
    123123
    124124    $userlink = bp_core_get_userlink( $user_id );
  • trunk/bp-xprofile/bp-xprofile-classes.php

    r5293 r5301  
    113113        $defaults = array(
    114114            'profile_group_id'  => false,
    115             'user_id'           => $bp->displayed_user->id,
     115            'user_id'           => bp_displayed_user_id(),
    116116            'hide_empty_groups' => false,
    117117            'hide_empty_fields' => false,
     
    945945
    946946        if ( !$user_ids )
    947             $user_ids = $bp->displayed_user->id;
     947            $user_ids = bp_displayed_user_id();
    948948
    949949        if ( is_array( $user_ids ) ) {
     
    964964
    965965        if ( !$user_id )
    966             $user_id = $bp->displayed_user->id;
     966            $user_id = bp_displayed_user_id();
    967967
    968968        $field_sql = '';
     
    10401040
    10411041        if ( !$user_id )
    1042             $user_id = $bp->displayed_user->id;
     1042            $user_id = bp_displayed_user_id();
    10431043
    10441044        $field_name = bp_xprofile_fullname_field_name();
  • trunk/bp-xprofile/bp-xprofile-functions.php

    r5167 r5301  
    156156
    157157    if ( empty( $user_id ) )
    158         $user_id = $bp->displayed_user->id;
     158        $user_id = bp_displayed_user_id();
    159159
    160160    if ( empty( $user_id ) )
     
    355355
    356356    if ( empty( $user_id ) )
    357         $user_id = $bp->displayed_user->id;
     357        $user_id = bp_displayed_user_id();
    358358
    359359    if ( empty( $directory ) )
  • trunk/bp-xprofile/bp-xprofile-loader.php

    r5300 r5301  
    221221            } else {
    222222                $bp->bp_options_avatar = bp_core_fetch_avatar( array(
    223                     'item_id' => $bp->displayed_user->id,
     223                    'item_id' => bp_displayed_user_id(),
    224224                    'type'    => 'thumb'
    225225                ) );
  • trunk/bp-xprofile/bp-xprofile-screens.php

    r5268 r5301  
    9999                    $value = $_POST['field_' . $field_id];
    100100
    101                 if ( !xprofile_set_field_data( $field_id, $bp->displayed_user->id, $value, $is_required[$field_id] ) )
     101                if ( !xprofile_set_field_data( $field_id, bp_displayed_user_id(), $value, $is_required[$field_id] ) )
    102102                    $errors = true;
    103103                else
     
    105105            }
    106106
    107             do_action( 'xprofile_updated_profile', $bp->displayed_user->id, $posted_field_ids, $errors );
     107            do_action( 'xprofile_updated_profile', bp_displayed_user_id(), $posted_field_ids, $errors );
    108108
    109109            // Set the feedback messages
     
    162162        check_admin_referer( 'bp_avatar_cropstore' );
    163163
    164         if ( !bp_core_avatar_handle_crop( array( 'item_id' => $bp->displayed_user->id, 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ) )
     164        if ( !bp_core_avatar_handle_crop( array( 'item_id' => bp_displayed_user_id(), 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ) )
    165165            bp_core_add_message( __( 'There was a problem cropping your avatar, please try uploading it again', 'buddypress' ), 'error' );
    166166        else {
  • trunk/bp-xprofile/bp-xprofile-template.php

    r5230 r5301  
    159159
    160160    $defaults = array(
    161         'user_id'           => $bp->displayed_user->id,
     161        'user_id'           => bp_displayed_user_id(),
    162162        'profile_group_id'  => false,
    163163        'hide_empty_groups' => true,
     
    689689        $defaults = array(
    690690            'field'   => false, // Field name or ID.
    691             'user_id' => $bp->displayed_user->id
     691            'user_id' => bp_displayed_user_id()
    692692        );
    693693
     
    774774        global $bp;
    775775
    776         $last_updated = bp_get_user_meta( $bp->displayed_user->id, 'profile_last_updated', true );
     776        $last_updated = bp_get_user_meta( bp_displayed_user_id(), 'profile_last_updated', true );
    777777
    778778        if ( $last_updated )
     
    804804    global $bp;
    805805
    806     if ( !bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'no_grav' => true ) ) )
     806    if ( !bp_core_fetch_avatar( array( 'item_id' => bp_displayed_user_id(), 'no_grav' => true ) ) )
    807807        return false;
    808808
Note: See TracChangeset for help on using the changeset viewer.