Skip to:
Content

BuddyPress.org

Changeset 5712


Ignore:
Timestamp:
02/11/2012 04:42:04 AM (13 years ago)
Author:
johnjamesjacoby
Message:

Remove unneeded globals and clean up some code in Friends component. See #3989.

Location:
trunk/bp-friends
Files:
7 edited

Legend:

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

    r4961 r5712  
    11<?php
     2
    23/**
     4 * BuddyPress Friends Actions
     5 *
    36 * Action functions are exactly the same as screen functions, however they do not
    47 * have a template screen associated with them. Usually they will send the user
    58 * back to the default screen after execution.
     9 *
     10 * @package BuddyPress
     11 * @subpackage FriendsActions
    612 */
    713
  • trunk/bp-friends/bp-friends-activity.php

    r5437 r5712  
    11<?php
     2
    23/**
    3  * These functions handle the recording, deleting and formatting of activity and
    4  * notifications for the user and for this specific component.
     4 * BuddyPress Friends Activity Functions
     5 *
     6 * These functions handle the recording, deleting and formatting of activity
     7 * for the user and for this specific component.
     8 *
     9 * @package BuddyPress
     10 * @subpackage FriendsActivity
    511 */
    612
     
    3743
    3844    if ( bp_is_active( 'activity' ) ) {
    39         extract( (array)$args );
     45        extract( (array) $args );
    4046        bp_activity_delete_by_item_id( array( 'item_id' => $item_id, 'component' => $bp->friends->id, 'type' => $type, 'user_id' => $user_id ) );
    4147    }
     
    7177 */
    7278function friends_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
    73     global $bp;
    7479
    7580    switch ( $action ) {
     
    110115            'link' => $link,
    111116            'text' => $text
    112         ), (int)$total_items );
     117        ), (int) $total_items );
    113118    }
    114119
  • trunk/bp-friends/bp-friends-cache.php

    r5302 r5712  
    11<?php
     2
    23/**
     4 * BuddyPress Friends Caching
     5 *
    36 * Caching functions handle the clearing of cached objects and pages on specific
    47 * actions throughout BuddyPress.
     8 *
     9 * @package BuddyPress
     10 * @subpackage FriendsCaching
    511 */
     12
    613
    714// Exit if accessed directly
  • trunk/bp-friends/bp-friends-functions.php

    r5676 r5712  
    11<?php
    2 /********************************************************************************
    3  * Business Functions
     2
     3/**
     4 * BuddyPress Friends Functions
    45 *
    5  * Business functions are where all the magic happens in BuddyPress. They will
     6 * Functions are where all the magic happens in BuddyPress. They will
    67 * handle the actual saving or manipulation of information. Usually they will
    78 * hand off to a database class for data access, then return
    89 * true or false on success or failure.
     10 *
     11 * @package BuddyPress
     12 * @subpackage FriendsFunctions
    913 */
    1014
     
    5357
    5458function friends_remove_friend( $initiator_userid, $friend_userid ) {
    55     global $bp;
    5659
    5760    $friendship_id = BP_Friends_Friendship::get_friendship_id( $initiator_userid, $friend_userid );
     
    138141
    139142function friends_check_friendship( $user_id, $possible_friend_id ) {
    140     global $bp;
    141143
    142144    if ( 'is_friend' == BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id ) )
     
    152154
    153155function friends_get_total_friend_count( $user_id = 0 ) {
    154     global $bp;
    155 
    156     if ( !$user_id )
     156
     157    if ( empty( $user_id ) )
    157158        $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
    158159
     
    182183}
    183184
    184 function friends_get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false, $filter = false ) {
     185function friends_get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false ) {
    185186    return BP_Friends_Friendship::get_friend_user_ids( $user_id, $friend_requests_only, $assoc_arr );
    186187}
     
    293294
    294295function friends_search_users( $search_terms, $user_id, $pag_num = 0, $pag_page = 0 ) {
    295     global $bp;
    296296
    297297    $user_ids = BP_Friends_Friendship::search_users( $search_terms, $user_id, $pag_num, $pag_page );
    298298
    299     if ( !$user_ids )
     299    if ( empty( $user_ids ) )
    300300        return false;
    301301
     302    $users = array();
    302303    for ( $i = 0, $count = count( $user_ids ); $i < $count; ++$i )
    303304        $users[] = new BP_Core_User( $user_ids[$i] );
     
    312313
    313314function friends_update_friend_totals( $initiator_user_id, $friend_user_id, $status = 'add' ) {
    314     global $bp;
    315315
    316316    if ( 'add' == $status ) {
     
    328328    do_action( 'friends_before_remove_data', $user_id );
    329329
    330     BP_Friends_Friendship::delete_all_for_user($user_id);
     330    BP_Friends_Friendship::delete_all_for_user( $user_id );
    331331
    332332    // Remove usermeta
  • trunk/bp-friends/bp-friends-notifications.php

    r5416 r5712  
    11<?php
     2
     3/**
     4 * BuddyPress Friends Activity Functions
     5 *
     6 * These functions handle the recording, deleting and formatting of activity
     7 * for the user and for this specific component.
     8 *
     9 * @package BuddyPress
     10 * @subpackage FriendsActivity
     11 */
     12
    213// Exit if accessed directly
    314if ( !defined( 'ABSPATH' ) ) exit;
    415
    516function friends_notification_new_request( $friendship_id, $initiator_id, $friend_id ) {
    6     global $bp;
    717
    818    $initiator_name = bp_core_get_user_displayname( $initiator_id );
     
    1121        return false;
    1222
    13     $ud = get_userdata( $friend_id );
    14     $initiator_ud = get_userdata( $initiator_id );
    15 
     23    $ud                = get_userdata( $friend_id );
    1624    $all_requests_link = bp_core_get_user_domain( $friend_id ) . bp_get_friends_slug() . '/requests/';
    17     $settings_slug    = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
    18     $settings_link    = trailingslashit( bp_core_get_user_domain( $friend_id ) .  $settings_slug . '/notifications' );
    19     $initiator_link   = bp_core_get_user_domain( $initiator_id );
     25    $settings_slug     = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
     26    $settings_link     = trailingslashit( bp_core_get_user_domain( $friend_id ) .  $settings_slug . '/notifications' );
     27    $initiator_link    = bp_core_get_user_domain( $initiator_id );
    2028
    2129    // Set up and send the message
     
    4755
    4856function friends_notification_accepted_request( $friendship_id, $initiator_id, $friend_id ) {
    49     global $bp;
    50 
    51     $friendship = new BP_Friends_Friendship( $friendship_id, false, false );
    5257
    5358    $friend_name = bp_core_get_user_displayname( $friend_id );
    5459
    55     if ( 'no' == bp_get_user_meta( (int)$initiator_id, 'notification_friends_friendship_accepted', true ) )
     60    if ( 'no' == bp_get_user_meta( (int) $initiator_id, 'notification_friends_friendship_accepted', true ) )
    5661        return false;
    5762
    58     $ud = get_userdata( $initiator_id );
    59 
     63    $ud            = get_userdata( $initiator_id );
    6064    $friend_link   = bp_core_get_user_domain( $friend_id );
    6165    $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
  • trunk/bp-friends/bp-friends-screens.php

    r5416 r5712  
    11<?php
     2
    23/**
     4 * BuddyPress Friends Screen Functions
     5 *
    36 * Screen functions are the controllers of BuddyPress. They will execute when their
    47 * specific URL is caught. They will first save or manipulate data using business
    58 * functions, then pass on the user to a template file.
     9 *
     10 * @package BuddyPress
     11 * @subpackage FriendsScreens
    612 */
    713
     
    5359
    5460function friends_screen_notification_settings() {
    55     global $bp;
    5661
    5762    if ( !$send_requests = bp_get_user_meta( bp_displayed_user_id(), 'notification_friends_friendship_request', true ) )
     
    5964
    6065    if ( !$accept_requests = bp_get_user_meta( bp_displayed_user_id(), 'notification_friends_friendship_accepted', true ) )
    61         $accept_requests = 'yes';
    62 ?>
     66        $accept_requests = 'yes'; ?>
    6367
    6468    <table class="notification-settings" id="friends-notification-settings">
  • trunk/bp-friends/bp-friends-template.php

    r5704 r5712  
    11<?php
     2
     3/**
     4 * BuddyPress Friends Template Functions
     5 *
     6 * @package BuddyPress
     7 * @subpackage FriendsTemplate
     8 */
     9
    210// Exit if accessed directly
    311if ( !defined( 'ABSPATH' ) ) exit;
     
    5866 */
    5967function bp_friends_header_tabs() {
    60     global $bp; ?>
     68?>
    6169
    6270    <li<?php if ( !bp_action_variable( 0 ) || bp_is_action_variable( 'recently-active', 0 ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_displayed_user_domain() . bp_get_friends_slug() . '/my-friends/recently-active' ) ?>"><?php _e( 'Recently Active', 'buddypress' ) ?></a></li>
     
    9199
    92100function bp_friends_random_friends() {
    93     global $bp;
    94101
    95102    if ( !$friend_ids = wp_cache_get( 'friends_friend_ids_' . bp_displayed_user_id(), 'bp' ) ) {
     
    123130
    124131        <?php } ?>
     132
    125133        <div class="clear"></div>
    126134    </div>
     135
    127136<?php
    128137}
     
    138147 */
    139148function bp_friends_random_members( $total_members = 5 ) {
    140     global $bp;
    141149
    142150    if ( !$user_ids = wp_cache_get( 'friends_random_users', 'bp' ) ) {
     
    196204
    197205function bp_friend_search_form() {
    198     global $friends_template, $bp;
    199206
    200207    $action = bp_displayed_user_domain() . bp_get_friends_slug() . '/my-friends/search/';
    201     $label = __( 'Filter Friends', 'buddypress' ); ?>
     208    $label  = __( 'Filter Friends', 'buddypress' ); ?>
    202209
    203210        <form action="<?php echo $action ?>" id="friend-search-form" method="post">
     
    228235
    229236function bp_member_total_friend_count() {
    230     global $members_template;
    231 
    232237    echo bp_get_member_total_friend_count();
    233238}
     
    257262     * Returns the ID of the potential friend
    258263     *
    259      * @global object $bp
    260264     * @global object $friends_template
    261265     * @param int $user_id
     
    263267     */
    264268    function bp_get_potential_friend_id( $user_id = 0 ) {
    265         global $bp, $friends_template;
     269        global $friends_template;
    266270
    267271        if ( empty( $user_id ) && isset( $friends_template->friendship->friend ) )
     
    278282 * Returns - 'is_friend', 'not_friends', 'pending'
    279283 *
    280  * @global object $bp
    281284 * @param int $potential_friend_id
    282285 * @return string
    283286 */
    284287function bp_is_friend( $user_id = 0 ) {
    285     global $bp;
    286288
    287289    if ( !is_user_logged_in() )
     
    301303}
    302304    function bp_get_add_friend_button( $potential_friend_id = 0, $friend_status = false ) {
    303         global $bp, $friends_template;
    304305
    305306        if ( empty( $potential_friend_id ) )
     
    367368
    368369function bp_get_friend_ids( $user_id = 0 ) {
    369     global $bp;
    370 
    371     if ( !$user_id )
     370
     371    if ( empty( $user_id ) )
    372372        $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
    373373
     
    380380}
    381381function bp_get_friendship_requests() {
    382     global $bp;
    383 
    384382    return apply_filters( 'bp_get_friendship_requests', implode( ',', (array) friends_get_friendship_request_user_ids( bp_loggedin_user_id() ) ) );
    385383}
     
    389387}
    390388    function bp_get_friend_friendship_id() {
    391         global $members_template, $bp;
     389        global $members_template;
    392390
    393391        if ( !$friendship_id = wp_cache_get( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id() ) ) {
     
    403401}
    404402    function bp_get_friend_accept_request_link() {
    405         global $members_template, $bp;
     403        global $members_template;
    406404
    407405        if ( !$friendship_id = wp_cache_get( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id() ) ) {
     
    417415}
    418416    function bp_get_friend_reject_request_link() {
    419         global $members_template, $bp;
     417        global $members_template;
    420418
    421419        if ( !$friendship_id = wp_cache_get( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id() ) ) {
     
    439437}
    440438    function bp_friend_get_total_requests_count( $user_id = 0 ) {
    441         global $bp;
    442 
    443439        if ( empty( $user_id ) )
    444440            $user_id = bp_loggedin_user_id();
Note: See TracChangeset for help on using the changeset viewer.