Skip to:
Content

BuddyPress.org

Changeset 3917


Ignore:
Timestamp:
01/25/2011 08:58:56 PM (13 years ago)
Author:
johnjamesjacoby
Message:

Rename new 'bp-users' component to 'bp-members' for consistency through-out project.
Core, Messages, and Friends Components now use the BP_Component class.
Split Friends and Messages components into smaller files.
Change references to 'profile' to 'xprofile' through-out project for consistency.
Introduce 'bp_actions' and 'bp_screens' standard hooks to replace the usage of 'wp' through-out project.
Move component loader sequence into bp-core-bootstrap.php,
Move old root_component action into 1.3 deprecated file.

Location:
trunk
Files:
7 added
8 deleted
48 edited
8 copied
1 moved

Legend:

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

    r3772 r3917  
    6262    bp_core_redirect( $redirect );
    6363}
    64 add_action( 'wp', 'bp_activity_action_permalink_router', 3 );
     64add_action( 'bp_actions', 'bp_activity_action_permalink_router' );
    6565
    6666function bp_activity_action_delete_activity() {
     
    100100    bp_core_redirect( wp_get_referer() );
    101101}
    102 add_action( 'wp', 'bp_activity_action_delete_activity', 3 );
     102add_action( 'bp_actions', 'bp_activity_action_delete_activity' );
    103103
    104104function bp_activity_action_post_update() {
     
    147147    bp_core_redirect( wp_get_referer() );
    148148}
    149 add_action( 'wp', 'bp_activity_action_post_update', 3 );
     149add_action( 'bp_actions', 'bp_activity_action_post_update' );
    150150
    151151function bp_activity_action_post_comment() {
     
    179179    bp_core_redirect( wp_get_referer() . '#ac-form-' . $activity_id );
    180180}
    181 add_action( 'wp', 'bp_activity_action_post_comment', 3 );
     181add_action( 'bp_actions', 'bp_activity_action_post_comment' );
    182182
    183183function bp_activity_action_mark_favorite() {
     
    197197    bp_core_redirect( wp_get_referer() . '#activity-' . $bp->action_variables[0] );
    198198}
    199 add_action( 'wp', 'bp_activity_action_mark_favorite', 3 );
     199add_action( 'bp_actions', 'bp_activity_action_mark_favorite' );
    200200
    201201function bp_activity_action_remove_favorite() {
     
    215215    bp_core_redirect( wp_get_referer() . '#activity-' . $bp->action_variables[0] );
    216216}
    217 add_action( 'wp', 'bp_activity_action_remove_favorite', 3 );
     217add_action( 'bp_actions', 'bp_activity_action_remove_favorite' );
    218218
    219219function bp_activity_action_sitewide_feed() {
     
    229229    die;
    230230}
    231 add_action( 'wp', 'bp_activity_action_sitewide_feed', 3 );
     231add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
    232232
    233233function bp_activity_action_personal_feed() {
     
    243243    die;
    244244}
    245 add_action( 'wp', 'bp_activity_action_personal_feed', 3 );
     245add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
    246246
    247247function bp_activity_action_friends_feed() {
     
    257257    die;
    258258}
    259 add_action( 'wp', 'bp_activity_action_friends_feed', 3 );
     259add_action( 'bp_actions', 'bp_activity_action_friends_feed' );
    260260
    261261function bp_activity_action_my_groups_feed() {
     
    271271    die;
    272272}
    273 add_action( 'wp', 'bp_activity_action_my_groups_feed', 3 );
     273add_action( 'bp_actions', 'bp_activity_action_my_groups_feed' );
    274274
    275275function bp_activity_action_mentions_feed() {
     
    285285    die;
    286286}
    287 add_action( 'wp', 'bp_activity_action_mentions_feed', 3 );
     287add_action( 'bp_actions', 'bp_activity_action_mentions_feed' );
    288288
    289289function bp_activity_action_favorites_feed() {
     
    299299    die;
    300300}
    301 add_action( 'wp', 'bp_activity_action_favorites_feed', 3 );
     301add_action( 'bp_actions', 'bp_activity_action_favorites_feed' );
    302302
    303303?>
  • trunk/bp-activity/bp-activity-classes.php

    r3903 r3917  
    151151
    152152        // Get the fullnames of users so we don't have to query in the loop
    153         if ( bp_is_active( 'profile' ) && $activities ) {
     153        if ( bp_is_active( 'xprofile' ) && $activities ) {
    154154            foreach ( (array)$activities as $activity ) {
    155155                if ( (int)$activity->user_id )
     
    365365            // Select the user's fullname with the query so we don't have to
    366366            // fetch it for each comment
    367             if ( bp_is_active( 'profile' ) ) {
     367            if ( bp_is_active( 'xprofile' ) ) {
    368368                $fullname_select = ", pd.value as user_fullname";
    369369                $fullname_from = ", {$bp->profile->table_name_data} pd ";
  • trunk/bp-activity/bp-activity-loader.php

    r3800 r3917  
    1818     */
    1919    function BP_Activity_Component() {
    20         parent::start( 'activity', __( 'Activity Streams', 'buddypress' ) );
     20        parent::start(
     21            'activity',
     22            __( 'Activity Streams', 'buddypress' ),
     23            BP_PLUGIN_DIR
     24        );
     25    }
     26
     27    /**
     28     * Include files
     29     */
     30    function _includes() {
     31        // Files to include
     32        $includes = array(
     33            'actions',
     34            'screens',
     35            'filters',
     36            'classes',
     37            'template',
     38            'functions',
     39            'notifications',
     40        );
     41
     42        parent::_includes( $includes );
    2143    }
    2244
     
    3759            define( 'BP_ACTIVITY_SLUG', $this->id );
    3860
    39         // Do some slug checks
    40         $this->slug      = BP_ACTIVITY_SLUG;
    41         $this->root_slug = isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : $this->slug;
    42 
    43         // Tables
    44         $this->table_name      = $bp->table_prefix . 'bp_activity';
    45         $this->table_name_meta = $bp->table_prefix . 'bp_activity_meta';
    46        
    47         // Register this in the active components array
    48         $bp->active_components[$this->id] = $this->id;
    49 
    50         // The default text for the blogs directory search box
    51         $bp->default_search_strings[$this->id] = __( 'Search Activity...', 'buddypress' );     
    52     }
    53 
    54     /**
    55      * Include files
    56      */
    57     function _includes() {
    58         require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-actions.php'   );
    59         require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-filters.php'   );
    60         require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-screens.php'   );
    61         require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-classes.php'   );
    62         require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-template.php'  );
    63         require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-functions.php' );
     61        // Global tables for messaging component
     62        $global_tables = array(
     63            'table_name'      => $bp->table_prefix . 'bp_activity',
     64            'table_name_meta' => $bp->table_prefix . 'bp_activity_meta',
     65        );
     66
     67        // All globals for messaging component.
     68        // Note that global_tables is included in this array.
     69        $globals = array(
     70            'path'                  => BP_PLUGIN_DIR,
     71            'slug'                  => BP_ACTIVITY_SLUG,
     72            'root_slug'             => isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : BP_ACTIVITY_SLUG,
     73            'search_string'         => __( 'Search Activity...', 'buddypress' ),
     74            'global_tables'         => $global_tables,
     75        );
     76
     77        parent::_setup_globals( $globals );
    6478    }
    6579
     
    7387
    7488        // Add 'Activity' to the main navigation
    75         bp_core_new_nav_item( array(
     89        $main_nav = array(
    7690            'name'                => __( 'Activity', 'buddypress' ),
    7791            'slug'                => $this->slug,
     
    7993            'screen_function'     => 'bp_activity_screen_my_activity',
    8094            'default_subnav_slug' => 'just-me',
    81             'item_css_id'         => $this->id )
     95            'item_css_id'         => $this->id
    8296        );
    8397
     
    101115
    102116        // Add the subnav items to the activity nav item if we are using a theme that supports this
    103         bp_core_new_subnav_item( array(
     117        $sub_nav[] = array(
    104118            'name'            => __( 'Personal', 'buddypress' ),
    105119            'slug'            => 'just-me',
     
    108122            'screen_function' => 'bp_activity_screen_my_activity',
    109123            'position'        => 10
    110         ) );
     124        );
    111125
    112126        // Additional menu if friends is active
    113127        if ( bp_is_active( 'friends' ) ) {
    114             bp_core_new_subnav_item( array(
     128            $sub_nav[] = array(
    115129                'name'            => __( 'Friends', 'buddypress' ),
    116130                'slug'            => $bp->friends->slug,
     
    120134                'position'        => 20,
    121135                'item_css_id'     => 'activity-friends'
    122             ) );
     136            ) ;
    123137        }
    124138
    125139        // Additional menu if groups is active
    126140        if ( bp_is_active( 'groups' ) ) {
    127             bp_core_new_subnav_item( array(
     141            $sub_nav[] = array(
    128142                'name'            => __( 'Groups', 'buddypress' ),
    129143                'slug'            => $bp->groups->slug,
     
    133147                'position'        => 30,
    134148                'item_css_id'     => 'activity-groups'
    135             ) );
     149            );
    136150        }
    137151
    138152        // Favorite activity items
    139         bp_core_new_subnav_item( array(
     153        $sub_nav[] = array(
    140154            'name'            => __( 'Favorites', 'buddypress' ),
    141155            'slug'            => 'favorites',
     
    145159            'position'        => 40,
    146160            'item_css_id'     => 'activity-favs'
    147         ) );
     161        );
    148162
    149163        // @ mentions
    150         bp_core_new_subnav_item( array(
     164        $sub_nav[] = array(
    151165            'name'            => sprintf( __( '@%s Mentions', 'buddypress' ), $user_login ),
    152166            'slug'            => 'mentions',
     
    156170            'position'        => 50,
    157171            'item_css_id'     => 'activity-mentions'
    158         ) );
     172        );
     173
     174        parent::_setup_nav( $main_nav, $sub_nav );
     175    }
     176
     177    /**
     178     * Sets up the title for pages and <title>
     179     *
     180     * @global obj $bp
     181     */
     182    function _setup_title() {
     183        global $bp;
    159184
    160185        // Adjust title based on view
     
    170195            }
    171196        }
     197
     198        parent::_setup_title();
    172199    }
    173200}
  • trunk/bp-activity/bp-activity-notifications.php

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

    r3844 r3917  
    2525    }
    2626}
    27 add_action( 'wp', 'bp_activity_screen_index', 2 );
     27add_action( 'bp_screens', 'bp_activity_screen_index' );
    2828
    2929function bp_activity_screen_my_activity() {
     
    8989    global $bp;
    9090
    91     bp_users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->activity->id, 'new_at_mention' );
     91    bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->activity->id, 'new_at_mention' );
    9292}
    9393add_action( 'bp_activity_screen_my_activity',               'bp_activity_remove_screen_notifications' );
     
    161161    bp_core_load_template( apply_filters( 'bp_activity_template_profile_activity_permalink', 'members/single/activity/permalink' ) );
    162162}
    163 add_action( 'wp', 'bp_activity_screen_single_activity_permalink', 3 );
     163add_action( 'bp_screens', 'bp_activity_screen_single_activity_permalink' );
    164164
    165165function bp_activity_screen_notification_settings() {
  • trunk/bp-activity/bp-activity-template.php

    r3904 r3917  
    10491049
    10501050            // Make sure all core internal component names are translatable
    1051             $translatable_components = array( __( 'profile', 'buddypress'), __( 'friends', 'buddypress' ), __( 'groups', 'buddypress' ), __( 'status', 'buddypress' ), __( 'blogs', 'buddypress' ) );
     1051            $translatable_components = array( __( 'xprofile', 'buddypress'), __( 'friends', 'buddypress' ), __( 'groups', 'buddypress' ), __( 'status', 'buddypress' ), __( 'blogs', 'buddypress' ) );
    10521052
    10531053            $component_links[] = $before . '<a href="' . esc_attr( $link ) . '">' . ucwords( __( $component, 'buddypress' ) ) . '</a>' . $after;
  • trunk/bp-blogs/bp-blogs-actions.php

    r3761 r3917  
    11<?php
    22
     3function bp_blogs_redirect_to_random_blog() {
     4    global $bp, $wpdb;
     5
     6    if ( bp_is_blogs_component() && isset( $_GET['random-blog'] ) ) {
     7        $blog = bp_blogs_get_random_blogs( 1, 1 );
     8
     9        bp_core_redirect( get_site_url( $blog['blogs'][0]->blog_id ) );
     10    }
     11}
     12add_action( 'bp_actions', 'bp_blogs_redirect_to_random_blog' );
     13
    314?>
  • trunk/bp-blogs/bp-blogs-functions.php

    r3903 r3917  
    412412}
    413413
    414 function bp_blogs_redirect_to_random_blog() {
    415     global $bp, $wpdb;
    416 
    417     if ( $bp->current_component == $bp->blogs->slug && isset( $_GET['random-blog'] ) ) {
    418         $blog = bp_blogs_get_random_blogs( 1, 1 );
    419 
    420         bp_core_redirect( get_site_url( $blog['blogs'][0]->blog_id ) );
    421     }
    422 }
    423 add_action( 'wp', 'bp_blogs_redirect_to_random_blog', 6 );
    424 
    425 
    426414/*******************************************************************************
    427415 * Blog meta functions
  • trunk/bp-blogs/bp-blogs-loader.php

    r3855 r3917  
    1818     */
    1919    function BP_Blogs_Component() {
    20         parent::start( 'blogs', __( 'Blogs Streams', 'buddypress' ) );
     20        parent::start(
     21            'blogs',
     22            __( 'Blogs Streams', 'buddypress' ),
     23            BP_PLUGIN_DIR
     24        );
    2125    }
    2226
     
    3640            define ( 'BP_BLOGS_SLUG', $this->id );
    3741
    38         // Do some slug checks
    39         $this->slug      = BP_BLOGS_SLUG;
    40         $this->root_slug = isset( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : $this->slug;
     42        // Global tables for messaging component
     43        $global_tables = array(
     44            'table_name'          => $bp->table_prefix . 'bp_user_blogs',
     45            'table_name_blogmeta' => $bp->table_prefix . 'bp_user_blogs_blogmeta',
     46        );
    4147
    42         // Tables
    43         $this->table_name          = $bp->table_prefix . 'bp_user_blogs';
    44         $this->table_name_blogmeta = $bp->table_prefix . 'bp_user_blogs_blogmeta';
     48        // All globals for messaging component.
     49        // Note that global_tables is included in this array.
     50        $globals = array(
     51            'path'                  => BP_PLUGIN_DIR,
     52            'slug'                  => BP_BLOGS_SLUG,
     53            'root_slug'             => isset( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : BP_BLOGS_SLUG,
     54            'notification_callback' => 'bp_blogs_format_notifications',
     55            'search_string'         => __( 'Search Blogs...', 'buddypress' ),
     56            'autocomplete_all'      => defined( 'BP_MESSAGES_AUTOCOMPLETE_ALL' ),
     57            'global_tables'         => $global_tables,
     58        );
    4559
    46         // Notifications
    47         $this->notification_callback = 'bp_blogs_format_notifications';
    48 
    49         // Register this in the active components array
    50         $bp->active_components[$this->id] = $this->id;
    51 
    52         // The default text for the blogs directory search box
    53         $bp->default_search_strings[$this->id] = __( 'Search Blogs...', 'buddypress' );
     60        // Setup the globals
     61        parent::_setup_globals( $globals );
    5462    }
    5563
     
    5866     */
    5967    function _includes() {
    60         require_once( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-cache.php'        );
    61         require_once( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-classes.php'      );
    62         require_once( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-screens.php'      );
    63         require_once( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-actions.php'      );
    64         require_once( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-activity.php'     );
    65         require_once( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-template.php'     );
    66         require_once( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-functions.php'    );
     68        // Files to include
     69        $includes = array(
     70            'cache',
     71            'actions',
     72            'screens',
     73            'classes',
     74            'template',
     75            'activity',
     76            'functions',
     77        );
    6778
    6879        if ( is_multisite() )
    69             require_once( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-widgets.php' );
     80            $includes[] = 'widgets';
     81
     82        // Include the files
     83        parent::_includes( $includes );
    7084    }
    7185
     
    87101
    88102        // Add 'Blogs' to the main navigation
    89         bp_core_new_nav_item( array(
     103        $main_nav = array(
    90104            'name'                => sprintf( __( 'Blogs <span>(%d)</span>', 'buddypress' ), bp_blogs_total_blogs_for_user() ),
    91105            'slug'                => $this->slug,
     
    94108            'default_subnav_slug' => 'my-blogs',
    95109            'item_css_id'         => $this->id
    96         ) );
     110        );
     111
     112        // Setup navigation
     113        parent::_setup_nav( $main_nav, $sub_nav );
     114    }
     115   
     116    /**
     117     * Sets up the title for pages and <title>
     118     *
     119     * @global obj $bp
     120     */
     121    function _setup_title() {
     122        global $bp;
    97123
    98124        // Set up the component options navigation for Blog
    99         if ( $bp->blogs->slug == $bp->current_component ) {
     125        if ( bp_is_blogs_component() ) {
    100126            if ( bp_is_my_profile() ) {
    101127                if ( function_exists('xprofile_setup_nav') ) {
     
    113139            }
    114140        }
     141
     142        parent::_setup_title();
    115143    }
    116144}
  • trunk/bp-blogs/bp-blogs-screens.php

    r3763 r3917  
    88
    99function bp_blogs_screen_my_blogs() {
    10     global $bp;
    11 
    1210    if ( !is_multisite() )
    1311        return false;
     
    1917
    2018function bp_blogs_screen_create_a_blog() {
    21     global $bp;
    22 
    23     if ( !is_multisite() || $bp->current_component != $bp->blogs->slug || 'create' != $bp->current_action )
     19    if ( !is_multisite() ||  !bp_is_blogs_component() || !bp_is_current_action( 'create' ) )
    2420        return false;
    2521
     
    3127    bp_core_load_template( apply_filters( 'bp_blogs_template_create_a_blog', 'blogs/create' ) );
    3228}
    33 add_action( 'wp', 'bp_blogs_screen_create_a_blog', 3 );
     29add_action( 'bp_screens', 'bp_blogs_screen_create_a_blog', 3 );
    3430
    3531function bp_blogs_screen_index() {
    3632    global $bp;
    3733
    38     if ( is_multisite() && $bp->current_component == $bp->blogs->slug && empty( $bp->current_action ) ) {
     34    if ( is_multisite() && bp_is_blogs_component() && !bp_current_action() ) {
    3935        $bp->is_directory = true;
    4036
     
    4440    }
    4541}
    46 add_action( 'wp', 'bp_blogs_screen_index', 2 );
     42add_action( 'bp_screens', 'bp_blogs_screen_index', 2 );
    4743
    4844?>
  • trunk/bp-core/admin/bp-core-admin.php

    r3790 r3917  
    101101        foreach ( (array)$_POST['bp-admin'] as $key => $value ) {
    102102
    103             if ( bp_is_active( 'profile' ) ) {
     103            if ( bp_is_active( 'xprofile' ) ) {
    104104                if ( 'bp-xprofile-base-group-name' == $key )
    105105                    $wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_groups} SET name = %s WHERE id = 1", stripslashes( $value ) ) );
     
    130130                <tbody>
    131131
    132                     <?php if ( bp_is_active( 'profile' ) ) : ?>
     132                    <?php if ( bp_is_active( 'xprofile' ) ) : ?>
    133133
    134134                        <tr>
  • trunk/bp-core/bp-core-buddybar.php

    r3861 r3917  
    6363    if ( bp_is_current_component( $slug ) && !bp_current_action() ) {
    6464        if ( !is_object( $screen_function[0] ) )
    65             add_action( 'wp', $screen_function, 3 );
     65            add_action( 'bp_screens', $screen_function );
    6666        else
    67             add_action( 'wp', array( &$screen_function[0], $screen_function[1] ), 3 );
     67            add_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ), 3 );
    6868
    6969        if ( !empty( $default_subnav_slug ) )
     
    9292    if ( $function = $bp->bp_nav[$parent_slug]['screen_function'] ) {
    9393        if ( !is_object( $function[0] ) )
    94             remove_action( 'wp', $function, 3 );
     94            remove_action( 'bp_screens', $function, 3 );
    9595        else
    96             remove_action( 'wp', array( &$function[0], $function[1] ), 3 );
     96            remove_action( 'bp_screens', array( &$function[0], $function[1] ), 3 );
    9797    }
    9898
     
    101101    if ( $bp->current_component == $parent_slug && !$bp->current_action ) {
    102102        if ( !is_object( $screen_function[0] ) )
    103             add_action( 'wp', $screen_function, 3 );
     103            add_action( 'bp_screens', $screen_function );
    104104        else
    105             add_action( 'wp', array( &$screen_function[0], $screen_function[1] ), 3 );
     105            add_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ) );
    106106
    107107        if ( $subnav_slug )
     
    189189    if ( ( $bp->current_action == $slug && $bp->current_component == $parent_slug ) && $user_has_access ) {
    190190        if ( !is_object( $screen_function[0] ) )
    191             add_action( 'wp', $screen_function, 3 );
     191            add_action( 'bp_screens', $screen_function );
    192192        else
    193             add_action( 'wp', array( &$screen_function[0], $screen_function[1] ), 3 );
     193            add_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ) );
    194194    }
    195195}
     
    244244    if ( $function = $bp->bp_nav[$parent_id]['screen_function'] ) {
    245245        if ( !is_object( $function[0] ) ) {
    246             remove_action( 'wp', $function, 3 );
     246            remove_action( 'bp_screens', $function );
    247247        } else {
    248             remove_action( 'wp', array( &$function[0], $function[1] ), 3 );
     248            remove_action( 'bp_screens', array( &$function[0], $function[1] ) );
    249249        }
    250250    }
     
    267267    if ( $screen_function ) {
    268268        if ( !is_object( $screen_function[0] ) )
    269             remove_action( 'wp', $screen_function, 3 );
     269            remove_action( 'bp_screens', $screen_function );
    270270        else
    271             remove_action( 'wp', array( &$screen_function[0], $screen_function[1] ), 3 );
     271            remove_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ) );
    272272    }
    273273
     
    484484    _e( 'Notifications', 'buddypress' );
    485485
    486     if ( $notifications = bp_users_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?>
     486    if ( $notifications = bp_members_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?>
    487487        <span><?php echo count( $notifications ) ?></span>
    488488    <?php
  • trunk/bp-core/bp-core-catchuri.php

    r3884 r3917  
    2121 *  Example:
    2222 *    - http://domain.com/members/andy/profile/edit/group/5/
    23  *    - $bp->current_component: string 'profile'
     23 *    - $bp->current_component: string 'xprofile'
    2424 *    - $bp->current_action: string 'edit'
    2525 *    - $bp->action_variables: array ['group', 5]
     
    280280    global $bp;
    281281
    282     if ( !bp_is_active( 'profile' ) )
     282    if ( !bp_is_active( 'xprofile' ) )
    283283        bp_core_load_template( apply_filters( 'bp_core_template_display_profile', 'members/single/home' ) );
    284284}
  • trunk/bp-core/bp-core-classes.php

    r3909 r3917  
    5656     */
    5757    function populate() {
    58         if ( bp_is_active( 'profile' ) )
     58        if ( bp_is_active( 'xprofile' ) )
    5959            $this->profile_data = $this->get_profile_data();
    6060
     
    124124        $sql['from'] = "FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN " . CUSTOM_USER_META_TABLE . " um ON um.user_id = u.ID";
    125125
    126         if ( $search_terms && bp_is_active( 'profile' ) || 'alphabetical' == $type )
     126        if ( $search_terms && bp_is_active( 'xprofile' ) || 'alphabetical' == $type )
    127127            $sql['join_profiledata'] = "LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id";
    128128
     
    167167        }
    168168
    169         if ( $search_terms && bp_is_active( 'profile' ) ) {
     169        if ( $search_terms && bp_is_active( 'xprofile' ) ) {
    170170            $search_terms             = like_escape( $wpdb->escape( $search_terms ) );
    171171            $sql['where_searchterms'] = "AND pd.value LIKE '%%$search_terms%%'";
     
    349349
    350350        // Fetch the user's full name
    351         if ( bp_is_active( 'profile' ) && 'alphabetical' != $type ) {
     351        if ( bp_is_active( 'xprofile' ) && 'alphabetical' != $type ) {
    352352            // Ensure xprofile globals are set
    353353            if ( !defined( 'BP_XPROFILE_FULLNAME_FIELD_NAME' ) )
  • trunk/bp-core/bp-core-component.php

    r3751 r3917  
    3434
    3535    /**
     36     * @var string The path to the plugins files
     37     */
     38    var $path;
     39
     40    /**
    3641     * @var WP_Query The loop for this component
    3742     */
     
    6368     * @uses bp_Component::_setup_actions() Setup the hooks and actions
    6469     */
    65     function start( $id, $name ) {
     70    function start( $id, $name, $path ) {
    6671        // Internal identifier of component
    6772        $this->id   = $id;
     
    7075        $this->name = $name;
    7176
    72         $this->_setup_actions ();
     77        // Path for includes
     78        $this->path = $path;
     79
     80        // Move on to the next step
     81        $this->_setup_actions();
    7382    }
    7483
     
    9099
    91100        $defaults = array(
    92             'slug'      => '',
    93             'root_slug' => ''
     101            'slug'                  => '',
     102            'root_slug'             => '',
     103            'notification_callback' => '',
     104            'global_tables'         => ''
    94105        );
    95106        $r = wp_parse_args( $args, $defaults );
     
    101112        $this->root_slug = apply_filters( 'bp_' . $this->id . '_root_slug', $r['root_slug'] );
    102113
     114        // Notifications callback
     115        $this->notification_callback = 'bp_' . $this->id . '_notification_callback';
     116
     117        // Setup global table names
     118        if ( !empty( $r['global_tables'] ) )
     119            foreach ( $r['global_tables'] as $global_name => $table_name )
     120                $this->$global_name = $table_name;
     121
    103122        /** BuddyPress ********************************************************/
    104123
    105         // Avoid syntactical errors
    106         $component_id = $this->id;
    107 
    108124        // Register this component in the active components array
    109         $bp->active_components[$bp->$component_id->slug] = $this->id;
    110 
    111         // Notifications callback
    112         $bp->$component_id->notification_callback = apply_filters( 'bp_' . $this->id . '_format_notifications', 'bp_' . $this->id . '_format_notifications' );
     125        $bp->active_components[$this->slug] = $this->id;
     126
     127        // Call action
     128        do_action( 'bp_' . $this->id . '_setup_globals' );
    113129    }
    114130
     
    121137     * @uses do_action() Calls 'bp_{@link bp_Component::name}_includes'
    122138     */
    123     function _includes() {
     139    function _includes( $includes = '' ) {
     140        if ( empty( $includes ) )
     141            return;
     142
     143        // Loop through files to be included
     144        foreach ( $includes as $file ) {
     145
     146            // Check path + file
     147            if ( file_exists( $this->path . '/' . $file ) )
     148                require_once( $this->path . '/' . $file );
     149
     150            // Check path + /bp-component/ + file
     151            elseif ( file_exists( $this->path . '/bp-' . $this->id . '/' . $file ) )
     152                require_once( $this->$path . '/bp-' . $this->id . '/' . $file );
     153
     154            // Check buddypress/bp-component/bp-component-$file.php
     155            elseif ( file_exists( $this->path . '/bp-' . $this->id . '/bp-' . $this->id . '-' . $file  . '.php' ) )
     156                require_once( $this->path . '/bp-' . $this->id . '/bp-' . $this->id . '-' . $file . '.php' );
     157
     158        }
     159
     160        // Call action
    124161        do_action( 'bp_' . $this->id . '_includes' );
    125162    }
     
    145182
    146183        // Register post types
     184        add_action( 'bp_setup_title',              array ( $this, '_setup_title'             ), 10 );
     185
     186        // Register post types
    147187        add_action( 'bp_register_post_types',      array ( $this, 'register_post_types'      ), 10 );
    148188
     
    161201
    162202    /**
     203     * Setup the navigation
     204     *
     205     * @param arr $main_nav
     206     * @param arr $sub_nav
     207     */
     208    function _setup_nav( $main_nav, $sub_nav ) {
     209        bp_core_new_nav_item( $main_nav );
     210
     211        foreach( $sub_nav as $nav )
     212            bp_core_new_subnav_item( $nav );
     213
     214        // Call action
     215        do_action( 'bp_' . $this->id . '_setup_nav' );
     216    }
     217
     218
     219    function _setup_title( ) {
     220       
     221    }
     222
     223    /**
    163224     * Setup the component post types
    164225     *
     
    204265    }
    205266}
    206 endif; // bp_Component
     267endif; // BP_Component
     268
     269?>
  • trunk/bp-core/bp-core-functions.php

    r3802 r3917  
    249249    @setcookie( 'bp-message-type', false, time() - 1000, COOKIEPATH );
    250250}
    251 add_action( 'wp', 'bp_core_setup_message', 2 );
     251add_action( 'bp_actions', 'bp_core_setup_message' );
    252252
    253253/**
     
    317317    );
    318318
    319     if ( !is_numeric( $older_date ) ) {
     319    if ( !empty( $older_date ) && !is_numeric( $older_date ) ) {
    320320        $time_chunks = explode( ':', str_replace( ' ', ':', $older_date ) );
    321321        $date_chunks = explode( '-', str_replace( ' ', '-', $older_date ) );
  • trunk/bp-core/bp-core-hooks.php

    r3874 r3917  
    77add_action( 'bp_loaded',      'bp_include', 2  );
    88
     9add_action( 'wp',             'bp_actions', 2  );
     10
     11add_action( 'wp',             'bp_screens', 2  );
    912
    1013/** Init **********************************************************************/
    1114
    1215// Attach bp_init to WordPress init
    13 add_action( 'init',    'bp_init'                     );
     16add_action( 'init',       'bp_init'                    );
    1417
    1518// Parse the URI and set globals
    16 add_action( 'bp_init', 'bp_core_set_uri_globals', 2 );
     19add_action( 'bp_init',    'bp_core_set_uri_globals', 2 );
    1720
    1821// Setup component globals
    19 add_action( 'bp_init', 'bp_setup_globals',         4 );
    20 
    21 // Setup root directories for components
    22 add_action( 'bp_init', 'bp_setup_root_components', 6 );
     22add_action( 'bp_init',    'bp_setup_globals',        4 );
    2323
    2424// Setup the navigation menu
    25 add_action( 'bp_init', 'bp_setup_nav',             8 );
     25add_action( 'bp_init',    'bp_setup_nav',            8 );
    2626
    2727// Setup widgets
    28 add_action( 'bp_init', 'bp_setup_widgets',         8 );
     28add_action( 'bp_init',    'bp_setup_widgets',        8 );
    2929   
    3030// Setup admin bar
    31 add_action( 'bp_loaded', 'bp_core_load_admin_bar'   );
     31add_action( 'bp_loaded',  'bp_core_load_admin_bar'    );
    3232
     33/** The hooks *****************************************************************/
     34
     35/**
     36 * Include files on this action
     37 */
     38function bp_include() {
     39    do_action( 'bp_include' );
     40}
     41
     42/**
     43 * Setup global variables and objects
     44 */
     45function bp_setup_globals() {
     46    do_action( 'bp_setup_globals' );
     47}
     48
     49/**
     50 * Set navigation elements
     51 */
     52function bp_setup_nav() {
     53    do_action( 'bp_setup_nav' );
     54}
     55
     56/**
     57 * Set the page title
     58 */
     59function bp_setup_title() {
     60    do_action( 'bp_setup_title' );
     61}
     62
     63/**
     64 * Register widgets
     65 */
     66function bp_setup_widgets() {
     67    do_action( 'bp_register_widgets' );
     68}
     69
     70/**
     71 * Initlialize code
     72 */
     73function bp_init() {
     74    do_action( 'bp_init' );
     75}
     76
     77/**
     78 * Attached to plugins_loaded
     79 */
     80function bp_loaded() {
     81    do_action( 'bp_loaded' );
     82}
     83
     84/**
     85 * Attach potential template actions
     86 */
     87function bp_actions() {
     88    do_action( 'bp_actions' );
     89}
     90
     91/**
     92 * Attach potential template screens
     93 */
     94function bp_screens() {
     95    do_action( 'bp_screens' );
     96}
    3397
    3498?>
  • trunk/bp-core/bp-core-loader.php

    r3829 r3917  
    11<?php
    22
    3 // Load the files containing functions that we globally will need.
    4 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-hooks.php'      );
    5 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-cssjs.php'      );
    6 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-classes.php'    );
    7 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-filters.php'    );
    8 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-avatars.php'    );
    9 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-widgets.php'    );
    10 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-template.php'   );
    11 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-buddybar.php'   );
    12 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-catchuri.php'   );
    13 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-component.php'  );
    14 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php'  );
     3// Require all of the BuddyPress core libraries
     4require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-component.php'  );
     5require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php'  );
     6require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-hooks.php'  );
     7require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-cssjs.php'  );
     8require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-classes.php'  );
     9require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-filters.php'  );
     10require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-avatars.php'  );
     11require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-widgets.php'  );
     12require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-template.php'  );
     13require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-buddybar.php'  );
     14require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-catchuri.php'  );
    1515
    16 // Do we load deprecated functions?
     16// Load deprecated functions
    1717if ( !defined( 'BP_SKIP_DEPRECATED' ) )
    18     require ( BP_PLUGIN_DIR . '/bp-core/deprecated/1.3.php' );
     18    require_once( BP_PLUGIN_DIR . '/bp-core/deprecated/1.3.php' );
    1919
    20 // If BP_DISABLE_ADMIN_BAR is defined, do not load the global admin bar.
     20// Load the WP admin bar.
    2121if ( !defined( 'BP_DISABLE_ADMIN_BAR' ) )
    22     require ( BP_PLUGIN_DIR . '/bp-core/bp-core-adminbar.php' );
     22    require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-adminbar.php' );
    2323
    2424/** "And now for something completely different" ******************************/
    2525
    26 /**
    27  * Sets up default global BuddyPress configuration settings and stores
    28  * them in a $bp variable.
    29  *
    30  * @package BuddyPress Core Core
    31  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    32  * @uses bp_core_get_user_domain() Returns the domain for a user
    33  */
    34 function bp_core_setup_globals() {
    35     global $bp;
    36     //global $current_action, $current_blog;
    37     global $bp_pages;
    38     //global $action_variables;
     26class BP_Core extends BP_Component {
    3927
    40     // Get the base database prefix
    41     $bp->table_prefix = bp_core_get_table_prefix();
    42 
    43     // The domain for the root of the site where the main blog resides
    44     $bp->root_domain  = bp_core_get_root_domain();
    45 
    46     // The names of the core WordPress pages used to display BuddyPress content
    47     $bp->pages        = $bp_pages;
    48 
    49     /** Component and Action **************************************************/
    50 
    51     // Used for overriding the 2nd level navigation menu so it can be used to
    52     // display custom navigation for an item (for example a group)
    53     $bp->is_single_item = false;
    54 
    55     // The default component to use if none are set and someone
    56     // visits: http://domain.com/members/andy
    57     if ( !defined( 'BP_DEFAULT_COMPONENT' ) ) {
    58         if ( isset( $bp->pages->activity ) )
    59             $bp->default_component = $bp->activity->id;
    60         else
    61             $bp->default_component = $bp->profile->id;
    62     } else {
    63         $bp->default_component     = BP_DEFAULT_COMPONENT;
     28    function BP_Core() {
     29        parent::start(
     30            '_core',
     31            __( 'BuddyPress Core', 'buddypress' )
     32            , BP_PLUGIN_DIR
     33        );
    6434    }
    6535
    66     // Fetches all of the core BuddyPress settings in one fell swoop
    67     $bp->site_options = bp_core_get_site_options();
     36    function _setup_globals() {
     37        global $bp, $bp_pages;
    6838
    69     // Sets up the array container for the component navigation rendered
    70     // by bp_get_nav()
    71     $bp->bp_nav            = array();
     39        // Setup the BuddyPress theme directory
     40        register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' );
    7241
    73     // Sets up the array container for the component options navigation
    74     // rendered by bp_get_options_nav()
    75     $bp->bp_options_nav    = array();
     42        // Get the base database prefix
     43        $bp->table_prefix = bp_core_get_table_prefix();
    7644
    77     // Contains an array of all the active components. The key is the slug,
    78     // value the internal ID of the component.
    79     $bp->active_components = array();
     45        // The domain for the root of the site where the main blog resides
     46        $bp->root_domain  = bp_core_get_root_domain();
    8047
    81     /** Avatars ***************************************************************/
     48        // The names of the core WordPress pages used to display BuddyPress content
     49        $bp->pages        = $bp_pages;
    8250
    83     // Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar
    84     $bp->grav_default->user  = apply_filters( 'bp_user_gravatar_default',  $bp->site_options['avatar_default'] );
    85     $bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', $bp->grav_default->user );
    86     $bp->grav_default->blog  = apply_filters( 'bp_blog_gravatar_default',  $bp->grav_default->user );
     51        /** Component and Action **************************************************/
    8752
    88     // Notifications Table
    89     $bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications';
     53        // Used for overriding the 2nd level navigation menu so it can be used to
     54        // display custom navigation for an item (for example a group)
     55        $bp->is_single_item = false;
    9056
    91     do_action( 'bp_core_setup_globals' );
    92 }
    93 add_action( 'bp_setup_globals', 'bp_core_setup_globals', 1 );
     57        // The default component to use if none are set and someone
     58        // visits: http://domain.com/members/andy
     59        if ( !defined( 'BP_DEFAULT_COMPONENT' ) ) {
     60            if ( isset( $bp->pages->activity ) )
     61                $bp->default_component = $bp->activity->id;
     62            else
     63                $bp->default_component = $bp->profile->id;
     64        } else {
     65            $bp->default_component     = BP_DEFAULT_COMPONENT;
     66        }
    9467
    95 /**
    96  * Sets up the profile navigation item if the Xprofile component is not installed.
    97  *
    98  * @package BuddyPress Core
    99  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    100  * @uses bp_core_new_nav_item() Adds a navigation item to the top level buddypress navigation
    101  * @uses bp_core_new_subnav_item() Adds a sub navigation item to a nav item
    102  * @uses bp_is_my_profile() Returns true if the current user being viewed is equal the logged in user
    103  * @uses bp_core_fetch_avatar() Returns the either the thumb or full avatar URL for the user_id passed
    104  */
    105 function bp_core_setup_nav() {
    106     global $bp;
     68        // Fetches all of the core BuddyPress settings in one fell swoop
     69        $bp->site_options = bp_core_get_site_options();
    10770
    108     /***
    109      * If the extended profiles component is disabled, we need to revert to using the
    110      * built in WordPress profile information
    111      */
    112     if ( !bp_is_active( 'profile' ) ) {
     71        // Sets up the array container for the component navigation rendered
     72        // by bp_get_nav()
     73        $bp->bp_nav            = array();
    11374
    114         // Fallback values if xprofile is disabled
    115         $bp->core->profile->slug = 'profile';
    116         $bp->active_components[$bp->core->profile->slug] = $bp->core->profile->slug;
     75        // Sets up the array container for the component options navigation
     76        // rendered by bp_get_options_nav()
     77        $bp->bp_options_nav    = array();
    11778
    118         // Add 'Profile' to the main navigation
    119         bp_core_new_nav_item( array(
    120             'name'                => __( 'Profile', 'buddypress' ),
    121             'slug'                => $bp->core->profile->slug,
    122             'position'            => 20,
    123             'screen_function'     => 'bp_core_catch_profile_uri',
    124             'default_subnav_slug' => 'public'
    125         ) );
     79        // Contains an array of all the active components. The key is the slug,
     80        // value the internal ID of the component.
     81        $bp->active_components = array();
    12682
    127         $profile_link = trailingslashit( $bp->loggedin_user->domain . '/' . $bp->core->profile->slug );
     83        /** Basic current user data ***********************************************/
    12884
    129         // Add the subnav items to the profile
    130         bp_core_new_subnav_item( array(
    131             'name'            => __( 'Public', 'buddypress' ),
    132             'slug'            => 'public',
    133             'parent_url'      => $profile_link,
    134             'parent_slug'     => $bp->core->profile->slug,
    135             'screen_function' => 'bp_core_catch_profile_uri'
    136         ) );
     85        // Logged in user is the 'current_user'
     86        $current_user            = wp_get_current_user();
    13787
    138         // Looking at a profile
    139         if ( 'profile' == $bp->current_component ) {
    140             if ( bp_is_my_profile() ) {
    141                 $bp->bp_options_title = __( 'My Profile', 'buddypress' );
    142             } else {
    143                 $bp->bp_options_avatar = bp_core_fetch_avatar( array(
    144                     'item_id' => $bp->displayed_user->id,
    145                     'type'    => 'thumb'
    146                 ) );
    147                 $bp->bp_options_title  = $bp->displayed_user->fullname;
    148             }
     88        // The user ID of the user who is currently logged in.
     89        $bp->loggedin_user->id   = $current_user->ID;
     90
     91        /** Avatars ***************************************************************/
     92
     93        // Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar
     94        $bp->grav_default->user  = apply_filters( 'bp_user_gravatar_default',  $bp->site_options['avatar_default'] );
     95        $bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', $bp->grav_default->user );
     96        $bp->grav_default->blog  = apply_filters( 'bp_blog_gravatar_default',  $bp->grav_default->user );
     97
     98        // Notifications Table
     99        $bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications';
     100
     101        do_action( 'bp_core_setup_globals' );
     102    }
     103
     104    function _setup_nav() {
     105        global $bp;
     106
     107        /***
     108         * If the extended profiles component is disabled, we need to revert to using the
     109         * built in WordPress profile information
     110         */
     111        if ( !bp_is_active( 'xprofile' ) ) {
     112
     113            // Fallback values if xprofile is disabled
     114            $bp->core->profile->slug = 'profile';
     115            $bp->active_components[$bp->core->profile->slug] = $bp->core->profile->slug;
     116
     117            // Add 'Profile' to the main navigation
     118            $main_nav = array(
     119                'name'                => __( 'Profile', 'buddypress' ),
     120                'slug'                => $bp->core->profile->slug,
     121                'position'            => 20,
     122                'screen_function'     => 'bp_core_catch_profile_uri',
     123                'default_subnav_slug' => 'public'
     124            );
     125
     126            $profile_link = trailingslashit( $bp->loggedin_user->domain . '/' . $bp->core->profile->slug );
     127
     128            // Add the subnav items to the profile
     129            $sub_nav[] = array(
     130                'name'            => __( 'Public', 'buddypress' ),
     131                'slug'            => 'public',
     132                'parent_url'      => $profile_link,
     133                'parent_slug'     => $bp->core->profile->slug,
     134                'screen_function' => 'bp_core_catch_profile_uri'
     135            );
    149136        }
    150137    }
    151138}
    152 add_action( 'bp_setup_nav', 'bp_core_setup_nav' );
    153 
     139$bp->core = new BP_Core();
    154140
    155141?>
  • trunk/bp-core/bp-core-template.php

    r3914 r3917  
    280280 */
    281281function bp_search_form_enabled() {
    282     if ( bp_is_active( 'profile' )
     282    if ( bp_is_active( 'xprofile' )
    283283         || bp_is_active( 'groups' )
    284284         || ( bp_is_active( 'blogs' ) && is_multisite() )
     
    311311    $options = array();
    312312
    313     if ( bp_is_active( 'profile' ) )
     313    if ( bp_is_active( 'xprofile' ) )
    314314        $options['members'] = __( 'Members', 'buddypress' );
    315315
     
    824824
    825825function bp_is_profile_component() {
    826     if ( bp_is_current_component( 'profile' ) )
     826    if ( bp_is_current_component( 'xprofile' ) )
    827827        return true;
    828828
     
    934934    global $bp;
    935935
    936     if ( bp_is_current_component( 'profile' ) )
     936    if ( bp_is_current_component( 'xprofile' ) )
    937937        return true;
    938938
     
    943943    global $bp;
    944944
    945     if ( bp_is_current_component( 'profile' ) && bp_is_current_action( 'edit' ) )
     945    if ( bp_is_current_component( 'xprofile' ) && bp_is_current_action( 'edit' ) )
    946946        return true;
    947947
     
    952952    global $bp;
    953953
    954     if ( bp_is_current_component( 'profile' ) && bp_is_current_action( 'change-avatar' ) )
     954    if ( bp_is_current_component( 'xprofile' ) && bp_is_current_action( 'change-avatar' ) )
    955955        return true;
    956956
     
    12401240        if ( !bp_is_blog_page() ) :
    12411241            if ( bp_is_user_profile() )
    1242                 $bp_classes[] = 'profile';
     1242                $bp_classes[] = 'xprofile';
    12431243
    12441244            if ( bp_is_activity_component() )
  • trunk/bp-core/deprecated/1.3.php

    r3853 r3917  
    99 */
    1010
     11/** Loader ********************************************************************/
     12
     13function bp_setup_root_components() {
     14    do_action( 'bp_setup_root_components' );
     15}
     16add_action( 'bp_init', 'bp_setup_root_components', 6 );
     17
    1118/** WP Abstraction ************************************************************/
    1219
     
    3542
    3643function bp_core_screen_signup() {
    37     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_screen_signup' );
    38     bp_users_screen_signup();
     44    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_screen_signup' );
     45    bp_members_screen_signup();
    3946}
    4047
    4148function bp_core_screen_activation() {
    42     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_screen_activation' );
    43     bp_users_screen_activation();
     49    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_screen_activation' );
     50    bp_members_screen_activation();
    4451}
    4552
    4653function bp_core_flush_illegal_names() {
    47     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_flush_illegal_names' );
    48     bp_users_flush_illegal_names();
     54    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_flush_illegal_names' );
     55    bp_members_flush_illegal_names();
    4956}
    5057
    5158function bp_core_illegal_names( $value = '', $oldvalue = '' ) {
    52     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_illegal_names' );
    53     bp_users_illegal_names( $value, $oldvalue );
     59    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_illegal_names' );
     60    bp_members_illegal_names( $value, $oldvalue );
    5461}
    5562
    5663function bp_core_validate_user_signup( $user_name, $user_email ) {
    57     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_validate_user_signup' );
    58     bp_users_validate_user_signup( $user_name, $user_email );
     64    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_validate_user_signup' );
     65    bp_members_validate_user_signup( $user_name, $user_email );
    5966}
    6067
    6168function bp_core_validate_blog_signup( $blog_url, $blog_title ) {
    62     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_validate_blog_signup' );
    63     bp_users_validate_blog_signup( $blog_url, $blog_title );
     69    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_validate_blog_signup' );
     70    bp_members_validate_blog_signup( $blog_url, $blog_title );
    6471}
    6572
    6673function bp_core_signup_user( $user_login, $user_password, $user_email, $usermeta ) {
    67     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_signup_user' );
    68     bp_users_signup_user( $user_login, $user_password, $user_email, $usermeta );
     74    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_signup_user' );
     75    bp_members_signup_user( $user_login, $user_password, $user_email, $usermeta );
    6976}
    7077
    7178function bp_core_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) {
    72     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_signup_blog' );
    73     bp_users_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta );
     79    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_signup_blog' );
     80    bp_members_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta );
    7481}
    7582
    7683function bp_core_activate_signup( $key ) {
    77     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_activate_signup' );
    78     bp_users_activate_signup( $key );
     84    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_activate_signup' );
     85    bp_members_activate_signup( $key );
    7986}
    8087
    8188function bp_core_new_user_activity( $user ) {
    82     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_new_user_activity' );
    83     bp_users_new_user_activity( $user );
     89    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_new_user_activity' );
     90    bp_members_new_user_activity( $user );
    8491}
    8592
    8693function bp_core_map_user_registration( $user_id ) {
    87     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_map_user_registration' );
    88     bp_users_map_user_registration( $user_id );
     94    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_map_user_registration' );
     95    bp_members_map_user_registration( $user_id );
    8996}
    9097
    9198function bp_core_signup_avatar_upload_dir() {
    92     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_signup_avatar_upload_dir' );
    93     bp_users_signup_avatar_upload_dir();
     99    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_signup_avatar_upload_dir' );
     100    bp_members_signup_avatar_upload_dir();
    94101}
    95102
    96103function bp_core_signup_send_validation_email( $user_id, $user_email, $key ) {
    97     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_signup_send_validation_email' );
    98     bp_users_signup_send_validation_email( $user_id, $user_email, $key );
     104    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_signup_send_validation_email' );
     105    bp_members_signup_send_validation_email( $user_id, $user_email, $key );
    99106}
    100107
    101108function bp_core_signup_disable_inactive( $auth_obj, $username ) {
    102     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_signup_disable_inactive' );
    103     bp_users_signup_disable_inactive( $auth_obj, $username );
     109    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_signup_disable_inactive' );
     110    bp_members_signup_disable_inactive( $auth_obj, $username );
    104111}
    105112
    106113function bp_core_wpsignup_redirect() {
    107     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_wpsignup_redirect' );
    108     bp_users_wpsignup_redirect();
     114    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_wpsignup_redirect' );
     115    bp_members_wpsignup_redirect();
    109116}
    110117
     
    117124
    118125function bp_core_can_edit_settings() {
    119     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_can_edit_settings' );
    120     bp_users_can_edit_settings();
     126    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_can_edit_settings' );
     127    bp_members_can_edit_settings();
    121128}
    122129
     
    163170
    164171function bp_core_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id = false, $date_notified = false ) {
    165     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_add_notification' );
    166     bp_users_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id, $date_notified );
     172    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_add_notification' );
     173    bp_members_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id, $date_notified );
    167174}
    168175
    169176function bp_core_delete_notification( $id ) {
    170     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_delete_notification' );
    171     bp_users_delete_notification( $id );
     177    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_delete_notification' );
     178    bp_members_delete_notification( $id );
    172179}
    173180
    174181function bp_core_get_notification( $id ) {
    175     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_get_notification' );
    176     bp_users_get_notification( $id );
     182    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_get_notification' );
     183    bp_members_get_notification( $id );
    177184}
    178185
    179186function bp_core_get_notifications_for_user( $user_id ) {
    180     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_get_notifications_for_user' );
    181     bp_users_get_notifications_for_user( $user_id );
     187    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_get_notifications_for_user' );
     188    bp_members_get_notifications_for_user( $user_id );
    182189}
    183190
    184191function bp_core_delete_notifications_by_type( $user_id, $component_name, $component_action ) {
    185     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_delete_notifications_by_type' );
    186     bp_users_delete_notifications_by_type( $user_id, $component_name, $component_action );
     192    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_delete_notifications_by_type' );
     193    bp_members_delete_notifications_by_type( $user_id, $component_name, $component_action );
    187194}
    188195
    189196function bp_core_delete_notifications_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false ) {
    190     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_delete_notifications_by_item_id' );
    191     bp_users_delete_notifications_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id );
     197    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_delete_notifications_by_item_id' );
     198    bp_members_delete_notifications_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id );
    192199}
    193200
    194201function bp_core_delete_all_notifications_by_type( $item_id, $component_name, $component_action = false, $secondary_item_id = false ) {
    195     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_delete_all_notifications_by_type' );
    196     bp_users_delete_all_notifications_by_type( $item_id, $component_name, $component_action, $secondary_item_id );
     202    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_delete_all_notifications_by_type' );
     203    bp_members_delete_all_notifications_by_type( $item_id, $component_name, $component_action, $secondary_item_id );
    197204}
    198205
    199206function bp_core_delete_notifications_from_user( $user_id, $component_name, $component_action ) {
    200     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_delete_notifications_from_user' );
    201     bp_users_delete_notifications_from_user( $user_id, $component_name, $component_action );
     207    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_delete_notifications_from_user' );
     208    bp_members_delete_notifications_from_user( $user_id, $component_name, $component_action );
    202209}
    203210
    204211function bp_core_check_notification_access( $user_id, $notification_id ) {
    205     _deprecated_function( __FUNCTION__, '1.3', 'bp_users_check_notification_access' );
    206     bp_users_check_notification_access( $user_id, $notification_id );
     212    _deprecated_function( __FUNCTION__, '1.3', 'bp_members_check_notification_access' );
     213    bp_members_check_notification_access( $user_id, $notification_id );
    207214}
    208215
  • trunk/bp-forums/bp-forums-functions.php

    r3916 r3917  
    2424    return !empty( $bp->site_options['bp-disable-forum-directory'] );
    2525}
    26 
    27 function bp_forums_directory_forums_setup() {
    28     global $bp;
    29 
    30     if ( bp_is_current_component( 'forums' ) ) {
    31         if ( bp_forum_directory_is_disabled() || !bp_is_active( 'groups' ) )
    32             return false;
    33 
    34         if ( !bp_forums_is_installed_correctly() ) {
    35             bp_core_add_message( __( 'The forums component has not been set up yet.', 'buddypress' ), 'error' );
    36             bp_core_redirect( $bp->root_domain );
    37         }
    38 
    39         $bp->is_directory = true;
    40 
    41         do_action( 'bbpress_init' );
    42 
    43         // Check to see if the user has posted a new topic from the forums page.
    44         if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic' ) ) {
    45             check_admin_referer( 'bp_forums_new_topic' );
    46 
    47             if ( $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) ) ) {
    48                 // Auto join this user if they are not yet a member of this group
    49                 if ( !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
    50                     groups_join_group( $bp->groups->current_group->id, $bp->groups->current_group->id );
    51 
    52                 $error_message = '';
    53                 if ( $forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ) ) {
    54                     if ( empty( $_POST['topic_title'] ) )
    55                         $error_message = __( 'Please provide a title for your forum topic.', 'buddypress' );
    56                     else if ( empty( $_POST['topic_text'] ) )
    57                         $error_message = __( 'Forum posts cannot be empty. Please enter some text.', 'buddypress' );
    58 
    59                     if ( $error_message ) {
    60                         bp_core_add_message( $error_message, 'error' );
    61                         $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum';
    62                     } else {
    63                         if ( !$topic = groups_new_group_forum_topic( $_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id ) ) {
    64                             bp_core_add_message( __( 'There was an error when creating the topic', 'buddypress'), 'error' );
    65                             $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum';
    66                         } else {
    67                             bp_core_add_message( __( 'The topic was created successfully', 'buddypress') );
    68                             $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/';
    69                         }
    70                     }
    71 
    72                     bp_core_redirect( $redirect );
    73 
    74                 } else {
    75                     bp_core_add_message( __( 'Please pick the group forum where you would like to post this topic.', 'buddypress' ), 'error' );
    76                 }
    77             }
    78         }
    79 
    80         do_action( 'bp_forums_directory_forums_setup' );
    81 
    82         bp_core_load_template( apply_filters( 'bp_forums_template_directory_forums_setup', 'forums/index' ) );
    83     }
    84 }
    85 add_action( 'wp', 'bp_forums_directory_forums_setup', 2 );
    8626
    8727/** Forum Functions ***********************************************************/
     
    380320
    381321    // Fetch fullname for the topic's last poster
    382     if ( bp_is_active( 'profile' ) ) {
     322    if ( bp_is_active( 'xprofile' ) ) {
    383323        $poster_names = $wpdb->get_results( $wpdb->prepare( "SELECT t.topic_id, pd.value FROM {$bp->profile->table_name_data} pd, {$bbdb->topics} t WHERE pd.user_id = t.topic_last_poster AND pd.field_id = 1 AND t.topic_id IN ( {$topic_ids} )" ) );
    384324        for ( $i = 0; $i < count( $topics ); $i++ ) {
     
    498438
    499439    // Fetch fullname for each poster.
    500     if ( bp_is_active( 'profile' ) ) {
     440    if ( bp_is_active( 'xprofile' ) ) {
    501441        $poster_names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id, pd.value FROM {$bp->profile->table_name_data} pd WHERE pd.user_id IN ( {$user_ids} )" ) );
    502442        for ( $i = 0; $i < count( $posts ); $i++ ) {
  • trunk/bp-forums/bp-forums-loader.php

    r3877 r3917  
    1818     */
    1919    function BP_Forums_Component() {
    20         parent::start( 'forums', __( 'Discussion Forums', 'buddypress' ) );
     20        parent::start(
     21            'forums',
     22            __( 'Discussion Forums', 'buddypress' ),
     23            BP_PLUGIN_DIR
     24        );
    2125    }
    2226
     
    4145            define( 'BP_FORUMS_SLUG', $this->id );
    4246
    43         // Do some slug checks
    44         $this->slug      = BP_FORUMS_SLUG;
    45         $this->root_slug = isset( $bp->pages->forums->slug ) ? $bp->pages->forums->slug : $this->slug;
    46 
    4747        // The location of the bbPress stand-alone config file
    4848        if ( isset( $bp->site_options['bb-config-location'] ) )
    4949            $this->bbconfig = $bp->site_options['bb-config-location'];
    5050
    51         // The default text for the blogs directory search box
    52         $this->default_search_string = __( 'Search Forums...', 'buddypress' );
     51        // All globals for messaging component.
     52        // Note that global_tables is included in this array.
     53        $globals = array(
     54            'slug'                  => BP_FORUMS_SLUG,
     55            'root_slug'             => isset( $bp->pages->forums->slug ) ? $bp->pages->forums->slug : BP_FORUMS_SLUG,
     56            'notification_callback' => 'messages_format_notifications',
     57            'search_string'         => __( 'Search Forums...', 'buddypress' ),
     58        );
    5359
    54         // Register this in the active components array
    55         $bp->active_components[$this->id] = $this->id;
     60        parent::_setup_globals( $globals );
    5661    }
    5762
     
    6166    function _includes() {
    6267
    63         // Support for bbPress stand-alone
     68        // Files to include
     69        $includes = array(
     70            'actions',
     71            'screens',
     72            'classes',
     73            'filters',
     74            'template',
     75            'functions',
     76        );
     77
     78        // Admin area
     79        if ( is_admin() )
     80            $includes[] = 'admin';
     81
     82        // bbPress stand-alone
    6483        if ( !defined( 'BB_PATH' ) )
    65             require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-bbpress-sa.php' );
     84            $includes[] = 'bbpress-sa';
    6685
    67         // Admin
    68         if ( is_admin() )
    69             require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-admin.php'   );
    70 
    71         require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-actions.php'   );
    72         require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-screens.php'   );
    73         require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-filters.php'   );
    74         require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-template.php'  );
    75         require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-functions.php' );
     86        parent::_includes( $includes );
    7687    }
    7788
     
    8596
    8697        // Add 'Forums' to the main navigation
    87         bp_core_new_nav_item( array(
     98        $main_nav = array(
    8899            'name'                => __( 'Forums', 'buddypress' ),
    89100            'slug'                => $this->slug,
     
    91102            'screen_function'     => 'bp_forums_screen_topics',
    92103            'default_subnav_slug' => 'topics',
    93             'item_css_id'         => $this->id )
     104            'item_css_id'         => $this->id
    94105        );
    95106
     
    113124
    114125        // Additional menu if friends is active
    115         bp_core_new_subnav_item( array(
     126        $sub_nav[] = array(
    116127            'name'            => __( 'Topics Started', 'buddypress' ),
    117128            'slug'            => 'topics',
     
    121132            'position'        => 20,
    122133            'item_css_id'     => 'forums-friends'
    123         ) );
     134        );
    124135
    125136        // Additional menu if friends is active
    126         bp_core_new_subnav_item( array(
     137        $sub_nav[] = array(
    127138            'name'            => __( 'Replies', 'buddypress' ),
    128139            'slug'            => 'replies',
     
    132143            'position'        => 40,
    133144            'item_css_id'     => 'forums-friends'
    134         ) );
     145        );
    135146
    136147        // Favorite forums items
    137         bp_core_new_subnav_item( array(
     148        $sub_nav[] = array(
    138149            'name'            => __( 'Favorite Topics', 'buddypress' ),
    139150            'slug'            => 'favorites',
     
    143154            'position'        => 60,
    144155            'item_css_id'     => 'forums-favs'
    145         ) );
     156        );
     157
     158        parent::_setup_nav( $main_nav, $sub_nav );
     159    }
     160
     161    /**
     162     * Sets up the title for pages and <title>
     163     *
     164     * @global obj $bp
     165     */
     166    function _setup_title() {
     167        global $bp;
    146168
    147169        // Adjust title based on view
     
    157179            }
    158180        }
     181
     182        parent::_setup_title();
    159183    }
    160184}
  • trunk/bp-forums/bp-forums-screens.php

    r3806 r3917  
    11<?php
    22
     3function bp_forums_directory_forums_setup() {
     4    global $bp;
     5
     6    if ( bp_is_current_component( 'forums' ) ) {
     7        if ( bp_forum_directory_is_disabled() || !bp_is_active( 'groups' ) )
     8            return false;
     9
     10        if ( !bp_forums_is_installed_correctly() ) {
     11            bp_core_add_message( __( 'The forums component has not been set up yet.', 'buddypress' ), 'error' );
     12            bp_core_redirect( $bp->root_domain );
     13        }
     14
     15        $bp->is_directory = true;
     16
     17        do_action( 'bbpress_init' );
     18
     19        // Check to see if the user has posted a new topic from the forums page.
     20        if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic' ) ) {
     21            check_admin_referer( 'bp_forums_new_topic' );
     22
     23            if ( $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) ) ) {
     24                // Auto join this user if they are not yet a member of this group
     25                if ( !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
     26                    groups_join_group( $bp->groups->current_group->id, $bp->groups->current_group->id );
     27
     28                $error_message = '';
     29                if ( $forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ) ) {
     30                    if ( empty( $_POST['topic_title'] ) )
     31                        $error_message = __( 'Please provide a title for your forum topic.', 'buddypress' );
     32                    else if ( empty( $_POST['topic_text'] ) )
     33                        $error_message = __( 'Forum posts cannot be empty. Please enter some text.', 'buddypress' );
     34
     35                    if ( $error_message ) {
     36                        bp_core_add_message( $error_message, 'error' );
     37                        $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum';
     38                    } else {
     39                        if ( !$topic = groups_new_group_forum_topic( $_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id ) ) {
     40                            bp_core_add_message( __( 'There was an error when creating the topic', 'buddypress'), 'error' );
     41                            $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum';
     42                        } else {
     43                            bp_core_add_message( __( 'The topic was created successfully', 'buddypress') );
     44                            $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/';
     45                        }
     46                    }
     47
     48                    bp_core_redirect( $redirect );
     49
     50                } else {
     51                    bp_core_add_message( __( 'Please pick the group forum where you would like to post this topic.', 'buddypress' ), 'error' );
     52                }
     53            }
     54        }
     55
     56        do_action( 'bp_forums_directory_forums_setup' );
     57
     58        bp_core_load_template( apply_filters( 'bp_forums_template_directory_forums_setup', 'forums/index' ) );
     59    }
     60}
     61add_action( 'bp_screens', 'bp_forums_directory_forums_setup' );
     62
    363?>
  • trunk/bp-friends/bp-friends-classes.php

    r3903 r3917  
    159159
    160160        // filter the user_ids based on the search criteria.
    161         if ( bp_is_active( 'profile' ) ) {
     161        if ( bp_is_active( 'xprofile' ) ) {
    162162            $sql = "SELECT DISTINCT user_id FROM {$bp->profile->table_name_data} WHERE user_id IN ($fids) AND value LIKE '$filter%%' {$pag_sql}";
    163163            $total_sql = "SELECT COUNT(DISTINCT user_id) FROM {$bp->profile->table_name_data} WHERE user_id IN ($fids) AND value LIKE '$filter%%'";
     
    225225
    226226        // filter the user_ids based on the search criteria.
    227         if ( bp_is_active( 'profile' ) ) {
     227        if ( bp_is_active( 'xprofile' ) ) {
    228228            $sql = $wpdb->prepare( "SELECT DISTINCT d.user_id as id FROM {$bp->profile->table_name_data} d, $users_table u WHERE d.user_id = u.id AND d.value LIKE '$filter%%' ORDER BY d.value DESC $pag_sql" );
    229229        } else {
     
    248248
    249249        // filter the user_ids based on the search criteria.
    250         if ( bp_is_active( 'profile' ) ) {
     250        if ( bp_is_active( 'xprofile' ) ) {
    251251            $sql = $wpdb->prepare( "SELECT COUNT(DISTINCT d.user_id) FROM {$bp->profile->table_name_data} d, $users_table u WHERE d.user_id = u.id AND d.value LIKE '$filter%%'" );
    252252        } else {
     
    265265        global $wpdb, $bp;
    266266
    267         if ( !bp_is_active( 'profile' ) )
     267        if ( !bp_is_active( 'xprofile' ) )
    268268            return false;
    269269
  • trunk/bp-friends/bp-friends-loader.php

    r3903 r3917  
    11<?php
    22
    3 // Required Files
    4 require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-classes.php'  );
    5 require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-template.php' );
     3/**
     4 * BuddyPress Friends Streams Loader
     5 *
     6 * The friends component is for users to create relationships with each other
     7 *
     8 * @package BuddyPress
     9 * @subpackage Friends Core
     10 */
    611
    7 define ( 'BP_FRIENDS_DB_VERSION', '1800' );
     12class BP_Friends_Component extends BP_Component {
    813
    9 // Define the slug for the component
    10 if ( !defined( 'BP_FRIENDS_SLUG' ) )
    11     define ( 'BP_FRIENDS_SLUG', 'friends' );
    12 
    13 function friends_setup_globals() {
    14     global $bp;
    15 
    16     // For internal identification
    17     $bp->friends->id = 'friends';
    18 
    19     // Slug
    20     $bp->friends->slug = BP_FRIENDS_SLUG;
    21 
    22     // Table
    23     $bp->friends->table_name = $bp->table_prefix . 'bp_friends';
    24 
    25     // Notifications
    26     $bp->friends->notification_callback = 'friends_format_notifications';
    27 
    28     // Register this in the active components array
    29     $bp->active_components[$bp->friends->slug] = $bp->friends->id;
    30 
    31     do_action( 'friends_setup_globals' );
    32 }
    33 add_action( 'bp_setup_globals', 'friends_setup_globals' );
    34 
    35 function friends_setup_nav() {
    36     global $bp;
    37 
    38     // Add 'Friends' to the main navigation
    39     bp_core_new_nav_item( array( 'name' => sprintf( __( 'Friends <span>(%d)</span>', 'buddypress' ), friends_get_total_friend_count() ), 'slug' => $bp->friends->slug, 'position' => 60, 'screen_function' => 'friends_screen_my_friends', 'default_subnav_slug' => 'my-friends', 'item_css_id' => $bp->friends->id ) );
    40 
    41     $friends_link = $bp->loggedin_user->domain . $bp->friends->slug . '/';
    42 
    43     // Add the subnav items to the friends nav item
    44     bp_core_new_subnav_item( array( 'name' => __( 'My Friends', 'buddypress' ), 'slug' => 'my-friends', 'parent_url' => $friends_link, 'parent_slug' => $bp->friends->slug, 'screen_function' => 'friends_screen_my_friends', 'position' => 10, 'item_css_id'     => 'friends-my-friends' ) );
    45     bp_core_new_subnav_item( array( 'name' => __( 'Requests',   'buddypress' ), 'slug' => 'requests',   'parent_url' => $friends_link, 'parent_slug' => $bp->friends->slug, 'screen_function' => 'friends_screen_requests',   'position' => 20, 'user_has_access' => bp_is_my_profile()   ) );
    46 
    47     if ( $bp->current_component == $bp->friends->slug ) {
    48         if ( bp_is_my_profile() ) {
    49             $bp->bp_options_title = __( 'My Friends', 'buddypress' );
    50         } else {
    51             $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
    52             $bp->bp_options_title = $bp->displayed_user->fullname;
    53         }
     14    /**
     15     * Start the friends component creation process
     16     *
     17     * @since BuddyPress {unknown}
     18     */
     19    function BP_Friends_Component() {
     20        parent::start(
     21            'friends',
     22            __( 'Friend Connections', 'buddypress' ),
     23            BP_PLUGIN_DIR
     24        );
    5425    }
    5526
    56     do_action( 'friends_setup_nav' );
    57 }
    58 add_action( 'bp_setup_nav', 'friends_setup_nav' );
     27    /**
     28     * Include files
     29     */
     30    function _includes() {
     31        // Files to include
     32        $includes = array(
     33            'actions',
     34            'screens',
     35            'filters',
     36            'classes',
     37            'activity',
     38            'template',
     39            'functions',
     40            'notifications',
     41        );
    5942
    60 /********************************************************************************
    61  * Screen Functions
    62  *
    63  * Screen functions are the controllers of BuddyPress. They will execute when their
    64  * specific URL is caught. They will first save or manipulate data using business
    65  * functions, then pass on the user to a template file.
    66  */
    67 
    68 function friends_screen_my_friends() {
    69     global $bp;
    70 
    71     // Delete any friendship acceptance notifications for the user when viewing a profile
    72     bp_users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->friends->id, 'friendship_accepted' );
    73 
    74     do_action( 'friends_screen_my_friends' );
    75 
    76     bp_core_load_template( apply_filters( 'friends_template_my_friends', 'members/single/home' ) );
    77 }
    78 
    79 function friends_screen_requests() {
    80     global $bp;
    81 
    82     if ( isset( $bp->action_variables[0] ) && isset( $bp->action_variables[1] ) && 'accept' == $bp->action_variables[0] && is_numeric( $bp->action_variables[1] ) ) {
    83         // Check the nonce
    84         check_admin_referer( 'friends_accept_friendship' );
    85 
    86         if ( friends_accept_friendship( $bp->action_variables[1] ) )
    87             bp_core_add_message( __( 'Friendship accepted', 'buddypress' ) );
    88         else
    89             bp_core_add_message( __( 'Friendship could not be accepted', 'buddypress' ), 'error' );
    90 
    91         bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
    92 
    93     } elseif ( isset( $bp->action_variables[0] ) && isset( $bp->action_variables[1] ) && 'reject' == $bp->action_variables[0] && is_numeric( $bp->action_variables[1] ) ) {
    94         // Check the nonce
    95         check_admin_referer( 'friends_reject_friendship' );
    96 
    97         if ( friends_reject_friendship( $bp->action_variables[1] ) )
    98             bp_core_add_message( __( 'Friendship rejected', 'buddypress' ) );
    99         else
    100             bp_core_add_message( __( 'Friendship could not be rejected', 'buddypress' ), 'error' );
    101 
    102         bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
     43        parent::_includes( $includes );
    10344    }
    10445
    105     do_action( 'friends_screen_requests' );
     46    /**
     47     * Setup globals
     48     *
     49     * The BP_FRIENDS_SLUG constant is deprecated, and only used here for
     50     * backwards compatibility.
     51     *
     52     * @since BuddyPress {unknown}
     53     * @global obj $bp
     54     */
     55    function _setup_globals() {
     56        global $bp;
    10657
    107     if ( isset( $_GET['new'] ) )
    108         bp_users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->friends->id, 'friendship_request' );
     58        define ( 'BP_FRIENDS_DB_VERSION', '1800' );
    10959
    110     bp_core_load_template( apply_filters( 'friends_template_requests', 'members/single/home' ) );
    111 }
     60        // Define a slug, if necessary
     61        if ( !defined( 'BP_FRIENDS_SLUG' ) )
     62            define( 'BP_FRIENDS_SLUG', $this->id );
    11263
    113 function friends_screen_notification_settings() {
    114     global $bp;
     64        // Global tables for messaging component
     65        $global_tables = array(
     66            'table_name'      => $bp->table_prefix . 'bp_friends',
     67            'table_name_meta' => $bp->table_prefix . 'bp_friends_meta',
     68        );
    11569
     70        // All globals for messaging component.
     71        // Note that global_tables is included in this array.
     72        $globals = array(
     73            'path'                  => BP_PLUGIN_DIR,
     74            'slug'                  => BP_FRIENDS_SLUG,
     75            'root_slug'             => isset( $bp->pages->friends->slug ) ? $bp->pages->friends->slug : BP_FRIENDS_SLUG,
     76            'search_string'         => __( 'Search Friends...', 'buddypress' ),
     77            'notification_callback' => 'friends_format_notifications',
     78            'global_tables'         => $global_tables,
     79        );
    11680
    117     if ( !$send_requests = get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_request', true ) )
    118         $send_requests   = 'yes';
     81        parent::_setup_globals( $globals );
     82    }
    11983
    120     if ( !$accept_requests = get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_accepted', true ) )
    121         $accept_requests = 'yes';
    122 ?>
     84    /**
     85     * Setup BuddyBar navigation
     86     *
     87     * @global obj $bp
     88     */
     89    function _setup_nav() {
     90        global $bp;
    12391
    124     <table class="notification-settings zebra" id="friends-notification-settings">
    125         <thead>
    126             <tr>
    127                 <th class="icon"></th>
    128                 <th class="title"><?php _e( 'Friends', 'buddypress' ) ?></th>
    129                 <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
    130                 <th class="no"><?php _e( 'No', 'buddypress' )?></th>
    131             </tr>
    132         </thead>
     92        // Add 'Friends' to the main navigation
     93        $main_nav = array(
     94            'name'                => sprintf( __( 'Friends <span>(%d)</span>', 'buddypress' ), friends_get_total_friend_count() ),
     95            'slug'                => $this->slug,
     96            'position'            => 60,
     97            'screen_function'     => 'friends_screen_my_friends',
     98            'default_subnav_slug' => 'my-friends',
     99            'item_css_id'         => $bp->friends->id
     100        );
    133101
    134         <tbody>
    135             <tr id="friends-notification-settings-request">
    136                 <td></td>
    137                 <td><?php _e( 'A member sends you a friendship request', 'buddypress' ) ?></td>
    138                 <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_request]" value="yes" <?php checked( $send_requests, 'yes', true ) ?>/></td>
    139                 <td class="no"><input type="radio" name="notifications[notification_friends_friendship_request]" value="no" <?php checked( $send_requests, 'no', true ) ?>/></td>
    140             </tr>
    141             <tr id="friends-notification-settings-accepted">
    142                 <td></td>
    143                 <td><?php _e( 'A member accepts your friendship request', 'buddypress' ) ?></td>
    144                 <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="yes" <?php checked( $accept_requests, 'yes', true ) ?>/></td>
    145                 <td class="no"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="no" <?php checked( $accept_requests, 'no', true ) ?>/></td>
    146             </tr>
     102        $friends_link = trailingslashit( $bp->loggedin_user->domain . $bp->friends->slug );
    147103
    148             <?php do_action( 'friends_screen_notification_settings' ); ?>
     104        // Add the subnav items to the friends nav item
     105        $sub_nav[] = array(
     106            'name' => __( 'My Friends', 'buddypress' ),
     107            'slug' => 'my-friends',
     108            'parent_url' => $friends_link,
     109            'parent_slug' => $bp->friends->slug,
     110            'screen_function' => 'friends_screen_my_friends',
     111            'position' => 10,
     112            'item_css_id'     => 'friends-my-friends'
     113        );
    149114
    150         </tbody>
    151     </table>
     115        $sub_nav[] = array(
     116            'name'            => __( 'Requests',   'buddypress' ),
     117            'slug'            => 'requests',
     118            'parent_url'      => $friends_link,
     119            'parent_slug'     => $bp->friends->slug,
     120            'screen_function' => 'friends_screen_requests',
     121            'position'        => 20,
     122            'user_has_access' => bp_is_my_profile()
     123        );
    152124
    153 <?php
    154 }
    155 add_action( 'bp_notification_settings', 'friends_screen_notification_settings' );
     125        parent::_setup_nav( $main_nav, $sub_nav );
     126    }
    156127
     128    /**
     129     * Sets up the title for pages and <title>
     130     *
     131     * @global obj $bp
     132     */
     133    function _setup_title() {
     134        global $bp;
    157135
    158 /********************************************************************************
    159  * Action Functions
    160  *
    161  * Action functions are exactly the same as screen functions, however they do not
    162  * have a template screen associated with them. Usually they will send the user
    163  * back to the default screen after execution.
    164  */
    165 
    166 function friends_action_add_friend() {
    167     global $bp;
    168 
    169     if ( $bp->current_component != $bp->friends->slug || $bp->current_action != 'add-friend' )
    170         return false;
    171 
    172     $potential_friend_id = $bp->action_variables[0];
    173 
    174     if ( !is_numeric( $potential_friend_id ) || !isset( $potential_friend_id ) )
    175         return false;
    176 
    177     if ( $potential_friend_id == $bp->loggedin_user->id )
    178         return false;
    179 
    180     $friendship_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id );
    181 
    182     if ( 'not_friends' == $friendship_status ) {
    183 
    184         if ( !check_admin_referer( 'friends_add_friend' ) )
    185             return false;
    186 
    187         if ( !friends_add_friend( $bp->loggedin_user->id, $potential_friend_id ) ) {
    188             bp_core_add_message( __( 'Friendship could not be requested.', 'buddypress' ), 'error' );
    189         } else {
    190             bp_core_add_message( __( 'Friendship requested', 'buddypress' ) );
     136        // Adjust title
     137        if ( bp_is_friends_component() ) {
     138            if ( bp_is_my_profile() ) {
     139                $bp->bp_options_title = __( 'My Friends', 'buddypress' );
     140            } else {
     141                $bp->bp_options_avatar = bp_core_fetch_avatar( array(
     142                    'item_id' => $bp->displayed_user->id,
     143                    'type'    => 'thumb'
     144                ) );
     145                $bp->bp_options_title   = $bp->displayed_user->fullname;
     146            }
    191147        }
    192148
    193     } else if ( 'is_friend' == $friendship_status ) {
    194         bp_core_add_message( __( 'You are already friends with this user', 'buddypress' ), 'error' );
    195     } else {
    196         bp_core_add_message( __( 'You already have a pending friendship request with this user', 'buddypress' ), 'error' );
    197     }
    198 
    199     bp_core_redirect( wp_get_referer() );
    200 
    201     return false;
    202 }
    203 add_action( 'bp_init', 'friends_action_add_friend' );
    204 
    205 function friends_action_remove_friend() {
    206     global $bp;
    207 
    208     if ( $bp->current_component != $bp->friends->slug || $bp->current_action != 'remove-friend' )
    209         return false;
    210 
    211     $potential_friend_id = $bp->action_variables[0];
    212 
    213     if ( !is_numeric( $potential_friend_id ) || !isset( $potential_friend_id ) )
    214         return false;
    215 
    216     if ( $potential_friend_id == $bp->loggedin_user->id )
    217         return false;
    218 
    219     $friendship_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id );
    220 
    221     if ( 'is_friend' == $friendship_status ) {
    222 
    223         if ( !check_admin_referer( 'friends_remove_friend' ) )
    224             return false;
    225 
    226         if ( !friends_remove_friend( $bp->loggedin_user->id, $potential_friend_id ) ) {
    227             bp_core_add_message( __( 'Friendship could not be canceled.', 'buddypress' ), 'error' );
    228         } else {
    229             bp_core_add_message( __( 'Friendship canceled', 'buddypress' ) );
    230         }
    231 
    232     } else if ( 'is_friends' == $friendship_status ) {
    233         bp_core_add_message( __( 'You are not yet friends with this user', 'buddypress' ), 'error' );
    234     } else {
    235         bp_core_add_message( __( 'You have a pending friendship request with this user', 'buddypress' ), 'error' );
    236     }
    237 
    238     bp_core_redirect( wp_get_referer() );
    239 
    240     return false;
    241 }
    242 add_action( 'bp_init', 'friends_action_remove_friend' );
    243 
    244 
    245 /********************************************************************************
    246  * Activity & Notification Functions
    247  *
    248  * These functions handle the recording, deleting and formatting of activity and
    249  * notifications for the user and for this specific component.
    250  */
    251 
    252 function friends_record_activity( $args = '' ) {
    253     global $bp;
    254 
    255     if ( !function_exists( 'bp_activity_add' ) )
    256         return false;
    257 
    258     $defaults = array (
    259         'user_id'           => $bp->loggedin_user->id,
    260         'action'            => '',
    261         'content'           => '',
    262         'primary_link'      => '',
    263         'component'         => $bp->friends->id,
    264         'type'              => false,
    265         'item_id'           => false,
    266         'secondary_item_id' => false,
    267         'recorded_time'     => bp_core_current_time(),
    268         'hide_sitewide'     => false
    269     );
    270 
    271     $r = wp_parse_args( $args, $defaults );
    272     extract( $r, EXTR_SKIP );
    273 
    274     return bp_activity_add( array( 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
    275 }
    276 
    277 function friends_delete_activity( $args ) {
    278     global $bp;
    279 
    280     if ( function_exists('bp_activity_delete_by_item_id') ) {
    281         extract( (array)$args );
    282         bp_activity_delete_by_item_id( array( 'item_id' => $item_id, 'component' => $bp->friends->id, 'type' => $type, 'user_id' => $user_id, 'secondary_item_id' => $secondary_item_id ) );
     149        parent::_setup_title();
    283150    }
    284151}
    285 
    286 function friends_register_activity_actions() {
    287     global $bp;
    288 
    289     if ( !function_exists( 'bp_activity_set_action' ) )
    290         return false;
    291 
    292     bp_activity_set_action( $bp->friends->id, 'friends_register_activity_action', __( 'New friendship created', 'buddypress' ) );
    293 
    294     do_action( 'friends_register_activity_actions' );
    295 }
    296 add_action( 'bp_register_activity_actions', 'friends_register_activity_actions' );
    297 
    298 function friends_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
    299     global $bp;
    300 
    301     switch ( $action ) {
    302         case 'friendship_accepted':
    303             if ( (int)$total_items > 1 ) {
    304                 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', 'buddypress' ), (int)$total_items ) . '</a>', (int)$total_items );
    305             } else {
    306                 $user_fullname = bp_core_get_user_displayname( $item_id );
    307                 $user_url = bp_core_get_user_domain( $item_id );
    308                 return apply_filters( 'bp_friends_single_friendship_accepted_notification', '<a href="' . $user_url . '?new" title="' . $user_fullname .'\'s profile">' . sprintf( __( '%s accepted your friendship request', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname );
    309             }
    310             break;
    311 
    312         case 'friendship_request':
    313             if ( (int)$total_items > 1 ) {
    314                 return apply_filters( 'bp_friends_multiple_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests/?new" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have %d pending friendship requests', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
    315             } else {
    316                 $user_fullname = bp_core_get_user_displayname( $item_id );
    317                 $user_url = bp_core_get_user_domain( $item_id );
    318                 return apply_filters( 'bp_friends_single_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests/?new" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have a friendship request from %s', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname );
    319             }
    320             break;
    321     }
    322 
    323     do_action( 'friends_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
    324 
    325     return false;
    326 }
    327 
    328 
    329 /********************************************************************************
    330  * Business Functions
    331  *
    332  * Business functions are where all the magic happens in BuddyPress. They will
    333  * handle the actual saving or manipulation of information. Usually they will
    334  * hand off to a database class for data access, then return
    335  * true or false on success or failure.
    336  */
    337 
    338 function friends_add_friend( $initiator_userid, $friend_userid, $force_accept = false ) {
    339     global $bp;
    340 
    341     $friendship = new BP_Friends_Friendship;
    342 
    343     if ( (int)$friendship->is_confirmed )
    344         return true;
    345 
    346     $friendship->initiator_user_id = $initiator_userid;
    347     $friendship->friend_user_id    = $friend_userid;
    348     $friendship->is_confirmed      = 0;
    349     $friendship->is_limited        = 0;
    350     $friendship->date_created      = bp_core_current_time();
    351 
    352     if ( $force_accept )
    353         $friendship->is_confirmed = 1;
    354 
    355     if ( $friendship->save() ) {
    356 
    357         if ( !$force_accept ) {
    358             // Add the on screen notification
    359             bp_users_add_notification( $friendship->initiator_user_id, $friendship->friend_user_id, $bp->friends->id, 'friendship_request' );
    360 
    361             // Send the email notification
    362             require_once( BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php' );
    363             friends_notification_new_request( $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
    364 
    365             do_action( 'friends_friendship_requested', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
    366         } else {
    367             do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
    368         }
    369 
    370         return true;
    371     }
    372 
    373     return false;
    374 }
    375 
    376 function friends_remove_friend( $initiator_userid, $friend_userid ) {
    377     global $bp;
    378 
    379     $friendship_id = BP_Friends_Friendship::get_friendship_id( $initiator_userid, $friend_userid );
    380     $friendship    = new BP_Friends_Friendship( $friendship_id );
    381 
    382     do_action( 'friends_before_friendship_delete', $friendship_id, $initiator_userid, $friend_userid );
    383 
    384     // Remove the activity stream item for the user who canceled the friendship
    385     friends_delete_activity( array( 'item_id' => $friendship_id, 'type' => 'friendship_accepted', 'user_id' => $bp->displayed_user->id ) );
    386 
    387     do_action( 'friends_friendship_deleted', $friendship_id, $initiator_userid, $friend_userid );
    388 
    389     if ( $friendship->delete() ) {
    390         friends_update_friend_totals( $initiator_userid, $friend_userid, 'remove' );
    391 
    392         return true;
    393     }
    394 
    395     return false;
    396 }
    397 
    398 function friends_accept_friendship( $friendship_id ) {
    399     global $bp;
    400 
    401     $friendship = new BP_Friends_Friendship( $friendship_id, true, false );
    402 
    403     if ( !$friendship->is_confirmed && BP_Friends_Friendship::accept( $friendship_id ) ) {
    404         friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id );
    405 
    406         // Remove the friend request notice
    407         bp_users_delete_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' );
    408 
    409         // Add a friend accepted notice for the initiating user
    410         bp_users_add_notification( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_accepted' );
    411 
    412         $initiator_link = bp_core_get_userlink( $friendship->initiator_user_id );
    413         $friend_link = bp_core_get_userlink( $friendship->friend_user_id );
    414 
    415         // Record in activity streams for the initiator
    416         friends_record_activity( array(
    417             'user_id'           => $friendship->initiator_user_id,
    418             'type'              => 'friendship_created',
    419             'action'            => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%1$s and %2$s are now friends', 'buddypress' ), $initiator_link, $friend_link ), $friendship ),
    420             'item_id'           => $friendship_id,
    421             'secondary_item_id' => $friendship->friend_user_id
    422         ) );
    423 
    424         // Record in activity streams for the friend
    425         friends_record_activity( array(
    426             'user_id'           => $friendship->friend_user_id,
    427             'type'              => 'friendship_created',
    428             'action'            => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%1$s and %2$s are now friends', 'buddypress' ), $friend_link, $initiator_link ), $friendship ),
    429             'item_id'           => $friendship_id,
    430             'secondary_item_id' => $friendship->initiator_user_id,
    431             'hide_sitewide'     => true // We've already got the first entry site wide
    432         ) );
    433 
    434         // Send the email notification
    435         require_once( BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php' );
    436         friends_notification_accepted_request( $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
    437 
    438         do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
    439 
    440         return true;
    441     }
    442 
    443     return false;
    444 }
    445 
    446 function friends_reject_friendship( $friendship_id ) {
    447     $friendship = new BP_Friends_Friendship( $friendship_id, true, false );
    448 
    449     if ( !$friendship->is_confirmed && BP_Friends_Friendship::reject( $friendship_id ) ) {
    450         // Remove the friend request notice
    451         bp_users_delete_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' );
    452 
    453         do_action_ref_array( 'friends_friendship_rejected', array( $friendship_id, &$friendship ) );
    454         return true;
    455     }
    456 
    457     return false;
    458 }
    459 
    460 function friends_check_friendship( $user_id, $possible_friend_id ) {
    461     global $bp;
    462 
    463     if ( 'is_friend' == BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id ) )
    464         return true;
    465 
    466     return false;
    467 }
    468 
    469 // Returns - 'is_friend', 'not_friends', 'pending'
    470 function friends_check_friendship_status( $user_id, $possible_friend_id ) {
    471     return BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id );
    472 }
    473 
    474 function friends_get_total_friend_count( $user_id = 0 ) {
    475     global $bp;
    476 
    477     if ( !$user_id )
    478         $user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id;
    479 
    480     if ( !$count = wp_cache_get( 'bp_total_friend_count_' . $user_id, 'bp' ) ) {
    481         $count = get_user_meta( $user_id, 'total_friend_count', true );
    482         if ( empty( $count ) ) $count = 0;
    483         wp_cache_set( 'bp_total_friend_count_' . $user_id, $count, 'bp' );
    484     }
    485 
    486     return apply_filters( 'friends_get_total_friend_count', $count );
    487 }
    488 
    489 function friends_check_user_has_friends( $user_id ) {
    490     $friend_count = friends_get_total_friend_count( $user_id );
    491 
    492     if ( empty( $friend_count ) )
    493         return false;
    494 
    495     if ( !(int)$friend_count )
    496         return false;
    497 
    498     return true;
    499 }
    500 
    501 function friends_get_friendship_id( $initiator_user_id, $friend_user_id ) {
    502     return BP_Friends_Friendship::get_friendship_id( $initiator_user_id, $friend_user_id );
    503 }
    504 
    505 function friends_get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false, $filter = false ) {
    506     return BP_Friends_Friendship::get_friend_user_ids( $user_id, $friend_requests_only, $assoc_arr, $filter );
    507 }
    508 
    509 function friends_search_friends( $search_terms, $user_id, $pag_num = 10, $pag_page = 1 ) {
    510     return BP_Friends_Friendship::search_friends( $search_terms, $user_id, $pag_num, $pag_page );
    511 }
    512 
    513 function friends_get_friendship_request_user_ids( $user_id ) {
    514     return BP_Friends_Friendship::get_friendship_request_user_ids( $user_id );
    515 }
    516 
    517 function friends_get_recently_active( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
    518     return apply_filters( 'friends_get_recently_active', BP_Core_User::get_users( 'active', $per_page, $page, $user_id, $filter ) );
    519 }
    520 
    521 function friends_get_alphabetically( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
    522     return apply_filters( 'friends_get_alphabetically', BP_Core_User::get_users( 'alphabetical', $per_page, $page, $user_id, $filter ) );
    523 }
    524 
    525 function friends_get_newest( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
    526     return apply_filters( 'friends_get_newest', BP_Core_User::get_users( 'newest', $per_page, $page, $user_id, $filter ) );
    527 }
    528 
    529 function friends_get_bulk_last_active( $friend_ids ) {
    530     return BP_Friends_Friendship::get_bulk_last_active( $friend_ids );
    531 }
    532 
    533 function friends_get_friends_invite_list( $user_id = 0 ) {
    534     global $bp;
    535 
    536     if ( !$user_id )
    537         $user_id = $bp->loggedin_user->id;
    538 
    539     if ( bp_has_members( 'user_id=' . $user_id . '&type=alphabetical&per_page=0' ) ) {
    540         while ( bp_members() ) : bp_the_member();
    541             $friends[] = array(
    542                 'id' => bp_get_member_user_id(),
    543                 'full_name' => bp_get_member_name()
    544             );
    545         endwhile;
    546     }
    547 
    548     if ( empty($friends) )
    549         return false;
    550 
    551     return $friends;
    552 }
    553 
    554 function friends_count_invitable_friends( $user_id, $group_id ) {
    555     return BP_Friends_Friendship::get_invitable_friend_count( $user_id, $group_id );
    556 }
    557 
    558 function friends_get_friend_count_for_user( $user_id ) {
    559     return BP_Friends_Friendship::total_friend_count( $user_id );
    560 }
    561 
    562 function friends_search_users( $search_terms, $user_id, $pag_num = 0, $pag_page = 0 ) {
    563     global $bp;
    564 
    565     $user_ids = BP_Friends_Friendship::search_users( $search_terms, $user_id, $pag_num, $pag_page );
    566 
    567     if ( !$user_ids )
    568         return false;
    569 
    570     for ( $i = 0; $i < count( $user_ids ); $i++  )
    571         $users[] = new BP_Core_User($user_ids[$i]);
    572 
    573     return array( 'users' => $users, 'count' => BP_Friends_Friendship::search_users_count( $search_terms ) );
    574 }
    575 
    576 function friends_is_friendship_confirmed( $friendship_id ) {
    577     $friendship = new BP_Friends_Friendship( $friendship_id );
    578     return $friendship->is_confirmed;
    579 }
    580 
    581 function friends_update_friend_totals( $initiator_user_id, $friend_user_id, $status = 'add' ) {
    582     if ( 'add' == $status ) {
    583         update_user_meta( $initiator_user_id, 'total_friend_count', (int)get_user_meta( $initiator_user_id, 'total_friend_count', true ) + 1 );
    584         update_user_meta( $friend_user_id, 'total_friend_count', (int)get_user_meta( $friend_user_id, 'total_friend_count', true ) + 1 );
    585     } else {
    586         update_user_meta( $initiator_user_id, 'total_friend_count', (int)get_user_meta( $initiator_user_id, 'total_friend_count', true ) - 1 );
    587         update_user_meta( $friend_user_id, 'total_friend_count', (int)get_user_meta( $friend_user_id, 'total_friend_count', true ) - 1 );
    588     }
    589 }
    590 
    591 function friends_remove_data( $user_id ) {
    592     global $bp;
    593 
    594     do_action( 'friends_before_remove_data', $user_id );
    595 
    596     BP_Friends_Friendship::delete_all_for_user($user_id);
    597 
    598     // Remove usermeta
    599     delete_user_meta( $user_id, 'total_friend_count' );
    600 
    601     // Remove friendship requests FROM user
    602     bp_users_delete_notifications_from_user( $user_id, $bp->friends->id, 'friendship_request' );
    603 
    604     do_action( 'friends_remove_data', $user_id );
    605 }
    606 add_action( 'wpmu_delete_user',  'friends_remove_data' );
    607 add_action( 'delete_user',       'friends_remove_data' );
    608 add_action( 'bp_make_spam_user', 'friends_remove_data' );
    609 
    610 
    611 /********************************************************************************
    612  * Caching
    613  *
    614  * Caching functions handle the clearing of cached objects and pages on specific
    615  * actions throughout BuddyPress.
    616  */
    617 
    618 function friends_clear_friend_object_cache( $friendship_id ) {
    619     if ( !$friendship = new BP_Friends_Friendship( $friendship_id ) )
    620         return false;
    621 
    622     wp_cache_delete( 'friends_friend_ids_' .    $friendship->initiator_user_id, 'bp' );
    623     wp_cache_delete( 'friends_friend_ids_' .    $friendship->friend_user_id,    'bp' );
    624     wp_cache_delete( 'bp_total_friend_count_' . $friendship->initiator_user_id, 'bp' );
    625     wp_cache_delete( 'bp_total_friend_count_' . $friendship->friend_user_id,    'bp' );
    626 }
    627 
    628 function friends_clear_friend_notifications() {
    629     global $bp;
    630 
    631     if ( isset( $_GET['new'] ) )
    632         bp_users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->friends->id, 'friendship_accepted' );
    633 }
    634 add_action( 'bp_activity_screen_my_activity', 'friends_clear_friend_notifications' );
    635 
    636 // List actions to clear object caches on
    637 add_action( 'friends_friendship_accepted', 'friends_clear_friend_object_cache' );
    638 add_action( 'friends_friendship_deleted',  'friends_clear_friend_object_cache' );
    639 
    640 // List actions to clear super cached pages on, if super cache is installed
    641 add_action( 'friends_friendship_rejected',  'bp_core_clear_cache' );
    642 add_action( 'friends_friendship_accepted',  'bp_core_clear_cache' );
    643 add_action( 'friends_friendship_deleted',   'bp_core_clear_cache' );
    644 add_action( 'friends_friendship_requested', 'bp_core_clear_cache' );
     152// Create the friends component
     153$bp->friends = new BP_Friends_Component();
    645154
    646155?>
  • trunk/bp-groups/bp-groups-actions.php

    r3845 r3917  
    182182    bp_core_load_template( apply_filters( 'groups_template_create_group', 'groups/create' ) );
    183183}
    184 add_action( 'wp', 'groups_action_create_group', 3 );
     184add_action( 'bp_actions', 'groups_action_create_group' );
    185185
    186186function groups_action_join_group() {
     
    216216    bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
    217217}
    218 add_action( 'wp', 'groups_action_join_group', 3 );
     218add_action( 'bp_actions', 'groups_action_join_group' );
    219219
    220220
     
    241241    bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
    242242}
    243 add_action( 'wp', 'groups_action_leave_group', 3 );
     243add_action( 'bp_actions', 'groups_action_leave_group' );
    244244
    245245
     
    277277    }
    278278}
    279 add_action( 'wp', 'groups_action_redirect_to_random_group', 6 );
     279add_action( 'bp_actions', 'groups_action_redirect_to_random_group' );
    280280
    281281function groups_action_group_feed() {
     
    296296    die;
    297297}
    298 add_action( 'wp', 'groups_action_group_feed', 3 );
     298add_action( 'bp_actions', 'groups_action_group_feed' );
    299299
    300300?>
  • trunk/bp-groups/bp-groups-classes.php

    r3905 r3917  
    10201020            $exclude_sql = $wpdb->prepare( " AND m.user_id NOT IN ({$exclude})" );
    10211021
    1022         if ( bp_is_active( 'profile' ) )
     1022        if ( bp_is_active( 'xprofile' ) )
    10231023            $members = $wpdb->get_results( $wpdb->prepare( "SELECT m.user_id, m.date_modified, m.is_banned, u.user_login, u.user_nicename, u.user_email, pd.value as display_name FROM {$bp->groups->table_name_members} m, {$wpdb->users} u, {$bp->profile->table_name_data} pd WHERE u.ID = m.user_id AND u.ID = pd.user_id AND pd.field_id = 1 AND group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_admins_sql} {$exclude_sql} ORDER BY m.date_modified DESC {$pag_sql}", $group_id ) );
    10241024        else
  • trunk/bp-groups/bp-groups-functions.php

    r3903 r3917  
    77 * true or false on success or failure.
    88 */
    9 
    10 function groups_directory_groups_setup() {
    11     global $bp;
    12 
    13     if ( bp_is_current_component( 'groups' ) && !bp_current_action() && !bp_current_item() ) {
    14         $bp->is_directory = true;
    15 
    16         do_action( 'groups_directory_groups_setup' );
    17 
    18         bp_core_load_template( apply_filters( 'groups_template_directory_groups', 'groups/index' ) );
    19     }
    20 }
    21 add_action( 'wp', 'groups_directory_groups_setup', 2 );
    229
    2310function groups_setup_adminbar_menu() {
     
    218205
    219206    // Remove all notifications for any user belonging to this group
    220     bp_users_delete_all_notifications_by_type( $group_id, $bp->groups->slug );
     207    bp_members_delete_all_notifications_by_type( $group_id, $bp->groups->slug );
    221208
    222209    // Remove forum if component is active and current group has one
     
    608595    groups_update_groupmeta( $group_id, 'last_activity', bp_core_current_time() );
    609596
    610     bp_users_delete_notifications_by_item_id( $user_id, $group_id, $bp->groups->id, 'group_invite' );
     597    bp_members_delete_notifications_by_item_id( $user_id, $group_id, $bp->groups->id, 'group_invite' );
    611598
    612599    do_action( 'groups_accept_invite', $user_id, $group_id );
     
    629616
    630617    if ( $delete )
    631         bp_users_delete_notifications_by_item_id( $user_id, $group_id, $bp->groups->id, 'group_invite' );
     618        bp_members_delete_notifications_by_item_id( $user_id, $group_id, $bp->groups->id, 'group_invite' );
    632619
    633620    return $delete;
  • trunk/bp-groups/bp-groups-loader.php

    r3858 r3917  
    2121     */
    2222    function BP_Groups_Component() {
    23         parent::start( 'groups', __( 'User Groups', 'buddypress' ) );
     23        parent::start(
     24            'groups',
     25            __( 'User Groups', 'buddypress' ),
     26            BP_PLUGIN_DIR
     27        );
     28    }
     29
     30    /**
     31     * Include files
     32     */
     33    function _includes() {
     34        $includes = array(
     35            'cache',
     36            'forums',
     37            'actions',
     38            'filters',
     39            'screens',
     40            'classes',
     41            'widgets',
     42            'activity',
     43            'template',
     44            'functions'
     45        );
     46        parent::_includes( $includes );
    2447    }
    2548
     
    4063            define( 'BP_GROUPS_SLUG', $this->id );
    4164
    42         // Do some slug checks
    43         $this->slug      = BP_GROUPS_SLUG;
    44         $this->root_slug = isset( $bp->pages->groups->slug ) ? $bp->pages->groups->slug : $this->slug;
    45 
    46         // Tables
    47         $this->table_name            = $bp->table_prefix . 'bp_groups';
    48         $this->table_name_members    = $bp->table_prefix . 'bp_groups_members';
    49         $this->table_name_groupmeta  = $bp->table_prefix . 'bp_groups_groupmeta';
    50 
    51         // Notifications
    52         $this->notification_callback = 'groups_format_notifications';
     65        // Global tables for messaging component
     66        $global_tables = array(
     67            'table_name'           => $bp->table_prefix . 'bp_groups',
     68            'table_name_members'   => $bp->table_prefix . 'bp_groups_members',
     69            'table_name_groupmeta' => $bp->table_prefix . 'bp_groups_groupmeta'
     70        );
     71
     72        // All globals for messaging component.
     73        // Note that global_tables is included in this array.
     74        $globals = array(
     75            'slug'                  => BP_GROUPS_SLUG,
     76            'root_slug'             => isset( $bp->pages->groups->slug ) ? $bp->pages->groups->slug : BP_GROUPS_SLUG,
     77            'notification_callback' => 'groups_format_notifications',
     78            'search_string'         => __( 'Search Groups...', 'buddypress' ),
     79            'global_tables'         => $global_tables,
     80        );
     81
     82        parent::_setup_globals( $globals );
     83
     84        /** Single Group Globals **********************************************/
     85
     86        // Are we viewing a single group?
     87        if ( bp_is_groups_component() && $group_id = BP_Groups_Group::group_exists( bp_current_action() ) ) {
     88
     89            $bp->is_single_item  = true;
     90            $this->current_group = new BP_Groups_Group( $group_id );
     91
     92            // When in a single group, the first action is bumped down one because of the
     93            // group name, so we need to adjust this and set the group name to current_item.
     94            $bp->current_item   = isset( $bp->current_action )      ? $bp->current_action      : false;
     95            $bp->current_action = isset( $bp->action_variables[0] ) ? $bp->action_variables[0] : false;
     96            array_shift( $bp->action_variables );
     97
     98            // Using "item" not "group" for generic support in other components.
     99            if ( is_super_admin() )
     100                $bp->is_item_admin = 1;
     101            else
     102                $bp->is_item_admin = groups_is_user_admin( $bp->loggedin_user->id, $this->current_group->id );
     103
     104            // If the user is not an admin, check if they are a moderator
     105            if ( empty( $bp->is_item_admin ) )
     106                $bp->is_item_mod = groups_is_user_mod( $bp->loggedin_user->id, $this->current_group->id );
     107
     108            // Is the logged in user a member of the group?
     109            if ( ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $this->current_group->id ) ) )
     110                $this->current_group->is_user_member = true;
     111            else
     112                $this->current_group->is_user_member = false;
     113
     114            // Should this group be visible to the logged in user?
     115            if ( 'public' == $this->current_group->status || $this->current_group->is_user_member )
     116                $this->current_group->is_visible = true;
     117            else
     118                $this->current_group->is_visible = false;
     119
     120            // If this is a private or hidden group, does the user have access?
     121            if ( 'private' == $this->current_group->status || 'hidden' == $this->current_group->status ) {
     122                if ( $this->current_group->is_user_member && is_user_logged_in() || is_super_admin() )
     123                    $this->current_group->user_has_access = true;
     124                else
     125                    $this->current_group->user_has_access = false;
     126            } else {
     127                $this->current_group->user_has_access = true;
     128            }
     129
     130        // Set current_group to 0 to prevent debug errors
     131        } else {
     132            $this->current_group = 0;
     133        }
    53134
    54135        // Illegal group names/slugs
    55         $this->forbidden_names       = apply_filters( 'groups_forbidden_names', array(
     136        $this->forbidden_names = apply_filters( 'groups_forbidden_names', array(
    56137            'my-groups',
    57138            'create',
     
    70151        ) );
    71152
    72         // The default text for the blogs directory search box
    73         $bp->default_search_strings[$this->id] = __( 'Search Groups...', 'buddypress' );
    74 
    75153        // Preconfigured group creation steps
    76154        $this->group_creation_steps = apply_filters( 'groups_create_group_steps', array(
     
    104182
    105183        // Auto join group when non group member performs group activity
    106         $this->auto_join = defined( 'BP_DISABLE_AUTO_GROUP_JOIN' ) ? false : true;
    107 
    108         // The default text for the groups directory search box
    109         $this->default_search_string = __( 'Search Groups...', 'buddypress' );
    110 
    111         // Register this in the active components array
    112         $bp->active_components[$this->id] = $this->id;
    113     }
    114 
    115     /**
    116      * Include files
    117      */
    118     function _includes() {
    119         require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-cache.php'     );
    120         require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-forums.php'    );
    121         require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-actions.php'   );
    122         require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-filters.php'   );
    123         require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-screens.php'   );
    124         require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-classes.php'   );
    125         require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-widgets.php'   );
    126         require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-activity.php'  );
    127         require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-template.php'  );
    128         require_once( BP_PLUGIN_DIR . '/bp-groups/bp-groups-functions.php' );
     184        $this->auto_join = defined( 'BP_DISABLE_AUTO_GROUP_JOIN' );
    129185    }
    130186
     
    137193        global $bp;
    138194
    139         // Are we viewing a single group?
    140         if ( bp_is_current_component( 'groups' ) && $group_id = BP_Groups_Group::group_exists( bp_current_action() ) ) {
    141 
    142             $bp->is_single_item  = true;
    143             $this->current_group = new BP_Groups_Group( $group_id );
    144 
    145             // Using "item" not "group" for generic support in other components.
    146             if ( is_super_admin() )
    147                 $bp->is_item_admin = 1;
    148             else
    149                 $bp->is_item_admin = groups_is_user_admin( $bp->loggedin_user->id, $this->current_group->id );
    150 
    151             // If the user is not an admin, check if they are a moderator
    152             if ( empty( $bp->is_item_admin ) )
    153                 $bp->is_item_mod = groups_is_user_mod( $bp->loggedin_user->id, $this->current_group->id );
    154 
    155             // Is the logged in user a member of the group?
    156             if ( ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $this->current_group->id ) ) )
    157                 $this->current_group->is_user_member = true;
    158             else
    159                 $this->current_group->is_user_member = false;
    160 
    161             // Should this group be visible to the logged in user?
    162             if ( 'public' == $this->current_group->status || $this->current_group->is_user_member )
    163                 $this->current_group->is_visible = true;
    164             else
    165                 $this->current_group->is_visible = false;
    166 
    167         // Set current_group to 0 to prevent debug errors
    168         } else {
    169             $this->current_group = 0;
    170         }
    171 
    172195        // Add 'Groups' to the main navigation
    173         bp_core_new_nav_item( array(
     196        $main_nav = array(
    174197            'name'                => sprintf( __( 'Groups <span>(%d)</span>', 'buddypress' ), groups_total_groups_for_user() ),
    175198            'slug'                => $this->slug,
     
    178201            'default_subnav_slug' => 'my-groups',
    179202            'item_css_id'         => $this->id
    180         ) );
     203        );
    181204
    182205        $groups_link = trailingslashit( $bp->loggedin_user->domain . $this->slug );
    183206
    184207        // Add the My Groups nav item
    185         bp_core_new_subnav_item( array(
     208        $sub_nav[] = array(
    186209            'name'            => __( 'My Groups', 'buddypress' ),
    187210            'slug'            => 'my-groups',
     
    191214            'position'        => 10,
    192215            'item_css_id'     => 'groups-my-groups'
    193         ) );
     216        );
    194217
    195218        // Add the Group Invites nav item
    196         bp_core_new_subnav_item( array(
     219        $sub_nav[] = array(
    197220            'name'            => __( 'Invitations',   'buddypress' ),
    198221            'slug'            => 'invites',
     
    202225            'position'        => 30,
    203226            'user_has_access' => bp_is_my_profile()
    204         ) );
    205 
    206 
    207         if ( bp_is_current_component( 'groups' ) ) {
     227        );
     228
     229        parent::_setup_nav( $main_nav, $sub_nav );
     230
     231        if ( bp_is_groups_component() ) {
     232            if ( bp_is_single_item() ) {
     233
     234                // Add 'Groups' to the main navigation
     235                $main_nav = array(
     236                    'name'                => __( 'Groups', 'buddypress' ),
     237                    'slug'                => $this->root_slug,
     238                    'position'            => -1, // Do not show in BuddyBar
     239                    'screen_function'     => 'groups_screen_group_home',
     240                    'default_subnav_slug' => 'home',
     241                    'item_css_id'         => $this->id
     242                );
     243
     244                $group_link = trailingslashit( $bp->root_domain . '/' . $this->root_slug . '/' . $this->current_group->slug );
     245
     246                // Add the "Home" subnav item, as this will always be present
     247                $sub_nav[] = array(
     248                    'name'            => __( 'Home', 'buddypress' ),
     249                    'slug'            => 'home',
     250                    'parent_url'      => $group_link,
     251                    'parent_slug'     => $this->root_slug,
     252                    'screen_function' => 'groups_screen_group_home',
     253                    'position'        => 10,
     254                    'item_css_id'     => 'home'
     255                );
     256
     257                // If the user is a group mod or more, then show the group admin nav item
     258                if ( bp_is_item_admin() || bp_is_item_mod() ) {
     259                    $sub_nav[] = array(
     260                        'name'            => __( 'Admin', 'buddypress' ),
     261                        'slug'            => 'admin',
     262                        'parent_url'      => $group_link,
     263                        'parent_slug'     => $this->root_slug,
     264                        'screen_function' => 'groups_screen_group_admin',
     265                        'position'        => 20,
     266                        'user_has_access' => ( $bp->is_item_admin + (int)$bp->is_item_mod ),
     267                        'item_css_id'     => 'admin'
     268                    );
     269                }
     270
     271                // If this is a private group, and the user is not a member, show a "Request Membership" nav item.
     272                if ( is_user_logged_in() &&
     273                     !is_super_admin() &&
     274                     !$this->current_group->is_user_member &&
     275                     !groups_check_for_membership_request( $bp->loggedin_user->id, $this->current_group->id ) &&
     276                     $this->current_group->status == 'private'
     277                    ) {
     278                    $sub_nav[] = array(
     279                        'name'               => __( 'Request Membership', 'buddypress' ),
     280                        'slug'               => 'request-membership',
     281                        'parent_url'         => $group_link,
     282                        'parent_slug'        => $this->root_slug,
     283                        'screen_function'    => 'groups_screen_group_request_membership',
     284                        'position'           => 30
     285                    );
     286                }
     287
     288                // Forums are enabled and turned on
     289                if ( $this->current_group->enable_forum && bp_is_active( 'forums' ) ) {
     290                    $sub_nav[] = array(
     291                        'name'            => __( 'Forum', 'buddypress' ),
     292                        'slug'            => 'forum',
     293                        'parent_url'      => $group_link,
     294                        'parent_slug'     => $this->root_slug,
     295                        'screen_function' => 'groups_screen_group_forum',
     296                        'position'        => 40,
     297                        'user_has_access' => $this->current_group->user_has_access,
     298                        'item_css_id'     => 'forums'
     299                    );
     300                }
     301
     302                $sub_nav[] = array(
     303                    'name'            => sprintf( __( 'Members (%s)', 'buddypress' ), number_format( $this->current_group->total_member_count ) ),
     304                    'slug'            => 'members',
     305                    'parent_url'      => $group_link,
     306                    'parent_slug'     => $this->root_slug,
     307                    'screen_function' => 'groups_screen_group_members',
     308                    'position'        => 60,
     309                    'user_has_access' => $this->current_group->user_has_access,
     310                    'item_css_id'     => 'members'
     311                );
     312
     313                if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $this->current_group->id ) ) {
     314                    if ( bp_is_active( 'friends' ) ) {
     315                        $sub_nav[] = array(
     316                            'name'            => __( 'Send Invites', 'buddypress' ),
     317                            'slug'            => 'send-invites',
     318                            'parent_url'      => $group_link,
     319                            'parent_slug'     => $this->root_slug,
     320                            'screen_function' => 'groups_screen_group_invite',
     321                            'item_css_id'     => 'invite',
     322                            'position'        => 70,
     323                            'user_has_access' => $this->current_group->user_has_access
     324                        );
     325                    }
     326                }
     327
     328                parent::_setup_nav( $main_nav, $sub_nav );
     329            }
     330        }
     331
     332        if ( isset( $this->current_group->user_has_access ) )
     333            do_action( 'groups_setup_nav', $this->current_group->user_has_access );
     334        else
     335            do_action( 'groups_setup_nav');
     336    }
     337
     338    /**
     339     * Sets up the title for pages and <title>
     340     *
     341     * @global obj $bp
     342     */
     343    function _setup_title() {
     344        global $bp;
     345
     346        if ( bp_is_groups_component() ) {
    208347
    209348            if ( bp_is_my_profile() && !bp_is_single_item() ) {
     
    211350                $bp->bp_options_title = __( 'My Groups', 'buddypress' );
    212351
    213             } else if ( !bp_is_my_profile() && !$bp->is_single_item ) {
     352            } else if ( !bp_is_my_profile() && !bp_is_single_item() ) {
    214353
    215354                $bp->bp_options_avatar = bp_core_fetch_avatar( array(
     
    222361            // group navigation menu using the $this->current_group global.
    223362            } else if ( bp_is_single_item() ) {
    224                 // When in a single group, the first action is bumped down one because of the
    225                 // group name, so we need to adjust this and set the group name to current_item.
    226                 $bp->current_item   = isset( $bp->current_action )      ? $bp->current_action      : false;
    227                 $bp->current_action = isset( $bp->action_variables[0] ) ? $bp->action_variables[0] : false;
    228                 array_shift( $bp->action_variables );
    229 
    230363                $bp->bp_options_title  = $this->current_group->name;
    231364                $bp->bp_options_avatar = bp_core_fetch_avatar( array(
     
    238371                if ( empty( $bp->bp_options_avatar ) )
    239372                    $bp->bp_options_avatar = '<img src="' . esc_attr( $group->avatar_full ) . '" class="avatar" alt="' . esc_attr( $group->name ) . '" />';
    240 
    241                 // Add 'Groups' to the main navigation
    242                 bp_core_new_nav_item( array(
    243                     'name'                => __( 'Groups', 'buddypress' ),
    244                     'slug'                => $this->root_slug,
    245                     'position'            => -1, // Do not show in BuddyBar
    246                     'screen_function'     => 'groups_screen_group_home',
    247                     'default_subnav_slug' => 'home',
    248                     'item_css_id'         => $this->id
    249                 ) );
    250 
    251                 $group_link = trailingslashit( $bp->root_domain . '/' . $this->root_slug . '/' . $this->current_group->slug );
    252 
    253                 // If this is a private or hidden group, does the user have access?
    254                 if ( 'private' == $this->current_group->status || 'hidden' == $this->current_group->status ) {
    255                     if ( $this->current_group->is_user_member && is_user_logged_in() || is_super_admin() )
    256                         $this->current_group->user_has_access = true;
    257                     else
    258                         $this->current_group->user_has_access = false;
    259                 } else {
    260                     $this->current_group->user_has_access = true;
    261                 }
    262 
    263                 // Add the "Home" subnav item, as this will always be present
    264                 bp_core_new_subnav_item( array(
    265                     'name'            => __( 'Home', 'buddypress' ),
    266                     'slug'            => 'home',
    267                     'parent_url'      => $group_link,
    268                     'parent_slug'     => $this->root_slug,
    269                     'screen_function' => 'groups_screen_group_home',
    270                     'position'        => 10,
    271                     'item_css_id'     => 'home'
    272                 ) );
    273 
    274                 // If the user is a group mod or more, then show the group admin nav item
    275                 if ( bp_is_item_admin() || bp_is_item_mod() ) {
    276                     bp_core_new_subnav_item( array(
    277                         'name'            => __( 'Admin', 'buddypress' ),
    278                         'slug'            => 'admin',
    279                         'parent_url'      => $group_link,
    280                         'parent_slug'     => $this->root_slug,
    281                         'screen_function' => 'groups_screen_group_admin',
    282                         'position'        => 20,
    283                         'user_has_access' => ( $bp->is_item_admin + (int)$bp->is_item_mod ),
    284                         'item_css_id'     => 'admin'
    285                     ) );
    286                 }
    287 
    288                 // If this is a private group, and the user is not a member, show a "Request Membership" nav item.
    289                 if ( is_user_logged_in() &&
    290                      !is_super_admin() &&
    291                      !$this->current_group->is_user_member &&
    292                      !groups_check_for_membership_request( $bp->loggedin_user->id, $this->current_group->id ) &&
    293                      $this->current_group->status == 'private'
    294                     ) {
    295                     bp_core_new_subnav_item( array(
    296                         'name'               => __( 'Request Membership', 'buddypress' ),
    297                         'slug'               => 'request-membership',
    298                         'parent_url'         => $group_link,
    299                         'parent_slug'        => $this->root_slug,
    300                         'screen_function'    => 'groups_screen_group_request_membership',
    301                         'position'           => 30
    302                     ) );
    303                 }
    304 
    305                 // Forums are enabled and turned on
    306                 if ( $this->current_group->enable_forum && bp_is_active( 'forums' ) ) {
    307                     bp_core_new_subnav_item( array(
    308                         'name'            => __( 'Forum', 'buddypress' ),
    309                         'slug'            => 'forum',
    310                         'parent_url'      => $group_link,
    311                         'parent_slug'     => $this->root_slug,
    312                         'screen_function' => 'groups_screen_group_forum',
    313                         'position'        => 40,
    314                         'user_has_access' => $this->current_group->user_has_access,
    315                         'item_css_id'     => 'forums'
    316                     ) );
    317                 }
    318 
    319                 bp_core_new_subnav_item( array(
    320                     'name'            => sprintf( __( 'Members (%s)', 'buddypress' ), number_format( $this->current_group->total_member_count ) ),
    321                     'slug'            => 'members',
    322                     'parent_url'      => $group_link,
    323                     'parent_slug'     => $this->root_slug,
    324                     'screen_function' => 'groups_screen_group_members',
    325                     'position'        => 60,
    326                     'user_has_access' => $this->current_group->user_has_access,
    327                     'item_css_id'     => 'members'
    328                 ) );
    329 
    330                 if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $this->current_group->id ) ) {
    331                     if ( bp_is_active( 'friends' ) ) {
    332                         bp_core_new_subnav_item( array(
    333                             'name'            => __( 'Send Invites', 'buddypress' ),
    334                             'slug'            => 'send-invites',
    335                             'parent_url'      => $group_link,
    336                             'parent_slug'     => $this->root_slug,
    337                             'screen_function' => 'groups_screen_group_invite',
    338                             'item_css_id'     => 'invite',
    339                             'position'        => 70,
    340                             'user_has_access' => $this->current_group->user_has_access
    341                         ) );
    342                     }
    343                 }
    344373            }
    345374        }
    346375
    347         if ( isset( $this->current_group->user_has_access ) )
    348             do_action( 'groups_setup_nav', $this->current_group->user_has_access );
    349         else
    350             do_action( 'groups_setup_nav');
     376        parent::_setup_title();
    351377    }
    352378}
  • trunk/bp-groups/bp-groups-notifications.php

    r3903 r3917  
    4646    global $bp;
    4747
    48     bp_users_add_notification( $requesting_user_id, $admin_id, 'groups', 'new_membership_request', $group_id );
     48    bp_members_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_users_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_accepted' );
     98        bp_members_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_accepted' );
    9999    else
    100         bp_users_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_rejected' );
     100        bp_members_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_users_add_notification( $group_id, $user_id, 'groups', $type );
     161    bp_members_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_users_add_notification( $group->id, $invited_user_id, 'groups', 'group_invite' );
     211        bp_members_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-screens.php

    r3910 r3917  
    99 */
    1010
     11function groups_directory_groups_setup() {
     12    global $bp;
     13
     14    if ( bp_is_groups_component() && !bp_current_action() && !bp_current_item() ) {
     15        $bp->is_directory = true;
     16
     17        do_action( 'groups_directory_groups_setup' );
     18
     19        bp_core_load_template( apply_filters( 'groups_template_directory_groups', 'groups/index' ) );
     20    }
     21}
     22add_action( 'bp_screens', 'groups_directory_groups_setup', 2 );
     23
    1124function groups_screen_my_groups() {
    1225    global $bp;
     
    1427    // Delete group request notifications for the user
    1528    if ( isset( $_GET['n'] ) ) {
    16         bp_users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_accepted' );
    17         bp_users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_rejected' );
    18         bp_users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_mod'      );
    19         bp_users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_admin'    );
     29        bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_accepted' );
     30        bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_rejected' );
     31        bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_mod'      );
     32        bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_admin'    );
    2033    }
    2134
     
    6881
    6982    // Remove notifications
    70     bp_users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'group_invite' );
     83    bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'group_invite' );
    7184
    7285    do_action( 'groups_screen_group_invites', $group_id );
     
    8093    if ( bp_is_single_item() ) {
    8194        if ( isset( $_GET['n'] ) ) {
    82             bp_users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_accepted' );
    83             bp_users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_rejected' );
    84             bp_users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_mod'      );
    85             bp_users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_admin'    );
     95            bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_accepted' );
     96            bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'membership_request_rejected' );
     97            bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_mod'      );
     98            bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'member_promoted_to_admin'    );
    8699        }
    87100
     
    410423    bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
    411424}
    412 add_action( 'wp', 'groups_screen_group_activity_permalink', 3 );
     425add_action( 'bp_screens', 'groups_screen_group_activity_permalink' );
    413426
    414427function groups_screen_group_admin() {
     
    454467    }
    455468}
    456 add_action( 'wp', 'groups_screen_group_admin_edit_details', 4 );
     469add_action( 'bp_screens', 'groups_screen_group_admin_edit_details' );
    457470
    458471function groups_screen_group_admin_settings() {
     
    490503    }
    491504}
    492 add_action( 'wp', 'groups_screen_group_admin_settings', 4 );
     505add_action( 'bp_screens', 'groups_screen_group_admin_settings' );
    493506
    494507function groups_screen_group_admin_avatar() {
     
    548561    }
    549562}
    550 add_action( 'wp', 'groups_screen_group_admin_avatar', 4 );
     563add_action( 'bp_screens', 'groups_screen_group_admin_avatar' );
    551564
    552565function groups_screen_group_admin_manage_members() {
     
    658671    }
    659672}
    660 add_action( 'wp', 'groups_screen_group_admin_manage_members', 4 );
     673add_action( 'bp_screens', 'groups_screen_group_admin_manage_members' );
    661674
    662675function groups_screen_group_admin_requests() {
     
    673686
    674687        // Remove any screen notifications
    675         bp_users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'new_membership_request' );
     688        bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->groups->id, 'new_membership_request' );
    676689
    677690        $request_action = $bp->action_variables[1];
     
    716729    }
    717730}
    718 add_action( 'wp', 'groups_screen_group_admin_requests', 4 );
     731add_action( 'bp_screens', 'groups_screen_group_admin_requests' );
    719732
    720733function groups_screen_group_admin_delete_group() {
     
    752765    }
    753766}
    754 add_action( 'wp', 'groups_screen_group_admin_delete_group', 4 );
     767add_action( 'bp_screens', 'groups_screen_group_admin_delete_group' );
    755768
    756769function groups_screen_notification_settings() {
  • trunk/bp-loader.php

    r3789 r3917  
    99 * Network:     true
    1010 */
    11 
    1211/** Constants *****************************************************************/
    1312
     
    4443/** Loader ********************************************************************/
    4544
    46 // Register BuddyPress themes contained within the bp-themes folder
    47 register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' );
    48      
    49 // Test to see whether this is a new installation or an upgraded version of BuddyPress 
    50 if ( !$bp_db_version = get_site_option( 'bp-db-version' ) )
    51     $bp_db_version = get_site_option( 'bp-core-db-version' );  // BP 1.2 option name
    52      
    53 // This is a new installation. Run the wizard before loading BP core files
    54 if ( empty( $bp_db_version ) ) {
    55     define( 'BP_IS_INSTALL', true );
    56     require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-update.php' );
    57    
    58 // Existing successful installation
    59 } else {
    60 
    61     /***
    62      * This file will load in each BuddyPress component based on which
    63      * of the components have been activated on the "BuddyPress" admin menu.
    64      */
    65     require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/bp-core-loader.php' );
    66     $bp_deactivated = apply_filters( 'bp_deactivated_components', get_site_option( 'bp-deactivated-components' ) );
    67 
    68     /**
    69      * At this point in the stack, BuddyPress core has been loaded but
    70      * individual components (friends/activity/groups/etc...) have not.
    71      *
    72      * The 'bp_core_loaded' action lets you execute code ahead of the
    73      * other components.
    74      */
    75     do_action( 'bp_core_loaded' );
    76 
    77     // Activity Streams
    78     if ( !isset( $bp_deactivated['bp-activity/bp-activity-loader.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-activity/bp-activity-loader.php') )
    79         include( BP_PLUGIN_DIR . '/bp-activity/bp-activity-loader.php' );
    80 
    81     // Blog Tracking
    82     if ( !isset( $bp_deactivated['bp-blogs/bp-blogs-loader.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-loader.php') )
    83         include( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-loader.php' );
    84 
    85     // bbPress Forum Integration
    86     if ( !isset( $bp_deactivated['bp-forums/bp-forums-loader.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-forums/bp-forums-loader.php') )
    87         include( BP_PLUGIN_DIR . '/bp-forums/bp-forums-loader.php' );
    88 
    89     // Friend Connections
    90     if ( !isset( $bp_deactivated['bp-friends/bp-friends-loader.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-friends/bp-friends-loader.php') )
    91         include( BP_PLUGIN_DIR . '/bp-friends/bp-friends-loader.php' );
    92 
    93     // Groups Support
    94     if ( !isset( $bp_deactivated['bp-groups/bp-groups-loader.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-groups/bp-groups-loader.php') )
    95         include( BP_PLUGIN_DIR . '/bp-groups/bp-groups-loader.php' );
    96 
    97     // Private Messaging
    98     if ( !isset( $bp_deactivated['bp-messages/bp-messages-loader.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-messages/bp-messages-loader.php') )
    99         include( BP_PLUGIN_DIR . '/bp-messages/bp-messages-loader.php' );
    100 
    101     // Extended Profiles
    102     if ( !isset( $bp_deactivated['bp-xprofile/bp-xprofile-loader.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-loader.php') )
    103         include( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-loader.php' );
    104        
    105     // Users
    106     include( BP_PLUGIN_DIR . '/bp-users/bp-users-loader.php'       );
    107 
    108     // Settings
    109     include( BP_PLUGIN_DIR . '/bp-settings/bp-settings-loader.php' );
    110 
    111     // If this is an upgrade, load the upgrade file
    112     if ( $bp_db_version < constant( 'BP_DB_VERSION' ) ) {
    113         define( 'BP_IS_UPGRADE', true );
    114         require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-update.php' );
    115     }
    116 }
    117 
    118 /********************************************************************************
    119  * Functions to set up custom BuddyPress actions that components should
    120  * hook in to.
    121  */
    122 
    123 /**
    124  * Include files on this action
    125  */
    126 function bp_include() {
    127     do_action( 'bp_include' );
    128 }
    129 
    130 /**
    131  * Setup BuddyPress root directory components
    132  */
    133 function bp_setup_root_components() {
    134     do_action( 'bp_setup_root_components' );
    135 }
    136 
    137 /**
    138  * Setup global variables and objects
    139  */
    140 function bp_setup_globals() {
    141     do_action( 'bp_setup_globals' );
    142 }
    143 
    144 /**
    145  * Set navigation elements
    146  */
    147 function bp_setup_nav() {
    148     do_action( 'bp_setup_nav' );
    149 }
    150 
    151 /**
    152  * Register widgets
    153  */
    154 function bp_setup_widgets() {
    155     do_action( 'bp_register_widgets' );
    156 }
    157 
    158 /**
    159  * Initlialize code
    160  */
    161 function bp_init() {
    162     do_action( 'bp_init' );
    163 }
    164 
    165 /**
    166  * Attached to plugins_loaded
    167  */
    168 function bp_loaded() {
    169     do_action( 'bp_loaded' );
    170 }
    171 
    172 /**
    173  * Attach potential template screens
    174  */
    175 function bp_screens() {
    176     do_action( 'bp_screens' );
    177 }
     45require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-bootstrap.php' );
    17846
    17947/**
  • trunk/bp-members/bp-members-actions.php

    r3916 r3917  
    2626 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    2727 */
    28 function bp_users_action_set_spammer_status() {
     28function bp_members_action_set_spammer_status() {
    2929    global $bp, $wpdb, $wp_version;
    3030
     
    8080            do_action( 'bp_make_spam_user', $bp->displayed_user->id );
    8181
    82         do_action( 'bp_users_action_set_spammer_status', $bp->displayed_user->id, $is_spam );
     82        do_action( 'bp_members_action_set_spammer_status', $bp->displayed_user->id, $is_spam );
    8383
    8484        bp_core_redirect( wp_get_referer() );
    8585    }
    8686}
    87 add_action( 'wp', 'bp_users_action_set_spammer_status', 3 );
     87add_action( 'bp_actions', 'bp_members_action_set_spammer_status' );
    8888
    8989/**
     
    9393 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    9494 */
    95 function bp_users_action_delete_user() {
     95function bp_members_action_delete_user() {
    9696    global $bp;
    9797
     
    112112        }
    113113
    114         do_action( 'bp_users_action_delete_user', $errors );
     114        do_action( 'bp_members_action_delete_user', $errors );
    115115
    116116        if ( $errors )
     
    120120    }
    121121}
    122 add_action( 'wp', 'bp_users_action_delete_user', 3 );
     122add_action( 'bp_actions', 'bp_members_action_delete_user' );
     123
     124/**
     125 * Returns the user_id for a user based on their username.
     126 *
     127 * @package BuddyPress Core
     128 * @param $username str Username to check.
     129 * @return false on no match
     130 * @return int the user ID of the matched user.
     131 */
     132function bp_core_get_random_member() {
     133    global $bp;
     134
     135    if ( isset( $_GET['random-member'] ) ) {
     136        $user = bp_core_get_users( array( 'type' => 'random', 'per_page' => 1 ) );
     137        bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->id ) );
     138    }
     139}
     140add_action( 'bp_actions', 'bp_core_get_random_member' );
    123141
    124142?>
  • trunk/bp-members/bp-members-functions.php

    r3916 r3917  
    130130 * @package BuddyPress Core
    131131 * @param $username str Username to check.
    132  * @return false on no match
    133  * @return int the user ID of the matched user.
    134  */
    135 function bp_core_get_random_member() {
    136     global $bp;
    137 
    138     if ( isset( $_GET['random-member'] ) ) {
    139         $user = bp_core_get_users( array( 'type' => 'random', 'per_page' => 1 ) );
    140         bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->id ) );
    141     }
    142 }
    143 add_action( 'wp', 'bp_core_get_random_member' );
    144 
    145 /**
    146  * Returns the user_id for a user based on their username.
    147  *
    148  * @package BuddyPress Core
    149  * @param $username str Username to check.
    150132 * @global $wpdb WordPress DB access object.
    151133 * @return false on no match
     
    242224    // Check $username for empty spaces and default to nicename if found
    243225    if ( strstr( $username, ' ' ) )
    244         $username = bp_users_get_user_nicename( $user_id );
     226        $username = bp_members_get_user_nicename( $user_id );
    245227
    246228    // Add this to cache
     
    265247 * @return str the username of the matched user.
    266248 */
    267 function bp_users_get_user_nicename( $user_id ) {
     249function bp_members_get_user_nicename( $user_id ) {
    268250    global $bp;
    269251
    270     if ( !$user_nicename = wp_cache_get( 'bp_users_user_nicename_' . $user_id, 'bp' ) ) {
     252    if ( !$user_nicename = wp_cache_get( 'bp_members_user_nicename_' . $user_id, 'bp' ) ) {
    271253        $update_cache = true;
    272254
     
    303285    // Add this to cache
    304286    if ( true == $update_cache && !empty( $user_nicename ) )
    305         wp_cache_set( 'bp_users_user_nicename_' . $user_id, $user_nicename, 'bp' );
    306 
    307     return apply_filters( 'bp_users_get_user_nicename', $user_nicename );
     287        wp_cache_set( 'bp_members_user_nicename_' . $user_id, $user_nicename, 'bp' );
     288
     289    return apply_filters( 'bp_members_get_user_nicename', $user_nicename );
    308290}
    309291
     
    399381
    400382    if ( !$fullname = wp_cache_get( 'bp_user_fullname_' . $user_id, 'bp' ) ) {
    401         if ( bp_is_active( 'profile' ) ) {
     383        if ( bp_is_active( 'xprofile' ) ) {
    402384            $fullname = xprofile_get_field_data( stripslashes( $bp->site_options['bp-xprofile-fullname-field-name'] ), $user_id );
    403385
     
    640622add_action( 'bp_make_spam_user', 'bp_core_remove_data' );
    641623
    642 function bp_users_can_edit_settings() {
     624function bp_members_can_edit_settings() {
    643625    if ( bp_is_my_profile() )
    644626        return true;
  • trunk/bp-members/bp-members-loader.php

    r3916 r3917  
    22
    33/**
    4  * BuddyPress User Loader
     4 * BuddyPress Member Loader
    55 *
    6  * A users component to help contain all of the user specific slugs
     6 * A members component to help contain all of the user specific slugs
    77 *
    88 * @package BuddyPress
     
    1010 */
    1111
    12 class BP_User_Component extends BP_Component {
    13 
    14     /**
    15      * Start the users component creation process
     12class BP_Members_Component extends BP_Component {
     13
     14    /**
     15     * Start the members component creation process
    1616     *
    1717     * @since BuddyPress {unknown}
    1818     */
    19     function BP_User_Component() {
    20         parent::start( 'members', __( 'Members', 'buddypress' ) );
     19    function BP_Members_Component() {
     20        parent::start(
     21            'members',
     22            __( 'Members', 'buddypress' ),
     23            BP_PLUGIN_DIR
     24        );
     25    }
     26
     27    /**
     28     * Include files
     29     *
     30     * @global obj $bp
     31     */
     32    function _includes() {
     33        $includes = array(
     34            'signup',
     35            'actions',
     36            'filters',
     37            'screens',
     38            'template',
     39            'functions',
     40            'notifications',
     41        );
     42        parent::_includes( $includes );
    2143    }
    2244
     
    3860
    3961        // Do some slug checks
    40         $this->slug      = BP_MEMBERS_SLUG;
    41         $this->root_slug = isset( $bp->pages->members->slug ) ? $bp->pages->members->slug : $this->slug;
    42 
    43         // Tables
    44         $this->table_name      = $bp->table_prefix . 'bp_users';
    45         $this->table_name_meta = $bp->table_prefix . 'bp_users_meta';
    46 
    47         // The default text for the members directory search box
    48         $this->default_search_string = __( 'Search Members...', 'buddypress' );
     62        $global_tables = array(
     63            'table_name'      => $bp->table_prefix . 'bp_users',
     64            'table_name_meta' => $bp->table_prefix . 'bp_members_meta',
     65        );
     66
     67        $globals = array(
     68            'slug'          => BP_MEMBERS_SLUG,
     69            'root_slug'     => isset( $bp->pages->members->slug ) ? $bp->pages->members->slug : BP_MEMBERS_SLUG,
     70            'search_string' => __( 'Search Members...', 'buddypress' ),
     71            'global_tables' => $global_tables
     72        );
     73
     74        parent::_setup_globals( $globals );
    4975
    5076        /** Logged in user ****************************************************/
    51 
    52         // Logged in user is the 'current_user'
    53         $current_user                      = wp_get_current_user();
    54 
    55         // The user ID of the user who is currently logged in.
    56         $bp->loggedin_user->id             = $current_user->ID;
    57 
    58         // The domain for the user currently logged in. eg: http://domain.com/members/andy
    59         $bp->loggedin_user->domain         = bp_core_get_user_domain( $bp->loggedin_user->id );
    60 
    61         // The core userdata of the user who is currently logged in.
    62         $bp->loggedin_user->userdata       = bp_core_get_core_userdata( $bp->loggedin_user->id );
    6377
    6478        // Fetch the full name for the logged in user
     
    6882        $bp->loggedin_user->is_super_admin = is_super_admin();
    6983        $bp->loggedin_user->is_site_admin  = $bp->loggedin_user->is_super_admin; // deprecated 1.2.6
     84
     85        // The domain for the user currently logged in. eg: http://domain.com/members/andy
     86        $bp->loggedin_user->domain         = bp_core_get_user_domain( $bp->loggedin_user->id );
     87
     88        // The core userdata of the user who is currently logged in.
     89        $bp->loggedin_user->userdata       = bp_core_get_core_userdata( $bp->loggedin_user->id );
    7090
    7191        /**
     
    99119        $bp->displayed_user->fullname = bp_core_get_user_displayname( $bp->displayed_user->id );
    100120
    101         /** Active Component **************************************************/
    102 
    103         // Users is active
    104         $bp->active_components[$this->id] = $this->id;
    105        
    106121        /** Default Profile Component *****************************************/
    107122        if ( !$bp->current_component && $bp->displayed_user->id )
     
    111126
    112127    /**
    113      * Include files
    114      *
    115      * @global obj $bp
    116      */
    117     function _includes() {
    118         require_once( BP_PLUGIN_DIR . '/bp-users/bp-users-signup.php'        );
    119         require_once( BP_PLUGIN_DIR . '/bp-users/bp-users-actions.php'       );
    120         require_once( BP_PLUGIN_DIR . '/bp-users/bp-users-filters.php'       );
    121         require_once( BP_PLUGIN_DIR . '/bp-users/bp-users-screens.php'       );
    122         require_once( BP_PLUGIN_DIR . '/bp-users/bp-users-template.php'      );
    123         require_once( BP_PLUGIN_DIR . '/bp-users/bp-users-functions.php'     );
    124         require_once( BP_PLUGIN_DIR . '/bp-users/bp-users-notifications.php' );
    125     }
    126 
    127     /**
    128128     * Setup BuddyBar navigation
    129129     *
     
    136136
    137137        // Add 'User' to the main navigation
    138         bp_core_new_nav_item( array(
     138        $main_nav = array(
    139139            'name'                => __( 'User', 'buddypress' ),
    140140            'slug'                => $this->slug,
    141141            'position'            => 10,
    142             'screen_function'     => 'bp_users_screen_my_users',
     142            'screen_function'     => 'bp_members_screen_my_users',
    143143            'default_subnav_slug' => 'just-me',
    144144            'item_css_id'         => $this->id
    145         ) );
     145        );
    146146
    147147        // Stop if there is no user displayed or logged in
     
    155155
    156156        // Add the subnav items to the users nav item if we are using a theme that supports this
    157         bp_core_new_subnav_item( array(
     157        $sub_nav[] = array(
    158158            'name'            => __( 'Personal', 'buddypress' ),
    159159            'slug'            => 'just-me',
    160160            'parent_url'      => $users_link,
    161161            'parent_slug'     => $this->slug,
    162             'screen_function' => 'bp_users_screen_my_users',
     162            'screen_function' => 'bp_members_screen_my_users',
    163163            'position'        => 10
    164         ) );
     164        );
    165165
    166166        // Additional menu if friends is active
    167167        if ( bp_is_active( 'friends' ) ) {
    168             bp_core_new_subnav_item( array(
     168            $sub_nav[] = array(
    169169                'name'            => __( 'Friends', 'buddypress' ),
    170170                'slug'            => BP_FRIENDS_SLUG,
    171171                'parent_url'      => $users_link,
    172172                'parent_slug'     => $this->slug,
    173                 'screen_function' => 'bp_users_screen_friends',
     173                'screen_function' => 'bp_members_screen_friends',
    174174                'position'        => 20,
    175175                'item_css_id'     => 'users-friends'
    176             ) );
     176            );
    177177        }
    178178
    179179        // Additional menu if groups is active
    180180        if ( bp_is_active( 'groups' ) ) {
    181             bp_core_new_subnav_item( array(
     181            $sub_nav[] = array(
    182182                'name'            => __( 'Groups', 'buddypress' ),
    183183                'slug'            => BP_GROUPS_SLUG,
    184184                'parent_url'      => $users_link,
    185185                'parent_slug'     => $this->slug,
    186                 'screen_function' => 'bp_users_screen_groups',
     186                'screen_function' => 'bp_members_screen_groups',
    187187                'position'        => 30,
    188188                'item_css_id'     => 'users-groups'
    189             ) );
     189            );
    190190        }
    191191
    192192        // Favorite users items
    193         bp_core_new_subnav_item( array(
     193        $sub_nav[] = array(
    194194            'name'            => __( 'Favorites', 'buddypress' ),
    195195            'slug'            => 'favorites',
    196196            'parent_url'      => $users_link,
    197197            'parent_slug'     => $this->slug,
    198             'screen_function' => 'bp_users_screen_favorites',
     198            'screen_function' => 'bp_members_screen_favorites',
    199199            'position'        => 40,
    200200            'item_css_id'     => 'users-favs'
    201         ) );
     201        );
    202202
    203203        // @ mentions
    204         bp_core_new_subnav_item( array(
     204        $sub_nav[] = array(
    205205            'name'            => sprintf( __( '@%s Mentions', 'buddypress' ), $user_login ),
    206206            'slug'            => 'mentions',
    207207            'parent_url'      => $users_link,
    208208            'parent_slug'     => $this->slug,
    209             'screen_function' => 'bp_users_screen_mentions',
     209            'screen_function' => 'bp_members_screen_mentions',
    210210            'position'        => 50,
    211211            'item_css_id'     => 'users-mentions'
    212         ) );
     212        );
    213213
    214214        // Adjust title based on view
    215215        if ( bp_is_users_component() ) {
    216216            if ( bp_is_my_profile() ) {
    217                 $bp->bp_options_title = __( 'My User', 'buddypress' );
     217                $bp->bp_options_title = __( 'You', 'buddypress' );
    218218            } else {
    219219                $bp->bp_options_avatar = bp_core_fetch_avatar( array(
     
    224224            }
    225225        }
     226
     227        parent::_setup_nav( $main_nav, $sub_nav );
    226228    }
    227229}
    228230// Create the users component
    229 $bp->members = new BP_User_Component();
     231$bp->members = new BP_Members_Component();
    230232
    231233?>
  • trunk/bp-members/bp-members-notifications.php

    r3916 r3917  
    11<?php
    22
    3 function bp_users_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id = 0, $date_notified = false ) {
     3function bp_members_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id = 0, $date_notified = false ) {
    44    global $bp;
    55
     
    2424}
    2525
    26 function bp_users_delete_notification( $id ) {
    27     if ( !bp_users_check_notification_access( $bp->loggedin_user->id, $id ) )
     26function bp_members_delete_notification( $id ) {
     27    if ( !bp_members_check_notification_access( $bp->loggedin_user->id, $id ) )
    2828        return false;
    2929
     
    3131}
    3232
    33 function bp_users_get_notification( $id ) {
     33function bp_members_get_notification( $id ) {
    3434    return new BP_Core_Notification( $id );
    3535}
    3636
    37 function bp_users_get_notifications_for_user( $user_id ) {
     37function bp_members_get_notifications_for_user( $user_id ) {
    3838    global $bp;
    3939
     
    7272}
    7373
    74 function bp_users_delete_notifications_by_type( $user_id, $component_name, $component_action ) {
     74function bp_members_delete_notifications_by_type( $user_id, $component_name, $component_action ) {
    7575    return BP_Core_Notification::delete_for_user_by_type( $user_id, $component_name, $component_action );
    7676}
    7777
    78 function bp_users_delete_notifications_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false ) {
     78function bp_members_delete_notifications_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false ) {
    7979    return BP_Core_Notification::delete_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id );
    8080}
    8181
    82 function bp_users_delete_all_notifications_by_type( $item_id, $component_name, $component_action = false, $secondary_item_id = false ) {
     82function bp_members_delete_all_notifications_by_type( $item_id, $component_name, $component_action = false, $secondary_item_id = false ) {
    8383    return BP_Core_Notification::delete_all_by_type( $item_id, $component_name, $component_action, $secondary_item_id );
    8484}
    8585
    86 function bp_users_delete_notifications_from_user( $user_id, $component_name, $component_action ) {
     86function bp_members_delete_notifications_from_user( $user_id, $component_name, $component_action ) {
    8787    return BP_Core_Notification::delete_from_user_by_type( $user_id, $component_name, $component_action );
    8888}
    8989
    90 function bp_users_check_notification_access( $user_id, $notification_id ) {
     90function bp_members_check_notification_access( $user_id, $notification_id ) {
    9191    if ( !BP_Core_Notification::check_access( $user_id, $notification_id ) )
    9292        return false;
  • trunk/bp-members/bp-members-screens.php

    r3916 r3917  
    11<?php
    22
    3 function bp_users_screen_index() {
     3function bp_members_screen_index() {
    44    global $bp;
    55
     
    77        $bp->is_directory = true;
    88
    9         do_action( 'bp_users_screen_index' );
     9        do_action( 'bp_members_screen_index' );
    1010
    11         bp_core_load_template( apply_filters( 'bp_users_screen_index', 'members/index' ) );
     11        bp_core_load_template( apply_filters( 'bp_members_screen_index', 'members/index' ) );
    1212    }
    1313}
    14 add_action( 'wp', 'bp_users_screen_index', 2 );
     14add_action( 'bp_screens', 'bp_members_screen_index' );
    1515
    1616
  • trunk/bp-members/bp-members-signup.php

    r3916 r3917  
    22
    33
    4 function bp_users_screen_signup() {
     4function bp_members_screen_signup() {
    55    global $bp, $wpdb;
    66
     
    3030
    3131        // Check the base account details for problems
    32         $account_details = bp_users_validate_user_signup( $_POST['signup_username'], $_POST['signup_email'] );
     32        $account_details = bp_members_validate_user_signup( $_POST['signup_username'], $_POST['signup_email'] );
    3333
    3434        // If there are errors with account details, set them for display
     
    8282
    8383            if ( 'blog' == $active_signup || 'all' == $active_signup ) {
    84                 $blog_details = bp_users_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] );
     84                $blog_details = bp_members_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] );
    8585
    8686                // If there are errors with blog details, set them for display
     
    9898        if ( !empty( $bp->signup->errors ) ) {
    9999            foreach ( (array)$bp->signup->errors as $fieldname => $error_message )
    100                 add_action( 'bp_' . $fieldname . '_errors', create_function( '', 'echo apply_filters(\'bp_users_signup_error_message\', "<div class=\"error\">' . $error_message . '</div>" );' ) );
     100                add_action( 'bp_' . $fieldname . '_errors', create_function( '', 'echo apply_filters(\'bp_members_signup_error_message\', "<div class=\"error\">' . $error_message . '</div>" );' ) );
    101101        } else {
    102102            $bp->signup->step = 'save-details';
     
    135135                // Finally, sign up the user and/or blog
    136136                if ( isset( $_POST['signup_with_blog'] ) && is_multisite() )
    137                     bp_users_signup_blog( $blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta );
     137                    bp_members_signup_blog( $blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta );
    138138                else
    139                     bp_users_signup_user( $_POST['signup_username'], $_POST['signup_password'], $_POST['signup_email'], $usermeta );
     139                    bp_members_signup_user( $_POST['signup_username'], $_POST['signup_password'], $_POST['signup_email'], $usermeta );
    140140
    141141                $bp->signup->step = 'completed-confirmation';
     
    148148
    149149    do_action( 'bp_core_screen_signup' );
    150     bp_core_load_template( apply_filters( 'bp_users_template_register', 'registration/register' ) );
    151 }
    152 add_action( 'wp', 'bp_users_screen_signup', 3 );
    153 
    154 function bp_users_screen_activation() {
     150    bp_core_load_template( apply_filters( 'bp_members_template_register', 'registration/register' ) );
     151}
     152add_action( 'bp_screens', 'bp_members_screen_signup' );
     153
     154function bp_members_screen_activation() {
    155155    global $bp, $wpdb;
    156156
     
    162162
    163163        // Activate the signup
    164         $user = apply_filters( 'bp_users_activate_account', bp_users_activate_signup( $_GET['key'] ) );
     164        $user = apply_filters( 'bp_members_activate_account', bp_members_activate_signup( $_GET['key'] ) );
    165165
    166166        // If there were errors, add a message and redirect
     
    191191        bp_core_load_template( apply_filters( 'bp_core_template_activate', 'registration/activate' ) );
    192192}
    193 add_action( 'wp', 'bp_users_screen_activation', 3 );
     193add_action( 'bp_screens', 'bp_members_screen_activation' );
    194194
    195195
     
    206206 * Flush illegal names by getting and setting 'illegal_names' site option
    207207 */
    208 function bp_users_flush_illegal_names() {
     208function bp_members_flush_illegal_names() {
    209209    $illegal_names = get_site_option( 'illegal_names' );
    210210    update_site_option( 'illegal_names', $illegal_names );
     
    219219 * @return array Merged and unique array of illegal names
    220220 */
    221 function bp_users_illegal_names( $value = '', $oldvalue = '' ) {
     221function bp_members_illegal_names( $value = '', $oldvalue = '' ) {
    222222
    223223    // Make sure $value is array
     
    263263
    264264    // Add our slugs to the array and allow them to be filtered
    265     $filtered_illegal_names = apply_filters( 'bp_users_illegal_usernames', array_merge( array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ), $bp_component_slugs ) );
     265    $filtered_illegal_names = apply_filters( 'bp_members_illegal_usernames', array_merge( array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ), $bp_component_slugs ) );
    266266
    267267    // Merge the arrays together
     
    271271    $illegal_names          = array_unique( (array)$merged_names );
    272272
    273     return apply_filters( 'bp_users_illegal_names', $illegal_names );
    274 }
    275 add_filter( 'pre_update_site_option_illegal_names', 'bp_users_illegal_names', 10, 2 );
     273    return apply_filters( 'bp_members_illegal_names', $illegal_names );
     274}
     275add_filter( 'pre_update_site_option_illegal_names', 'bp_members_illegal_names', 10, 2 );
    276276
    277277/**
     
    283283 * @return array Results of user validation including errors, if any
    284284 */
    285 function bp_users_validate_user_signup( $user_name, $user_email ) {
     285function bp_members_validate_user_signup( $user_name, $user_email ) {
    286286    global $wpdb;
    287287
     
    299299
    300300    // Make sure illegal names include BuddyPress slugs and values
    301     bp_users_flush_illegal_names();
     301    bp_members_flush_illegal_names();
    302302
    303303    $illegal_names = get_site_option( 'illegal_names' );
     
    347347    $result = apply_filters( 'wpmu_validate_user_signup', $result );
    348348
    349     return apply_filters( 'bp_users_validate_user_signup', $result );
    350 }
    351 
    352 function bp_users_validate_blog_signup( $blog_url, $blog_title ) {
     349    return apply_filters( 'bp_members_validate_user_signup', $result );
     350}
     351
     352function bp_members_validate_blog_signup( $blog_url, $blog_title ) {
    353353    if ( !is_multisite() || !function_exists( 'wpmu_validate_blog_signup' ) )
    354354        return false;
    355355
    356     return apply_filters( 'bp_users_validate_blog_signup', wpmu_validate_blog_signup( $blog_url, $blog_title ) );
    357 }
    358 
    359 function bp_users_signup_user( $user_login, $user_password, $user_email, $usermeta ) {
     356    return apply_filters( 'bp_members_validate_blog_signup', wpmu_validate_blog_signup( $blog_url, $blog_title ) );
     357}
     358
     359function bp_members_signup_user( $user_login, $user_password, $user_email, $usermeta ) {
    360360    global $bp, $wpdb;
    361361
     
    406406     * and validate their email address. Multisite installs send their own email, so this is only for single blog installs.
    407407     *
    408      * To disable sending activation emails you can user the filter 'bp_users_signup_send_activation_key' and return false.
     408     * To disable sending activation emails you can user the filter 'bp_members_signup_send_activation_key' and return false.
    409409     */
    410     if ( apply_filters( 'bp_users_signup_send_activation_key', true ) ) {
     410    if ( apply_filters( 'bp_members_signup_send_activation_key', true ) ) {
    411411        if ( !is_multisite() ) {
    412412            $activation_key = wp_hash( $user_id );
    413413            update_user_meta( $user_id, 'activation_key', $activation_key );
    414             bp_users_signup_send_validation_email( $user_id, $user_email, $activation_key );
     414            bp_members_signup_send_validation_email( $user_id, $user_email, $activation_key );
    415415        }
    416416    }
    417417
    418     do_action( 'bp_users_signup_user', $user_id, $user_login, $user_password, $user_email, $usermeta );
     418    do_action( 'bp_members_signup_user', $user_id, $user_login, $user_password, $user_email, $usermeta );
    419419
    420420    return $user_id;
    421421}
    422422
    423 function bp_users_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) {
     423function bp_members_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) {
    424424    if ( !is_multisite() || !function_exists( 'wpmu_signup_blog' ) )
    425425        return false;
    426426
    427     return apply_filters( 'bp_users_signup_blog', wpmu_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) );
    428 }
    429 
    430 function bp_users_activate_signup( $key ) {
     427    return apply_filters( 'bp_members_signup_blog', wpmu_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) );
     428}
     429
     430function bp_members_activate_signup( $key ) {
    431431    global $bp, $wpdb;
    432432
     
    481481        require_once( ABSPATH . WPINC . '/registration.php' );
    482482
    483     wp_update_user( array( 'ID' => $user_id, 'user_url' => bp_users_get_user_domain( $user_id ), 'display_name' => bp_core_get_user_displayname( $user_id ) ) );
     483    wp_update_user( array( 'ID' => $user_id, 'user_url' => bp_members_get_user_domain( $user_id ), 'display_name' => bp_core_get_user_displayname( $user_id ) ) );
    484484
    485485    // Set the password on multisite installs
     
    490490    wp_cache_delete( 'bp_total_member_count', 'bp' );
    491491
    492     do_action( 'bp_users_activated_user', $user_id, $key, $user );
     492    do_action( 'bp_members_activated_user', $user_id, $key, $user );
    493493
    494494    return $user_id;
    495495}
    496496
    497 function bp_users_new_user_activity( $user ) {
     497function bp_members_new_user_activity( $user ) {
    498498    if ( empty( $user ) || !function_exists( 'bp_activity_add' ) )
    499499        return false;
     
    507507        return false;
    508508
    509     $userlink = bp_users_get_userlink( $user_id );
     509    $userlink = bp_members_get_userlink( $user_id );
    510510
    511511    bp_activity_add( array(
    512         'user_id' => $user_id,
    513         'action' => apply_filters( 'bp_users_activity_registered_member_action', sprintf( __( '%s became a registered member', 'buddypress' ), $userlink ), $user_id ),
    514         'component' => 'profile',
    515         'type' => 'new_member'
     512        'user_id'   => $user_id,
     513        'action'    => apply_filters( 'bp_members_activity_registered_member_action', sprintf( __( '%s became a registered member', 'buddypress' ), $userlink ), $user_id ),
     514        'component' => 'xprofile',
     515        'type'      => 'new_member'
    516516    ) );
    517517}
    518 add_action( 'bp_users_activated_user', 'bp_users_new_user_activity' );
    519 
    520 function bp_users_map_user_registration( $user_id ) {
     518add_action( 'bp_members_activated_user', 'bp_members_new_user_activity' );
     519
     520function bp_members_map_user_registration( $user_id ) {
    521521    // Only map data when the site admin is adding users, not on registration.
    522522    if ( !is_admin() )
     
    535535    }
    536536}
    537 add_action( 'user_register', 'bp_users_map_user_registration' );
    538 
    539 function bp_users_signup_avatar_upload_dir() {
     537add_action( 'user_register', 'bp_members_map_user_registration' );
     538
     539function bp_members_signup_avatar_upload_dir() {
    540540    global $bp;
    541541
     
    553553    $newsubdir = '/avatars/signups/' . $bp->signup->avatar_dir;
    554554
    555     return apply_filters( 'bp_users_signup_avatar_upload_dir', array( 'path' => $path, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) );
    556 }
    557 
    558 function bp_users_signup_send_validation_email( $user_id, $user_email, $key ) {
     555    return apply_filters( 'bp_members_signup_avatar_upload_dir', array( 'path' => $path, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) );
     556}
     557
     558function bp_members_signup_send_validation_email( $user_id, $user_email, $key ) {
    559559    $activate_url = bp_get_activation_page() ."?key=$key";
    560560    $activate_url = esc_url( $activate_url );
     
    566566
    567567    // Send the message
    568     $to      = apply_filters( 'bp_users_signup_send_validation_email_to',     $user_email, $user_id                );
    569     $subject = apply_filters( 'bp_users_signup_send_validation_email_subject', $subject,    $user_id                );
    570     $message = apply_filters( 'bp_users_signup_send_validation_email_message', $message,    $user_id, $activate_url );
     568    $to      = apply_filters( 'bp_members_signup_send_validation_email_to',     $user_email, $user_id                );
     569    $subject = apply_filters( 'bp_members_signup_send_validation_email_subject', $subject,    $user_id                );
     570    $message = apply_filters( 'bp_members_signup_send_validation_email_message', $message,    $user_id, $activate_url );
    571571
    572572    wp_mail( $to, $subject, $message );
    573573
    574     do_action( 'bp_users_sent_user_validation_email', $subject, $message, $user_id, $user_email, $key );
     574    do_action( 'bp_members_sent_user_validation_email', $subject, $message, $user_id, $user_email, $key );
    575575}
    576576
    577577// Stop user accounts logging in that have not been activated (user_status = 2)
    578 function bp_users_signup_disable_inactive( $auth_obj, $username ) {
     578function bp_members_signup_disable_inactive( $auth_obj, $username ) {
    579579    global $bp, $wpdb;
    580580
     
    589589        return $auth_obj;
    590590}
    591 add_filter( 'authenticate', 'bp_users_signup_disable_inactive', 30, 2 );
    592 
    593 /* Kill the wp-signup.php if custom registration signup templates are present */
    594 function bp_users_wpsignup_redirect() {
     591add_filter( 'authenticate', 'bp_members_signup_disable_inactive', 30, 2 );
     592
     593// Kill the wp-signup.php if custom registration signup templates are present
     594function bp_members_wpsignup_redirect() {
    595595    $action = '';
    596596    if ( isset( $_GET['action'] ) )
     
    604604}
    605605if ( is_multisite() )
    606     add_action( 'wp', 'bp_users_wpsignup_redirect' );
     606    add_action( 'bp_screens', 'bp_members_wpsignup_redirect' );
    607607else
    608     add_action( 'bp_init', 'bp_users_wpsignup_redirect' );
     608    add_action( 'bp_init', 'bp_members_wpsignup_redirect' );
    609609
    610610?>
  • trunk/bp-members/bp-members-template.php

    r3916 r3917  
    409409        global $members_template;
    410410
    411         if ( !bp_is_active( 'profile' ) )
     411        if ( !bp_is_active( 'xprofile' ) )
    412412            return false;
    413413
     
    927927 * @since 1.3
    928928 */
    929 function bp_users_activity_feed() {
     929function bp_members_activity_feed() {
    930930    if ( !bp_is_active( 'activity' ) || !bp_is_user() )
    931931        return; ?>
     
    935935<?php
    936936}
    937 add_action( 'bp_head', 'bp_users_activity_feed' );
     937add_action( 'bp_head', 'bp_members_activity_feed' );
    938938
    939939?>
  • trunk/bp-messages/bp-messages-actions.php

    r3757 r3917  
    4141    bp_core_load_template( apply_filters( 'messages_template_view_message', 'members/single/home' ) );
    4242}
    43 add_action( 'wp', 'messages_action_view_message', 3 );
     43add_action( 'bp_actions', 'messages_action_view_message' );
    4444
    4545function messages_action_delete_message() {
     
    6666    }
    6767}
    68 add_action( 'wp', 'messages_action_delete_message', 3 );
     68add_action( 'bp_actions', 'messages_action_delete_message' );
    6969
    7070function messages_action_bulk_delete() {
     
    9090    }
    9191}
    92 add_action( 'wp', 'messages_action_bulk_delete', 3 );
     92add_action( 'bp_actions', 'messages_action_bulk_delete' );
    9393
    9494?>
  • trunk/bp-messages/bp-messages-cssjs.php

    r3777 r3917  
    55
    66    // Include the autocomplete JS for composing a message.
    7     if ( $bp->current_component == $bp->messages->slug && 'compose' == $bp->current_action ) {
     7    if ( bp_is_messages_component() && bp_is_current_action( 'compose' ) ) {
    88        add_action( 'wp_head', 'messages_autocomplete_init_jsblock' );
    99
     
    2222    }
    2323}
    24 add_action( 'wp', 'messages_add_autocomplete_js', 2 );
     24add_action( 'bp_actions', 'messages_add_autocomplete_js' );
    2525
    2626function messages_add_autocomplete_css() {
    2727    global $bp;
    2828
    29     if ( $bp->current_component == $bp->messages->slug && 'compose' == $bp->current_action ) {
     29    if ( bp_is_messages_component() && bp_is_current_item( 'compose' ) ) {
    3030        if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG )
    3131            wp_enqueue_style( 'bp-messages-autocomplete', BP_PLUGIN_URL . '/bp-messages/css/autocomplete/jquery.autocompletefb.dev.css', array(), BP_VERSION );
  • trunk/bp-messages/bp-messages-functions.php

    r3903 r3917  
    8585        // Send screen notifications to the recipients
    8686        foreach ( (array)$message->recipients as $recipient )
    87             bp_users_add_notification( $message->id, $recipient->user_id, 'messages', 'new_message' );
     87            bp_members_add_notification( $message->id, $recipient->user_id, 'messages', 'new_message' );
    8888
    8989        // Send email notifications to the recipients
     
    193193}
    194194
     195/*******************************************************************************
     196 * These functions handle the recording, deleting and formatting of activity and
     197 * notifications for the user and for this specific component.
     198 */
     199
     200function messages_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
     201    global $bp;
     202
     203    if ( 'new_message' == $action ) {
     204        if ( (int)$total_items > 1 )
     205            return apply_filters( 'bp_messages_multiple_new_message_notification', '<a href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/inbox" title="' . __( 'Inbox', 'buddypress' ) . '">' . sprintf( __('You have %d new messages', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
     206        else
     207            return apply_filters( 'bp_messages_single_new_message_notification', '<a href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/inbox" title="' . __( 'Inbox', 'buddypress' ) . '">' . sprintf( __('You have %d new message', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
     208    }
     209
     210    do_action( 'messages_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
     211
     212    return false;
     213}
     214
    195215?>
  • trunk/bp-messages/bp-messages-loader.php

    r3757 r3917  
    11<?php
    22
    3 // Required Files
    4 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-cssjs.php'     );
    5 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-actions.php'   );
    6 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-screens.php'   );
    7 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-classes.php'   );
    8 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-filters.php'   );
    9 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-template.php'  );
    10 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-functions.php' );
     3/**
     4 * BuddyPress Private Messages Loader
     5 *
     6 * A private messages component, for users to send messages to each other
     7 *
     8 * @package BuddyPress
     9 * @subpackage Messages Core
     10 */
    1111
    12 function messages_setup_globals() {
    13     global $bp;
     12class BP_Messages_Component extends BP_Component {
    1413
    15     if ( !defined( 'BP_MESSAGES_SLUG' ) )
    16         define ( 'BP_MESSAGES_SLUG', 'messages' );
    17 
    18     // For internal identification
    19     $bp->messages->id = 'messages';
    20 
    21     // Slug
    22     $bp->messages->slug = BP_MESSAGES_SLUG;
    23 
    24     // Tables
    25     $bp->messages->table_name_notices       = $bp->table_prefix . 'bp_messages_notices';
    26     $bp->messages->table_name_messages      = $bp->table_prefix . 'bp_messages_messages';
    27     $bp->messages->table_name_recipients    = $bp->table_prefix . 'bp_messages_recipients';
    28 
    29     // Notifications
    30     $bp->messages->notification_callback = 'messages_format_notifications';
    31 
    32     // Register this in the active components array
    33     $bp->active_components[$bp->messages->slug] = $bp->messages->id;
    34 
    35     // Include all members in the To: autocomplete?
    36     $bp->messages->autocomplete_all = defined( 'BP_MESSAGES_AUTOCOMPLETE_ALL' ) ? true : false;
    37 
    38     do_action( 'messages_setup_globals' );
    39 }
    40 add_action( 'bp_setup_globals', 'messages_setup_globals' );
    41 
    42 function messages_setup_nav() {
    43     global $bp;
    44 
    45     if ( $count = messages_get_unread_count() )
    46         $name = sprintf( __('Messages <strong>(%s)</strong>', 'buddypress'), $count );
    47     else
    48         $name = __('Messages <strong></strong>', 'buddypress');
    49 
    50     // Add 'Messages' to the main navigation
    51     bp_core_new_nav_item( array( 'name' => $name, 'slug' => $bp->messages->slug, 'position' => 50, 'show_for_displayed_user' => false, 'screen_function' => 'messages_screen_inbox', 'default_subnav_slug' => 'inbox', 'item_css_id' => $bp->messages->id ) );
    52 
    53     $messages_link = $bp->loggedin_user->domain . $bp->messages->slug . '/';
    54 
    55     // Add the subnav items to the profile
    56     bp_core_new_subnav_item( array( 'name' => __( 'Inbox', 'buddypress' ), 'slug' => 'inbox', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_inbox', 'position' => 10, 'user_has_access' => bp_is_my_profile() ) );
    57     bp_core_new_subnav_item( array( 'name' => __( 'Sent Messages', 'buddypress' ), 'slug' => 'sentbox', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_sentbox', 'position' => 20, 'user_has_access' => bp_is_my_profile() ) );
    58     bp_core_new_subnav_item( array( 'name' => __( 'Compose', 'buddypress' ), 'slug' => 'compose', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_compose', 'position' => 30, 'user_has_access' => bp_is_my_profile() ) );
    59 
    60     if ( is_super_admin() )
    61         bp_core_new_subnav_item( array( 'name' => __( 'Notices', 'buddypress' ), 'slug' => 'notices', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_notices', 'position' => 90, 'user_has_access' => is_super_admin() ) );
    62 
    63     if ( $bp->current_component == $bp->messages->slug ) {
    64         if ( bp_is_my_profile() ) {
    65             $bp->bp_options_title = __( 'My Messages', 'buddypress' );
    66         } else {
    67             $bp_options_avatar =  bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
    68             $bp->bp_options_title = $bp->displayed_user->fullname;
    69         }
     14    /**
     15     * Start the messages component creation process
     16     *
     17     * @since BuddyPress {unknown}
     18     */
     19    function BP_Messages_Component() {
     20        parent::start(
     21            'messages',
     22            __( 'Private Messages', 'buddypress' ),
     23            BP_PLUGIN_DIR
     24        );
    7025    }
    7126
    72     do_action( 'messages_setup_nav' );
    73 }
    74 add_action( 'bp_setup_nav', 'messages_setup_nav' );
     27    /**
     28     * Include files
     29     */
     30    function _includes() {
     31        // Files to include
     32        $includes = array(
     33            'cssjs',
     34            'cache',
     35            'actions',
     36            'screens',
     37            'classes',
     38            'filters',
     39            'template',
     40            'functions',
     41        );
    7542
    76 /*******************************************************************************
    77  * These functions handle the recording, deleting and formatting of activity and
    78  * notifications for the user and for this specific component.
    79  */
    80 
    81 function messages_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
    82     global $bp;
    83 
    84     if ( 'new_message' == $action ) {
    85         if ( (int)$total_items > 1 )
    86             return apply_filters( 'bp_messages_multiple_new_message_notification', '<a href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/inbox" title="' . __( 'Inbox', 'buddypress' ) . '">' . sprintf( __('You have %d new messages', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
    87         else
    88             return apply_filters( 'bp_messages_single_new_message_notification', '<a href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/inbox" title="' . __( 'Inbox', 'buddypress' ) . '">' . sprintf( __('You have %d new message', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
     43        parent::_includes( $includes );
    8944    }
    9045
    91     do_action( 'messages_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
     46    /**
     47     * Setup globals
     48     *
     49     * The BP_MESSAGES_SLUG constant is deprecated, and only used here for
     50     * backwards compatibility.
     51     *
     52     * @since BuddyPress {unknown}
     53     * @global obj $bp
     54     */
     55    function _setup_globals() {
     56        global $bp;
    9257
    93     return false;
     58        // Define a slug, if necessary
     59        if ( !defined( 'BP_MESSAGES_SLUG' ) )
     60            define( 'BP_MESSAGES_SLUG', $this->id );
     61
     62        // Global tables for messaging component
     63        $global_tables = array(
     64            'table_name_notices'    => $bp->table_prefix . 'bp_messages_notices',
     65            'table_name_messages'   => $bp->table_prefix . 'bp_messages_messages',
     66            'table_name_recipients' => $bp->table_prefix . 'bp_messages_recipients'
     67        );
     68
     69        // All globals for messaging component.
     70        // Note that global_tables is included in this array.
     71        $globals = array(
     72            'slug'                  => BP_MESSAGES_SLUG,
     73            'root_slug'             => isset( $bp->pages->messages->slug ) ? $bp->pages->messages->slug : BP_MESSAGES_SLUG,
     74            'notification_callback' => 'messages_format_notifications',
     75            'search_string'         => __( 'Search Messages...', 'buddypress' ),
     76            'autocomplete_all'      => defined( 'BP_MESSAGES_AUTOCOMPLETE_ALL' ),
     77            'global_tables'         => $global_tables,
     78        );
     79
     80        parent::_setup_globals( $globals );
     81    }
     82
     83    /**
     84     * Setup BuddyBar navigation
     85     *
     86     * @global obj $bp
     87     */
     88    function _setup_nav() {
     89        global $bp;
     90
     91        if ( $count = messages_get_unread_count() )
     92            $name = sprintf( __( 'Messages <strong>(%s)</strong>', 'buddypress' ), $count );
     93        else
     94            $name = __( 'Messages <strong></strong>', 'buddypress' );
     95
     96        // Add 'Messages' to the main navigation
     97        $main_nav = array(
     98            'name'                    => $name,
     99            'slug'                    => $this->slug,
     100            'root_slug'               => $this->root_slug,
     101            'position'                => 50,
     102            'show_for_displayed_user' => false,
     103            'screen_function'         => 'messages_screen_inbox',
     104            'default_subnav_slug'     => 'inbox',
     105            'item_css_id'             => $this->id
     106        );
     107
     108        // Link to user messages
     109        $messages_link = trailingslashit( $bp->loggedin_user->domain . $this->slug );
     110
     111        // Add the subnav items to the profile
     112        $sub_nav[] = array(
     113            'name'            => __( 'Inbox', 'buddypress' ),
     114            'slug'            => 'inbox',
     115            'parent_url'      => $messages_link,
     116            'parent_slug'     => $this->slug,
     117            'screen_function' => 'messages_screen_inbox',
     118            'position'        => 10,
     119            'user_has_access' => bp_is_my_profile()
     120        );
     121
     122        $sub_nav[] = array(
     123            'name'            => __( 'Sent Messages', 'buddypress' ),
     124            'slug'            => 'sentbox',
     125            'parent_url'      => $messages_link,
     126            'parent_slug'     => $this->slug,
     127            'screen_function' => 'messages_screen_sentbox',
     128            'position'        => 20,
     129            'user_has_access' => bp_is_my_profile()
     130        );
     131
     132        $sub_nav[] = array(
     133            'name'            => __( 'Compose', 'buddypress' ),
     134            'slug'            => 'compose',
     135            'parent_url'      => $messages_link,
     136            'parent_slug'     => $this->slug,
     137            'screen_function' => 'messages_screen_compose',
     138            'position'        => 30,
     139            'user_has_access' => bp_is_my_profile()
     140        );
     141
     142        if ( is_super_admin() ) {
     143            $sub_nav[] = array(
     144                'name'            => __( 'Notices', 'buddypress' ),
     145                'slug'            => 'notices',
     146                'parent_url'      => $messages_link,
     147                'parent_slug'     => $this->slug,
     148                'screen_function' => 'messages_screen_notices',
     149                'position'        => 90,
     150                'user_has_access' => is_super_admin()
     151            );
     152        }
     153
     154        if ( bp_is_messages_component() ) {
     155            if ( bp_is_my_profile() ) {
     156                $bp->bp_options_title = __( 'My Messages', 'buddypress' );
     157            } else {
     158                $bp->bp_options_avatar = bp_core_fetch_avatar( array(
     159                    'item_id' => $bp->displayed_user->id,
     160                    'type'    => 'thumb'
     161                ) );
     162                $bp->bp_options_title = $bp->displayed_user->fullname;
     163            }
     164        }
     165
     166        parent::_setup_nav( $main_nav, $sub_nav );
     167    }
    94168}
    95 
    96 /*******************************************************************************
    97  * Caching functions handle the clearing of cached objects and pages on specific
    98  * actions throughout BuddyPress.
    99  */
    100 
    101 // List actions to clear super cached pages on, if super cache is installed
    102 add_action( 'messages_delete_thread',  'bp_core_clear_cache' );
    103 add_action( 'messages_send_notice',    'bp_core_clear_cache' );
    104 add_action( 'messages_message_sent',   'bp_core_clear_cache' );
    105 
    106 // Don't cache message inbox/sentbox/compose as it's too problematic
    107 add_action( 'messages_screen_compose', 'bp_core_clear_cache' );
    108 add_action( 'messages_screen_sentbox', 'bp_core_clear_cache' );
    109 add_action( 'messages_screen_inbox',   'bp_core_clear_cache' );
     169// Create the messages component
     170$bp->messages = new BP_Messages_Component();
    110171
    111172?>
  • trunk/bp-messages/bp-messages-template.php

    r3757 r3917  
    166166    } else {
    167167        if ( 'inbox' == $bp->current_action )
    168             bp_users_delete_notifications_by_type( $bp->loggedin_user->id, $bp->messages->id, 'new_message' );
     168            bp_members_delete_notifications_by_type( $bp->loggedin_user->id, $bp->messages->id, 'new_message' );
    169169
    170170        if ( 'sentbox' == $bp->current_action )
  • trunk/bp-settings/bp-settings-actions.php

    r3838 r3917  
    107107
    108108    // Load the template
    109     bp_core_load_template( apply_filters( 'bp_users_template_settings', 'members/single/settings/general' ) );
     109    bp_core_load_template( apply_filters( 'bp_members_template_settings', 'members/single/settings/general' ) );
    110110}
    111111
  • trunk/bp-settings/bp-settings-loader.php

    r3778 r3917  
    99     */
    1010    function BP_Settings_Component() {
    11         parent::start( 'settings', __( 'Settings', 'buddypress' ) );
     11        parent::start(
     12            'settings',
     13            __( 'Settings', 'buddypress' ),
     14            BP_PLUGIN_DIR
     15        );
     16    }
     17
     18    /**
     19     * Include files
     20     *
     21     * @global obj $bp
     22     */
     23    function _includes() {
     24        // Files to include
     25        $includes = array(
     26            'actions',
     27            'screens',
     28            'template',
     29            'functions',
     30        );
     31
     32        parent::_includes( $includes );
    1233    }
    1334
     
    2849            define( 'BP_SETTINGS_SLUG', $this->id );
    2950
    30         // Do some slug checks
    31         $this->slug      = BP_SETTINGS_SLUG;
    32         $this->root_slug = isset( $bp->pages->settings->slug ) ? $bp->pages->settings->slug : $this->slug;
    33        
    34         // Register this in the active components array
    35         $bp->active_components[$this->id] = $this->id;
    36     }
     51        // All globals for messaging component.
     52        // Note that global_tables is included in this array.
     53        $globals = array(
     54            'slug'      => BP_SETTINGS_SLUG,
     55            'root_slug' => isset( $bp->pages->settings->slug ) ? $bp->pages->settings->slug : BP_SETTINGS_SLUG,
     56        );
    3757
    38     /**
    39      * Include files
    40      *
    41      * @global obj $bp
    42      */
    43     function _includes() {
    44         require_once( BP_PLUGIN_DIR . '/bp-settings/bp-settings-actions.php'   );
    45         require_once( BP_PLUGIN_DIR . '/bp-settings/bp-settings-screens.php'   );
    46         require_once( BP_PLUGIN_DIR . '/bp-settings/bp-settings-template.php'  );
    47         require_once( BP_PLUGIN_DIR . '/bp-settings/bp-settings-functions.php' );
     58        parent::_setup_globals( $globals );
    4859    }
    4960
     
    5768
    5869        // Add the settings navigation item
    59         bp_core_new_nav_item( array(
     70        $main_nav = array(
    6071            'name'                    => __( 'Settings', 'buddypress' ),
    6172            'slug'                    => $this->slug,
    6273            'position'                => 100,
    63             'show_for_displayed_user' => bp_users_can_edit_settings(),
     74            'show_for_displayed_user' => bp_members_can_edit_settings(),
    6475            'screen_function'         => 'bp_settings_screen_general_settings',
    6576            'default_subnav_slug'     => 'general'
    66         ) );
     77        );
    6778
    68         $settings_link = trailingslashit( $bp->displayed_user->domain . $bp->settings->slug );
     79        $settings_link = trailingslashit( $bp->displayed_user->domain . $this->slug );
    6980
    7081        // Add General Settings nav item
    71         bp_core_new_subnav_item( array(
     82        $sub_nav[] = array(
    7283            'name'            => __( 'General', 'buddypress' ),
    7384            'slug'            => 'general',
     
    7687            'screen_function' => 'bp_settings_screen_general_settings',
    7788            'position'        => 10,
    78             'user_has_access' => bp_users_can_edit_settings()
    79         ) );
     89            'user_has_access' => bp_members_can_edit_settings()
     90        );
    8091
    8192        // Add Notifications nav item
    82         bp_core_new_subnav_item( array(
     93        $sub_nav[] = array(
    8394            'name'            => __( 'Notifications', 'buddypress' ),
    8495            'slug'            => 'notifications',
     
    8798            'screen_function' => 'bp_settings_screen_notification_settings',
    8899            'position'        => 20,
    89             'user_has_access' => bp_users_can_edit_settings()
    90         ) );
     100            'user_has_access' => bp_members_can_edit_settings()
     101        );
    91102
    92103        // Add Delete Account nav item
    93104        if ( !is_super_admin() && empty( $bp->site_options['bp-disable-account-deletion'] ) ) {
    94             bp_core_new_subnav_item( array(
     105            $sub_nav[] = array(
    95106                'name'            => __( 'Delete Account', 'buddypress' ),
    96107                'slug'            => 'delete-account',
     
    100111                'position'        => 90,
    101112                'user_has_access' => bp_is_my_profile()
    102             ) );
     113            );
    103114        }
     115
     116        parent::_setup_nav( $main_nav, $sub_nav );
    104117    }
    105118}
  • trunk/bp-themes/bp-default/groups/single/members.php

    r3819 r3917  
    1616                    <option value="newest"><?php _e( 'Newest Registered', 'buddypress' ); ?></option>
    1717
    18                     <?php if ( bp_is_active( 'profile' ) ) : ?>
     18                    <?php if ( bp_is_active( 'xprofile' ) ) : ?>
    1919
    2020                        <option value="alphabetical"><?php _e( 'Alphabetical', 'buddypress' ); ?></option>
  • trunk/bp-themes/bp-default/members/index.php

    r3810 r3917  
    5555                            <option value="newest"><?php _e( 'Newest Registered', 'buddypress' ); ?></option>
    5656
    57                             <?php if ( bp_is_active( 'profile' ) ) : ?>
     57                            <?php if ( bp_is_active( 'xprofile' ) ) : ?>
    5858
    5959                                <option value="alphabetical"><?php _e( 'Alphabetical', 'buddypress' ); ?></option>
  • trunk/bp-themes/bp-default/members/single/profile.php

    r3810 r3917  
    3636
    3737        // Display XProfile
    38         elseif ( bp_is_active( 'profile' ) )
     38        elseif ( bp_is_active( 'xprofile' ) )
    3939            locate_template( array( 'members/single/profile/profile-loop.php' ), true );
    4040
  • trunk/bp-themes/bp-default/members/single/settings/delete-account.php

    r3757 r3917  
    5858                    <input type="checkbox" name="delete-account-understand" id="delete-account-understand" value="1" onclick="if(this.checked) { document.getElementById('delete-account-button').disabled = ''; } else { document.getElementById('delete-account-button').disabled = 'disabled'; }" /> <?php _e( 'I understand the consequences of deleting my account.', 'buddypress' ); ?>
    5959
    60                     <?php do_action( 'bp_users_delete_account_before_submit' ); ?>
     60                    <?php do_action( 'bp_members_delete_account_before_submit' ); ?>
    6161
    6262                    <div class="submit">
     
    6464                    </div>
    6565
    66                     <?php do_action( 'bp_users_delete_account_after_submit' ); ?>
     66                    <?php do_action( 'bp_members_delete_account_after_submit' ); ?>
    6767
    6868                    <?php wp_nonce_field( 'delete-account' ); ?>
  • trunk/bp-themes/bp-default/members/single/settings/notifications.php

    r3757 r3917  
    5757                    <?php do_action( 'bp_notification_settings' ); ?>
    5858
    59                     <?php do_action( 'bp_users_notification_settings_before_submit' ); ?>
     59                    <?php do_action( 'bp_members_notification_settings_before_submit' ); ?>
    6060
    6161                    <div class="submit">
     
    6363                    </div>
    6464
    65                     <?php do_action( 'bp_users_notification_settings_after_submit' ); ?>
     65                    <?php do_action( 'bp_members_notification_settings_after_submit' ); ?>
    6666
    6767                    <?php wp_nonce_field('bp_settings_notifications'); ?>
  • trunk/bp-themes/bp-default/registration/register.php

    r3790 r3917  
    4848                <?php /***** Extra Profile Details ******/ ?>
    4949
    50                 <?php if ( bp_is_active( 'profile' ) ) : ?>
     50                <?php if ( bp_is_active( 'xprofile' ) ) : ?>
    5151
    5252                    <?php do_action( 'bp_before_signup_profile_fields' ) ?>
     
    5757
    5858                        <?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?>
    59                         <?php if ( bp_is_active( 'profile' ) ) : if ( bp_has_profile( 'profile_group_id=1' ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
     59                        <?php if ( bp_is_active( 'xprofile' ) ) : if ( bp_has_profile( 'profile_group_id=1' ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
    6060
    6161                        <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
  • trunk/bp-xprofile/bp-xprofile-actions.php

    r3791 r3917  
    3838    bp_core_redirect( wp_get_referer() );
    3939}
    40 add_action( 'wp', 'xprofile_action_delete_avatar', 3 );
     40add_action( 'bp_actions', 'xprofile_action_delete_avatar' );
    4141
    4242?>
  • trunk/bp-xprofile/bp-xprofile-loader.php

    r3790 r3917  
    1919     */
    2020    function BP_XProfile_Component() {
    21         parent::start( 'profile', __( 'Extended Profiles', 'buddypress' ) );
     21        parent::start(
     22            'xprofile',
     23            __( 'Extended Profiles', 'buddypress' ),
     24            BP_PLUGIN_DIR
     25        );
     26    }
     27
     28    /**
     29     * Include files
     30     */
     31    function _includes() {
     32        $includes = array(
     33            'cssjs',
     34            'actions',
     35            'screens',
     36            'classes',
     37            'filters',
     38            'template',
     39            'functions'
     40        );
     41
     42        if ( is_admin() )
     43            $includes[] = 'admin';
     44
     45        parent::_includes( $includes );
    2246    }
    2347
     
    4367        define ( 'BP_XPROFILE_FULLNAME_FIELD_NAME', stripslashes( $bp->site_options['bp-xprofile-fullname-field-name'] ) );
    4468
    45         // Do some slug checks
    46         $this->slug      = BP_XPROFILE_SLUG;
    47         $this->root_slug = isset( $bp->pages->xprofile->slug ) ? $bp->pages->xprofile->slug : $this->slug;
    48 
    49         // Tables
    50         $this->table_name_data   = $bp->table_prefix . 'bp_xprofile_data';
    51         $this->table_name_groups = $bp->table_prefix . 'bp_xprofile_groups';
    52         $this->table_name_fields = $bp->table_prefix . 'bp_xprofile_fields';
    53         $this->table_name_meta   = $bp->table_prefix . 'bp_xprofile_meta';
    54 
    55         // Notifications
    56         $this->notification_callback = 'xprofile_format_notifications';
    57 
    58         // Register this in the active components array
    59         $bp->active_components[$this->id] = $this->id;
    60 
    6169        // Set the support field type ids
    6270        $this->field_types = apply_filters( 'xprofile_field_types', array(
     
    6977            'datebox'
    7078        ) );
    71     }
    7279
    73     /**
    74      * Include files
    75      */
    76     function _includes() {
    77         require_once( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-cssjs.php'     );
    78         require_once( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-admin.php'     );
    79         require_once( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-actions.php'   );
    80         require_once( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-screens.php'   );
    81         require_once( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-classes.php'   );
    82         require_once( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-filters.php'   );
    83         require_once( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-template.php'  );
    84         require_once( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-functions.php' );
     80        // Tables
     81        $global_tables = array(
     82            'table_name_data'   => $bp->table_prefix . 'bp_xprofile_data',
     83            'table_name_groups' => $bp->table_prefix . 'bp_xprofile_groups',
     84            'table_name_fields' => $bp->table_prefix . 'bp_xprofile_fields',
     85            'table_name_meta'   => $bp->table_prefix . 'bp_xprofile_meta',
     86        );
     87
     88        $globals = array(
     89            'slug'                  => BP_XPROFILE_SLUG,
     90            'root_slug'             => isset( $bp->pages->xprofile->slug ) ? $bp->pages->xprofile->slug : BP_XPROFILE_SLUG,
     91            'notification_callback' => 'xprofile_format_notifications',
     92            'global_tables'         => $global_tables
     93        );
     94
     95        parent::_setup_globals( $globals );
    8596    }
    8697
     
    94105
    95106        // Add 'Profile' to the main navigation
    96         bp_core_new_nav_item( array(
     107        $main_nav = array(
    97108            'name'                => __( 'Profile', 'buddypress' ),
    98109            'slug'                => $this->slug,
     
    101112            'default_subnav_slug' => 'public',
    102113            'item_css_id'         => $this->id
    103         ) );
     114        );
    104115
    105116        $profile_link = trailingslashit( $bp->loggedin_user->domain . $this->slug );
    106117
    107118        // Add the subnav items to the profile
    108         bp_core_new_subnav_item( array(
     119        $sub_nav[] = array(
    109120            'name'            => __( 'Public', 'buddypress' ),
    110121            'slug'            => 'public',
     
    113124            'screen_function' => 'xprofile_screen_display_profile',
    114125            'position'        => 10
    115         ) );
     126        );
    116127
    117128        // Edit Profile
    118         bp_core_new_subnav_item( array(
     129        $sub_nav[] = array(
    119130            'name'            => __( 'Edit Profile', 'buddypress' ),
    120131            'slug'            => 'edit',
     
    123134            'screen_function' => 'xprofile_screen_edit_profile',
    124135            'position'        => 20
    125         ) );
     136        );
    126137
    127138        // Change Avatar
    128         bp_core_new_subnav_item( array(
     139        $sub_nav[] = array(
    129140            'name'            => __( 'Change Avatar', 'buddypress' ),
    130141            'slug'            => 'change-avatar',
     
    133144            'screen_function' => 'xprofile_screen_change_avatar',
    134145            'position'        => 30
    135         ) );
     146        );
    136147
    137         if ( $bp->current_component == $this->id ) {
     148        parent::_setup_nav( $main_nav, $sub_nav );
     149    }
     150
     151    /**
     152     * Sets up the title for pages and <title>
     153     *
     154     * @global obj $bp
     155     */
     156    function _setup_title() {
     157        global $bp;
     158
     159        if ( bp_is_profile_component() ) {
    138160            if ( bp_is_my_profile() ) {
    139161                $bp->bp_options_title = __( 'My Profile', 'buddypress' );
     
    146168            }
    147169        }
     170
     171        parent::_setup_title();
    148172    }
    149173}
  • trunk/bp-xprofile/bp-xprofile-template.php

    r3903 r3917  
    739739    bp_button( array (
    740740        'id'                => 'edit_profile',
    741         'component'         => 'profile',
     741        'component'         => 'xprofile',
    742742        'must_be_logged_in' => true,
    743743        'block_self'        => true,
Note: See TracChangeset for help on using the changeset viewer.