Changeset 1021 for trunk/bp-friends.php
- Timestamp:
- 02/06/2009 03:07:48 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-friends.php
r1017 r1021 29 29 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 30 30 31 $sql[] = "CREATE TABLE ". $bp['friends']['table_name'] ."(31 $sql[] = "CREATE TABLE {$bp->friends->table_name} ( 32 32 id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, 33 33 initiator_user_id int(11) NOT NULL, … … 57 57 global $bp, $wpdb; 58 58 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; 67 65 } 68 66 add_action( 'wp', 'friends_setup_globals', 1 ); … … 74 72 if ( is_site_admin() ) { 75 73 /* 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 ) ) 77 75 friends_install(); 78 76 } … … 90 88 91 89 /* 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 . '/'; 96 94 97 95 /* 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 ) { 103 100 if ( bp_is_home() ) { 104 $bp ['bp_options_title'] = __('My Friends', 'buddypress');101 $bp->bp_options_title = __( 'My Friends', 'buddypress' ); 105 102 } 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; 108 105 } 109 106 } … … 118 115 119 116 // 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' ); 121 118 122 119 do_action( 'friends_screen_my_friends' ); … … 128 125 global $bp; 129 126 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' ) ); 134 131 } 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' ); 136 133 } 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' ) ); 143 140 } 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' ); 145 142 } 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 ); 147 144 } 148 145 … … 259 256 case 'friendship_accepted': 260 257 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 ); 262 259 } else { 263 260 $user_fullname = bp_core_global_user_fullname( $item_id ); … … 269 266 case 'friendship_request': 270 267 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 ); 272 269 } else { 273 270 $user_fullname = bp_core_global_user_fullname( $item_id ); 274 271 $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 ); 276 273 } 277 274 break; … … 286 283 $friend_count = get_usermeta( $user_id, 'total_friend_count'); 287 284 288 if ( $friend_count == '')285 if ( empty( $friend_count ) ) 289 286 return false; 290 287 … … 406 403 407 404 if ( !$user_id ) 408 $user_id = $bp ['loggedin_userid'];405 $user_id = $bp->loggedin_user->id; 409 406 410 407 $friend_ids = friends_get_alphabetically( $user_id ); … … 520 517 521 518 // 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 ) ); 523 520 524 521 do_action( 'friends_friendship_deleted', $friendship_id, $initiator_userid, $friend_userid );
Note: See TracChangeset
for help on using the changeset viewer.