Skip to:
Content

BuddyPress.org

Changeset 2863


Ignore:
Timestamp:
03/22/2010 11:34:23 AM (14 years ago)
Author:
apeatling
Message:

Added new install/upgrade wizard. Removed root components and replaced them with actual WordPress pages. Testing on WordPress vhost/novhost and root profile support still to do.

Location:
trunk
Files:
17 added
1 deleted
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity.php

    r2842 r2863  
    11<?php
    2 
    3 define ( 'BP_ACTIVITY_DB_VERSION', '2100' );
    4 
    5 /* Define the slug for the component */
    6 if ( !defined( 'BP_ACTIVITY_SLUG' ) )
    7     define ( 'BP_ACTIVITY_SLUG', 'activity' );
    8 
    92require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-classes.php' );
    103require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-templatetags.php' );
    114require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-filters.php' );
    125
    13 function bp_activity_install() {
    14     global $wpdb, $bp;
    15 
    16     if ( !empty($wpdb->charset) )
    17         $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    18 
    19     /* Rename the old user activity cached table if needed. */
    20     if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$wpdb->base_prefix}bp_activity_user_activity_cached%'" ) )
    21         $wpdb->query( "RENAME TABLE {$wpdb->base_prefix}bp_activity_user_activity_cached TO {$bp->activity->table_name}" );
    22 
    23     /* Rename fields from pre BP 1.2 */
    24     if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$bp->activity->table_name}%'" ) ) {
    25         if ( $wpdb->get_var( "SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_action'" ) )
    26             $wpdb->query( "ALTER TABLE {$bp->activity->table_name} CHANGE component_action type varchar(75) NOT NULL" );
    27 
    28         if ( $wpdb->get_var( "SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_name'" ) )
    29             $wpdb->query( "ALTER TABLE {$bp->activity->table_name} CHANGE component_name component varchar(75) NOT NULL" );
    30     }
    31 
    32     /**
    33      * Build the tables
    34      */
    35     $sql[] = "CREATE TABLE {$bp->activity->table_name} (
    36                 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    37                 user_id bigint(20) NOT NULL,
    38                 component varchar(75) NOT NULL,
    39                 type varchar(75) NOT NULL,
    40                 action text NOT NULL,
    41                 content longtext NOT NULL,
    42                 primary_link varchar(150) NOT NULL,
    43                 item_id varchar(75) NOT NULL,
    44                 secondary_item_id varchar(75) DEFAULT NULL,
    45                 date_recorded datetime NOT NULL,
    46                 hide_sitewide bool DEFAULT 0,
    47                 mptt_left int(11) NOT NULL DEFAULT 0,
    48                 mptt_right int(11) NOT NULL DEFAULT 0,
    49                 KEY date_recorded (date_recorded),
    50                 KEY user_id (user_id),
    51                 KEY item_id (item_id),
    52                 KEY secondary_item_id (secondary_item_id),
    53                 KEY component (component),
    54                 KEY type (type),
    55                 KEY mptt_left (mptt_left),
    56                 KEY mptt_right (mptt_right),
    57                 KEY hide_sitewide (hide_sitewide)
    58                ) {$charset_collate};";
    59 
    60     $sql[] = "CREATE TABLE {$bp->activity->table_name_meta} (
    61                 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    62                 activity_id bigint(20) NOT NULL,
    63                 meta_key varchar(255) DEFAULT NULL,
    64                 meta_value longtext DEFAULT NULL,
    65                 KEY activity_id (activity_id),
    66                 KEY meta_key (meta_key)
    67                ) {$charset_collate};";
    68 
    69     require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
    70     dbDelta($sql);
    71 
    72     update_site_option( 'bp-activity-db-version', BP_ACTIVITY_DB_VERSION );
    73 }
    74 
    756function bp_activity_setup_globals() {
    767    global $bp, $wpdb, $current_blog;
    778
    78     /* Internal identifier */
     9    if ( !defined( 'BP_ACTIVITY_SLUG' ) )
     10        define ( 'BP_ACTIVITY_SLUG', $bp->pages->activity->slug );
     11
     12    /* For internal identification */
    7913    $bp->activity->id = 'activity';
     14    $bp->activity->name = $bp->pages->activity->name;
     15    $bp->activity->slug = BP_ACTIVITY_SLUG;
    8016
    8117    $bp->activity->table_name = $wpdb->base_prefix . 'bp_activity';
    8218    $bp->activity->table_name_meta = $wpdb->base_prefix . 'bp_activity_meta';
    83     $bp->activity->slug = BP_ACTIVITY_SLUG;
    8419    $bp->activity->format_notification_function = 'bp_activity_format_notifications';
    8520
     
    9126add_action( 'bp_setup_globals', 'bp_activity_setup_globals' );
    9227
    93 function bp_activity_check_installed() {
    94     global $wpdb, $bp;
    95 
    96     if ( get_site_option( 'bp-activity-db-version' ) < BP_ACTIVITY_DB_VERSION )
    97         bp_activity_install();
    98 }
    99 add_action( 'admin_menu', 'bp_activity_check_installed' );
    100 
    101 function bp_activity_setup_root_component() {
    102     /* Register 'activity' as a root component (for RSS feed use) */
    103     bp_core_add_root_component( BP_ACTIVITY_SLUG );
    104 }
    105 add_action( 'bp_setup_root_components', 'bp_activity_setup_root_component' );
    106 
    10728function bp_activity_setup_nav() {
    10829    global $bp;
    10930
    11031    /* Add 'Activity' to the main navigation */
    111     bp_core_new_nav_item( array( 'name' => __( 'Activity', 'buddypress' ), 'slug' => $bp->activity->slug, 'position' => 10, 'screen_function' => 'bp_activity_screen_my_activity', 'default_subnav_slug' => 'just-me', 'item_css_id' => $bp->activity->id ) );
     32    bp_core_new_nav_item( array( 'name' => __( 'Activity', 'buddypress' ), 'slug' => $bp->activity->name, 'position' => 10, 'screen_function' => 'bp_activity_screen_my_activity', 'default_subnav_slug' => 'just-me', 'item_css_id' => $bp->activity->id ) );
    11233
    11334    $user_domain = ( !empty( $bp->displayed_user->domain ) ) ? $bp->displayed_user->domain : $bp->loggedin_user->domain;
    11435    $user_login = ( !empty( $bp->displayed_user->userdata->user_login ) ) ? $bp->displayed_user->userdata->user_login : $bp->loggedin_user->userdata->user_login;
    115     $activity_link = $user_domain . $bp->activity->slug . '/';
     36    $activity_link = $user_domain . $bp->activity->name . '/';
    11637
    11738    /* Add the subnav items to the activity nav item if we are using a theme that supports this */
    118     bp_core_new_subnav_item( array( 'name' => __( 'Personal', 'buddypress' ), 'slug' => 'just-me', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_my_activity', 'position' => 10 ) );
     39    bp_core_new_subnav_item( array( 'name' => __( 'Personal', 'buddypress' ), 'slug' => 'just-me', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_my_activity', 'position' => 10 ) );
    11940
    12041    if ( bp_is_active( 'friends' ) )
    121         bp_core_new_subnav_item( array( 'name' => __( 'Friends', 'buddypress' ), 'slug' => BP_FRIENDS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_friends', 'position' => 20, 'item_css_id' => 'activity-friends' ) );
     42        bp_core_new_subnav_item( array( 'name' => __( 'Friends', 'buddypress' ), 'slug' => BP_FRIENDS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_friends', 'position' => 20, 'item_css_id' => 'activity-friends' ) );
    12243
    12344    if ( bp_is_active( 'groups' ) )
    124         bp_core_new_subnav_item( array( 'name' => __( 'Groups', 'buddypress' ), 'slug' => BP_GROUPS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_groups', 'position' => 30, 'item_css_id' => 'activity-groups' ) );
    125 
    126     bp_core_new_subnav_item( array( 'name' => __( 'Favorites', 'buddypress' ), 'slug' => 'favorites', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_favorites', 'position' => 40, 'item_css_id' => 'activity-favs' ) );
    127     bp_core_new_subnav_item( array( 'name' => sprintf( __( '@%s Mentions', 'buddypress' ), $user_login ), 'slug' => 'mentions', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_mentions', 'position' => 50, 'item_css_id' => 'activity-mentions' ) );
     45        bp_core_new_subnav_item( array( 'name' => __( 'Groups', 'buddypress' ), 'slug' => $bp->groups->name, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_groups', 'position' => 30, 'item_css_id' => 'activity-groups' ) );
     46
     47    bp_core_new_subnav_item( array( 'name' => __( 'Favorites', 'buddypress' ), 'slug' => 'favorites', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_favorites', 'position' => 40, 'item_css_id' => 'activity-favs' ) );
     48    bp_core_new_subnav_item( array( 'name' => sprintf( __( '@%s Mentions', 'buddypress' ), $user_login ), 'slug' => 'mentions', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_mentions', 'position' => 50, 'item_css_id' => 'activity-mentions' ) );
    12849
    12950    if ( $bp->current_component == $bp->activity->slug ) {
     
    215136    global $bp;
    216137
    217     if ( !$bp->displayed_user->id || $bp->current_component != $bp->activity->slug )
     138    if ( !$bp->displayed_user->id || $bp->current_component != $bp->activity->name )
    218139        return false;
    219140
  • trunk/bp-blogs.php

    r2842 r2863  
    11<?php
    2 
    3 define ( 'BP_BLOGS_DB_VERSION', '2015' );
    4 
    5 /* Define the slug for the component */
    6 if ( !defined( 'BP_BLOGS_SLUG' ) )
    7     define ( 'BP_BLOGS_SLUG', 'blogs' );
    8 
    92require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-classes.php' );
    103require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-templatetags.php' );
     
    147    require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-widgets.php' );
    158
    16 function bp_blogs_install() {
    17     global $wpdb, $bp;
    18 
    19     if ( !empty($wpdb->charset) )
    20         $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    21 
    22     $sql[] = "CREATE TABLE {$bp->blogs->table_name} (
    23                 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    24                 user_id bigint(20) NOT NULL,
    25                 blog_id bigint(20) NOT NULL,
    26                 KEY user_id (user_id),
    27                 KEY blog_id (blog_id)
    28              ) {$charset_collate};";
    29 
    30     $sql[] = "CREATE TABLE {$bp->blogs->table_name_blogmeta} (
    31                 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    32                 blog_id bigint(20) NOT NULL,
    33                 meta_key varchar(255) DEFAULT NULL,
    34                 meta_value longtext DEFAULT NULL,
    35                 KEY blog_id (blog_id),
    36                 KEY meta_key (meta_key)
    37              ) {$charset_collate};";
    38 
    39 
    40     require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
    41 
    42     dbDelta($sql);
    43 
    44     // On first installation - record all existing blogs in the system.
    45     if ( !(int)$bp->site_options['bp-blogs-first-install'] && bp_core_is_multisite() ) {
    46         bp_blogs_record_existing_blogs();
    47         add_site_option( 'bp-blogs-first-install', 1 );
    48     }
    49 
    50     update_site_option( 'bp-blogs-db-version', BP_BLOGS_DB_VERSION );
    51 }
    52 
    53 function bp_blogs_check_installed() {
    54     global $wpdb, $bp, $userdata;
    55 
    56     /* Only create the bp-blogs tables if this is a multisite install */
    57     if ( is_site_admin() && bp_core_is_multisite() ) {
    58         /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
    59         if ( get_site_option( 'bp-blogs-db-version' ) < BP_BLOGS_DB_VERSION )
    60             bp_blogs_install();
    61     }
    62 }
    63 add_action( 'admin_menu', 'bp_blogs_check_installed' );
    64 
    659function bp_blogs_setup_globals() {
    6610    global $bp, $wpdb;
    6711
     12    if ( !defined( 'BP_BLOGS_SLUG' ) )
     13        define ( 'BP_BLOGS_SLUG', $bp->pages->blogs->slug );
     14
    6815    /* For internal identification */
    6916    $bp->blogs->id = 'blogs';
     17    $bp->blogs->name = $bp->pages->blogs->name;
     18    $bp->blogs->slug = BP_BLOGS_SLUG;
    7019
    7120    $bp->blogs->table_name = $wpdb->base_prefix . 'bp_user_blogs';
    7221    $bp->blogs->table_name_blogmeta = $wpdb->base_prefix . 'bp_user_blogs_blogmeta';
    7322    $bp->blogs->format_notification_function = 'bp_blogs_format_notifications';
    74     $bp->blogs->slug = BP_BLOGS_SLUG;
    7523
    7624    /* Register this in the active components array */
     
    8028}
    8129add_action( 'bp_setup_globals', 'bp_blogs_setup_globals' );
    82 
    83 function bp_blogs_setup_root_component() {
    84     /* Register 'blogs' as a root component */
    85     bp_core_add_root_component( BP_BLOGS_SLUG );
    86 }
    87 add_action( 'bp_setup_root_components', 'bp_blogs_setup_root_component' );
    8830
    8931/**
     
    10547
    10648    /* Add 'Blogs' to the main navigation */
    107     bp_core_new_nav_item( array( 'name' => sprintf( __( 'Blogs <span>(%d)</span>', 'buddypress' ), bp_blogs_total_blogs_for_user() ), 'slug' => $bp->blogs->slug, 'position' => 30, 'screen_function' => 'bp_blogs_screen_my_blogs', 'default_subnav_slug' => 'my-blogs', 'item_css_id' => $bp->blogs->id ) );
    108 
    109     $blogs_link = $bp->loggedin_user->domain . $bp->blogs->slug . '/';
     49    bp_core_new_nav_item( array( 'name' => sprintf( __( 'Blogs <span>(%d)</span>', 'buddypress' ), bp_blogs_total_blogs_for_user() ), 'slug' => $bp->blogs->name, 'position' => 30, 'screen_function' => 'bp_blogs_screen_my_blogs', 'default_subnav_slug' => 'my-blogs', 'item_css_id' => $bp->blogs->id ) );
     50
     51    $blogs_link = $bp->loggedin_user->domain . $bp->blogs->name . '/';
    11052
    11153    /* Set up the component options navigation for Blog */
  • trunk/bp-core.php

    r2842 r2863  
    11<?php
    2 
    3 /* Define the current version number for checking if DB tables are up to date. */
    4 define( 'BP_CORE_DB_VERSION', '1800' );
    52
    63/***
     
    4643    require ( BP_PLUGIN_DIR . '/bp-core/bp-core-adminbar.php' );
    4744
    48 /* Define the slug for member pages and the members directory (e.g. domain.com/[members] ) */
    49 if ( !defined( 'BP_MEMBERS_SLUG' ) )
    50     define( 'BP_MEMBERS_SLUG', 'members' );
    51 
    52 /* Define the slug for the register/signup page */
    53 if ( !defined( 'BP_REGISTER_SLUG' ) )
    54     define( 'BP_REGISTER_SLUG', 'register' );
    55 
    56 /* Define the slug for the activation page */
    57 if ( !defined( 'BP_ACTIVATION_SLUG' ) )
    58     define( 'BP_ACTIVATION_SLUG', 'activate' );
    59 
    60 /* Define the slug for the search page */
    61 if ( !defined( 'BP_SEARCH_SLUG' ) )
    62     define( 'BP_SEARCH_SLUG', 'search' );
    63 
    6445/* Register BuddyPress themes contained within the bp-theme folder */
    6546if ( function_exists( 'register_theme_directory') )
     
    8768    global $bp, $wpdb;
    8869    global $current_user, $current_component, $current_action, $current_blog;
    89     global $displayed_user_id;
     70    global $displayed_user_id, $bp_pages;
    9071    global $action_variables;
    9172
     
    9576    $bp->root_domain = bp_core_get_root_domain();
    9677
     78    /* Contains an array of all the active components. The key is the slug, value the internal ID of the component */
     79    $bp->active_components = array();
     80
     81    /* The names of the core WordPress pages used to display BuddyPress content */
     82    $bp->pages = $bp_pages;
     83
     84    /* Set up the members id and active components entry */
     85    $bp->members->id = 'members';
     86    $bp->members->slug = $bp->pages->members->slug;
     87    $bp->active_components[$bp->members->slug] = $bp->members->id;
     88
    9789    /* The user ID of the user who is currently logged in. */
    9890    $bp->loggedin_user->id = $current_user->ID;
     
    133125    /* The default component to use if none are set and someone visits: http://domain.com/members/andy */
    134126    if ( !defined( 'BP_DEFAULT_COMPONENT' ) ) {
    135         if ( defined( 'BP_ACTIVITY_SLUG' ) )
    136             $bp->default_component = BP_ACTIVITY_SLUG;
     127        if ( isset( $bp->pages->activity ) )
     128            $bp->default_component = $bp->pages->activity->name;
    137129        else
    138             $bp->default_component = 'profile';
     130            $bp->default_component = $bp->pages->profile->name;
    139131    } else {
    140132        $bp->default_component = BP_DEFAULT_COMPONENT;
     
    149141    /* Sets up the array container for the component options navigation rendered by bp_get_options_nav() */
    150142    $bp->bp_options_nav = array();
    151 
    152     /* Contains an array of all the active components. The key is the slug, value the internal ID of the component */
    153     $bp->active_components = array();
    154143
    155144    /* Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar */
     
    181170
    182171/**
    183  * bp_core_setup_root_uris()
    184  *
    185  * Adds the core URIs that should run in the root of the installation.
    186  *
    187  * For example: http://example.org/search/ or http://example.org/members/
    188  *
    189  * @package BuddyPress Core
    190  * @uses bp_core_add_root_component() Adds a slug to the root components global variable.
    191  */
    192 function bp_core_setup_root_uris() {
    193     /* Add core root components */
    194     bp_core_add_root_component( BP_MEMBERS_SLUG );
    195     bp_core_add_root_component( BP_REGISTER_SLUG );
    196     bp_core_add_root_component( BP_ACTIVATION_SLUG );
    197     bp_core_add_root_component( BP_SEARCH_SLUG );
    198 }
    199 add_action( 'plugins_loaded', 'bp_core_setup_root_uris', 2 );
    200 
    201 
    202 /**
    203  * bp_core_install()
    204  *
    205  * Installs the core DB tables for BuddyPress.
    206  *
    207  * @package BuddyPress Core
     172 * bp_core_define_slugs()
     173 *
     174 * Define the slugs used for BuddyPress pages, based on the slugs of the WP pages used.
     175 * These can be overridden manually by defining these slugs in wp-config.php.
     176 *
     177 * @package BuddyPress Core Core
    208178 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    209  * @global $wpdb WordPress DB access object.
    210  * @uses dbDelta() Performs a table creation, or upgrade based on what already exists in the DB.
    211  * @uses bp_core_add_illegal_names() Adds illegal blog names to the WP settings
    212  */
    213 function bp_core_install() {
    214     global $wpdb, $bp;
    215 
    216     if ( !empty($wpdb->charset) )
    217         $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    218 
    219     $sql[] = "CREATE TABLE {$bp->core->table_name_notifications} (
    220                 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    221                 user_id bigint(20) NOT NULL,
    222                 item_id bigint(20) NOT NULL,
    223                 secondary_item_id bigint(20),
    224                 component_name varchar(75) NOT NULL,
    225                 component_action varchar(75) NOT NULL,
    226                 date_notified datetime NOT NULL,
    227                 is_new bool NOT NULL DEFAULT 0,
    228                 KEY item_id (item_id),
    229                 KEY secondary_item_id (secondary_item_id),
    230                 KEY user_id (user_id),
    231                 KEY is_new (is_new),
    232                 KEY component_name (component_name),
    233                 KEY component_action (component_action),
    234                 KEY useritem (user_id,is_new)
    235                ) {$charset_collate};";
    236 
    237     require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
    238     dbDelta( $sql );
    239 
    240     /* Add names of root components to the banned blog list to avoid conflicts */
    241     if ( bp_core_is_multisite() )
    242         bp_core_add_illegal_names();
    243 
    244     update_site_option( 'bp-core-db-version', BP_CORE_DB_VERSION );
    245 }
    246 
    247 /**
    248  * bp_core_check_installed()
    249  *
    250  * Checks to make sure the database tables are set up for the core component.
    251  *
    252  * @package BuddyPress Core
    253  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    254  * @global $wpdb WordPress DB access object.
    255  * @global $current_user WordPress global variable containing current logged in user information
     179 */
     180function bp_core_define_slugs() {
     181    global $bp;
     182
     183    if ( !defined( 'BP_MEMBERS_SLUG' ) )
     184        define( 'BP_MEMBERS_SLUG', $bp->pages->members->slug );
     185
     186    if ( !defined( 'BP_REGISTER_SLUG' ) )
     187        define( 'BP_REGISTER_SLUG', $bp->pages->register->slug );
     188
     189    if ( !defined( 'BP_ACTIVATION_SLUG' ) )
     190        define( 'BP_ACTIVATION_SLUG', $bp->pages->activate->slug );
     191}
     192add_action( 'bp_setup_globals', 'bp_core_define_slugs' );
     193
     194function bp_core_get_page_names() {
     195    global $wpdb;
     196
     197    $page_ids = get_site_option( 'bp-pages' );
     198
     199    if ( empty( $page_ids ) )
     200        return false;
     201
     202    $page_ids_sql = implode( ',', (array)$page_ids );
     203    $page_names = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM {$wpdb->posts} WHERE ID IN ({$page_ids_sql}) " ) );
     204    $pages = new stdClass;
     205
     206    foreach ( (array)$page_ids as $key => $page_id ) {
     207        foreach ( (array)$page_names as $page_name ) {
     208            if ( $page_name->ID == $page_id ) {
     209                $pages->{$key}->name = $page_name->post_name;
     210                $pages->{$key}->id = $page_name->ID;
     211
     212                $slug[] = $page_name->post_name;
     213
     214                /* Get the slug */
     215                while ( $page_name->post_parent != 0 ) {
     216                    $parent = $wpdb->get_results( $wpdb->prepare( "SELECT post_name, post_parent FROM {$wpdb->posts} WHERE ID = %d", $page_name->post_parent ) );
     217                    $slug[] = $parent[0]->post_name;
     218                    $page_name->post_parent = $parent[0]->post_parent;
     219                }
     220
     221                $pages->{$key}->slug = implode( '/', array_reverse( (array)$slug ) );
     222            }
     223
     224            unset( $slug );
     225        }
     226    }
     227
     228
     229    return apply_filters( 'bp_core_get_page_names', $pages );
     230}
     231
     232/**
     233 * bp_core_admin_menu_init()
     234 *
     235 * Initializes the wp-admin area "BuddyPress" menus and sub menus.
     236 *
     237 * @package BuddyPress Core
    256238 * @uses is_site_admin() returns true if the current user is a site admin, false if not
    257  * @uses get_site_option() fetches the value for a meta_key in the wp_sitemeta table
    258  * @uses bp_core_install() runs the installation of DB tables for the core component
    259  */
    260 function bp_core_check_installed() {
    261     global $wpdb, $bp;
    262 
     239 */
     240function bp_core_admin_menu_init() {
    263241    if ( !is_site_admin() )
    264242        return false;
    265243
    266     require ( BP_PLUGIN_DIR . '/bp-core/bp-core-admin.php' );
    267 
    268     /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
    269     if ( get_site_option( 'bp-core-db-version' ) < BP_CORE_DB_VERSION )
    270         bp_core_install();
    271 }
    272 add_action( 'admin_menu', 'bp_core_check_installed' );
     244    require ( BP_PLUGIN_DIR . '/bp-core/admin/bp-core-admin.php' );
     245}
     246add_action( 'admin_menu', 'bp_core_admin_menu_init' );
    273247
    274248/**
     
    288262
    289263    /* Add the administration tab under the "Site Admin" tab for site administrators */
    290     bp_core_add_admin_menu_page( array(
     264    $hook = bp_core_add_admin_menu_page( array(
    291265        'menu_title' => __( 'BuddyPress', 'buddypress' ),
    292266        'page_title' => __( 'BuddyPress', 'buddypress' ),
    293267        'access_level' => 10, 'file' => 'bp-general-settings',
    294         'function' => 'bp_core_admin_settings',
     268        'function' => 'bp_core_admin_dashboard',
    295269        'position' => 2
    296270    ) );
    297271
    298     add_submenu_page( 'bp-general-settings', __( 'General Settings', 'buddypress'), __( 'General Settings', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_settings' );
    299     add_submenu_page( 'bp-general-settings', __( 'Component Setup', 'buddypress'), __( 'Component Setup', 'buddypress' ), 'manage_options', 'bp-component-setup', 'bp_core_admin_component_setup' );
     272    add_submenu_page( 'bp-general-settings', __( 'BuddyPress Dashboard', 'buddypress' ), __( 'Dashboard', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_dashboard' );
     273    add_submenu_page( 'bp-general-settings', __( 'Settings', 'buddypress' ), __( 'Settings', 'buddypress' ), 'manage_options', 'bp-settings', 'bp_core_admin_settings' );
     274
     275    /* Add a hook for css/js */
     276    add_action( "admin_print_styles-$hook", 'bp_core_add_admin_menu_styles' );
    300277}
    301278add_action( 'admin_menu', 'bp_core_add_admin_menu' );
    302279
    303 /**
    304  * bp_core_is_root_component()
    305  *
    306  * Checks to see if a component's URL should be in the root, not under a member page:
    307  * eg: http://domain.com/groups/the-group NOT http://domain.com/members/andy/groups/the-group
    308  *
    309  * @package BuddyPress Core
    310  * @return true if root component, else false.
    311  */
    312 function bp_core_is_root_component( $component_name ) {
    313     global $bp;
    314 
    315     return in_array( $component_name, $bp->root_components );
    316 }
    317280
    318281/**
     
    395358    global $bp;
    396359
    397     if ( is_null( $bp->displayed_user->id ) && $bp->current_component == BP_MEMBERS_SLUG ) {
     360    if ( is_null( $bp->displayed_user->id ) && $bp->current_component == $bp->members->slug ) {
    398361        $bp->is_directory = true;
    399362
     
    507470add_action( 'wp', 'bp_core_action_delete_user', 3 );
    508471
    509 
    510472/********************************************************************************
    511473 * Business Functions
     
    564526        /* If we are using a members slug, include it. */
    565527        if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) )
    566             $domain = $bp->root_domain . '/' . BP_MEMBERS_SLUG . '/' . $username . '/';
     528            $domain = $bp->root_domain . '/' . $bp->members->slug . '/' . $username . '/';
    567529        else
    568530            $domain = $bp->root_domain . '/' . $username . '/';
     
    689651     * default subnav function so we can display a directory or something else.
    690652     */
    691     if ( bp_core_is_root_component( $slug ) && !$bp->displayed_user->id )
     653    if ( !$bp->displayed_user->id )
    692654        return;
    693655
     
    916878}
    917879
    918 /**
    919  * bp_core_load_template()
    920  *
    921  * Uses the bp_catch_uri function to load a specific template file with fallback support.
    922  *
    923  * Example:
    924  *   bp_core_load_template( 'profile/edit-profile' );
    925  * Loads:
    926  *   wp-content/themes/[activated_theme]/profile/edit-profile.php
     880
     881/**
     882 * bp_core_get_random_member()
     883 *
     884 * Returns the user_id for a user based on their username.
    927885 *
    928886 * @package BuddyPress Core
     
    932890 * @return int the user ID of the matched user.
    933891 */
    934 function bp_core_load_template( $template, $skip_blog_check = false ) {
    935     return bp_catch_uri( $template, $skip_blog_check );
    936 }
    937 
    938 /**
    939  * bp_core_add_root_component()
    940  *
    941  * Adds a component to the $bp->root_components global.
    942  * Any component that runs in the "root" of an install should be added.
    943  * The "root" as in, it can or always runs outside of the /members/username/ path.
    944  *
    945  * Example of a root component:
    946  *  Groups: http://domain.com/groups/group-name
    947  *          http://community.domain.com/groups/group-name
    948  *          http://domain.com/wpmu/groups/group-name
    949  *
    950  * Example of a component that is NOT a root component:
    951  *  Friends: http://domain.com/members/andy/friends
    952  *           http://community.domain.com/members/andy/friends
    953  *           http://domain.com/wpmu/members/andy/friends
    954  *
    955  * @package BuddyPress Core
    956  * @param $slug str The slug of the component
    957  * @global $bp BuddyPress global settings
    958  */
    959 function bp_core_add_root_component( $slug ) {
    960     global $bp;
    961 
    962     $bp->root_components[] = $slug;
    963 }
    964 
    965 /**
    966  * bp_core_get_random_member()
     892function bp_core_get_random_member() {
     893    global $bp, $wpdb;
     894
     895    if ( isset( $_GET['random-member'] ) ) {
     896        $user = bp_core_get_users( array( 'type' => 'random', 'per_page' => 1 ) );
     897        bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->id ) );
     898    }
     899}
     900add_action( 'wp', 'bp_core_get_random_member' );
     901
     902/**
     903 * bp_core_get_userid()
    967904 *
    968905 * Returns the user_id for a user based on their username.
     
    974911 * @return int the user ID of the matched user.
    975912 */
    976 function bp_core_get_random_member() {
    977     global $bp, $wpdb;
    978 
    979     if ( isset( $_GET['random-member'] ) ) {
    980         $user = bp_core_get_users( array( 'type' => 'random', 'per_page' => 1 ) );
    981         bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->id ) );
    982     }
    983 }
    984 add_action( 'wp', 'bp_core_get_random_member' );
    985 
    986 /**
    987  * bp_core_get_userid()
    988  *
    989  * Returns the user_id for a user based on their username.
     913function bp_core_get_userid( $username ) {
     914    global $wpdb;
     915
     916    if ( !empty( $username ) )
     917        return apply_filters( 'bp_core_get_userid', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ) );
     918}
     919
     920/**
     921 * bp_core_get_userid_from_nicename()
     922 *
     923 * Returns the user_id for a user based on their user_nicename.
    990924 *
    991925 * @package BuddyPress Core
     
    995929 * @return int the user ID of the matched user.
    996930 */
    997 function bp_core_get_userid( $username ) {
     931function bp_core_get_userid_from_nicename( $user_nicename ) {
    998932    global $wpdb;
    999933
    1000     if ( !empty( $username ) )
    1001         return apply_filters( 'bp_core_get_userid', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ) );
    1002 }
     934    if ( empty( $user_nicename ) )
     935        return false;
     936
     937    return apply_filters( 'bp_core_get_userid_from_nicename', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_nicename = %s", $user_nicename ) ) );
     938}
     939
    1003940
    1004941/**
     
    17181655            switch ( $search_which ) {
    17191656                case 'members': default:
    1720                     $slug = BP_MEMBERS_SLUG;
     1657                    $slug = $bp->members->slug;
    17211658                    $var = '/?s=';
    17221659                    break;
     
    20401977remove_action( 'plugins_loaded', 'catch_nonexistant_blogs' );
    20411978
     1979
     1980/* DEPRECATED FUNCTIONS ****/
     1981
     1982/**
     1983 * bp_core_add_root_component()
     1984 *
     1985 * This function originally let plugins add support for pages in the root of the install.
     1986 * These pages are now handled by actual WordPress pages so this function is deprecated.
     1987 * It now simply facilitates backwards compatibility by adding a WP page if the plugin has not been
     1988 * updated to do so.
     1989 *
     1990 * @package BuddyPress Core
     1991 * @param $slug str The slug of the component
     1992 * @global $bp BuddyPress global settings
     1993 */
     1994function bp_core_add_root_component( $slug ) {
     1995    global $bp, $bp_pages;
     1996
     1997    if ( empty( $bp_pages ) )
     1998        $bp_pages = bp_core_get_page_names();
     1999
     2000    $match = false;
     2001
     2002    /* Check if the slug is registered in the $bp->pages global */
     2003    foreach ( (array)$bp_pages as $key => $page ) {
     2004        if ( $key == $slug || $page->slug == $slug )
     2005            $match = true;
     2006    }
     2007
     2008    /* If there was no match, add a page for this root component */
     2009    if ( empty( $match ) ) {
     2010        $bp->add_root[] = $slug;
     2011        add_action( 'init', 'bp_core_create_root_component_page' );
     2012    }
     2013}
     2014
     2015function bp_core_create_root_component_page() {
     2016    global $bp;
     2017
     2018    $new_page_ids = array();
     2019
     2020    var_dump( $bp->add_root );
     2021
     2022    foreach ( (array)$bp->add_root as $slug )
     2023        $new_page_ids[$slug] = wp_insert_post( array( 'post_title' => ucwords( $slug ), 'post_status' => 'publish', 'post_type' => 'page' ) );
     2024
     2025    $page_ids = get_site_option( 'bp-pages' );
     2026    $page_ids = (array) $page_ids;
     2027    $page_ids = array_merge( (array) $new_page_ids, (array) $page_ids );
     2028    update_site_option( 'bp-pages', $page_ids );
     2029}
     2030
     2031function bp_core_is_root_component( $component_name ) {
     2032    global $bp;
     2033
     2034    foreach ( (array) $bp->pages as $key => $page ) {
     2035        if ( $key == $component_name || $page->slug == $component_name )
     2036            return true;
     2037    }
     2038
     2039    return false;
     2040}
     2041
    20422042?>
  • trunk/bp-core/bp-core-adminbar.php

    r2770 r2863  
    222222        <a href="#"><?php _e( 'Visit', 'buddypress' ) ?></a>
    223223        <ul class="random-list">
    224             <li><a href="<?php echo $bp->root_domain . '/' . BP_MEMBERS_SLUG . '/?random-member' ?>"><?php _e( 'Random Member', 'buddypress' ) ?></a></li>
     224            <li><a href="<?php echo $bp->root_domain . '/' . $bp->members->slug . '/?random-member' ?>"><?php _e( 'Random Member', 'buddypress' ) ?></a></li>
    225225
    226226            <?php if ( function_exists('groups_install') ) : ?>
  • trunk/bp-core/bp-core-catchuri.php

    r2695 r2863  
    2828function bp_core_set_uri_globals() {
    2929    global $current_component, $current_action, $action_variables;
    30     global $displayed_user_id;
     30    global $displayed_user_id, $bp_pages;
    3131    global $is_member_page;
    32     global $bp_unfiltered_uri;
     32    global $bp_unfiltered_uri, $bp_unfiltered_uri_offset;
    3333    global $bp, $current_blog;
     34
     35    /* Fetch all the WP page names for each component */
     36    if ( empty( $bp_pages ) )
     37        $bp_pages = bp_core_get_page_names();
    3438
    3539    if ( !defined( 'BP_ENABLE_MULTIBLOG' ) && bp_core_is_multisite() ) {
     
    6973    $action_index = $component_index + 1;
    7074
    71     // If this is a WordPress page, return from the function.
    72     if ( is_page( $bp_uri[$component_index] ) )
    73         return false;
    74 
    7575    /* Get site path items */
    7676    $paths = explode( '/', bp_core_get_site_path() );
     
    9494    $bp_unfiltered_uri = $bp_uri;
    9595
    96     /* If we are under anything with a members slug, set the correct globals */
    97     if ( $bp_uri[0] == BP_MEMBERS_SLUG ) {
    98         $is_member_page = true;
    99         $is_root_component = true;
    100     }
    101 
    102     /* Catch a member page and set the current member ID */
    103     if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) ) {
    104         if ( ( $bp_uri[0] == BP_MEMBERS_SLUG && !empty( $bp_uri[1] ) ) || in_array( 'wp-load.php', $bp_uri ) ) {
    105             // We are within a member page, set up user id globals
    106             $displayed_user_id = bp_core_get_displayed_userid( $bp_uri[1] );
    107 
    108             unset($bp_uri[0]);
    109             unset($bp_uri[1]);
    110 
    111             /* Reset the keys by merging with an empty array */
    112             $bp_uri = array_merge( array(), $bp_uri );
    113         }
    114     } else {
    115         if ( get_userdatabylogin( $bp_uri[0] ) || in_array( 'wp-load.php', $bp_uri ) ) {
    116             $is_member_page = true;
    117             $is_root_component = true;
    118 
    119             // We are within a member page, set up user id globals
    120             $displayed_user_id = bp_core_get_displayed_userid( $bp_uri[0] );
    121 
    122             unset($bp_uri[0]);
    123 
    124             /* Reset the keys by merging with an empty array */
    125             $bp_uri = array_merge( array(), $bp_uri );
    126         }
    127     }
    128 
    129     if ( !isset($is_root_component) )
    130         $is_root_component = in_array( $bp_uri[0], $bp->root_components );
    131 
    132     if ( 'no' == VHOST && !$is_root_component ) {
    133         $component_index++;
    134         $action_index++;
    135     }
     96    /* Find a match within registered BuddyPress controlled WP pages (check members first) */
     97    foreach ( (array)$bp_pages as $page_key => $bp_page ) {
     98        if ( in_array( $bp_page->name, (array)$bp_uri ) ) {
     99            /* Match found, now match the slug to make sure. */
     100            $uri_chunks = explode( '/', $bp_page->slug );
     101
     102            foreach ( (array)$uri_chunks as $key => $uri_chunk ) {
     103                if ( $bp_uri[$key] == $uri_chunk ) {
     104                    $matches[] = 1;
     105                } else {
     106                    $matches[] = 0;
     107                }
     108            }
     109
     110            if ( !in_array( 0, (array) $matches ) ) {
     111                $match = $bp_page;
     112                $match->key = $page_key;
     113                break;
     114            };
     115
     116            unset( $matches );
     117        }
     118
     119        unset( $uri_chunks );
     120    }
     121
     122    /* This is not a BuddyPress page, so just return. */
     123    if ( in_array( 0, (array) $matches ) )
     124        return false;
     125
     126    /* Find the offset */
     127    $uri_offset = 0;
     128    $slug = explode( '/', $match->slug );
     129
     130    if ( !empty( $slug ) && 1 != count( $slug ) ) {
     131        array_pop( $slug );
     132        $uri_offset = count( $slug );
     133    }
     134
     135    /* Global the unfiltered offset to use in bp_core_load_template() */
     136    $bp_unfiltered_uri_offset = $uri_offset;
     137
     138    /* This is a members page so lets check if we have a displayed member */
     139    if ( 'members' == $match->key ) {
     140        if ( !empty( $bp_uri[$uri_offset + 1] ) ) {
     141            if ( defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) )
     142                $displayed_user_id = (int) bp_core_get_userid( $bp_uri[$uri_offset + 1] );
     143            else
     144                $displayed_user_id = (int) bp_core_get_userid_from_nicename( $bp_uri[$uri_offset + 1] );
     145
     146            $uri_offset = $uri_offset + 2;
     147
     148            /* Remove everything from the URI up to the offset and take it from there. */
     149            for ( $i = 0; $i < $uri_offset; $i++ ) {
     150                unset( $bp_uri[$i] );
     151            }
     152
     153            $current_component = $bp_uri[$uri_offset];
     154        }
     155    }
     156
     157    /* Reset the keys by merging with an empty array */
     158    $bp_uri = array_merge( array(), $bp_uri );
    136159
    137160    /* Set the current component */
    138     $current_component = $bp_uri[$component_index];
     161    if ( empty( $current_component ) ) {
     162        for ( $i = 0; $i <= $uri_offset; $i++ ) {
     163            if ( !empty( $bp_uri[$i] ) ) {
     164                $current_component .= $bp_uri[$i];
     165
     166                if ( $i != $uri_offset )
     167                    $current_component .= '/';
     168            }
     169        }
     170    } else
     171        $i = 1;
    139172
    140173    /* Set the current action */
    141     $current_action = $bp_uri[$action_index];
     174    $current_action = $bp_uri[$i];
     175
     176    /* Unset the current_component and action from action_variables */
     177    for ( $j = 0; $j <= $i; $j++ )
     178        unset( $bp_uri[$j] );
    142179
    143180    /* Set the entire URI as the action variables, we will unset the current_component and action in a second */
    144181    $action_variables = $bp_uri;
    145182
    146     /* Unset the current_component and action from action_variables */
    147     unset($action_variables[$component_index]);
    148     unset($action_variables[$action_index]);
    149 
    150183    /* Remove the username from action variables if this is not a VHOST install */
    151184    if ( 'no' == VHOST && !$is_root_component )
    152         array_shift($action_variables);
     185        array_shift($bp_uri);
    153186
    154187    /* Reset the keys by merging with an empty array */
    155188    $action_variables = array_merge( array(), $action_variables );
    156189
    157     //var_dump($current_component, $current_action, $action_variables); die;
     190    //var_dump($current_component, $current_action, $bp_uri);
    158191}
    159192add_action( 'plugins_loaded', 'bp_core_set_uri_globals', 3 );
    160193
    161194/**
    162  * bp_catch_uri()
    163  *
    164  * Takes either a single page name or array of page names and
    165  * loads the first template file that can be found.
    166  *
    167  * Please don't call this function directly anymore, use: bp_core_load_template()
     195 * bp_core_load_template()
     196 *
     197 * Load a specific template file with fallback support.
     198 *
     199 * Example:
     200 *   bp_core_load_template( 'members/index' );
     201 * Loads:
     202 *   wp-content/themes/[activated_theme]/members/index.php
    168203 *
    169204 * @package BuddyPress Core
    170  * @global $bp_path BuddyPress global containing the template file names to use.
    171  * @param $pages Template file names to use.
    172  * @uses add_action() Hooks a function on to a specific action
     205 * @param $username str Username to check.
     206 * @global $wpdb WordPress DB access object.
     207 * @return false on no match
     208 * @return int the user ID of the matched user.
    173209 */
    174 function bp_catch_uri( $pages, $skip_blog_check = false ) {
    175     global $bp_path, $bp_skip_blog_check;
    176 
    177     $bp_skip_blog_check = $skip_blog_check;
    178 
    179     $bp_path = $pages;
    180 
    181     if ( !bp_is_blog_page() ) {
    182         remove_action( 'template_redirect', 'redirect_canonical' );
    183     }
    184     add_action( 'template_redirect', 'bp_core_do_catch_uri', 2 );
    185 }
    186 
    187 /**
    188  * bp_core_do_catch_uri()
    189  *
    190  * Loads the first template file found based on the $bp_path global.
    191  *
    192  * @package BuddyPress Core
    193  * @global $bp_path BuddyPress global containing the template file names to use.
    194  */
    195 function bp_core_do_catch_uri() {
    196     global $bp_path, $bp, $wpdb;
    197     global $current_blog, $bp_skip_blog_check;
    198     global $bp_no_status_set;
    199     global $wp_query;
    200 
    201     /* Can be a single template or an array of templates */
    202     $templates = $bp_path;
    203 
    204     /* Don't hijack any URLs on blog pages */
    205     if ( bp_is_blog_page() ) {
    206         if ( !$bp_skip_blog_check )
    207             return false;
    208     } else {
    209         $wp_query->is_home = false;
    210     }
    211 
    212     /* Make sure this is not reported as a 404 */
    213     if ( !$bp_no_status_set ) {
    214         status_header( 200 );
    215         $wp_query->is_404 = false;
    216         $wp_query->is_page = true;
    217     }
    218 
     210function bp_core_load_template( $templates ) {
     211    global $bp, $wpdb, $wp_query, $bp_unfiltered_uri, $bp_unfiltered_uri_offset;
     212
     213    /* Determine if the root object WP page exists for this request (is there an API function for this?)*/
     214    if ( !$page_exists = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_name = %s", $bp_unfiltered_uri[$bp_unfiltered_uri_offset] ) ) )
     215        return false;
     216
     217    /* Set the root object as the current wp_query-ied item */
     218    foreach ( $bp->pages as $page ) {
     219        if ( $page->name == $bp_unfiltered_uri[$bp_unfiltered_uri_offset] )
     220            $object_id = $page->id;
     221    }
     222
     223    $wp_query->queried_object = &get_post( $object_id );
     224    $wp_query->queried_object_id = $object_id;
     225
     226    /* Fetch each template and add the php suffix */
    219227    foreach ( (array)$templates as $template )
    220228        $filtered_templates[] = $template . '.php';
    221229
     230    /* Filter the template locations so that plugins can alter where they are located */
    222231    if ( $located_template = apply_filters( 'bp_located_template', locate_template( (array) $filtered_templates, false ), $filtered_templates ) ) {
     232        /* Template was located, lets set this as a valid page and not a 404. */
     233        status_header( 200 );
     234        $wp_query->is_page = true;
     235        $wp_query->is_404 = false;
     236
    223237        load_template( apply_filters( 'bp_load_template', $located_template ) );
    224     } else {
    225         if ( $located_template = locate_template( array( '404.php' ) ) ) {
    226             status_header( 404 );
    227             load_template( $located_template );
    228         } else
    229             bp_core_redirect( $bp->root_domain );
    230     }
     238    }
     239
     240    /* Kill any other output after this. */
    231241    die;
    232242}
    233 
    234 function bp_core_catch_no_access() {
    235     global $bp, $bp_path, $bp_unfiltered_uri, $bp_no_status_set;
    236 
    237     // If bp_core_redirect() and $bp_no_status_set is true,
    238     // we are redirecting to an accessable page, so skip this check.
    239     if ( $bp_no_status_set )
    240         return false;
    241 
    242     /* If this user has been marked as a spammer and the logged in user is not a site admin, redirect. */
    243     if ( isset( $bp->displayed_user->id ) && bp_core_is_user_spammer( $bp->displayed_user->id ) ) {
    244         if ( !is_site_admin() )
    245             bp_core_redirect( $bp->root_domain );
    246         else
    247             bp_core_add_message( __( 'This user has been marked as a spammer. Only site admins can view this profile.', 'buddypress' ), 'error' );
    248     }
    249 
    250     // If this user does not exist, redirect to the root domain.
    251     if ( !$bp->displayed_user->id && $bp_unfiltered_uri[0] == BP_MEMBERS_SLUG && isset($bp_unfiltered_uri[1]) )
    252         bp_core_redirect( $bp->root_domain );
    253 
    254     // If the template file doesn't exist, redirect to the root domain.
    255     if ( !bp_is_blog_page() && !file_exists( apply_filters( 'bp_located_template', locate_template( array( $bp_path . '.php' ), false ), array( $bp_path . '.php' ) ) ) )
    256         bp_core_redirect( $bp->root_domain );
    257 
    258     if ( !$bp_path && !bp_is_blog_page() ) {
    259         if ( is_user_logged_in() ) {
    260             wp_redirect( $bp->root_domain );
    261         } else {
    262             wp_redirect( site_url( 'wp-login.php?redirect_to=' . site_url() . $_SERVER['REQUEST_URI'] ) );
    263         }
    264     }
    265 }
    266 add_action( 'wp', 'bp_core_catch_no_access' );
    267243
    268244/**
  • trunk/bp-core/bp-core-filters.php

    r2842 r2863  
    11<?php
     2
     3/**
     4 * bp_core_exclude_pages()
     5 *
     6 * Excludes specific pages from showing on page listings, for example the "Activation" page.
     7 *
     8 * @package BuddyPress Core
     9 * @uses bp_is_active() checks if a BuddyPress component is active.
     10 * @return array The list of page ID's to exclude
     11 */
     12function bp_core_exclude_pages( $pages ) {
     13    global $bp;
     14
     15    $pages = explode( ',', $pages );
     16    $pages[] = $bp->pages->activate->id;
     17    $pages[] = $bp->pages->register->id;
     18
     19    if ( !bp_is_active( 'forums' ) || ( function_exists( 'bp_forums_is_installed_correctly' ) && !bp_forums_is_installed_correctly() ) )
     20        $pages[] = $bp->pages->forums->id;
     21
     22    return apply_filters( 'bp_core_exclude_pages', $pages );
     23}
     24add_filter( 'wp_list_pages_excludes', 'bp_core_exclude_pages' );
    225
    326/**
  • trunk/bp-core/bp-core-signup.php

    r2842 r2863  
    246246
    247247function bp_core_validate_user_signup( $user_name, $user_email ) {
    248     global $wpdb;
     248    global $wpdb, $bp;
    249249
    250250    $errors = new WP_Error();
     
    258258
    259259    $db_illegal_names = get_site_option( 'illegal_names' );
    260     $filtered_illegal_names = apply_filters( 'bp_core_illegal_usernames', array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', BP_GROUPS_SLUG, BP_MEMBERS_SLUG, BP_FORUMS_SLUG, BP_BLOGS_SLUG, BP_REGISTER_SLUG, BP_ACTIVATION_SLUG ) );
     260    $filtered_illegal_names = apply_filters( 'bp_core_illegal_usernames', array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', BP_GROUPS_SLUG, $bp->members->slug, BP_FORUMS_SLUG, BP_BLOGS_SLUG, BP_REGISTER_SLUG, BP_ACTIVATION_SLUG ) );
    261261
    262262    $illegal_names = array_merge( (array)$db_illegal_names, (array)$filtered_illegal_names );
     
    362362        $activation_key = wp_hash( $user_id );
    363363        update_usermeta( $user_id, 'activation_key', $activation_key );
    364         bp_core_signup_send_validation_email( $user_id, $activation_key );
     364        bp_core_signup_send_validation_email( $user_id, $user_email, $activation_key );
    365365    }
    366366
     
    508508}
    509509
    510 function bp_core_signup_send_validation_email( $user_id, $key ) {
     510function bp_core_signup_send_validation_email( $user_id, $user_email, $key ) {
    511511    $activate_url = bp_get_activation_page() ."?key=$key";
    512512    $activate_url = clean_url( $activate_url );
  • trunk/bp-core/bp-core-templatetags.php

    r2842 r2863  
    907907
    908908    } else if ( $bp->is_directory ) {
    909         if ( !$bp->current_component )
    910             $title = sprintf( __( '%s Directory', 'buddypress' ), ucwords( BP_MEMBERS_SLUG ) );
    911         else
    912             $title = sprintf( __( '%s Directory', 'buddypress' ), ucwords( $bp->current_component ) );
     909        $title = get_the_title();
    913910
    914911    } else if ( bp_is_register_page() ) {
     912
    915913        $title = __( 'Create an Account', 'buddypress' );
    916914
     
    14861484    global $bp;
    14871485
    1488     if ( BP_ACTIVITY_SLUG == $bp->current_component )
     1486    if ( $bp->activity->name == $bp->current_component )
    14891487        return true;
    14901488
     
    14951493    global $bp;
    14961494
    1497     if ( BP_ACTIVITY_SLUG == $bp->current_component && 'my-friends' == $bp->current_action )
     1495    if ( $bp->activity->name == $bp->current_component && 'my-friends' == $bp->current_action )
    14981496        return true;
    14991497
     
    15401538    global $bp;
    15411539
    1542     if ( BP_GROUPS_SLUG == $bp->current_component )
     1540    if ( $bp->groups->name == $bp->current_component )
    15431541        return true;
    15441542
     
    16671665    global $bp;
    16681666
    1669     if ( BP_BLOGS_SLUG == $bp->current_component )
     1667    if ( $bp->blogs->name == $bp->current_component )
    16701668        return true;
    16711669
     
    16761674    global $bp;
    16771675
    1678     if ( BP_BLOGS_SLUG == $bp->current_component && 'recent-posts' == $bp->current_action )
     1676    if ( $bp->blogs->name == $bp->current_component && 'recent-posts' == $bp->current_action )
    16791677        return true;
    16801678
     
    16851683    global $bp;
    16861684
    1687     if ( BP_BLOGS_SLUG == $bp->current_component && 'recent-comments' == $bp->current_action )
     1685    if ( $bp->blogs->name == $bp->current_component && 'recent-comments' == $bp->current_action )
    16881686        return true;
    16891687
  • trunk/bp-core/bp-core-widgets.php

    r2705 r2863  
    3232            <div class="item-options" id="members-list-options">
    3333                <span class="ajax-loader" id="ajax-loader-members"></span>
    34                 <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="newest-members" class="selected"><?php _e( 'Newest', 'buddypress' ) ?></a> |
    35                 <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="recently-active-members"><?php _e( 'Active', 'buddypress' ) ?></a> |
    36                 <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="popular-members"><?php _e( 'Popular', 'buddypress' ) ?></a>
     34                <a href="<?php echo site_url() . '/' . $bp->members->slug ?>" id="newest-members" class="selected"><?php _e( 'Newest', 'buddypress' ) ?></a> |
     35                <a href="<?php echo site_url() . '/' . $bp->members->slug ?>" id="recently-active-members"><?php _e( 'Active', 'buddypress' ) ?></a> |
     36                <a href="<?php echo site_url() . '/' . $bp->members->slug ?>" id="popular-members"><?php _e( 'Popular', 'buddypress' ) ?></a>
    3737            </div>
    3838
  • trunk/bp-forums.php

    r2695 r2863  
    11<?php
    2 
    32/* Define the parent forum ID */
    43if ( !defined( 'BP_FORUMS_PARENT_FORUM_ID' ) )
    54    define( 'BP_FORUMS_PARENT_FORUM_ID', 1 );
    65
    7 if ( !defined( 'BP_FORUMS_SLUG' ) )
    8     define( 'BP_FORUMS_SLUG', 'forums' );
    9 
    106if ( !defined( 'BB_PATH' ) )
    117    require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-bbpress.php' );
     
    1713    global $bp;
    1814
     15    if ( !defined( 'BP_FORUMS_SLUG' ) )
     16        define ( 'BP_FORUMS_SLUG', $bp->pages->forums->slug );
     17
    1918    /* For internal identification */
    2019    $bp->forums->id = 'forums';
     20    $bp->forums->name = $bp->pages->forums->name;
     21    $bp->forums->slug = BP_FORUMS_SLUG;
    2122
    2223    $bp->forums->image_base = BP_PLUGIN_URL . '/bp-forums/images';
    2324    $bp->forums->bbconfig = $bp->site_options['bb-config-location'];
    24     $bp->forums->slug = BP_FORUMS_SLUG;
    2525
    2626    /* Register this in the active components array */
     
    4040}
    4141
    42 function bp_forums_setup_root_component() {
    43     /* Register 'forums' as a root component */
    44     bp_core_add_root_component( BP_FORUMS_SLUG );
    45 }
    46 add_action( 'bp_setup_root_components', 'bp_forums_setup_root_component' );
    47 
    4842function bp_forums_directory_forums_setup() {
    4943    global $bp;
    5044
    5145    if ( $bp->current_component == $bp->forums->slug ) {
    52         if ( (int) $bp->site_options['bp-disable-forum-directory'] || !function_exists( 'groups_install' ) )
     46        if ( (int) $bp->site_options['bp-disable-forum-directory'] || !bp_is_active( 'groups' ) )
    5347            return false;
    5448
  • trunk/bp-friends.php

    r2822 r2863  
    11<?php
    2 
    3 define ( 'BP_FRIENDS_DB_VERSION', '1800' );
    4 
    5 /* Define the slug for the component */
    6 if ( !defined( 'BP_FRIENDS_SLUG' ) )
    7     define ( 'BP_FRIENDS_SLUG', 'friends' );
    8 
    92require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-classes.php' );
    103require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-templatetags.php' );
    114
    12 function friends_install() {
    13     global $wpdb, $bp;
    14 
    15     if ( !empty($wpdb->charset) )
    16         $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    17 
    18     $sql[] = "CREATE TABLE {$bp->friends->table_name} (
    19                 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    20                 initiator_user_id bigint(20) NOT NULL,
    21                 friend_user_id bigint(20) NOT NULL,
    22                 is_confirmed bool DEFAULT 0,
    23                 is_limited bool DEFAULT 0,
    24                 date_created datetime NOT NULL,
    25                 KEY initiator_user_id (initiator_user_id),
    26                 KEY friend_user_id (friend_user_id)
    27                ) {$charset_collate};";
    28 
    29     require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
    30     dbDelta($sql);
    31 
    32     update_site_option( 'bp-friends-db-version', BP_FRIENDS_DB_VERSION );
    33 }
    34 
    355function friends_setup_globals() {
    366    global $bp, $wpdb;
     7
     8    if ( !defined( 'BP_FRIENDS_SLUG' ) )
     9        define( 'BP_FRIENDS_SLUG', 'friends' );
    3710
    3811    /* For internal identification */
     
    4922}
    5023add_action( 'bp_setup_globals', 'friends_setup_globals' );
    51 
    52 function friends_check_installed() {
    53     global $wpdb, $bp;
    54 
    55     if ( !is_site_admin() )
    56         return false;
    57 
    58     /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
    59     if ( get_site_option( 'bp-friends-db-version' ) < BP_FRIENDS_DB_VERSION )
    60         friends_install();
    61 }
    62 add_action( 'admin_menu', 'friends_check_installed' );
    6324
    6425function friends_setup_nav() {
  • trunk/bp-groups.php

    r2842 r2863  
    11<?php
    2 
    3 define ( 'BP_GROUPS_DB_VERSION', '1900' );
    4 
    5 /* Define the slug for the component */
    6 if ( !defined( 'BP_GROUPS_SLUG' ) )
    7     define ( 'BP_GROUPS_SLUG', 'groups' );
    8 
    92require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-classes.php' );
    103require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-templatetags.php' );
     
    125require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-filters.php' );
    136
    14 function groups_install() {
    15     global $wpdb, $bp;
    16 
    17     if ( !empty($wpdb->charset) )
    18         $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    19 
    20     $sql[] = "CREATE TABLE {$bp->groups->table_name} (
    21             id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    22             creator_id bigint(20) NOT NULL,
    23             name varchar(100) NOT NULL,
    24             slug varchar(100) NOT NULL,
    25             description longtext NOT NULL,
    26             status varchar(10) NOT NULL DEFAULT 'public',
    27             enable_forum tinyint(1) NOT NULL DEFAULT '1',
    28             date_created datetime NOT NULL,
    29             KEY creator_id (creator_id),
    30             KEY status (status)
    31            ) {$charset_collate};";
    32 
    33     $sql[] = "CREATE TABLE {$bp->groups->table_name_members} (
    34             id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    35             group_id bigint(20) NOT NULL,
    36             user_id bigint(20) NOT NULL,
    37             inviter_id bigint(20) NOT NULL,
    38             is_admin tinyint(1) NOT NULL DEFAULT '0',
    39             is_mod tinyint(1) NOT NULL DEFAULT '0',
    40             user_title varchar(100) NOT NULL,
    41             date_modified datetime NOT NULL,
    42             comments longtext NOT NULL,
    43             is_confirmed tinyint(1) NOT NULL DEFAULT '0',
    44             is_banned tinyint(1) NOT NULL DEFAULT '0',
    45             invite_sent tinyint(1) NOT NULL DEFAULT '0',
    46             KEY group_id (group_id),
    47             KEY is_admin (is_admin),
    48             KEY is_mod (is_mod),
    49             KEY user_id (user_id),
    50             KEY inviter_id (inviter_id),
    51             KEY is_confirmed (is_confirmed)
    52            ) {$charset_collate};";
    53 
    54     $sql[] = "CREATE TABLE {$bp->groups->table_name_groupmeta} (
    55             id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    56             group_id bigint(20) NOT NULL,
    57             meta_key varchar(255) DEFAULT NULL,
    58             meta_value longtext DEFAULT NULL,
    59             KEY group_id (group_id),
    60             KEY meta_key (meta_key)
    61            ) {$charset_collate};";
    62 
    63     require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
    64     dbDelta($sql);
    65 
    66     do_action( 'groups_install' );
    67 
    68     update_site_option( 'bp-groups-db-version', BP_GROUPS_DB_VERSION );
    69 }
    70 
    717function groups_setup_globals() {
    728    global $bp, $wpdb;
    739
     10    if ( !defined( 'BP_GROUPS_SLUG' ) )
     11        define ( 'BP_GROUPS_SLUG', $bp->pages->groups->slug );
     12
    7413    /* For internal identification */
    7514    $bp->groups->id = 'groups';
     15    $bp->groups->name = $bp->pages->groups->name;
     16    $bp->groups->slug = BP_GROUPS_SLUG;
    7617
    7718    $bp->groups->table_name = $wpdb->base_prefix . 'bp_groups';
     
    7920    $bp->groups->table_name_groupmeta = $wpdb->base_prefix . 'bp_groups_groupmeta';
    8021    $bp->groups->format_notification_function = 'groups_format_notifications';
    81     $bp->groups->slug = BP_GROUPS_SLUG;
    8222
    8323    /* Register this in the active components array */
     
    10141add_action( 'bp_setup_globals', 'groups_setup_globals' );
    10242
    103 function groups_setup_root_component() {
    104     /* Register 'groups' as a root component */
    105     bp_core_add_root_component( BP_GROUPS_SLUG );
    106 }
    107 add_action( 'bp_setup_root_components', 'groups_setup_root_component' );
    108 
    109 function groups_check_installed() {
    110     /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
    111     if ( get_site_option( 'bp-groups-db-version' ) < BP_GROUPS_DB_VERSION )
    112         groups_install();
    113 }
    114 add_action( 'admin_menu', 'groups_check_installed' );
    115 
    11643function groups_setup_nav() {
    11744    global $bp;
     
    14168
    14269    /* Add 'Groups' to the main navigation */
    143     bp_core_new_nav_item( array( 'name' => sprintf( __( 'Groups <span>(%d)</span>', 'buddypress' ), groups_total_groups_for_user() ), 'slug' => $bp->groups->slug, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $bp->groups->id ) );
    144 
    145     $groups_link = $bp->loggedin_user->domain . $bp->groups->slug . '/';
     70    bp_core_new_nav_item( array( 'name' => sprintf( __( 'Groups <span>(%d)</span>', 'buddypress' ), groups_total_groups_for_user() ), 'slug' => $bp->groups->name, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $bp->groups->id ) );
     71
     72    $groups_link = $bp->loggedin_user->domain . $bp->groups->name . '/';
    14673
    14774    /* Add the subnav items to the groups nav item */
    148     bp_core_new_subnav_item( array( 'name' => __( 'My Groups', 'buddypress' ), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_my_groups', 'position' => 10, 'item_css_id' => 'groups-my-groups' ) );
    149     bp_core_new_subnav_item( array( 'name' => __( 'Invites', 'buddypress' ), 'slug' => 'invites', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_invites', 'position' => 30, 'user_has_access' => bp_is_my_profile() ) );
     75    bp_core_new_subnav_item( array( 'name' => __( 'My Groups', 'buddypress' ), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->name, 'screen_function' => 'groups_screen_my_groups', 'position' => 10, 'item_css_id' => 'groups-my-groups' ) );
     76    bp_core_new_subnav_item( array( 'name' => __( 'Invites', 'buddypress' ), 'slug' => 'invites', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->name, 'screen_function' => 'groups_screen_group_invites', 'position' => 30, 'user_has_access' => bp_is_my_profile() ) );
    15077
    15178    if ( $bp->current_component == $bp->groups->slug ) {
     
    13541281
    13551282            if ( (int)$total_items > 1 ) {
    1356                 return apply_filters( 'bp_groups_multiple_membership_request_rejected_notification', '<a href="' . site_url() . '/' . BP_MEMBERS_SLUG . '/' . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d rejected group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group->name );
     1283                return apply_filters( 'bp_groups_multiple_membership_request_rejected_notification', '<a href="' . site_url() . '/' . $bp->members->slug . '/' . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d rejected group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group->name );
    13571284            } else {
    13581285                return apply_filters( 'bp_groups_single_membership_request_rejected_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __('Membership for group "%s" rejected'), $group->name ) . '</a>', $group_link, $group->name );
  • trunk/bp-loader.php

    r2844 r2863  
    55Description: Social networking in a box. Build a social network for your company, school, sports team or niche community all based on the power and flexibility of WordPress.
    66Author: The BuddyPress Community
    7 Version: 1.2.2
     7Version: 1.3-bleeding
    88Author URI: http://buddypress.org/developers/
    99Site Wide Only: true
    1010*/
    1111
    12 define( 'BP_VERSION', '1.2.2' );
     12define( 'BP_VERSION', '1.3-bleeding' );
     13define( 'BP_DB_VERSION', 1225 );
    1314
    1415/***
    15  * This file will load in each BuddyPress component based on which
    16  * of the components have been activated on the "BuddyPress" admin menu.
     16 * Check if this is the first time BuddyPress has been loaded, or the first time
     17 * since an upgrade. If so, load the install/upgrade routine only.
    1718 */
     19if ( get_site_option( 'bp-db-version' ) < constant( 'BP_DB_VERSION' ) ) {
     20    require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-upgrade.php' );
    1821
    19 require_once( WP_PLUGIN_DIR . '/buddypress/bp-core.php' );
    20 $bp_deactivated = apply_filters( 'bp_deactivated_components', get_site_option( 'bp-deactivated-components' ) );
     22/***
     23 * If the install or upgrade routine is completed and everything is up to date
     24 * continue loading BuddyPress as normal.
     25 */
     26} else {
     27    /***
     28     * This file will load in each BuddyPress component based on which
     29     * of the components have been activated on the "BuddyPress" admin menu.
     30     */
     31    require_once( WP_PLUGIN_DIR . '/buddypress/bp-core.php' );
     32    $bp_deactivated = apply_filters( 'bp_deactivated_components', get_site_option( 'bp-deactivated-components' ) );
    2133
    22 do_action( 'bp_core_loaded' );
     34    do_action( 'bp_core_loaded' );
    2335
    24 /* Activity Streams */
    25 if ( !isset( $bp_deactivated['bp-activity.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-activity.php') )
    26     include( BP_PLUGIN_DIR . '/bp-activity.php' );
     36    /* Activity Streams */
     37    if ( !isset( $bp_deactivated['bp-activity.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-activity.php') )
     38        include( BP_PLUGIN_DIR . '/bp-activity.php' );
    2739
    28 /* Blog Tracking */
    29 if ( !isset( $bp_deactivated['bp-blogs.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-blogs.php') )
    30     include( BP_PLUGIN_DIR . '/bp-blogs.php' );
     40    /* Blog Tracking */
     41    if ( !isset( $bp_deactivated['bp-blogs.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-blogs.php') )
     42        include( BP_PLUGIN_DIR . '/bp-blogs.php' );
    3143
    32 /* bbPress Forum Integration */
    33 if ( !isset( $bp_deactivated['bp-forums.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-forums.php') )
    34     include( BP_PLUGIN_DIR . '/bp-forums.php' );
     44    /* bbPress Forum Integration */
     45    if ( !isset( $bp_deactivated['bp-forums.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-forums.php') )
     46        include( BP_PLUGIN_DIR . '/bp-forums.php' );
    3547
    36 /* Friend Connections */
    37 if ( !isset( $bp_deactivated['bp-friends.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-friends.php') )
    38     include( BP_PLUGIN_DIR . '/bp-friends.php' );
     48    /* Friend Connections */
     49    if ( !isset( $bp_deactivated['bp-friends.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-friends.php') )
     50        include( BP_PLUGIN_DIR . '/bp-friends.php' );
    3951
    40 /* Groups Support */
    41 if ( !isset( $bp_deactivated['bp-groups.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-groups.php') )
    42     include( BP_PLUGIN_DIR . '/bp-groups.php' );
     52    /* Groups Support */
     53    if ( !isset( $bp_deactivated['bp-groups.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-groups.php') )
     54        include( BP_PLUGIN_DIR . '/bp-groups.php' );
    4355
    44 /* Private Messaging */
    45 if ( !isset( $bp_deactivated['bp-messages.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-messages.php') )
    46     include( BP_PLUGIN_DIR . '/bp-messages.php' );
     56    /* Private Messaging */
     57    if ( !isset( $bp_deactivated['bp-messages.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-messages.php') )
     58        include( BP_PLUGIN_DIR . '/bp-messages.php' );
    4759
    48 /* Extended Profiles */
    49 if ( !isset( $bp_deactivated['bp-xprofile.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-xprofile.php') )
    50     include( BP_PLUGIN_DIR . '/bp-xprofile.php' );
     60    /* Extended Profiles */
     61    if ( !isset( $bp_deactivated['bp-xprofile.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-xprofile.php') )
     62        include( BP_PLUGIN_DIR . '/bp-xprofile.php' );
    5163
    52 /* Allow dependent plugins to hook into BuddyPress in a safe way */
    53 function bp_loaded() {
    54     do_action( 'bp_init' );
     64    /* Allow dependent plugins to hook into BuddyPress in a safe way */
     65    function bp_loaded() {
     66        do_action( 'bp_init' );
     67    }
     68    add_action( 'plugins_loaded', 'bp_loaded' );
    5569}
    56 add_action( 'plugins_loaded', 'bp_loaded' );
    5770
    5871/* Activation Function */
     
    7487        return false;
    7588
    76     delete_site_option( 'bp-core-db-version' );
    77     delete_site_option( 'bp-activity-db-version' );
    78     delete_site_option( 'bp-blogs-db-version' );
    79     delete_site_option( 'bp-friends-db-version' );
    80     delete_site_option( 'bp-groups-db-version' );
    81     delete_site_option( 'bp-messages-db-version' );
    82     delete_site_option( 'bp-xprofile-db-version' );
    8389    delete_site_option( 'bp-deactivated-components' );
    8490    delete_site_option( 'bp-blogs-first-install' );
     91    delete_site_option( 'bp-pages' );
    8592
    8693    do_action( 'bp_loader_deactivate' );
  • trunk/bp-messages.php

    r2761 r2863  
    11<?php
    2 
    3 define ( 'BP_MESSAGES_DB_VERSION', '2000' );
    4 
    5 /* Define the slug for the component */
    6 if ( !defined( 'BP_MESSAGES_SLUG' ) )
    7     define ( 'BP_MESSAGES_SLUG', 'messages' );
    8 
    92require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-classes.php' );
    103require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-cssjs.php' );
     
    125require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-filters.php' );
    136
    14 function messages_install() {
    15     global $wpdb, $bp;
    16 
    17     if ( !empty($wpdb->charset) )
    18         $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    19 
    20     $sql[] = "CREATE TABLE {$bp->messages->table_name_recipients} (
    21                 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    22                 user_id bigint(20) NOT NULL,
    23                 thread_id bigint(20) NOT NULL,
    24                 unread_count int(10) NOT NULL DEFAULT '0',
    25                 sender_only tinyint(1) NOT NULL DEFAULT '0',
    26                 is_deleted tinyint(1) NOT NULL DEFAULT '0',
    27                 KEY user_id (user_id),
    28                 KEY thread_id (thread_id),
    29                 KEY is_deleted (is_deleted),
    30                 KEY sender_only (sender_only),
    31                 KEY unread_count (unread_count)
    32                ) {$charset_collate};";
    33 
    34     $sql[] = "CREATE TABLE {$bp->messages->table_name_messages} (
    35                 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    36                 thread_id bigint(20) NOT NULL,
    37                 sender_id bigint(20) NOT NULL,
    38                 subject varchar(200) NOT NULL,
    39                 message longtext NOT NULL,
    40                 date_sent datetime NOT NULL,
    41                 KEY sender_id (sender_id),
    42                 KEY thread_id (thread_id)
    43                ) {$charset_collate};";
    44 
    45     $sql[] = "CREATE TABLE {$bp->messages->table_name_notices} (
    46                 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    47                 subject varchar(200) NOT NULL,
    48                 message longtext NOT NULL,
    49                 date_sent datetime NOT NULL,
    50                 is_active tinyint(1) NOT NULL DEFAULT '0',
    51                 KEY is_active (is_active)
    52                ) {$charset_collate};";
    53 
    54     require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
    55     dbDelta($sql);
    56 
    57     /* Upgrade and remove the message threads table if it exists */
    58     if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$wpdb->base_prefix}bp_messages_threads%'" ) ) {
    59         $upgrade = BP_Messages_Thread::upgrade_tables();
    60 
    61         if ( $upgrade )
    62             $wpdb->query( "DROP TABLE {$wpdb->base_prefix}bp_messages_threads" );
    63     }
    64 
    65     add_site_option( 'bp-messages-db-version', BP_MESSAGES_DB_VERSION );
    66 }
    67 
    687function messages_setup_globals() {
    698    global $bp, $wpdb;
     9
     10    if ( !defined( 'BP_MESSAGES_SLUG' ) )
     11        define ( 'BP_MESSAGES_SLUG', 'messages' );
    7012
    7113    /* For internal identification */
     
    8426}
    8527add_action( 'bp_setup_globals', 'messages_setup_globals' );
    86 
    87 function messages_check_installed() {
    88     global $wpdb, $bp;
    89 
    90     if ( !is_site_admin() )
    91         return false;
    92 
    93     /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
    94     if ( get_site_option( 'bp-messages-db-version' ) < BP_MESSAGES_DB_VERSION )
    95         messages_install();
    96 }
    97 add_action( 'admin_menu', 'messages_check_installed' );
    9828
    9929function messages_setup_nav() {
  • trunk/bp-themes/bp-default/header.php

    r2822 r2863  
    4949                </li>
    5050
    51                 <?php if ( 'activity' != bp_dtheme_page_on_front() && bp_is_active( 'activity' ) ) : ?>
    52                     <li<?php if ( bp_is_page( BP_ACTIVITY_SLUG ) ) : ?> class="selected"<?php endif; ?>>
    53                         <a href="<?php echo site_url() ?>/<?php echo BP_ACTIVITY_SLUG ?>/" title="<?php _e( 'Activity', 'buddypress' ) ?>"><?php _e( 'Activity', 'buddypress' ) ?></a>
    54                     </li>
    55                 <?php endif; ?>
    56 
    57                 <li<?php if ( bp_is_page( BP_MEMBERS_SLUG ) || bp_is_member() ) : ?> class="selected"<?php endif; ?>>
    58                     <a href="<?php echo site_url() ?>/<?php echo BP_MEMBERS_SLUG ?>/" title="<?php _e( 'Members', 'buddypress' ) ?>"><?php _e( 'Members', 'buddypress' ) ?></a>
    59                 </li>
    60 
    61                 <?php if ( bp_is_active( 'groups' ) ) : ?>
    62                     <li<?php if ( bp_is_page( BP_GROUPS_SLUG ) || bp_is_group() ) : ?> class="selected"<?php endif; ?>>
    63                         <a href="<?php echo site_url() ?>/<?php echo BP_GROUPS_SLUG ?>/" title="<?php _e( 'Groups', 'buddypress' ) ?>"><?php _e( 'Groups', 'buddypress' ) ?></a>
    64                     </li>
    65 
    66                     <?php if ( bp_is_active( 'forums' ) && ( function_exists( 'bp_forums_is_installed_correctly' ) && !(int) bp_get_option( 'bp-disable-forum-directory' ) ) && bp_forums_is_installed_correctly() ) : ?>
    67                         <li<?php if ( bp_is_page( BP_FORUMS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
    68                             <a href="<?php echo site_url() ?>/<?php echo BP_FORUMS_SLUG ?>/" title="<?php _e( 'Forums', 'buddypress' ) ?>"><?php _e( 'Forums', 'buddypress' ) ?></a>
    69                         </li>
    70                     <?php endif; ?>
    71                 <?php endif; ?>
    72 
    73                 <?php if ( bp_is_active( 'blogs' ) && bp_core_is_multisite() ) : ?>
    74                     <li<?php if ( bp_is_page( BP_BLOGS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
    75                         <a href="<?php echo site_url() ?>/<?php echo BP_BLOGS_SLUG ?>/" title="<?php _e( 'Blogs', 'buddypress' ) ?>"><?php _e( 'Blogs', 'buddypress' ) ?></a>
    76                     </li>
    77                 <?php endif; ?>
    78 
    7951                <?php wp_list_pages( 'title_li=&depth=1&exclude=' . bp_dtheme_page_on_front() ); ?>
    8052
  • trunk/bp-themes/bp-default/style.css

    r2842 r2863  
    33Theme URI: http://buddypress.org/extend/themes/
    44Description: The default theme for BuddyPress.
    5 Version: 1.2.2
     5Version: 1.3-bleeding
    66Author: BuddyPress.org
    77Author URI: http://buddypress.org
  • trunk/bp-xprofile.php

    r2842 r2863  
    11<?php
    2 define ( 'BP_XPROFILE_DB_VERSION', '1950' );
    3 
    4 /* Define the slug for the component */
    5 if ( !defined( 'BP_XPROFILE_SLUG' ) )
    6     define ( 'BP_XPROFILE_SLUG', 'profile' );
    7 
    82require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-admin.php' );
    93require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-classes.php' );
     
    137
    148/**
    15  * xprofile_install()
    16  *
    17  * Set up the database tables needed for the xprofile component.
    18  *
    19  * @package BuddyPress XProfile
    20  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    21  * @uses dbDelta() Takes SQL statements and compares them to any existing tables and creates/updates them.
    22  * @uses add_site_option() adds a value for a meta_key into the wp_sitemeta table
    23  */
    24 function xprofile_install() {
    25     global $bp, $wpdb;
    26 
    27     if ( !empty($wpdb->charset) )
    28         $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    29 
    30     if ( empty( $bp->site_options['bp-xprofile-base-group-name'] ) )
    31         update_site_option( 'bp-xprofile-base-group-name', 'Base' );
    32 
    33     if ( empty( $bp->site_options['bp-xprofile-fullname-field-name'] ) )
    34         update_site_option( 'bp-xprofile-fullname-field-name', 'Name' );
    35 
    36     $sql[] = "CREATE TABLE {$bp->profile->table_name_groups} (
    37               id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
    38               name varchar(150) NOT NULL,
    39               description mediumtext NOT NULL,
    40               group_order bigint(20) NOT NULL DEFAULT '0',
    41               can_delete tinyint(1) NOT NULL,
    42               KEY can_delete (can_delete)
    43     ) {$charset_collate};";
    44 
    45     $sql[] = "CREATE TABLE {$bp->profile->table_name_fields} (
    46               id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
    47               group_id bigint(20) unsigned NOT NULL,
    48               parent_id bigint(20) unsigned NOT NULL,
    49               type varchar(150) NOT NULL,
    50               name varchar(150) NOT NULL,
    51               description longtext NOT NULL,
    52               is_required tinyint(1) NOT NULL DEFAULT '0',
    53               is_default_option tinyint(1) NOT NULL DEFAULT '0',
    54               field_order bigint(20) NOT NULL DEFAULT '0',
    55               option_order bigint(20) NOT NULL DEFAULT '0',
    56               order_by varchar(15) NOT NULL,
    57               can_delete tinyint(1) NOT NULL DEFAULT '1',
    58               KEY group_id (group_id),
    59               KEY parent_id (parent_id),
    60               KEY field_order (field_order),
    61               KEY can_delete (can_delete),
    62               KEY is_required (is_required)
    63     ) {$charset_collate};";
    64 
    65     $sql[] = "CREATE TABLE {$bp->profile->table_name_data} (
    66               id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
    67               field_id bigint(20) unsigned NOT NULL,
    68               user_id bigint(20) unsigned NOT NULL,
    69               value longtext NOT NULL,
    70               last_updated datetime NOT NULL,
    71               KEY field_id (field_id),
    72               KEY user_id (user_id)
    73     ) {$charset_collate};";
    74 
    75     if ( '' == get_site_option( 'bp-xprofile-db-version' ) ) {
    76         if ( !$wpdb->get_var( "SELECT id FROM {$bp->profile->table_name_groups} WHERE id = 1" ) )
    77             $sql[] = "INSERT INTO {$bp->profile->table_name_groups} VALUES ( 1, '" . get_site_option( 'bp-xprofile-base-group-name' ) . "', '', 0 );";
    78 
    79         if ( !$wpdb->get_var( "SELECT id FROM {$bp->profile->table_name_fields} WHERE id = 1" ) ) {
    80             $sql[] = "INSERT INTO {$bp->profile->table_name_fields} (
    81                         id, group_id, parent_id, type, name, is_required, can_delete
    82                       ) VALUES (
    83                         1, 1, 0, 'textbox', '" . get_site_option( 'bp-xprofile-fullname-field-name' ) . "', 1, 0
    84                       );";
    85         }
    86     }
    87 
    88     require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
    89     dbDelta( $sql );
    90 
    91     do_action( 'xprofile_install' );
    92 
    93     update_site_option( 'bp-xprofile-db-version', BP_XPROFILE_DB_VERSION );
    94 }
    95 
    96 /**
    979 * xprofile_setup_globals()
    9810 *
     
    10618function xprofile_setup_globals() {
    10719    global $bp, $wpdb;
     20
     21    if ( !defined( 'BP_XPROFILE_SLUG' ) )
     22        define ( 'BP_XPROFILE_SLUG', 'profile' );
    10823
    10924    /* Assign the base group and fullname field names to constants to use in SQL statements */
     
    15570    /* Add the administration tab under the "Site Admin" tab for site administrators */
    15671    add_submenu_page( 'bp-general-settings', __( 'Profile Field Setup', 'buddypress' ), __( 'Profile Field Setup', 'buddypress' ), 'manage_options', 'bp-profile-setup', 'xprofile_admin' );
    157 
    158     /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
    159     if ( get_site_option( 'bp-xprofile-db-version' ) < BP_XPROFILE_DB_VERSION )
    160         xprofile_install();
    16172}
    16273add_action( 'admin_menu', 'xprofile_add_admin_menu' );
  • trunk/bp-xprofile/bp-xprofile-filters.php

    r2810 r2863  
    5555
    5656function xprofile_filter_link_profile_data( $field_value, $field_type = 'textbox' ) {
     57    global $bp;
     58
    5759    if ( 'datebox' == $field_type )
    5860        return $field_value;
     
    7476                    $new_values[] = $value;
    7577                else
    76                     $new_values[] = '<a href="' . site_url( BP_MEMBERS_SLUG ) . '/?s=' . strip_tags( $value ) . '">' . $value . '</a>';
     78                    $new_values[] = '<a href="' . site_url( $bp->members->slug ) . '/?s=' . strip_tags( $value ) . '">' . $value . '</a>';
    7779            }
    7880        }
Note: See TracChangeset for help on using the changeset viewer.