Skip to:
Content

BuddyPress.org

Changeset 1021 for trunk/bp-friends.php


Ignore:
Timestamp:
02/06/2009 03:07:48 AM (17 years ago)
Author:
apeatling
Message:

Converted $bp as an array to $bp as an object. See this post for more info: http://buddypress.org/forums/topic.php?id=1125

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-friends.php

    r1017 r1021  
    2929                $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    3030               
    31         $sql[] = "CREATE TABLE ". $bp['friends']['table_name'] ." (
     31        $sql[] = "CREATE TABLE {$bp->friends->table_name} (
    3232                                id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    3333                                initiator_user_id int(11) NOT NULL,
     
    5757        global $bp, $wpdb;
    5858       
    59         $bp['friends'] = array(
    60                 'table_name' => $wpdb->base_prefix . 'bp_friends',
    61                 'image_base' => site_url( MUPLUGINDIR . '/bp-friends/images' ),
    62                 'format_activity_function' => 'friends_format_activity',
    63                 'slug'           => BP_FRIENDS_SLUG
    64         );
    65 
    66         $bp['version_numbers'][$bp['friends']['slug']] = BP_FRIENDS_VERSION;
     59        $bp->friends->table_name = $wpdb->base_prefix . 'bp_friends';
     60        $bp->friends->image_base = site_url( MUPLUGINDIR . '/bp-friends/images' );
     61        $bp->friends->format_activity_function = 'friends_format_activity';
     62        $bp->friends->slug = BP_FRIENDS_SLUG;
     63
     64        $bp->version_numbers->friends = BP_FRIENDS_VERSION;
    6765}
    6866add_action( 'wp', 'friends_setup_globals', 1 );
     
    7472        if ( is_site_admin() ) {
    7573                /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
    76                 if ( ( $wpdb->get_var("SHOW TABLES LIKE '%" . $bp['friends']['table_name'] . "%'") == false ) || ( get_site_option('bp-friends-db-version') < BP_FRIENDS_DB_VERSION )  )
     74                if ( ( $wpdb->get_var( "SHOW TABLES LIKE '%{$bp->friends->table_name}%'") == false ) || ( get_site_option('bp-friends-db-version') < BP_FRIENDS_DB_VERSION )  )
    7775                        friends_install();
    7876        }
     
    9088       
    9189        /* Add 'Friends' to the main navigation */
    92         bp_core_add_nav_item( __('Friends', 'buddypress'), $bp['friends']['slug'] );
    93         bp_core_add_nav_default( $bp['friends']['slug'], 'friends_screen_my_friends', 'my-friends' );
    94        
    95         $friends_link = $bp['loggedin_domain'] . $bp['friends']['slug'] . '/';
     90        bp_core_add_nav_item( __('Friends', 'buddypress'), $bp->friends->slug );
     91        bp_core_add_nav_default( $bp->friends->slug, 'friends_screen_my_friends', 'my-friends' );
     92       
     93        $friends_link = $bp->loggedin_user->domain . $bp->friends->slug . '/';
    9694       
    9795        /* Add the subnav items to the friends nav item */
    98         bp_core_add_subnav_item( $bp['friends']['slug'], 'my-friends', __('My Friends', 'buddypress'), $friends_link, 'friends_screen_my_friends', 'friends-my-friends' );
    99         bp_core_add_subnav_item( $bp['friends']['slug'], 'requests', __('Requests', 'buddypress'), $friends_link, 'friends_screen_requests', false, bp_is_home() );
    100         //bp_core_add_subnav_item( $bp['friends']['slug'], 'invite-friend', __('Invite Friends', 'buddypress'), $friends_link, 'friends_screen_invite_friends' );
    101        
    102         if ( $bp['current_component'] == $bp['friends']['slug'] ) {
     96        bp_core_add_subnav_item( $bp->friends->slug, 'my-friends', __( 'My Friends', 'buddypress' ), $friends_link, 'friends_screen_my_friends', 'friends-my-friends' );
     97        bp_core_add_subnav_item( $bp->friends->slug, 'requests', __( 'Requests', 'buddypress' ), $friends_link, 'friends_screen_requests', false, bp_is_home() );
     98       
     99        if ( $bp->current_component == $bp->friends->slug ) {
    103100                if ( bp_is_home() ) {
    104                         $bp['bp_options_title'] = __('My Friends', 'buddypress');
     101                        $bp->bp_options_title = __( 'My Friends', 'buddypress' );
    105102                } else {
    106                         $bp['bp_options_avatar'] = bp_core_get_avatar( $bp['current_userid'], 1 );
    107                         $bp['bp_options_title'] = $bp['current_fullname'];
     103                        $bp->bp_options_avatar = bp_core_get_avatar( $bp->displayed_user->id, 1 );
     104                        $bp->bp_options_title = $bp->displayed_user->fullname;
    108105                }
    109106        }
     
    118115
    119116        // Delete any friendship acceptance notifications for the user when viewing a profile
    120         bp_core_delete_notifications_for_user_by_type( $bp['loggedin_userid'], 'friends', 'friendship_accepted' );
     117        bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'friends', 'friendship_accepted' );
    121118
    122119        do_action( 'friends_screen_my_friends' );
     
    128125        global $bp;
    129126                       
    130         if ( isset($bp['action_variables']) && $bp['action_variables'][0] == 'accept' && is_numeric($bp['action_variables'][1]) ) {
    131                
    132                 if ( friends_accept_friendship( $bp['action_variables'][1] ) ) {
    133                         bp_core_add_message( __('Friendship accepted', 'buddypress') );
     127        if ( isset($bp->action_variables) && $bp->action_variables[0] == 'accept' && is_numeric($bp->action_variables[1]) ) {
     128               
     129                if ( friends_accept_friendship( $bp->action_variables[1] ) ) {
     130                        bp_core_add_message( __( 'Friendship accepted', 'buddypress' ) );
    134131                } else {
    135                         bp_core_add_message( __('Friendship could not be accepted', 'buddypress'), 'error' );
     132                        bp_core_add_message( __( 'Friendship could not be accepted', 'buddypress' ), 'error' );
    136133                }
    137                 bp_core_redirect( $bp['loggedin_domain'] . $bp['current_component'] . '/' . $bp['current_action'] );
    138                
    139         } else if ( isset($bp['action_variables']) && $bp['action_variables'][0] == 'reject' && is_numeric($bp['action_variables'][1]) ) {
    140                
    141                 if ( friends_reject_friendship( $bp['action_variables'][1] ) ) {
    142                         bp_core_add_message( __('Friendship rejected', 'buddypress') );
     134                bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
     135               
     136        } else if ( isset($bp->action_variables) && $bp->action_variables[0] == 'reject' && is_numeric($bp->action_variables[1]) ) {
     137               
     138                if ( friends_reject_friendship( $bp->action_variables[1] ) ) {
     139                        bp_core_add_message( __( 'Friendship rejected', 'buddypress' ) );
    143140                } else {
    144                         bp_core_add_message( __('Friendship could not be rejected', 'buddypress'), 'error' );
     141                        bp_core_add_message( __( 'Friendship could not be rejected', 'buddypress' ), 'error' );
    145142                }       
    146                 bp_core_redirect( $bp['loggedin_domain'] . $bp['current_component'] . '/' . $bp['current_action'] );
     143                bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
    147144        }
    148145       
     
    259256                case 'friendship_accepted':
    260257                        if ( (int)$total_items > 1 ) {
    261                                 return apply_filters( 'bp_friends_multiple_friendship_accepted_notification', '<a href="' . $bp['loggedin_domain'] . $bp['friends']['slug'] . '/my-friends/newest" title="' . __( 'My Friends', 'buddypress' ) . '">' . sprintf( __('%d friends accepted your friendship requests'), (int)$total_items ) . '</a>', (int)$total_items );         
     258                                return apply_filters( 'bp_friends_multiple_friendship_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/my-friends/newest" title="' . __( 'My Friends', 'buddypress' ) . '">' . sprintf( __('%d friends accepted your friendship requests'), (int)$total_items ) . '</a>', (int)$total_items );         
    262259                        } else {
    263260                                $user_fullname = bp_core_global_user_fullname( $item_id );
     
    269266                case 'friendship_request':
    270267                        if ( (int)$total_items > 1 ) {
    271                                 return apply_filters( 'bp_friends_multiple_friendship_request_notification', '<a href="' . $bp['loggedin_domain'] . $bp['friends']['slug'] . '/requests" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have %d pending friendship requests'), (int)$total_items ) . '</a>', $total_items );           
     268                                return apply_filters( 'bp_friends_multiple_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have %d pending friendship requests'), (int)$total_items ) . '</a>', $total_items );           
    272269                        } else {
    273270                                $user_fullname = bp_core_global_user_fullname( $item_id );
    274271                                $user_url = bp_core_get_userurl( $item_id );
    275                                 return apply_filters( 'bp_friends_single_friendship_request_notification', '<a href="' . $bp['loggedin_domain'] . $bp['friends']['slug'] . '/requests" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have a friendship request from %s'), $user_fullname ) . '</a>', $user_fullname );
     272                                return apply_filters( 'bp_friends_single_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have a friendship request from %s'), $user_fullname ) . '</a>', $user_fullname );
    276273                        }       
    277274                break;
     
    286283        $friend_count = get_usermeta( $user_id, 'total_friend_count');
    287284
    288         if ( $friend_count == '' )
     285        if ( empty( $friend_count ) )
    289286                return false;
    290287       
     
    406403       
    407404        if ( !$user_id )
    408                 $user_id = $bp['loggedin_userid'];
     405                $user_id = $bp->loggedin_user->id;
    409406       
    410407        $friend_ids = friends_get_alphabetically( $user_id );
     
    520517       
    521518        // Remove the activity stream items
    522         friends_delete_activity( array( 'item_id' => $friendship_id, 'component_name' => 'friends', 'component_action' => 'friendship_accepted', 'user_id' => $bp['current_userid'] ) );
     519        friends_delete_activity( array( 'item_id' => $friendship_id, 'component_name' => 'friends', 'component_action' => 'friendship_accepted', 'user_id' => $bp->displayed_user->id ) );
    523520       
    524521        do_action( 'friends_friendship_deleted', $friendship_id, $initiator_userid, $friend_userid );
Note: See TracChangeset for help on using the changeset viewer.