Skip to:
Content

BuddyPress.org

Ticket #2566: jeffsayre_2566_repatch.patch

File jeffsayre_2566_repatch.patch, 8.9 KB (added by jeffsayre, 14 years ago)

bp-messages-templatetags.php, bp-activity-templatetags.php, bp-friends-templatetags.php, and member-header.php changes

  • buddypress/bp-themes/bp-default/members/single/member-header.php

     
    2121                <?php endif; ?>
    2222
    2323                <div id="item-buttons">
    24                         <?php if ( function_exists( 'bp_add_friend_button' ) ) : ?>
    25                                 <?php bp_add_friend_button() ?>
    26                         <?php endif; ?>
     24                        <?php if ( function_exists( 'bp_add_friend_button' ) ) :
     25                                list( $button, $potential_friend_id, $friend_status ) = bp_add_friend_button();
     26                       
     27                                if ( $button != false ) { ?>
     28                                        <div class="generic-button friendship-button <?php echo $friend_status ?>" id="friendship-button-<?php echo $potential_friend_id ?>">
     29                                                <?php echo $button ?>
     30                                        </div>
     31                                <?php };
     32                        endif; ?>
    2733
    28                         <?php if ( is_user_logged_in() && !bp_is_my_profile() && function_exists( 'bp_send_public_message_link' ) ) : ?>
    29                                 <div class="generic-button" id="post-mention">
    30                                         <a href="<?php bp_send_public_message_link() ?>" title="<?php _e( 'Mention this user in a new public message, this will send the user a notification to get their attention.', 'buddypress' ) ?>"><?php _e( 'Mention this User', 'buddypress' ) ?></a>
    31                                 </div>
    32                         <?php endif; ?>
    33 
    34                         <?php if ( is_user_logged_in() && !bp_is_my_profile() && function_exists( 'bp_send_private_message_link' ) ) : ?>
    35                                 <div class="generic-button" id="send-private-message">
    36                                         <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>
    37                                 </div>
    38                         <?php endif; ?>
     34                        <?php if ( function_exists( 'bp_send_public_message_link' ) ) :
     35                                $button = bp_send_public_message_link();
     36                       
     37                                if ( $button != false ) { ?>
     38                                        <div class="generic-button" id="post-mention">
     39                                                <a href="<?php echo $button ?>" title="<?php _e( 'Mention this user in a new public message, this will send the user a notification to get their attention.', 'buddypress' ) ?>"><?php _e( 'Mention this User', 'buddypress' ) ?></a>
     40                                        </div>
     41                                <?php };
     42                        endif; ?>
     43                       
     44                        <?php if ( function_exists( 'bp_send_private_message_link' ) ) :
     45                                $button = bp_send_private_message_link();
     46                       
     47                                if ( $button != false ) { ?>
     48                                        <div class="generic-button" id="send-private-message">
     49                                                <a href="<?php echo $button ?>" title="<?php _e( 'Send a private message to this user.', 'buddypress' ) ?>"><?php _e( 'Send Private Message', 'buddypress' ) ?></a>
     50                                        </div>
     51                                <?php };
     52                        endif; ?>
    3953                </div><!-- #item-buttons -->
    4054
    4155                <?php
  • buddypress/bp-friends/bp-friends-templatetags.php

     
    115115}
    116116
    117117function bp_add_friend_button( $potential_friend_id = false, $friend_status = false ) {
    118         echo bp_get_add_friend_button( $potential_friend_id, $friend_status );
    119 }
    120         function bp_get_add_friend_button( $potential_friend_id = false, $friend_status = false ) {
    121                 global $bp, $friends_template;
     118        global $bp, $friends_template;
    122119
    123                 if ( !is_user_logged_in() )
    124                         return false;
     120        if ( !is_user_logged_in() )
     121                return false;
    125122
    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;
     123        if ( !$potential_friend_id && $friends_template->friendship->friend )
     124                $potential_friend_id = $friends_template->friendship->friend->id;
     125        else if ( !$potential_friend_id && !$friends_template->friendship->friend )
     126                $potential_friend_id = $bp->displayed_user->id;
    130127
    131                 if ( $bp->loggedin_user->id == $potential_friend_id )
    132                         return false;
     128        if ( $bp->loggedin_user->id == $potential_friend_id )
     129                return false;
    133130
    134                 if ( empty( $friend_status ) )
    135                         $friend_status = friends_check_friendship_status( $bp->loggedin_user->id, $potential_friend_id );
     131        if ( empty( $friend_status ) )
     132                $friend_status = friends_check_friendship_status( $bp->loggedin_user->id, $potential_friend_id );
    136133
    137                 $button = '<div class="generic-button friendship-button ' . $friend_status . '" id="friendship-button-' . $potential_friend_id . '">';
    138 
    139                 if ( 'pending' == $friend_status )
    140                         $button .= '<a class="requested" href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/">' . __( 'Friendship Requested', 'buddypress' ) . '</a>';
    141                 else if ( 'is_friend' == $friend_status )
    142                         $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>';
    143                 else
    144                         $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>';
    145 
    146                 $button .= '</div>';
    147 
    148                 return apply_filters( 'bp_get_add_friend_button', $button, $potential_friend_id, $friend_status );
     134        if ( 'pending' == $friend_status ) {
     135                $button = '<a class="requested" href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/">' . __( 'Friendship Requested', 'buddypress' ) . '</a>';
     136        } else if ( 'is_friend' == $friend_status ) {
     137                $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>';
     138        } else {
     139                $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>';
    149140        }
     141       
     142        return apply_filters( 'bp_get_add_friend_button', array( $button, $potential_friend_id, $friend_status ) );
    150143
     144}
     145
    151146function bp_get_friend_ids( $user_id = false ) {
    152147        global $bp;
    153148
  • buddypress/bp-activity/bp-activity-templatetags.php

     
    911911        }
    912912
    913913function bp_send_public_message_link() {
    914         echo bp_get_send_public_message_link();
    915 }
    916         function bp_get_send_public_message_link() {
    917                 global $bp;
     914        global $bp;
     915       
     916        if ( is_user_logged_in() && !bp_is_my_profile() ) {
    918917
    919                 return apply_filters( 'bp_get_send_public_message_link', $bp->loggedin_user->domain . $bp->activity->slug . '/?r=' . bp_core_get_username( $bp->displayed_user->user_id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) );
     918                $button = wp_nonce_url( $bp->loggedin_user->domain . $bp->activity->slug . '/?r=' . bp_core_get_username( $bp->displayed_user->user_id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) );
     919
     920                return apply_filters( 'bp_get_send_public_message_link', $button );
    920921        }
     922        return;
     923}
    921924
    922925function bp_activity_post_form_action() {
    923926        echo bp_get_activity_post_form_action();
  • buddypress/bp-messages/bp-messages-templatetags.php

     
    492492}
    493493
    494494function bp_send_private_message_link() {
    495         echo bp_get_send_private_message_link();
    496 }
    497         function bp_get_send_private_message_link() {
    498                 global $bp;
     495        global $bp;
     496       
     497        if ( is_user_logged_in() && !bp_is_my_profile() ) {
     498               
     499                $button = wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/compose/?r=' . bp_core_get_username( $bp->displayed_user->user_id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) );
    499500
    500                 return apply_filters( 'bp_get_send_private_message_link', $bp->loggedin_user->domain . $bp->messages->slug . '/compose/?r=' . bp_core_get_username( $bp->displayed_user->user_id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) );
     501                return apply_filters( 'bp_get_send_private_message_link', $button );
    501502        }
     503        return;
     504}
    502505
    503506function bp_send_message_button() {
    504507        echo bp_get_send_message_button();