Skip to:
Content

BuddyPress.org

Changeset 4845


Ignore:
Timestamp:
07/25/2011 12:11:32 AM (14 years ago)
Author:
boonebgorges
Message:

Global/slug audit in Friends component. See #3325

Location:
trunk/bp-friends
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-friends/bp-friends-actions.php

    r4822 r4845  
    1010
    1111function friends_action_add_friend() {
    12     global $bp;
    13 
    1412    if ( !bp_is_friends_component() || !bp_is_current_action( 'add-friend' ) )
    1513        return false;
    1614
    17     $potential_friend_id = $bp->action_variables[0];
    18 
    19     if ( !is_numeric( $potential_friend_id ) || !isset( $potential_friend_id ) )
     15    if ( !$potential_friend_id = (int)bp_action_variable( 0 ) )
    2016        return false;
    2117
    22     if ( $potential_friend_id == $bp->loggedin_user->id )
     18    if ( $potential_friend_id == bp_loggedin_user_id() )
    2319        return false;
    2420
    25     $friendship_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id );
     21    $friendship_status = BP_Friends_Friendship::check_is_friend( bp_loggedin_user_id(), $potential_friend_id );
    2622
    2723    if ( 'not_friends' == $friendship_status ) {
     
    3026            return false;
    3127
    32         if ( !friends_add_friend( $bp->loggedin_user->id, $potential_friend_id ) ) {
     28        if ( !friends_add_friend( bp_loggedin_user_id(), $potential_friend_id ) ) {
    3329            bp_core_add_message( __( 'Friendship could not be requested.', 'buddypress' ), 'error' );
    3430        } else {
     
    4945
    5046function friends_action_remove_friend() {
    51     global $bp;
    52 
    5347    if ( !bp_is_friends_component() || !bp_is_current_action( 'remove-friend' ) )
    5448        return false;
    5549
    56     $potential_friend_id = $bp->action_variables[0];
    57 
    58     if ( !is_numeric( $potential_friend_id ) || !isset( $potential_friend_id ) )
     50    if ( !$potential_friend_id = (int)bp_action_variable( 0 ) )
    5951        return false;
    6052
    61     if ( $potential_friend_id == $bp->loggedin_user->id )
     53    if ( $potential_friend_id == bp_loggedin_user_id() )
    6254        return false;
    6355
    64     $friendship_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id );
     56    $friendship_status = BP_Friends_Friendship::check_is_friend( bp_loggedin_user_id(), $potential_friend_id );
    6557
    6658    if ( 'is_friend' == $friendship_status ) {
     
    6961            return false;
    7062
    71         if ( !friends_remove_friend( $bp->loggedin_user->id, $potential_friend_id ) ) {
     63        if ( !friends_remove_friend( bp_loggedin_user_id(), $potential_friend_id ) ) {
    7264            bp_core_add_message( __( 'Friendship could not be canceled.', 'buddypress' ), 'error' );
    7365        } else {
  • trunk/bp-friends/bp-friends-screens.php

    r4822 r4845  
    2121
    2222function friends_screen_requests() {
    23     global $bp;
    24 
    25     if ( isset( $bp->action_variables[0] ) && isset( $bp->action_variables[1] ) && 'accept' == $bp->action_variables[0] && is_numeric( $bp->action_variables[1] ) ) {
     23    if ( bp_is_action_variable( 'accept', 0 ) && is_numeric( bp_action_variable( 1 ) ) ) {
    2624        // Check the nonce
    2725        check_admin_referer( 'friends_accept_friendship' );
    2826
    29         if ( friends_accept_friendship( $bp->action_variables[1] ) )
     27        if ( friends_accept_friendship( bp_action_variable( 1 ) ) )
    3028            bp_core_add_message( __( 'Friendship accepted', 'buddypress' ) );
    3129        else
    3230            bp_core_add_message( __( 'Friendship could not be accepted', 'buddypress' ), 'error' );
    3331
    34         bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
     32        bp_core_redirect( bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action() );
    3533
    36     } elseif ( isset( $bp->action_variables[0] ) && isset( $bp->action_variables[1] ) && 'reject' == $bp->action_variables[0] && is_numeric( $bp->action_variables[1] ) ) {
     34    } elseif ( bp_is_action_variable( 'reject', 0 ) && is_numeric( bp_action_variable( 1 ) ) ) {
    3735        // Check the nonce
    3836        check_admin_referer( 'friends_reject_friendship' );
    3937
    40         if ( friends_reject_friendship( $bp->action_variables[1] ) )
     38        if ( friends_reject_friendship( bp_action_variable( 1 ) ) )
    4139            bp_core_add_message( __( 'Friendship rejected', 'buddypress' ) );
    4240        else
    4341            bp_core_add_message( __( 'Friendship could not be rejected', 'buddypress' ), 'error' );
    4442
    45         bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
     43        bp_core_redirect( bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action() );
    4644    }
    4745
     
    4947
    5048    if ( isset( $_GET['new'] ) )
    51         bp_core_delete_notifications_by_type( $bp->loggedin_user->id, $bp->friends->id, 'friendship_request' );
     49        bp_core_delete_notifications_by_type( bp_loggedin_user_id(), 'friends', 'friendship_request' );
    5250
    5351    bp_core_load_template( apply_filters( 'friends_template_requests', 'members/single/home' ) );
  • trunk/bp-friends/bp-friends-template.php

    r4822 r4845  
    5151    }
    5252
     53/**
     54 * Displays Friends header tabs
     55 *
     56 * @package BuddyPress
     57 * @todo Deprecate?
     58 */
    5359function bp_friends_header_tabs() {
    5460    global $bp; ?>
    5561
    56     <li<?php if ( !isset($bp->action_variables[0]) || 'recently-active' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . bp_get_friends_slug() ?>/my-friends/recently-active"><?php _e( 'Recently Active', 'buddypress' ) ?></a></li>
    57     <li<?php if ( 'newest' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . bp_get_friends_slug() ?>/my-friends/newest"><?php _e( 'Newest', 'buddypress' ) ?></a></li>
    58     <li<?php if ( 'alphabetically' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . bp_get_friends_slug() ?>/my-friends/alphabetically"><?php _e( 'Alphabetically', 'buddypress' ) ?></a></li>
     62    <li<?php if ( !bp_action_variable( 0 ) || bp_is_action_variable( 'recently-active', 0 ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . bp_get_friends_slug() ?>/my-friends/recently-active"><?php _e( 'Recently Active', 'buddypress' ) ?></a></li>
     63    <li<?php if ( bp_is_action_variable( 'newest', 0 ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . bp_get_friends_slug() ?>/my-friends/newest"><?php _e( 'Newest', 'buddypress' ) ?></a></li>
     64    <li<?php if ( bp_is_action_variable( 'alphabetically', 0 ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . bp_get_friends_slug() ?>/my-friends/alphabetically"><?php _e( 'Alphabetically', 'buddypress' ) ?></a></li>
    5965
    6066<?php
     
    6268}
    6369
     70/**
     71 * Filters the title for the Friends component
     72 *
     73 * @package BuddyPress
     74 * @todo Deprecate?
     75 */
    6476function bp_friends_filter_title() {
    65     global $bp;
    66 
    67     $current_filter = $bp->action_variables[0];
    68 
     77    $current_filter = bp_action_variable( 0 );
     78   
    6979    switch ( $current_filter ) {
    7080        case 'recently-active': default:
Note: See TracChangeset for help on using the changeset viewer.