Skip to:
Content

BuddyPress.org


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.2/bp-friends.php

    • Property svn:eol-style set to native
    r3297 r3111  
    2727               ) {$charset_collate};";
    2828
    29     require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
     29    require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
    3030    dbDelta($sql);
    3131
     
    3434
    3535function friends_setup_globals() {
    36     global $bp;
     36    global $bp, $wpdb;
    3737
    3838    /* For internal identification */
    3939    $bp->friends->id = 'friends';
    4040
     41    $bp->friends->table_name = $wpdb->base_prefix . 'bp_friends';
     42    $bp->friends->format_notification_function = 'friends_format_notifications';
    4143    $bp->friends->slug = BP_FRIENDS_SLUG;
    42 
    43     $bp->friends->table_name = $bp->table_prefix . 'bp_friends';
    44 
    45     $bp->friends->format_notification_function = 'friends_format_notifications';
    4644
    4745    /* Register this in the active components array */
     
    5351
    5452function friends_check_installed() {
    55     global $bp;
    56 
    57     if ( !is_super_admin() )
     53    global $wpdb, $bp;
     54
     55    if ( !is_site_admin() )
    5856        return false;
    5957
     
    158156                <td></td>
    159157                <td><?php _e( 'A member sends you a friendship request', 'buddypress' ) ?></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>
     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>
    162160            </tr>
    163161            <tr>
    164162                <td></td>
    165163                <td><?php _e( 'A member accepts your friendship request', 'buddypress' ) ?></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>
     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>
    168166            </tr>
    169167
     
    283281        'item_id' => false,
    284282        'secondary_item_id' => false,
    285         'recorded_time' => bp_core_current_time(),
     283        'recorded_time' => gmdate( "Y-m-d H:i:s" ),
    286284        'hide_sitewide' => false
    287285    );
     
    364362    $friendship->is_confirmed = 0;
    365363    $friendship->is_limited = 0;
    366     $friendship->date_created = bp_core_current_time();
     364    $friendship->date_created = time();
    367365
    368366    if ( $force_accept )
     
    418416        friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id );
    419417
    420         // Remove the friend request notice
     418        /* Remove the friend request notice */
    421419        bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' );
    422420
    423         // Add a friend accepted notice for the initiating user
     421        /* Add a friend accepted notice for the initiating user */
    424422        bp_core_add_notification( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_accepted' );
    425423
     
    427425        $friend_link = bp_core_get_userlink( $friendship->friend_user_id );
    428426
    429         // Record in activity streams for the initiator
     427        /* Record in activity streams for the initiator */
    430428        friends_record_activity( array(
    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
     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
    436433        ) );
    437434
    438         // Record in activity streams for the friend
     435        /* Record in activity streams for the friend */
    439436        friends_record_activity( array(
    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
     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 */
    446442        ) );
    447443
    448         // Send the email notification
     444        /* Send the email notification */
    449445        require_once( BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php' );
    450446        friends_notification_accepted_request( $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
     
    492488
    493489    if ( !$count = wp_cache_get( 'bp_total_friend_count_' . $user_id, 'bp' ) ) {
    494         $count = get_user_meta( $user_id, 'total_friend_count', true );
     490        $count = get_usermeta( $user_id, 'total_friend_count' );
    495491        if ( empty( $count ) ) $count = 0;
    496492        wp_cache_set( 'bp_total_friend_count_' . $user_id, $count, 'bp' );
     
    595591function friends_update_friend_totals( $initiator_user_id, $friend_user_id, $status = 'add' ) {
    596592    if ( 'add' == $status ) {
    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 );
     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 );
    599595    } else {
    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 );
     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 );
    602598    }
    603599}
     
    607603
    608604    /* Remove usermeta */
    609     delete_user_meta( $user_id, 'total_friend_count' );
     605    delete_usermeta( $user_id, 'total_friend_count' );
    610606
    611607    /* Remove friendship requests FROM user */
Note: See TracChangeset for help on using the changeset viewer.