Skip to:
Content

BuddyPress.org

Changeset 3757


Ignore:
Timestamp:
01/20/2011 10:53:49 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Second pass at huge component refactor.

Move component files out of root directory and append '-loader' to the file names. Split those files up into smaller pieces.

Abstract 'settings' component out of 'core' and into its own component for future extension, including new template files in bp-default.

Append '-sa' to bbPress bridge file for 'Stand Alone' compatibility, to make room for bbPress plugin compatibility layer.

Various bug fixes through-out all components. Various code clean-up and documentation through-out all components.

Still more refactoring to do.

Location:
trunk
Files:
30 added
11 deleted
12 edited
7 moved

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-functions.php

    r3751 r3757  
    11<?php
     2
     3/**
     4 * BuddyPress Activity Functions
     5 *
     6 * Functions for the Activity Streams component
     7 *
     8 * @package BuddyPress
     9 * @subpackage Activity Core
     10 */
     11
     12/**
     13 * @todo Figure out if this is still needed
     14 *
     15 * @global obj $bp
     16 */
     17function bp_activity_directory_activity_setup() {
     18    global $bp;
     19
     20    if ( bp_is_activity_component() && empty( $bp->current_action ) ) {
     21        $bp->is_directory = true;
     22
     23        do_action( 'bp_activity_directory_activity_setup' );
     24
     25        bp_core_load_template( apply_filters( 'bp_activity_directory_activity_setup', 'activity/index' ) );
     26    }
     27}
     28add_action( 'wp', 'bp_activity_directory_activity_setup', 2 );
     29
     30/**
     31 * Searches through the content of an activity item to locate usernames, designated by an @ sign
     32 *
     33 * @package BuddyPress Activity
     34 * @since 1.3
     35 *
     36 * @param $content The content of the activity, usually found in $activity->content
     37 * @return array $usernames Array of the found usernames that match existing users
     38 */
     39function bp_activity_find_mentions( $content ) {
     40    $pattern = '/[@]+([A-Za-z0-9-_\.]+)/';
     41    preg_match_all( $pattern, $content, $usernames );
     42
     43    // Make sure there's only one instance of each username
     44    if ( !$usernames = array_unique( $usernames[1] ) )
     45        return false;
     46
     47    return $usernames;
     48}
     49
     50/**
     51 * Reduces new mention count for mentioned users when activity items are deleted
     52 *
     53 * @package BuddyPress Activity
     54 * @since 1.3
     55 *
     56 * @param $activity_id The unique id for the activity item
     57 */
     58function bp_activity_reduce_mention_count( $activity_id ) {
     59    $activity = new BP_Activity_Activity( $activity_id );
     60
     61    if ( $usernames = bp_activity_find_mentions( strip_tags( $activity->content ) ) ) {
     62        if ( ! function_exists( 'username_exists' ) )
     63            require_once( ABSPATH . WPINC . '/registration.php' );
     64
     65        foreach( (array)$usernames as $username ) {
     66            if ( !$user_id = username_exists( $username ) )
     67                continue;
     68
     69            // Decrease the number of new @ mentions for the user
     70            $new_mention_count = (int)get_user_meta( $user_id, 'bp_new_mention_count', true );
     71            update_user_meta( $user_id, 'bp_new_mention_count', $new_mention_count - 1 );
     72        }
     73    }
     74}
     75add_action( 'bp_activity_action_delete_activity', 'bp_activity_reduce_mention_count' );
     76
     77/**
     78 * Formats notifications related to activity
     79 *
     80 * @package BuddyPress Activity
     81 * @param $action The type of activity item. Just 'new_at_mention' for now
     82 * @param $item_id The activity id
     83 * @param $secondary_item_id In the case of at-mentions, this is the mentioner's id
     84 * @param $total_items The total number of notifications to format
     85 */
     86function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
     87    global $bp;
     88
     89    switch ( $action ) {
     90        case 'new_at_mention':
     91            $activity_id      = $item_id;
     92            $poster_user_id   = $secondary_item_id;
     93            $at_mention_link  = $bp->loggedin_user->domain . $bp->activity->slug . '/mentions/';
     94            $at_mention_title = sprintf( __( '@%s Mentions', 'buddypress' ), $bp->loggedin_user->userdata->user_nicename );
     95
     96            if ( (int)$total_items > 1 ) {
     97                return apply_filters( 'bp_activity_multiple_at_mentions_notification', '<a href="' . $at_mention_link . '" title="' . $at_mention_title . '">' . sprintf( __( 'You have %1$d new activity mentions', 'buddypress' ), (int)$total_items ) . '</a>', $at_mention_link, $total_items, $activity_id, $poster_user_id );
     98            } else {
     99                $user_fullname = bp_core_get_user_displayname( $poster_user_id );
     100
     101                return apply_filters( 'bp_activity_single_at_mentions_notification', '<a href="' . $at_mention_link . '" title="' . $at_mention_title . '">' . sprintf( __( '%1$s mentioned you in an activity update', 'buddypress' ), $user_fullname ) . '</a>', $at_mention_link, $total_items, $activity_id, $poster_user_id );
     102            }
     103        break;
     104    }
     105
     106    do_action( 'activity_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
     107
     108    return false;
     109}
     110
     111/** Actions *******************************************************************/
     112
     113/**
     114 * Sets the current action for a given activity stream location
     115 *
     116 * @global obj $bp
     117 * @param str $component_id
     118 * @param str $key
     119 * @param str $value
     120 * @return bool False on error, True on success
     121 */
     122function bp_activity_set_action( $component_id, $key, $value ) {
     123    global $bp;
     124
     125    // Return false if any of the above values are not set
     126    if ( empty( $component_id ) || empty( $key ) || empty( $value ) )
     127        return false;
     128
     129    // Set activity action
     130    $bp->activity->actions->{$component_id}->{$key} = apply_filters( 'bp_activity_set_action', array(
     131        'key'   => $key,
     132        'value' => $value
     133    ), $component_id, $key, $value );
     134
     135    return true;
     136}
     137
     138/**
     139 * Retreives the current action from a component and key
     140 *
     141 * @global obj $bp
     142 * @param str $component_id
     143 * @param str $key
     144 * @return mixed False on error, action on success
     145 */
     146function bp_activity_get_action( $component_id, $key ) {
     147    global $bp;
     148
     149    // Return false if any of the above values are not set
     150    if ( empty( $component_id ) || empty( $key ) )
     151        return false;
     152
     153    return apply_filters( 'bp_activity_get_action', $bp->activity->actions->{$component_id}->{$key}, $component_id, $key );
     154}
     155
     156/** Favorites *****************************************************************/
     157
     158/**
     159 * Get a users favorite activity stream items
     160 *
     161 * @global obj $bp
     162 * @param int $user_id
     163 * @return array Array of users favorite activity stream ID's
     164 */
     165function bp_activity_get_user_favorites( $user_id = 0 ) {
     166    global $bp;
     167
     168    // Fallback to logged in user if no user_id is passed
     169    if ( empty( $user_id ) )
     170        $user_id = $bp->displayed_user->id;
     171
     172    // Get favorites for user
     173    $favs          = get_user_meta( $user_id, 'bp_favorite_activities', true );
     174    $existing_favs = bp_activity_get_specific( array( 'activity_ids' => $favs ) );
     175
     176    foreach( (array)$existing_favs['activities'] as $fav )
     177        $new_favs[] = $fav->id;
     178
     179    $new_favs = array_unique( (array)$new_favs );
     180    update_user_meta( $user_id, 'bp_favorite_activities', $new_favs );
     181
     182    return apply_filters( 'bp_activity_get_user_favorites', $new_favs );
     183}
     184
     185/**
     186 * Add an activity stream item as a favorite for a user
     187 *
     188 * @global obj $bp
     189 * @param int $activity_id
     190 * @param int $user_id
     191 * @return bool
     192 */
     193function bp_activity_add_user_favorite( $activity_id, $user_id = 0 ) {
     194    global $bp;
     195
     196    // Favorite activity stream items are for logged in users only
     197    if ( !is_user_logged_in() )
     198        return false;
     199
     200    // Fallback to logged in user if no user_id is passed
     201    if ( empty( $user_id ) )
     202        $user_id = $bp->loggedin_user->id;
     203
     204    // Update the user's personal favorites
     205    $my_favs   = get_user_meta( $bp->loggedin_user->id, 'bp_favorite_activities', true );
     206    $my_favs[] = $activity_id;
     207
     208    // Update the total number of users who have favorited this activity
     209    $fav_count = bp_activity_get_meta( $activity_id, 'favorite_count' );
     210    $fav_count = !empty( $fav_count ) ? (int)$fav_count + 1 : 1;
     211
     212    // Update user meta
     213    update_user_meta( $bp->loggedin_user->id, 'bp_favorite_activities', $my_favs );
     214
     215    // Update activity meta counts
     216    if ( true === bp_activity_update_meta( $activity_id, 'favorite_count', $fav_count ) ) {
     217
     218        // Execute additional code
     219        do_action( 'bp_activity_add_user_favorite', $activity_id, $user_id );
     220
     221        // Success
     222        return true;
     223
     224    // Saving meta was unsuccessful for an unknown reason
     225    } else {
     226        // Execute additional code
     227        do_action( 'bp_activity_add_user_favorite_fail', $activity_id, $user_id );
     228
     229        return false;
     230    }
     231}
     232
     233function bp_activity_remove_user_favorite( $activity_id, $user_id = 0 ) {
     234    global $bp;
     235
     236    // Favorite activity stream items are for logged in users only
     237    if ( !is_user_logged_in() )
     238        return false;
     239
     240    // Fallback to logged in user if no user_id is passed
     241    if ( empty( $user_id ) )
     242        $user_id = $bp->loggedin_user->id;
     243
     244    // Remove the fav from the user's favs
     245    $my_favs = get_user_meta( $user_id, 'bp_favorite_activities', true );
     246    $my_favs = array_flip( (array) $my_favs );
     247    unset( $my_favs[$activity_id] );
     248    $my_favs = array_unique( array_flip( $my_favs ) );
     249
     250    // Update the total number of users who have favorited this activity
     251    if ( $fav_count = bp_activity_get_meta( $activity_id, 'favorite_count' ) ) {
     252
     253        // Deduct from total favorites
     254        if ( bp_activity_update_meta( $activity_id, 'favorite_count', (int)$fav_count - 1 ) ) {
     255
     256            // Update users favorites
     257            if ( update_user_meta( $user_id, 'bp_favorite_activities', $my_favs ) ) {
     258
     259                // Execute additional code
     260                do_action( 'bp_activity_remove_user_favorite', $activity_id, $user_id );
     261
     262                // Success
     263                return true;
     264
     265            // Error updating
     266            } else {
     267                return false;
     268            }
     269
     270        // Error updating favorite count
     271        } else {
     272            return false;
     273        }
     274
     275    // Error getting favorite count
     276    } else {
     277        return false;
     278    }
     279}
     280
     281/**
     282 * Check if activity exists by scanning content
     283 *
     284 * @param str $content
     285 * @return bool
     286 */
     287function bp_activity_check_exists_by_content( $content ) {
     288    return apply_filters( 'bp_activity_check_exists_by_content', BP_Activity_Activity::check_exists_by_content( $content ) );
     289}
     290
     291/**
     292 * Retreive the last time activity was updated
     293 *
     294 * @return str
     295 */
     296function bp_activity_get_last_updated() {
     297    return apply_filters( 'bp_activity_get_last_updated', BP_Activity_Activity::get_last_updated() );
     298}
     299
     300/**
     301 * Retreive the number of favorite activity stream items a user has
     302 *
     303 * @global obj $bp
     304 * @param int $user_id
     305 * @return int
     306 */
     307function bp_activity_total_favorites_for_user( $user_id = 0 ) {
     308    global $bp;
     309
     310    // Fallback on displayed user, and then logged in user
     311    if ( empty( $user_id ) )
     312        $user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
     313
     314    return BP_Activity_Activity::total_favorite_count( $user_id );
     315}
     316
     317/** Meta **********************************************************************/
     318
     319/**
     320 * Delete a meta entry from the DB for an activity stream item
     321 *
     322 * @global DB $wpdb
     323 * @global obj $bp
     324 * @param int $activity_id
     325 * @param str $meta_key
     326 * @param str $meta_value
     327 * @return bool
     328 */
     329function bp_activity_delete_meta( $activity_id, $meta_key = '', $meta_value = '' ) {
     330    global $wpdb, $bp;
     331
     332    // Return false if any of the above values are not set
     333    if ( !is_numeric( $activity_id ) )
     334        return false;
     335
     336    // Sanitize key
     337    $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
     338
     339    if ( is_array( $meta_value ) || is_object( $meta_value ) )
     340        $meta_value = serialize( $meta_value );
     341
     342    // Trim off whitespace
     343    $meta_value = trim( $meta_value );
     344
     345    // Delete all for activity_id
     346    if ( empty( $meta_key ) )
     347        $retval = $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_meta} WHERE activity_id = %d", $activity_id ) );
     348
     349    // Delete only when all match
     350    else if ( $meta_value )
     351        $retval = $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_meta} WHERE activity_id = %d AND meta_key = %s AND meta_value = %s", $activity_id, $meta_key, $meta_value ) );
     352
     353    // Delete only when activity_id and meta_key match
     354    else
     355        $retval = $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_meta} WHERE activity_id = %d AND meta_key = %s", $activity_id, $meta_key ) );
     356
     357    // Delete cache entry
     358    wp_cache_delete( 'bp_activity_meta_' . $meta_key . '_' . $activity_id, 'bp' );
     359
     360    // Success
     361    if ( !is_wp_error( $retval ) )
     362        return true;
     363
     364    // Fail
     365    else
     366        return false;
     367}
     368
     369/**
     370 * Get activity meta
     371 *
     372 * @global DB $wpdb
     373 * @global obj $bp
     374 * @param int $activity_id
     375 * @param str $meta_key
     376 * @return bool
     377 */
     378function bp_activity_get_meta( $activity_id = 0, $meta_key = '' ) {
     379    global $wpdb, $bp;
     380
     381    // Make sure activity_id is valid
     382    if ( empty( $activity_id ) || !is_numeric( $activity_id ) )
     383        return false;
     384
     385    // We have a key to look for
     386    if ( !empty( $meta_key ) ) {
     387
     388        // Sanitize key
     389        $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
     390
     391        // Check cache
     392        if ( !$metas = wp_cache_get( 'bp_activity_meta_' . $meta_key . '_' . $activity_id, 'bp' ) ) {
     393
     394            // No cache so hit the DB
     395            $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM {$bp->activity->table_name_meta} WHERE activity_id = %d AND meta_key = %s", $activity_id, $meta_key ) );
     396
     397            // Set cache
     398            wp_cache_set( 'bp_activity_meta_' . $meta_key . '_' . $activity_id, $metas, 'bp' );
     399        }
     400
     401    // No key so get all for activity_id
     402    } else {
     403        $metas = $wpdb->get_col( $wpdb->prepare( "SELECT meta_value FROM {$bp->activity->table_name_meta} WHERE activity_id = %d", $activity_id ) );
     404    }
     405
     406    // No result so return false
     407    if ( empty( $metas ) )
     408        return false;
     409
     410    // Maybe, just maybe... unserialize
     411    $metas = array_map( 'maybe_unserialize', (array)$metas );
     412
     413    // Return first item in array if only 1, else return all metas found
     414    $retval = ( 1 == count( $metas ) ? $metas[0] : $metas );
     415
     416    // Filter result before returning
     417    return apply_filters( 'bp_activity_get_meta', $retval, $activity_id, $meta_key );
     418}
     419
     420/**
     421 * Update activity meta
     422 *
     423 * @global DB $wpdb
     424 * @global obj $bp
     425 * @param int $activity_id
     426 * @param str $meta_key
     427 * @param str $meta_value
     428 * @return bool
     429 */
     430function bp_activity_update_meta( $activity_id, $meta_key, $meta_value ) {
     431    global $wpdb, $bp;
     432
     433    // Make sure activity_id is valid
     434    if ( !is_numeric( $activity_id ) )
     435        return false;
     436
     437    // Sanitize key
     438    $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
     439
     440    // Sanitize value
     441    if ( is_string( $meta_value ) )
     442        $meta_value = stripslashes( $wpdb->escape( $meta_value ) );
     443
     444    // Maybe, just maybe... serialize
     445    $meta_value = maybe_serialize( $meta_value );
     446
     447    // If value is empty, delete the meta key
     448    if ( empty( $meta_value ) )
     449        return bp_activity_delete_meta( $activity_id, $meta_key );
     450
     451    // See if meta key exists for activity_id
     452    $cur = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name_meta} WHERE activity_id = %d AND meta_key = %s", $activity_id, $meta_key ) );
     453
     454    // Meta key does not exist so INSERT
     455    if ( empty( $cur ) )
     456        $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->activity->table_name_meta} ( activity_id, meta_key, meta_value ) VALUES ( %d, %s, %s )", $activity_id, $meta_key, $meta_value ) );
     457
     458    // Meta key exists, so UPDATE
     459    else if ( $cur->meta_value != $meta_value )
     460        $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name_meta} SET meta_value = %s WHERE activity_id = %d AND meta_key = %s", $meta_value, $activity_id, $meta_key ) );
     461
     462    // Weirdness, so return false
     463    else
     464        return false;
     465
     466    // Set cache
     467    wp_cache_set( 'bp_activity_meta_' . $meta_key . '_' . $activity_id, $meta_value, 'bp' );
     468
     469    // Victory is ours!
     470    return true;
     471}
     472
     473/** Clean up ******************************************************************/
     474
     475/**
     476 * Completely remove
     477 * @param int $user_id
     478 */
     479function bp_activity_remove_all_user_data( $user_id = 0 ) {
     480
     481    // Do not delete user data unless a logged in user says so
     482    if ( empty( $user_id ) || !is_user_logged_in() )
     483        return false;
     484
     485    // Clear the user's activity from the sitewide stream and clear their activity tables
     486    bp_activity_delete( array( 'user_id' => $user_id ) );
     487
     488    // Remove any usermeta
     489    delete_user_meta( $user_id, 'bp_latest_update' );
     490    delete_user_meta( $user_id, 'bp_favorite_activities' );
     491
     492    // Execute additional code
     493    do_action( 'bp_activity_remove_data', $user_id ); // Deprecated! Do not use!
     494
     495    // Use this going forward
     496    do_action( 'bp_activity_remove_all_user_data', $user_id );
     497}
     498add_action( 'wpmu_delete_user',  'bp_activity_remove_all_user_data' );
     499add_action( 'delete_user',       'bp_activity_remove_all_user_data' );
     500add_action( 'bp_make_spam_user', 'bp_activity_remove_all_user_data' );
     501
     502/**
     503 * Register the activity stream actions for updates
     504 *
     505 * @global obj $bp
     506 */
     507function updates_register_activity_actions() {
     508    global $bp;
     509
     510    bp_activity_set_action( $bp->activity->id, 'activity_update', __( 'Posted an update', 'buddypress' ) );
     511
     512    do_action( 'updates_register_activity_actions' );
     513}
     514add_action( 'bp_register_activity_actions', 'updates_register_activity_actions' );
    2515
    3516/*******************************************************************************
  • trunk/bp-activity/bp-activity-notifications.php

    r3665 r3757  
    2424            continue;
    2525
    26         bp_core_add_notification( $activity_id, $receiver_user_id, 'activity', 'new_at_mention', $poster_user_id );
     26        bp_users_add_notification( $activity_id, $receiver_user_id, 'activity', 'new_at_mention', $poster_user_id );
    2727
    2828        $subject = '';
  • trunk/bp-activity/bp-activity-screens.php

    r3751 r3757  
    7171    global $bp;
    7272
    73     bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->activity->id, 'new_at_mention' );
     73    bp_users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->activity->id, 'new_at_mention' );
    7474}
    7575add_action( 'bp_activity_screen_my_activity',               'bp_activity_remove_screen_notifications' );
  • trunk/bp-core/bp-core-adminbar.php

    r3743 r3757  
    189189    _e( 'Notifications', 'buddypress' );
    190190
    191     if ( $notifications = bp_core_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?>
     191    if ( $notifications = bp_users_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?>
    192192        <span><?php echo count( $notifications ) ?></span>
    193193    <?php
  • trunk/bp-core/bp-core-avatars.php

    r3742 r3757  
    11<?php
    2 /*
    3  Based on contributions from: Beau Lebens - http://www.dentedreality.com.au/
    4  Modified for BuddyPress by: Andy Peatling - http://apeatling.wordpress.com/
    5 */
     2/**
     3 * BuddyPress Avatars
     4 *
     5 * Based on contributions from: Beau Lebens - http://www.dentedreality.com.au/
     6 * Modified for BuddyPress by: Andy Peatling - http://apeatling.wordpress.com/
     7 */
    68
    79/***
     
    3436    if ( !defined( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE' ) ) {
    3537        if ( !isset( $bp->site_options['fileupload_maxk'] ) )
    36             define( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', 5120000 ); /* 5mb */
     38            define( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', 5120000 ); // 5mb
    3739        else
    3840            define( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', $bp->site_options['fileupload_maxk'] * 1024 );
     
    4547        define( 'BP_AVATAR_DEFAULT_THUMB', BP_PLUGIN_URL . '/bp-core/images/mystery-man-50.jpg' );
    4648}
    47 add_action( 'bp_init', 'bp_core_set_avatar_constants', 8 );
     49add_action( 'bp_init', 'bp_core_set_avatar_constants', 3 );
    4850
    4951/**
     
    164166     * or thumbnail image.
    165167     */
    166     $avatar_size = ( 'full' == $type ) ? '-bpfull' : '-bpthumb';
    167     $legacy_user_avatar_name = ( 'full' == $type ) ? '-avatar2' : '-avatar1';
     168    $avatar_size              = ( 'full' == $type ) ? '-bpfull' : '-bpthumb';
     169    $legacy_user_avatar_name  = ( 'full' == $type ) ? '-avatar2' : '-avatar1';
    168170    $legacy_group_avatar_name = ( 'full' == $type ) ? '-groupavatar-full' : '-groupavatar-thumb';
    169171
     
    263265
    264266        // Filter gravatar vars
    265         $email      = apply_filters( 'bp_core_gravatar_email', $email, $item_id, $object );
    266         $gravatar   = apply_filters( 'bp_gravatar_url', $host ) . md5( strtolower( $email ) ) . '?d=' . $default_grav . '&amp;s=' . $grav_size;
     267        $email    = apply_filters( 'bp_core_gravatar_email', $email, $item_id, $object );
     268        $gravatar = apply_filters( 'bp_gravatar_url', $host ) . md5( strtolower( $email ) ) . '?d=' . $default_grav . '&amp;s=' . $grav_size;
    267269
    268270    } else {
     
    281283
    282284    $defaults = array(
    283         'item_id' => false,
    284         'object' => 'user', // user OR group OR blog OR custom type (if you use filters)
     285        'item_id'    => false,
     286        'object'     => 'user', // user OR group OR blog OR custom type (if you use filters)
    285287        'avatar_dir' => false
    286288    );
     
    372374    }
    373375
    374     /* Filter the upload location */
     376    // Filter the upload location
    375377    add_filter( 'upload_dir', $upload_dir_filter, 10, 0 );
    376378
    377379    $bp->avatar_admin->original = wp_handle_upload( $file['file'], array( 'action'=> 'bp_avatar_upload' ) );
    378380
    379     /* Move the file to the correct upload location. */
     381    // Move the file to the correct upload location.
    380382    if ( !empty( $bp->avatar_admin->original['error'] ) ) {
    381383        bp_core_add_message( sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $bp->avatar_admin->original['error'] ), 'error' );
     
    383385    }
    384386
    385     /* Get image size */
     387    // Get image size
    386388    $size = @getimagesize( $bp->avatar_admin->original['file'] );
    387389
    388     /* Check image size and shrink if too large */
     390    // Check image size and shrink if too large
    389391    if ( $size[0] > BP_AVATAR_ORIGINAL_MAX_WIDTH ) {
    390392        $thumb = wp_create_thumbnail( $bp->avatar_admin->original['file'], BP_AVATAR_ORIGINAL_MAX_WIDTH );
    391393
    392         /* Check for thumbnail creation errors */
     394        // Check for thumbnail creation errors
    393395        if ( is_wp_error( $thumb ) ) {
    394396            bp_core_add_message( sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $thumb->get_error_message() ), 'error' );
     
    396398        }
    397399
    398         /* Thumbnail is good so proceed */
     400        // Thumbnail is good so proceed
    399401        $bp->avatar_admin->resized = $thumb;
    400402    }
    401403
    402     /* We only want to handle one image after resize. */
     404    // We only want to handle one image after resize.
    403405    if ( empty( $bp->avatar_admin->resized ) )
    404406        $bp->avatar_admin->image->dir = str_replace( BP_AVATAR_UPLOAD_PATH, '', $bp->avatar_admin->original['file'] );
     
    414416    }
    415417
    416     /* Set the url value for the image */
     418    // Set the url value for the image
    417419    $bp->avatar_admin->image->url = BP_AVATAR_URL . $bp->avatar_admin->image->dir;
    418420
     
    424426
    425427    $defaults = array(
    426         'object' => 'user',
    427         'avatar_dir' => 'avatars',
    428         'item_id' => false,
     428        'object'        => 'user',
     429        'avatar_dir'    => 'avatars',
     430        'item_id'       => false,
    429431        'original_file' => false,
    430         'crop_w' => BP_AVATAR_FULL_WIDTH,
    431         'crop_h' => BP_AVATAR_FULL_HEIGHT,
    432         'crop_x' => 0,
    433         'crop_y' => 0
     432        'crop_w'        => BP_AVATAR_FULL_WIDTH,
     433        'crop_h'        => BP_AVATAR_FULL_HEIGHT,
     434        'crop_x'        => 0,
     435        'crop_y'        => 0
    434436    );
    435437
     
    464466    require_once( ABSPATH . '/wp-admin/includes/file.php' );
    465467
    466     /* Delete the existing avatar files for the object */
     468    // Delete the existing avatar files for the object
    467469    bp_core_delete_existing_avatar( array( 'object' => $object, 'avatar_path' => $avatar_folder_dir ) );
    468470
    469     /* Make sure we at least have a width and height for cropping */
     471    // Make sure we at least have a width and height for cropping
    470472    if ( !(int)$crop_w )
    471473        $crop_w = BP_AVATAR_FULL_WIDTH;
     
    474476        $crop_h = BP_AVATAR_FULL_HEIGHT;
    475477
    476     /* Set the full and thumb filenames */
    477     $full_filename = wp_hash( $original_file . time() ) . '-bpfull.jpg';
     478    // Set the full and thumb filenames
     479    $full_filename  = wp_hash( $original_file . time() ) . '-bpfull.jpg';
    478480    $thumb_filename = wp_hash( $original_file . time() ) . '-bpthumb.jpg';
    479481
    480     /* Crop the image */
    481     $full_cropped = wp_crop_image( $original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, BP_AVATAR_FULL_WIDTH, BP_AVATAR_FULL_HEIGHT, false, $avatar_folder_dir . '/' . $full_filename );
     482    // Crop the image
     483    $full_cropped  = wp_crop_image( $original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, BP_AVATAR_FULL_WIDTH, BP_AVATAR_FULL_HEIGHT, false, $avatar_folder_dir . '/' . $full_filename );
    482484    $thumb_cropped = wp_crop_image( $original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, BP_AVATAR_THUMB_WIDTH, BP_AVATAR_THUMB_HEIGHT, false, $avatar_folder_dir . '/' . $thumb_filename );
    483485
    484     /* Remove the original */
     486    // Remove the original
    485487    @unlink( $original_file );
    486488
  • trunk/bp-core/bp-core-deprecated.php

    r3748 r3757  
    66 * @package BuddyPress
    77 * @subpackage Core
    8  *
     8 * @deprecated Since 1.3
    99 */
     10
     11/** Sign up *******************************************************************/
     12
     13function bp_core_screen_signup() {
     14    _deprecated_function( 'bp_core_screen_signup', '1.3', 'bp_users_screen_signup' );
     15    bp_users_screen_signup();
     16}
     17
     18function bp_core_screen_activation() {
     19    _deprecated_function( 'bp_core_screen_activation', '1.3', 'bp_users_screen_activation' );
     20    bp_users_screen_activation();
     21}
     22
     23function bp_core_flush_illegal_names() {
     24    _deprecated_function( 'bp_core_flush_illegal_names', '1.3', 'bp_users_flush_illegal_names' );
     25    bp_users_flush_illegal_names();
     26}
     27
     28function bp_core_illegal_names( $value = '', $oldvalue = '' ) {
     29    _deprecated_function( 'bp_core_illegal_names', '1.3', 'bp_users_illegal_names' );
     30    bp_users_illegal_names( $value, $oldvalue );
     31}
     32
     33function bp_core_validate_user_signup( $user_name, $user_email ) {
     34    _deprecated_function( 'bp_core_validate_user_signup', '1.3', 'bp_users_validate_user_signup' );
     35    bp_users_validate_user_signup( $user_name, $user_email );
     36}
     37
     38function bp_core_validate_blog_signup( $blog_url, $blog_title ) {
     39    _deprecated_function( 'bp_core_validate_blog_signup', '1.3', 'bp_users_validate_blog_signup' );
     40    bp_users_validate_blog_signup( $blog_url, $blog_title );
     41}
     42
     43function bp_core_signup_user( $user_login, $user_password, $user_email, $usermeta ) {
     44    _deprecated_function( 'bp_core_signup_user', '1.3', 'bp_users_signup_user' );
     45    bp_users_signup_user( $user_login, $user_password, $user_email, $usermeta );
     46}
     47
     48function bp_core_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) {
     49    _deprecated_function( 'bp_core_signup_blog', '1.3', 'bp_users_signup_blog' );
     50    bp_users_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta );
     51}
     52
     53function bp_core_activate_signup( $key ) {
     54    _deprecated_function( 'bp_core_activate_signup', '1.3', 'bp_users_activate_signup' );
     55    bp_users_activate_signup( $key );
     56}
     57
     58function bp_core_new_user_activity( $user ) {
     59    _deprecated_function( 'bp_core_new_user_activity', '1.3', 'bp_users_new_user_activity' );
     60    bp_users_new_user_activity( $user );
     61}
     62
     63function bp_core_map_user_registration( $user_id ) {
     64    _deprecated_function( 'bp_core_map_user_registration', '1.3', 'bp_users_map_user_registration' );
     65    bp_users_map_user_registration( $user_id );
     66}
     67
     68function bp_core_signup_avatar_upload_dir() {
     69    _deprecated_function( 'bp_core_signup_avatar_upload_dir', '1.3', 'bp_users_signup_avatar_upload_dir' );
     70    bp_users_signup_avatar_upload_dir();
     71}
     72
     73function bp_core_signup_send_validation_email( $user_id, $user_email, $key ) {
     74    _deprecated_function( 'bp_core_signup_send_validation_email', '1.3', 'bp_users_signup_send_validation_email' );
     75    bp_users_signup_send_validation_email( $user_id, $user_email, $key );
     76}
     77
     78function bp_core_signup_disable_inactive( $auth_obj, $username ) {
     79    _deprecated_function( 'bp_core_signup_disable_inactive', '1.3', 'bp_users_signup_disable_inactive' );
     80    bp_users_signup_disable_inactive( $auth_obj, $username );
     81}
     82
     83function bp_core_wpsignup_redirect() {
     84    _deprecated_function( 'bp_core_wpsignup_redirect', '1.3', 'bp_users_wpsignup_redirect' );
     85    bp_users_wpsignup_redirect();
     86}
     87
     88/** Settings ******************************************************************/
     89
     90function bp_core_add_settings_nav() {
     91    _deprecated_function( 'bp_core_add_settings_nav', '1.3', 'bp_settings_add_settings_nav' );
     92    bp_settings_add_settings_nav();
     93}
     94
     95function bp_core_can_edit_settings() {
     96    _deprecated_function( 'bp_core_can_edit_settings', '1.3', 'bp_users_can_edit_settings' );
     97    bp_users_can_edit_settings();
     98}
     99
     100function bp_core_screen_general_settings() {
     101    _deprecated_function( 'bp_core_screen_general_settings', '1.3', 'bp_settings_screen_general_settings' );
     102    bp_settings_screen_general_settings();
     103}
     104
     105function bp_core_screen_general_settings_title() {
     106    _deprecated_function( 'bp_core_screen_general_settings_title', '1.3', 'bp_settings_screen_general_settings' );
     107}
     108
     109function bp_core_screen_general_settings_content() {
     110    _deprecated_function( 'bp_core_screen_general_settings_content', '1.3', 'bp_settings_screen_general_settings' );
     111}
     112
     113function bp_core_screen_notification_settings() {
     114    _deprecated_function( 'bp_core_screen_notification_settings', '1.3', 'bp_settings_screen_notification_settings' );
     115    bp_settings_screen_notification_settings();
     116}
     117
     118function bp_core_screen_notification_settings_title() {
     119    _deprecated_function( 'bp_core_screen_notification_settings_title', '1.3', 'bp_settings_screen_notification_settings' );
     120}
     121
     122function bp_core_screen_notification_settings_content() {
     123    _deprecated_function( 'bp_core_screen_notification_settings_content', '1.3', 'bp_settings_screen_notification_settings' );
     124}
     125
     126function bp_core_screen_delete_account() {
     127    _deprecated_function( 'bp_core_screen_delete_account', '1.3', 'bp_settings_screen_delete_account' );
     128    bp_settings_screen_delete_account();
     129}
     130
     131function bp_core_screen_delete_account_title() {
     132    _deprecated_function( 'bp_core_screen_delete_account_title', '1.3', 'bp_settings_screen_delete_account' );
     133}
     134
     135function bp_core_screen_delete_account_content() {
     136    _deprecated_function( 'bp_core_screen_delete_account_content', '1.3', 'bp_settings_screen_delete_account' );
     137}
     138
     139/** Notifications *************************************************************/
     140
     141function bp_core_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id = false, $date_notified = false ) {
     142    _deprecated_function( 'bp_core_add_notification', '1.3', 'bp_users_add_notification' );
     143    bp_users_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id, $date_notified );
     144}
     145
     146function bp_core_delete_notification( $id ) {
     147    _deprecated_function( 'bp_core_delete_notification', '1.3', 'bp_users_delete_notification' );
     148    bp_users_delete_notification( $id );
     149}
     150
     151function bp_core_get_notification( $id ) {
     152    _deprecated_function( 'bp_core_get_notification', '1.3', 'bp_users_get_notification' );
     153    bp_users_get_notification( $id );
     154}
     155
     156function bp_core_get_notifications_for_user( $user_id ) {
     157    _deprecated_function( 'bp_core_get_notifications_for_user', '1.3', 'bp_users_get_notifications_for_user' );
     158    bp_users_get_notifications_for_user( $user_id );
     159}
     160
     161function bp_core_delete_notifications_by_type( $user_id, $component_name, $component_action ) {
     162    _deprecated_function( 'bp_core_delete_notifications_by_type', '1.3', 'bp_users_delete_notifications_by_type' );
     163    bp_users_delete_notifications_by_type( $user_id, $component_name, $component_action );
     164}
     165
     166function bp_core_delete_notifications_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false ) {
     167    _deprecated_function( 'bp_core_delete_notifications_for_user_by_item_id', '1.3', 'bp_users_delete_notifications_by_item_id' );
     168    bp_users_delete_notifications_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id );
     169}
     170
     171function bp_core_delete_all_notifications_by_type( $item_id, $component_name, $component_action = false, $secondary_item_id = false ) {
     172    _deprecated_function( 'bp_core_delete_all_notifications_by_type', '1.3', 'bp_users_delete_all_notifications_by_type' );
     173    bp_users_delete_all_notifications_by_type( $item_id, $component_name, $component_action, $secondary_item_id );
     174}
     175
     176function bp_core_delete_notifications_from_user( $user_id, $component_name, $component_action ) {
     177    _deprecated_function( 'bp_core_delete_notifications_from_user', '1.3', 'bp_users_delete_notifications_from_user' );
     178    bp_users_delete_notifications_from_user( $user_id, $component_name, $component_action );
     179}
     180
     181function bp_core_check_notification_access( $user_id, $notification_id ) {
     182    _deprecated_function( 'bp_core_check_notification_access', '1.3', 'bp_users_check_notification_access' );
     183    bp_users_check_notification_access( $user_id, $notification_id );
     184}
     185
     186/** Core **********************************************************************/
    10187
    11188/**
     
    58235}
    59236
     237/** Theme *********************************************************************/
     238
    60239/**
    61  * Contains functions which were moved out of BP-Default's functions.php in BuddyPress 1.3.
     240 * Contains functions which were moved out of BP-Default's functions.php
     241 * in BuddyPress 1.3.
    62242 *
    63243 * @since 1.3
     
    66246    if ( !function_exists( 'bp_dtheme_wp_pages_filter' ) ) :
    67247    /**
    68      * In BuddyPress 1.2.x, this function filtered the dropdown on the Settings > Reading screen for selecting
    69      * the page to show on front to include "Activity Stream."
    70      * As of 1.3.x, it is no longer required.
     248     * In BuddyPress 1.2.x, this function filtered the dropdown on the
     249     * Settings > Reading screen for selecting the page to show on front to
     250     * include "Activity Stream." As of 1.3.x, it is no longer required.
    71251     *
    72252     * @deprecated 1.3
  • trunk/bp-core/bp-core-template.php

    r3751 r3757  
    17891789    global $bp_deactivated;
    17901790
    1791     if ( !isset( $bp_deactivated[ 'bp-' . $component . '.php' ] ) )
     1791    if ( !isset( $bp_deactivated[ 'bp-' . $component . '/bp-' . $component . '-loader.php' ] ) )
    17921792        return true;
    17931793
  • trunk/bp-groups/bp-groups-notifications.php

    r3592 r3757  
    4646    global $bp;
    4747
    48     bp_core_add_notification( $requesting_user_id, $admin_id, 'groups', 'new_membership_request', $group_id );
     48    bp_users_add_notification( $requesting_user_id, $admin_id, 'groups', 'new_membership_request', $group_id );
    4949
    5050    if ( 'no' == get_user_meta( $admin_id, 'notification_groups_membership_request', true ) )
     
    9696    // Post a screen notification first.
    9797    if ( $accepted )
    98         bp_core_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_accepted' );
     98        bp_users_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_accepted' );
    9999    else
    100         bp_core_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_rejected' );
     100        bp_users_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_rejected' );
    101101
    102102    if ( 'no' == get_user_meta( $requesting_user_id, 'notification_membership_request_completed', true ) )
     
    159159
    160160    // Post a screen notification first.
    161     bp_core_add_notification( $group_id, $user_id, 'groups', $type );
     161    bp_users_add_notification( $group_id, $user_id, 'groups', $type );
    162162
    163163    if ( 'no' == get_user_meta( $user_id, 'notification_groups_admin_promotion', true ) )
     
    209209
    210210        // Post a screen notification first.
    211         bp_core_add_notification( $group->id, $invited_user_id, 'groups', 'group_invite' );
     211        bp_users_add_notification( $group->id, $invited_user_id, 'groups', 'group_invite' );
    212212
    213213        if ( 'no' == get_user_meta( $invited_user_id, 'notification_groups_invite', true ) )
  • trunk/bp-groups/bp-groups-template.php

    r3750 r3757  
    11<?php
     2
     3/**
     4 * Output the groups component slug
     5 *
     6 * @package BuddyPress
     7 * @subpackage Activity Template
     8 * @since BuddyPress {unknown}
     9 *
     10 * @uses bp_get_groups_slug()
     11 */
     12function bp_groups_slug() {
     13    echo bp_get_groups_slug();
     14}
     15    /**
     16     * Return the groups component slug
     17     *
     18     * @package BuddyPress
     19     * @subpackage Activity Template
     20     * @since BuddyPress {unknown}
     21     */
     22    function bp_get_groups_slug() {
     23        global $bp;
     24        return apply_filters( 'bp_get_groups_slug', $bp->groups->slug );
     25    }
     26
     27/**
     28 * Output the groups component root slug
     29 *
     30 * @package BuddyPress
     31 * @subpackage Activity Template
     32 * @since BuddyPress {unknown}
     33 *
     34 * @uses bp_get_groups_root_slug()
     35 */
     36function bp_groups_root_slug() {
     37    echo bp_get_groups_root_slug();
     38}
     39    /**
     40     * Return the groups component root slug
     41     *
     42     * @package BuddyPress
     43     * @subpackage Activity Template
     44     * @since BuddyPress {unknown}
     45     */
     46    function bp_get_groups_root_slug() {
     47        global $bp;
     48        return apply_filters( 'bp_get_groups_root_slug', $bp->groups->root_slug );
     49    }
    250
    351/*****************************************************************************
     
    140188     * pass their parameters directly to the loop.
    141189     */
    142     $slug = false;
    143     $type = 'active';
     190    $slug    = false;
     191    $type    = 'active';
    144192    $user_id = 0;
    145 
    146     /* User filtering */
     193    $order   = '';
     194
     195    // User filtering
    147196    if ( !empty( $bp->displayed_user->id ) )
    148197        $user_id = $bp->displayed_user->id;
    149198
    150     /* Type */
     199    // Type
    151200    if ( 'my-groups' == $bp->current_action ) {
    152201        if ( 'most-popular' == $order ) {
  • trunk/bp-loader.php

    r3743 r3757  
    11<?php
    2 /*
    3 Plugin Name: BuddyPress
    4 Plugin URI: http://buddypress.org
    5 Description: Social networking in a box. Build a social network for your company, school, sports team or niche community all based on the power and flexibility of WordPress.
    6 Author: The BuddyPress Community
    7 Version: 1.3-bleeding
    8 Author URI: http://buddypress.org/community/members/
    9 Network: true
    10 */
     2/**
     3 * Plugin Name: BuddyPress
     4 * Plugin URI:  http://buddypress.org
     5 * Description: Social networking in a box. Build a social network for your company, school, sports team or niche community all based on the power and flexibility of WordPress.
     6 * Author:      The BuddyPress Community
     7 * Version:     1.3-bleeding
     8 * Author URI:  http://buddypress.org/community/members/
     9 * Network:     true
     10 */
     11
     12/** Constants *****************************************************************/
    1113
    1214define( 'BP_VERSION', '1.3-bleeding' );
    13 define( 'BP_DB_VERSION', 3705 );
     15define( 'BP_DB_VERSION', 3605 );
    1416
    1517// Define on which blog ID BuddyPress should run
    1618if ( !defined( 'BP_ROOT_BLOG' ) )
    1719    define( 'BP_ROOT_BLOG', 1 );
     20
     21// Path and URL
     22define( 'BP_PLUGIN_DIR', WP_PLUGIN_DIR . '/buddypress' );
     23define( 'BP_PLUGIN_URL', plugins_url( $path = '/buddypress' ) );
     24
     25// Load the WP abstraction file so BuddyPress can run on all WordPress setups.
     26require ( BP_PLUGIN_DIR . '/bp-core/bp-core-wpabstraction.php' );
     27
     28// Place your custom code (actions/filters) in a file called
     29// '/plugins/bp-custom.php' and it will be loaded before anything else.
     30if ( file_exists( WP_PLUGIN_DIR . '/bp-custom.php' ) )
     31    require( WP_PLUGIN_DIR . '/bp-custom.php' );
     32
     33// Define the user and usermeta table names, useful if you are using custom or shared tables.
     34if ( !defined( 'CUSTOM_USER_TABLE' ) )
     35    define( 'CUSTOM_USER_TABLE',      $wpdb->base_prefix . 'users' );
     36
     37if ( !defined( 'CUSTOM_USER_META_TABLE' ) )
     38    define( 'CUSTOM_USER_META_TABLE', $wpdb->base_prefix . 'usermeta' );
     39
     40// The search slug has to be defined nice and early because of the way search requests are loaded
     41if ( !defined( 'BP_SEARCH_SLUG' ) )
     42    define( 'BP_SEARCH_SLUG', 'search' );
     43
     44/** Loader ********************************************************************/
    1845
    1946// Register BuddyPress themes contained within the bp-themes folder
     
    3158// Existing successful installation
    3259} else {
     60
    3361    /***
    3462     * This file will load in each BuddyPress component based on which
    3563     * of the components have been activated on the "BuddyPress" admin menu.
    3664     */
    37     require_once( WP_PLUGIN_DIR . '/buddypress/bp-core.php' );
     65    require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/bp-core-loader.php' );
    3866    $bp_deactivated = apply_filters( 'bp_deactivated_components', get_site_option( 'bp-deactivated-components' ) );
    3967
     
    4775    do_action( 'bp_core_loaded' );
    4876
     77    // Users
     78    include( BP_PLUGIN_DIR . '/bp-users/bp-users-loader.php'       );
     79    include( BP_PLUGIN_DIR . '/bp-settings/bp-settings-loader.php' );
     80
    4981    // Activity Streams
    50     if ( !isset( $bp_deactivated['bp-activity.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-activity.php') )
    51         include( BP_PLUGIN_DIR . '/bp-activity.php' );
     82    if ( !isset( $bp_deactivated['bp-activity/bp-activity-loader.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-activity/bp-activity-loader.php') )
     83        include( BP_PLUGIN_DIR . '/bp-activity/bp-activity-loader.php' );
    5284
    5385    // Blog Tracking
    54     if ( !isset( $bp_deactivated['bp-blogs.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-blogs.php') )
    55         include( BP_PLUGIN_DIR . '/bp-blogs.php' );
     86    if ( !isset( $bp_deactivated['bp-blogs/bp-blogs-loader.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-loader.php') )
     87        include( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-loader.php' );
    5688
    5789    // bbPress Forum Integration
    58     if ( !isset( $bp_deactivated['bp-forums.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-forums.php') )
    59         include( BP_PLUGIN_DIR . '/bp-forums.php' );
     90    if ( !isset( $bp_deactivated['bp-forums/bp-forums-loader.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-forums/bp-forums-loader.php') )
     91        include( BP_PLUGIN_DIR . '/bp-forums/bp-forums-loader.php' );
    6092
    6193    // Friend Connections
    62     if ( !isset( $bp_deactivated['bp-friends.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-friends.php') )
    63         include( BP_PLUGIN_DIR . '/bp-friends.php' );
     94    if ( !isset( $bp_deactivated['bp-friends/bp-friends-loader.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-friends/bp-friends-loader.php') )
     95        include( BP_PLUGIN_DIR . '/bp-friends/bp-friends-loader.php' );
    6496
    6597    // Groups Support
    66     if ( !isset( $bp_deactivated['bp-groups.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-groups.php') )
    67         include( BP_PLUGIN_DIR . '/bp-groups.php' );
     98    if ( !isset( $bp_deactivated['bp-groups/bp-groups-loader.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-groups/bp-groups-loader.php') )
     99        include( BP_PLUGIN_DIR . '/bp-groups/bp-groups-loader.php' );
    68100
    69101    // Private Messaging
    70     if ( !isset( $bp_deactivated['bp-messages.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-messages.php') )
    71         include( BP_PLUGIN_DIR . '/bp-messages.php' );
     102    if ( !isset( $bp_deactivated['bp-messages/bp-messages-loader.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-messages/bp-messages-loader.php') )
     103        include( BP_PLUGIN_DIR . '/bp-messages/bp-messages-loader.php' );
    72104
    73105    // Extended Profiles
    74     if ( !isset( $bp_deactivated['bp-xprofile.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-xprofile.php') )
    75         include( BP_PLUGIN_DIR . '/bp-xprofile.php' );
     106    if ( !isset( $bp_deactivated['bp-xprofile/bp-xprofile-loader.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-loader.php') )
     107        include( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-loader.php' );
    76108       
    77109    // If this is an upgrade, load the upgrade file
     
    83115
    84116/********************************************************************************
    85  * Custom Actions
    86  *
    87117 * Functions to set up custom BuddyPress actions that components should
    88118 * hook in to.
     
    136166function bp_loaded() {
    137167    do_action( 'bp_loaded' );
     168}
     169
     170/**
     171 * Attach potential template screens
     172 */
     173function bp_screens() {
     174    do_action( 'bp_screens' );
    138175}
    139176
  • trunk/bp-messages/bp-messages-notifications.php

    r3592 r3757  
    33function messages_notification_new_message( $args ) {
    44    global $bp;
     5
    56    extract($args);
    67
    7     $sender_name = bp_core_get_user_displayname( $sender_id );
     8    $email_subject = $email_content = $args = '';
     9    $sender_name   = bp_core_get_user_displayname( $sender_id );
    810
    911    foreach( $recipients as $recipient ) {
    10         if ( $sender_id == $recipient->user_id || 'no' == get_user_meta( $recipient->user_id, 'notification_messages_new_message', true ) ) continue;
     12        if ( $sender_id == $recipient->user_id || 'no' == get_user_meta( $recipient->user_id, 'notification_messages_new_message', true ) )
     13            continue;
    1114
    12         $ud = get_userdata( $recipient->user_id );
    13         $message_link = bp_core_get_user_domain( $recipient->user_id ) . BP_MESSAGES_SLUG .'/';
     15        // User data and links
     16        $ud            = get_userdata( $recipient->user_id );
     17        $message_link  = bp_core_get_user_domain( $recipient->user_id ) . BP_MESSAGES_SLUG .'/';
    1418        $settings_link = bp_core_get_user_domain( $recipient->user_id ) .  BP_SETTINGS_SLUG . '/notifications/';
    1519
    16         $sender_name = stripslashes( $sender_name );
    17         $subject = stripslashes( wp_filter_kses( $subject ) );
    18         $content = stripslashes( wp_filter_kses( $content ) );
     20        // Sender info
     21        $sender_name   = stripslashes( $sender_name );
     22        $subject       = stripslashes( wp_filter_kses( $subject ) );
     23        $content       = stripslashes( wp_filter_kses( $content ) );
    1924
    2025        // Set up and send the message
     
    3742        $email_content .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    3843
    39         /* Send the message */
     44        // Send the message
    4045        $email_to = apply_filters( 'messages_notification_new_message_to', $email_to );
    4146        $email_subject = apply_filters( 'messages_notification_new_message_subject', $email_subject, $sender_name );
  • trunk/bp-messages/bp-messages-template.php

    r3750 r3757  
    166166    } else {
    167167        if ( 'inbox' == $bp->current_action )
    168             bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->messages->id, 'new_message' );
     168            bp_users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->messages->id, 'new_message' );
    169169
    170170        if ( 'sentbox' == $bp->current_action )
     
    343343        global $bp;
    344344
    345         return apply_filters( 'bp_get_messages_form_action', trailingslashit( $bp->loggedin_user->domain . $bp->messages->slug . '/' . $bp->current_action . '/' . $bp->action_variables[0] . '/' ) );
     345        if ( isset( $bp->action_variables[0] ) )
     346            $av = $bp->action_variables[0];
     347        else
     348            $av = '';
     349
     350        return apply_filters( 'bp_get_messages_form_action', trailingslashit( $bp->loggedin_user->domain . $bp->messages->slug . '/' . $bp->current_action . '/' . $av . '/' ) );
    346351    }
    347352
     
    734739        global $thread_template, $bp;
    735740
    736         if ( count($thread_template->thread->recipients) >= 5 )
     741        $recipient_links = array();
     742
     743        if ( count( $thread_template->thread->recipients ) >= 5 )
    737744            return apply_filters( 'bp_get_the_thread_recipients', sprintf( __( '%d Recipients', 'buddypress' ), count($thread_template->thread->recipients) ) );
    738745
  • trunk/bp-themes/bp-default/_inc/ajax.php

    r3751 r3757  
    601601
    602602
    603     if ( $user_ids ) {
     603    if ( !empty( $user_ids ) ) {
    604604        foreach ( $user_ids as $user_id ) {
    605605            $ud = get_userdata($user_id);
  • trunk/bp-themes/bp-default/members/single/messages.php

    r3460 r3757  
    11<div class="item-list-tabs no-ajax" id="subnav" role="navigation">
    22    <ul>
    3         <?php bp_get_options_nav() ?>
     3
     4        <?php bp_get_options_nav(); ?>
     5
    46    </ul>
    57</div><!-- .item-list-tabs -->
    68
    7 <?php if ( 'compose' == bp_current_action() ) : ?>
    8     <?php locate_template( array( 'members/single/messages/compose.php' ), true ) ?>
     9<?php
    910
    10 <?php elseif ( 'view' == bp_current_action() ) : ?>
    11     <?php locate_template( array( 'members/single/messages/single.php' ), true ) ?>
     11    if ( 'compose' == bp_current_action() ) :
     12        locate_template( array( 'members/single/messages/compose.php' ), true );
    1213
    13 <?php else : ?>
     14    elseif ( 'view' == bp_current_action() ) :
     15        locate_template( array( 'members/single/messages/single.php' ), true );
    1416
    15     <?php do_action( 'bp_before_member_messages_content' ) ?>
     17    else :
     18        do_action( 'bp_before_member_messages_content' ); ?>
    1619
    1720    <div class="messages" role="main">
    18         <?php if ( 'notices' == bp_current_action() ) : ?>
    19             <?php locate_template( array( 'members/single/messages/notices-loop.php' ), true ) ?>
    2021
    21         <?php else : ?>
    22             <?php locate_template( array( 'members/single/messages/messages-loop.php' ), true ) ?>
     22        <?php
     23            if ( 'notices' == bp_current_action() ) :
     24                locate_template( array( 'members/single/messages/notices-loop.php' ), true );
    2325
    24         <?php endif; ?>
     26            else :
     27                locate_template( array( 'members/single/messages/messages-loop.php' ), true );
     28
     29            endif;
     30        ?>
     31
    2532    </div><!-- .messages -->
    2633
    27     <?php do_action( 'bp_after_member_messages_content' ) ?>
     34    <?php do_action( 'bp_after_member_messages_content' ); ?>
    2835
    2936<?php endif; ?>
  • trunk/bp-themes/bp-default/members/single/profile.php

    r3460 r3757  
    11<?php if ( bp_is_my_profile() ) : ?>
     2
    23    <div class="item-list-tabs no-ajax" id="subnav" role="navigation">
    34        <ul>
    4             <?php bp_get_options_nav() ?>
     5
     6            <?php bp_get_options_nav(); ?>
     7
    58        </ul>
    69    </div><!-- .item-list-tabs -->
     10
    711<?php endif; ?>
    812
    9 <?php do_action( 'bp_before_profile_content' ) ?>
     13<?php do_action( 'bp_before_profile_content' ); ?>
    1014
    1115<div class="profile" role="main">
    12     <?php if ( 'edit' == bp_current_action() ) : ?>
    13         <?php locate_template( array( 'members/single/profile/edit.php' ), true ) ?>
    1416
    15     <?php elseif ( 'change-avatar' == bp_current_action() ) : ?>
    16         <?php locate_template( array( 'members/single/profile/change-avatar.php' ), true ) ?>
     17    <?php
     18        if ( 'edit' == bp_current_action() ) :
     19            locate_template( array( 'members/single/profile/edit.php' ), true );
    1720
    18     <?php else : ?>
    19         <?php locate_template( array( 'members/single/profile/profile-loop.php' ), true ) ?>
     21        elseif ( 'change-avatar' == bp_current_action() ) :
     22            locate_template( array( 'members/single/profile/change-avatar.php' ), true );
    2023
    21     <?php endif; ?>
     24        else :
     25            locate_template( array( 'members/single/profile/profile-loop.php' ), true );
     26
     27        endif;
     28    ?>
     29
    2230</div><!-- .profile -->
    2331
    24 <?php do_action( 'bp_after_profile_content' ) ?>
     32<?php do_action( 'bp_after_profile_content' ); ?>
Note: See TracChangeset for help on using the changeset viewer.