Skip to:
Content

BuddyPress.org

Changeset 2276


Ignore:
Timestamp:
01/09/2010 09:31:33 AM (17 years ago)
Author:
apeatling
Message:

Better public @ message usability with a button on a user profile page. Made core userdata available for logged in and displayed user.

Location:
trunk
Files:
12 edited

Legend:

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

    r2273 r2276  
    666666        }
    667667
     668function bp_send_public_message_link() {
     669        echo bp_get_send_public_message_link();
     670}
     671        function bp_get_send_public_message_link() {
     672                global $bp;
     673
     674                return apply_filters( 'bp_get_send_public_message_link', $bp->loggedin_user->domain . $bp->activity->slug . '/?r=' . $bp->displayed_user->userdata->user_login );
     675        }
    668676
    669677/* RSS Feed Template Tags ***************************/
  • trunk/bp-core.php

    r2274 r2276  
    103103
    104104        /* The domain for the user currently logged in. eg: http://domain.com/members/andy */
    105         $bp->loggedin_user->domain = bp_core_get_user_domain($current_user->ID);
     105        $bp->loggedin_user->domain = bp_core_get_user_domain( $bp->loggedin_user->id );
     106
     107        /* The core userdata of the user who is currently logged in. */
     108        $bp->loggedin_user->userdata = bp_core_get_core_userdata( $bp->loggedin_user->id );
    106109
    107110        /* The user id of the user currently being viewed, set in /bp-core/bp-core-catchuri.php */
     
    109112
    110113        /* The domain for the user currently being displayed */
    111         $bp->displayed_user->domain = bp_core_get_user_domain($displayed_user_id);
     114        $bp->displayed_user->domain = bp_core_get_user_domain( $bp->displayed_user->id );
     115
     116        /* The core userdata of the user who is currently being displayed */
     117        $bp->displayed_user->userdata = bp_core_get_core_userdata( $bp->displayed_user->id );
    112118
    113119        /* The component being used eg: http://domain.com/members/andy/ [profile] */
     
    161167
    162168        /* Used to determine if user has admin rights on current content. If the logged in user is viewing
    163            their own profile and wants to delete a post on their wire, is_item_admin is used. This is a
    164            generic variable so it can be used in other components. It can also be modified, so when viewing a group
     169           their own profile and wants to delete something, is_item_admin is used. This is a
     170           generic variable so it can be used by other components. It can also be modified, so when viewing a group
    165171           'is_item_admin' would be 1 if they are a group admin, 0 if they are not. */
    166         $bp->is_item_admin = bp_is_home();
     172        $bp->is_item_admin = bp_is_my_profile();
    167173
    168174        /* Used to determine if the logged in user is a moderator for the current content. */
     
    185191 * Adds the core URIs that should run in the root of the installation.
    186192 *
    187  * For example: http://example.org/search or http://example.org/members
     193 * For example: http://example.org/search/ or http://example.org/members/
    188194 *
    189195 * @package BuddyPress Core
     
    558564
    559565/**
     566 * bp_core_get_core_userdata()
     567 *
     568 * Fetch everything in the wp_users table for a user, without any usermeta.
     569 *
     570 * @package BuddyPress Core
     571 * @param user_id The ID of the user.
     572 * @uses BP_Core_User::get_core_userdata() Performs the query.
     573 */
     574function bp_core_get_core_userdata( $user_id ) {
     575        if ( empty( $user_id ) )
     576                return false;
     577
     578        return apply_filters( 'bp_core_get_core_userdata', BP_Core_User::get_core_userdata( $user_id ) );
     579}
     580
     581/**
    560582 * bp_core_get_root_domain()
    561583 *
     
    10221044                $email = $ud->user_email;
    10231045        }
     1046
     1047        wp_cache_set( 'bp_user_email_' . $uid, $email, 'bp' );
     1048
    10241049        return apply_filters( 'bp_core_get_user_email', $email );
    10251050}
     
    10481073 */
    10491074function bp_core_get_userlink( $user_id, $no_anchor = false, $just_link = false, $deprecated = false, $with_s = false ) {
    1050         global $userdata;
    1051 
    1052         $ud = get_userdata($user_id);
    1053 
    1054         if ( !$ud )
    1055                 return false;
    1056 
    1057         if ( function_exists( 'bp_core_get_user_displayname' ) ) {
    1058                 $display_name = bp_core_get_user_displayname( $user_id );
    1059 
    1060                 if ( $with_s )
    1061                         $display_name = sprintf( __( "%s's", 'buddypress' ), $display_name );
    1062 
    1063         } else {
    1064                 $display_name = $ud->display_name;
    1065         }
     1075
     1076        $display_name = bp_core_get_user_displayname( $user_id );
     1077
     1078        if ( $with_s )
     1079                $display_name = sprintf( __( "%s's", 'buddypress' ), $display_name );
    10661080
    10671081        if ( $no_anchor )
     
    11021116                        $fullname = xprofile_get_field_data( 1, $user_id );
    11031117
    1104                         if ( empty($fullname) || !$fullname ) {
    1105                                 $ud = get_userdata($user_id);
     1118                        if ( empty($fullname) ) {
     1119                                $ud = get_userdata( $user_id );
    11061120
    11071121                                if ( !empty( $ud->display_name ) )
  • trunk/bp-core/bp-core-classes.php

    r2273 r2276  
    358358                return $paged_users;
    359359        }
     360
     361        function get_core_userdata( $user_id ) {
     362                global $wpdb;
     363
     364                if ( !$user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE ID = %d LIMIT 1", $user_id ) ) )
     365                        return false;
     366
     367                return $user;
     368        }
    360369}
    361370
  • trunk/bp-core/bp-core-wpabstraction.php

    r2274 r2276  
    3333
    3434if ( !function_exists( 'get_site_option' ) ) {
    35         function get_site_option( $option_value ) {
    36                 return get_option( $option_value );
     35        function get_site_option( $option_value, $default = false ) {
     36                return get_option( $option_value, $default );
    3737        }
    3838}
     
    5151
    5252if ( !function_exists( 'get_blog_option' ) ) {
    53         function get_blog_option( $blog_id, $option_name ) {
    54                 return get_option( $option_name );
     53        function get_blog_option( $blog_id, $option_name, $default = false ) {
     54                return get_option( $option_name, $default );
    5555        }
    5656}
  • trunk/bp-friends.php

    r2223 r2276  
    475475}
    476476
     477function friends_check_friendship_status( $user_id, $possible_friend_id ) {
     478        /* Returns - 'is_friend', 'not_friends', 'pending' */
     479        return BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id );
     480}
     481
    477482function friends_get_total_friend_count( $user_id = false ) {
    478483        global $bp;
  • trunk/bp-friends/bp-friends-templatetags.php

    r2198 r2276  
    121121                global $bp, $friends_template;
    122122
    123                 $button = false;
    124 
    125                 if ( is_user_logged_in() ) {
    126 
    127                         if ( !$potential_friend_id && $friends_template->friendship->friend )
    128                                 $potential_friend_id = $friends_template->friendship->friend->id;
    129                         else if ( !$potential_friend_id && !$friends_template->friendship->friend )
    130                                 $potential_friend_id = $bp->displayed_user->id;
    131 
    132                         if ( $bp->loggedin_user->id == $potential_friend_id )
    133                                 return false;
    134 
    135                         $friend_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id );
    136 
    137                         $button = '<div class="generic-button friendship-button ' . $friend_status . '" id="friendship-button-' . $potential_friend_id . '">';
    138                         if ( 'pending' == $friend_status ) {
    139                                 $button .= '<a class="requested" href="' . $bp->loggedin_user->domain . $bp->friends->slug . '">' . __( 'Friendship Requested', 'buddypress' ) . '</a>';
    140                         } else if ( 'is_friend' == $friend_status ) {
    141                                 $button .= '<a href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/remove-friend/' . $potential_friend_id, 'friends_remove_friend' ) . '" title="' . __('Cancel Friendship', 'buddypress') . '" id="friend-' . $potential_friend_id . '" rel="remove" class="remove">' . __('Cancel Friendship', 'buddypress') . '</a>';
    142                         } else {
    143                                 $button .= '<a href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/add-friend/' . $potential_friend_id, 'friends_add_friend' ) . '" title="' . __('Add Friend', 'buddypress') . '" id="friend-' . $potential_friend_id . '" rel="add" class="add">' . __('Add Friend', 'buddypress') . '</a>';
    144                         }
    145                         $button .= '</div>';
     123                if ( !is_user_logged_in() )
     124                        return false;
     125
     126                if ( !$potential_friend_id && $friends_template->friendship->friend )
     127                        $potential_friend_id = $friends_template->friendship->friend->id;
     128                else if ( !$potential_friend_id && !$friends_template->friendship->friend )
     129                        $potential_friend_id = $bp->displayed_user->id;
     130
     131                if ( $bp->loggedin_user->id == $potential_friend_id )
     132                        return false;
     133
     134                $friend_status = friends_check_friendship_status( $bp->loggedin_user->id, $potential_friend_id );
     135
     136                $button = '<div class="generic-button friendship-button ' . $friend_status . '" id="friendship-button-' . $potential_friend_id . '">';
     137                if ( 'pending' == $friend_status ) {
     138                        $button .= '<a class="requested" href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/">' . __( 'Friendship Requested', 'buddypress' ) . '</a>';
     139                } else if ( 'is_friend' == $friend_status ) {
     140                        $button .= '<a href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/remove-friend/' . $potential_friend_id . '/', 'friends_remove_friend' ) . '" title="' . __('Cancel Friendship', 'buddypress') . '" id="friend-' . $potential_friend_id . '" rel="remove" class="remove">' . __('Cancel Friendship', 'buddypress') . '</a>';
     141                } else {
     142                        $button .= '<a href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/add-friend/' . $potential_friend_id . '/', 'friends_add_friend' ) . '" title="' . __('Add Friend', 'buddypress') . '" id="friend-' . $potential_friend_id . '" rel="add" class="add">' . __('Add Friend', 'buddypress') . '</a>';
    146143                }
     144                $button .= '</div>';
    147145
    148146                return apply_filters( 'bp_get_add_friend_button', $button );
  • trunk/bp-messages/bp-messages-templatetags.php

    r2209 r2276  
    436436}
    437437
     438function bp_send_private_message_link() {
     439        echo bp_get_send_private_message_link();
     440}
     441        function bp_get_send_private_message_link() {
     442                global $bp;
     443
     444                return apply_filters( 'bp_get_send_public_message_link', $bp->loggedin_user->domain . $bp->messages->slug . '/compose/?r=' . $bp->displayed_user->userdata->user_login );
     445        }
     446
    438447function bp_send_message_button() {
    439448        echo bp_get_send_message_button();
     
    445454                        return false;
    446455
    447                 $ud = get_userdata( $bp->displayed_user->id );
    448 
    449                 return apply_filters( 'bp_get_send_message_button', '<div class="generic-button"><a class="send-message" title="' . __( 'Send Message', 'buddypress' ) . '" href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/compose/?r=' . $ud->user_login . '">' . __( 'Send Message', 'buddypress' ) . '</a></div>' );
     456                return apply_filters( 'bp_get_send_message_button', '<div class="generic-button"><a class="send-message" title="' . __( 'Send Message', 'buddypress' ) . '" href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/compose/?r=' . $bp->displayed_user->userdata->user_login . '">' . __( 'Send Message', 'buddypress' ) . '</a></div>' );
    450457        }
    451458
  • trunk/bp-themes/bp-default/_inc/css/default.css

    r2271 r2276  
    358358                }
    359359
    360         div#item-header div.generic-button {
     360        div#item-header div.generic-button, div#item-header a.button {
    361361                float: left;
    362362                margin: 10px 10px 0 0;
  • trunk/bp-themes/bp-default/_inc/global.js

    r2266 r2276  
    2626                j('div#new-topic-post').hide();
    2727                bp_filter_request( j.cookie('bp-forums-type'), j.cookie('bp-forums-filter'), 'forums', 'div.forums', j.cookie('bp-forums-page'), j.cookie('bp-forums-search-terms') );
     28        }
     29
     30        /* @message Compose Scrolling */
     31        if ( j.query.get('r') ) {
     32                if ( j('textarea#whats-new').length ) {
     33                        j.scrollTo( j('textarea#whats-new'), 500, { offset:-75, easing:'easeout' } );
     34                        j('textarea#whats-new').focus();
     35                }
    2836        }
    2937
  • trunk/bp-themes/bp-default/activity/post-form.php

    r2188 r2276  
    1515        <div id="whats-new-content">
    1616                <div id="whats-new-textarea">
    17                         <textarea name="whats-new" id="whats-new" value="" /></textarea>
     17                        <textarea name="whats-new" id="whats-new" value="" /><?php if ( isset( $_GET['r'] ) ) : ?>@<?php echo esc_attr( $_GET['r'] ) ?> <?php endif; ?></textarea>
    1818                </div>
    1919
  • trunk/bp-themes/bp-default/functions.php

    r2251 r2276  
    33/* Stop the theme from killing WordPress if BuddyPress is not enabled. */
    44if ( !class_exists( 'BP_Core_User' ) )
    5         return false;
     5        return;
    66
    77/* Register the widget columns */
  • trunk/bp-themes/bp-default/members/single/member-header.php

    r2191 r2276  
    99
    1010        <div id="item-buttons">
    11                 <?php if ( function_exists('bp_add_friend_button') ) : ?>
     11                <?php if ( function_exists( 'bp_add_friend_button' ) ) : ?>
    1212                        <?php bp_add_friend_button() ?>
    1313                <?php endif; ?>
    1414
    15                 <?php if ( function_exists('bp_send_message_button') ) : ?>
    16                         <?php bp_send_message_button() ?>
     15                <?php if ( is_user_logged_in() && !bp_is_my_profile() && function_exists( 'bp_send_public_message_link' ) ) : ?>
     16                        <div class="generic-button" id="send-public-message">
     17                                <a href="<?php bp_send_public_message_link() ?>" title="<?php _e( 'Send a public message to this user', 'buddypress' ) ?>"><?php _e( 'Send Public Message', 'buddypress' ) ?></a>
     18                        </div>
     19                <?php endif; ?>
     20
     21                <?php if ( is_user_logged_in() && !bp_is_my_profile() && function_exists( 'bp_send_private_message_link' ) ) : ?>
     22                        <div class="generic-button" id="send-private-message">
     23                                <a href="<?php bp_send_private_message_link() ?>" title="<?php _e( 'Send a private message to this user', 'buddypress' ) ?>"><?php _e( 'Send Private Message', 'buddypress' ) ?></a>
     24                        </div>
    1725                <?php endif; ?>
    1826        </div>
Note: See TracChangeset for help on using the changeset viewer.