Skip to:
Content

BuddyPress.org


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tags/1.2.6/bp-friends.php

    • Property svn:eol-style deleted
    r3111 r3297  
    2727               ) {$charset_collate};";
    2828
    29     require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
     29    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    3030    dbDelta($sql);
    3131
     
    3434
    3535function friends_setup_globals() {
    36     global $bp, $wpdb;
     36    global $bp;
    3737
    3838    /* For internal identification */
    3939    $bp->friends->id = 'friends';
    4040
    41     $bp->friends->table_name = $wpdb->base_prefix . 'bp_friends';
     41    $bp->friends->slug = BP_FRIENDS_SLUG;
     42
     43    $bp->friends->table_name = $bp->table_prefix . 'bp_friends';
     44
    4245    $bp->friends->format_notification_function = 'friends_format_notifications';
    43     $bp->friends->slug = BP_FRIENDS_SLUG;
    4446
    4547    /* Register this in the active components array */
     
    5153
    5254function friends_check_installed() {
    53     global $wpdb, $bp;
    54 
    55     if ( !is_site_admin() )
     55    global $bp;
     56
     57    if ( !is_super_admin() )
    5658        return false;
    5759
     
    156158                <td></td>
    157159                <td><?php _e( 'A member sends you a friendship request', 'buddypress' ) ?></td>
    158                 <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_request]" value="yes" <?php if ( !get_usermeta( $current_user->id,'notification_friends_friendship_request') || 'yes' == get_usermeta( $current_user->id,'notification_friends_friendship_request') ) { ?>checked="checked" <?php } ?>/></td>
    159                 <td class="no"><input type="radio" name="notifications[notification_friends_friendship_request]" value="no" <?php if ( get_usermeta( $current_user->id,'notification_friends_friendship_request') == 'no' ) { ?>checked="checked" <?php } ?>/></td>
     160                <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_request]" value="yes" <?php if ( !get_user_meta( $current_user->id, 'notification_friends_friendship_request', true ) || 'yes' == get_user_meta( $current_user->id, 'notification_friends_friendship_request', true ) ) { ?>checked="checked" <?php } ?>/></td>
     161                <td class="no"><input type="radio" name="notifications[notification_friends_friendship_request]" value="no" <?php if ( get_user_meta( $current_user->id, 'notification_friends_friendship_request', true ) == 'no' ) { ?>checked="checked" <?php } ?>/></td>
    160162            </tr>
    161163            <tr>
    162164                <td></td>
    163165                <td><?php _e( 'A member accepts your friendship request', 'buddypress' ) ?></td>
    164                 <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="yes" <?php if ( !get_usermeta( $current_user->id,'notification_friends_friendship_accepted') || 'yes' == get_usermeta( $current_user->id,'notification_friends_friendship_accepted') ) { ?>checked="checked" <?php } ?>/></td>
    165                 <td class="no"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id,'notification_friends_friendship_accepted') ) { ?>checked="checked" <?php } ?>/></td>
     166                <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="yes" <?php if ( !get_user_meta( $current_user->id, 'notification_friends_friendship_accepted', true ) || 'yes' == get_user_meta( $current_user->id, 'notification_friends_friendship_accepted', true ) ) { ?>checked="checked" <?php } ?>/></td>
     167                <td class="no"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="no" <?php if ( 'no' == get_user_meta( $current_user->id, 'notification_friends_friendship_accepted', true ) ) { ?>checked="checked" <?php } ?>/></td>
    166168            </tr>
    167169
     
    281283        'item_id' => false,
    282284        'secondary_item_id' => false,
    283         'recorded_time' => gmdate( "Y-m-d H:i:s" ),
     285        'recorded_time' => bp_core_current_time(),
    284286        'hide_sitewide' => false
    285287    );
     
    362364    $friendship->is_confirmed = 0;
    363365    $friendship->is_limited = 0;
    364     $friendship->date_created = time();
     366    $friendship->date_created = bp_core_current_time();
    365367
    366368    if ( $force_accept )
     
    416418        friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id );
    417419
    418         /* Remove the friend request notice */
     420        // Remove the friend request notice
    419421        bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' );
    420422
    421         /* Add a friend accepted notice for the initiating user */
     423        // Add a friend accepted notice for the initiating user
    422424        bp_core_add_notification( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_accepted' );
    423425
     
    425427        $friend_link = bp_core_get_userlink( $friendship->friend_user_id );
    426428
    427         /* Record in activity streams for the initiator */
     429        // Record in activity streams for the initiator
    428430        friends_record_activity( array(
    429             'user_id' => $friendship->initiator_user_id,
    430             'type' => 'friendship_created',
    431             'action' => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%s and %s are now friends', 'buddypress' ), $initiator_link, $friend_link ), &$friendship ),
    432             'item_id' => $friendship_id
     431            'user_id'           => $friendship->initiator_user_id,
     432            'type'              => 'friendship_created',
     433            'action'            => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%s and %s are now friends', 'buddypress' ), $initiator_link, $friend_link ), &$friendship ),
     434            'item_id'           => $friendship_id,
     435            'secondary_item_id' => $friendship->friend_user_id
    433436        ) );
    434437
    435         /* Record in activity streams for the friend */
     438        // Record in activity streams for the friend
    436439        friends_record_activity( array(
    437             'user_id' => $friendship->friend_user_id,
    438             'type' => 'friendship_created',
    439             'action' => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%s and %s are now friends', 'buddypress' ), $friend_link, $initiator_link ), &$friendship ),
    440             'item_id' => $friendship_id,
    441             'hide_sitewide' => true /* We've already got the first entry site wide */
     440            'user_id'           => $friendship->friend_user_id,
     441            'type'              => 'friendship_created',
     442            'action'            => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%s and %s are now friends', 'buddypress' ), $friend_link, $initiator_link ), &$friendship ),
     443            'item_id'           => $friendship_id,
     444            'secondary_item_id' => $friendship->initiator_user_id,
     445            'hide_sitewide'     => true // We've already got the first entry site wide
    442446        ) );
    443447
    444         /* Send the email notification */
     448        // Send the email notification
    445449        require_once( BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php' );
    446450        friends_notification_accepted_request( $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
     
    488492
    489493    if ( !$count = wp_cache_get( 'bp_total_friend_count_' . $user_id, 'bp' ) ) {
    490         $count = get_usermeta( $user_id, 'total_friend_count' );
     494        $count = get_user_meta( $user_id, 'total_friend_count', true );
    491495        if ( empty( $count ) ) $count = 0;
    492496        wp_cache_set( 'bp_total_friend_count_' . $user_id, $count, 'bp' );
     
    591595function friends_update_friend_totals( $initiator_user_id, $friend_user_id, $status = 'add' ) {
    592596    if ( 'add' == $status ) {
    593         update_usermeta( $initiator_user_id, 'total_friend_count', (int)get_usermeta( $initiator_user_id, 'total_friend_count' ) + 1 );
    594         update_usermeta( $friend_user_id, 'total_friend_count', (int)get_usermeta( $friend_user_id, 'total_friend_count' ) + 1 );
     597        update_user_meta( $initiator_user_id, 'total_friend_count', (int)get_user_meta( $initiator_user_id, 'total_friend_count', true ) + 1 );
     598        update_user_meta( $friend_user_id, 'total_friend_count', (int)get_user_meta( $friend_user_id, 'total_friend_count', true ) + 1 );
    595599    } else {
    596         update_usermeta( $initiator_user_id, 'total_friend_count', (int)get_usermeta( $initiator_user_id, 'total_friend_count' ) - 1 );
    597         update_usermeta( $friend_user_id, 'total_friend_count', (int)get_usermeta( $friend_user_id, 'total_friend_count' ) - 1 );
     600        update_user_meta( $initiator_user_id, 'total_friend_count', (int)get_user_meta( $initiator_user_id, 'total_friend_count', true ) - 1 );
     601        update_user_meta( $friend_user_id, 'total_friend_count', (int)get_user_meta( $friend_user_id, 'total_friend_count', true ) - 1 );
    598602    }
    599603}
     
    603607
    604608    /* Remove usermeta */
    605     delete_usermeta( $user_id, 'total_friend_count' );
     609    delete_user_meta( $user_id, 'total_friend_count' );
    606610
    607611    /* Remove friendship requests FROM user */
Note: See TracChangeset for help on using the changeset viewer.