Skip to:
Content

BuddyPress.org

Changeset 392


Ignore:
Timestamp:
10/12/2008 11:58:11 PM (18 years ago)
Author:
apeatling
Message:

Fixed catch-uri functions so that BuddyPress no longer has to be installed in the root of a site.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core.php

    r391 r392  
    4242    global $current_user, $current_component, $current_action;
    4343    global $action_variables;
    44 
     44   
    4545    /* The user ID of the user who is currently logged in. */
    4646    $bp['loggedin_userid'] = $current_user->ID;
     
    10341034    global $bp;
    10351035   
    1036     if ( !is_user_logged_in() )
     1036    if ( !is_user_logged_in() || !get_usermeta( $bp['loggedin_userid'], 'last_activity') )
    10371037        return false;
    10381038   
     
    11111111add_action( 'get_comment_author_link', 'bp_core_replace_comment_author_link', 10, 4 );
    11121112
     1113/**
     1114 * bp_core_get_site_path()
     1115 *
     1116 * Get the path of of the current site.
     1117 *
     1118 * @package BuddyPress Core
     1119 * @global $comment WordPress comment global for the current comment.
     1120 * @uses bp_core_get_userlink_by_email() Fetches a userlink via email address.
     1121 */
     1122function bp_core_get_site_path() {
     1123    global $wpdb;
     1124   
     1125    return $wpdb->get_var( $wpdb->prepare( "SELECT path FROM {$wpdb->base_prefix}site WHERE id = 1") );
     1126}
    11131127
    11141128/**
  • trunk/bp-core/bp-core-catchuri.php

    r388 r392  
    1717 *   - VHOST: http:// andy.domain.com / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
    1818 *   - NO VHOST: http:// domain.com / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
     19 *   - OUTSIDE ROOT: http:// domain.com / sites / buddypress / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
    1920 *
    20  * Example:
     21 *  Example:
    2122 *    - http://andy.domain.com/profile/edit/group/5/
    2223 *    - $current_component: string 'profile'
     
    2829function bp_core_set_uri_globals() {
    2930    global $current_component, $current_action, $action_variables;
    30    
     31
    3132    /* Fetch the current URI and explode each part seperated by '/' into an array */
    3233    $bp_uri = explode( "/", $_SERVER['REQUEST_URI'] );
    33 
    34     /* This is used to determine where the component and action indexes should start */
    35     $root_components = explode( ',', BP_CORE_ROOT_COMPONENTS );
    36     $is_root_component = in_array( $bp_uri[1], $root_components );
    3734   
    3835    /* Set the indexes, these are incresed by one if we are not on a VHOST install */
    3936    $component_index = 0;
    40     $action_index = 1;
     37    $action_index = $component_index + 1;
     38   
     39    /* Get site path items */
     40    $paths = explode( '/', bp_core_get_site_path() );
    4141
    42     if ( VHOST == 'no' && !$is_root_component ) {
    43         $component_index++;
    44         $action_index++;
    45     }
     42    /* Take empties off the end */
     43    if ( $paths[count($paths) - 1] == "" )
     44        array_pop( $paths );
    4645
     46    /* Take empties off the start */
     47    if ( $paths[0] == "" )
     48        array_shift( $paths );
     49   
    4750    /* Take empties off the end */
    4851    if ( $bp_uri[count($bp_uri) - 1] == "" )
     
    5255    if ( $bp_uri[0] == "" )
    5356        array_shift( $bp_uri );
    54 
     57       
    5558    /* Get total URI segment count */
    5659    $bp_uri_count = count( $bp_uri ) - 1;
     60
     61    for ( $i = 0; $i < $bp_uri_count; $i++ ) {
     62        if ( in_array( $bp_uri[$i], $paths )) {
     63            unset( $bp_uri[$i] );
     64        }
     65    }
    5766   
     67    /* Reset the keys by merging with an empty array */
     68    $bp_uri = array_merge( array(), $bp_uri );
     69   
     70    /* This is used to determine where the component and action indexes should start */
     71    $root_components = explode( ',', BP_CORE_ROOT_COMPONENTS );
     72    $is_root_component = in_array( $bp_uri[0], $root_components );
     73   
     74    if ( VHOST == 'no' && !$is_root_component ) {
     75        $component_index++;
     76        $action_index++;
     77    }
     78
    5879    /* Set the current component */
    5980    $current_component = $bp_uri[$component_index];
     
    6586    $action_variables = $bp_uri;
    6687
    67     /* Remove the username from action variables if this is not a VHOST install */
    68     if ( VHOST == 'no' )
    69         unset($action_variables[0]);
    70 
    7188    /* Unset the current_component and action from action_variables */
    7289    unset($action_variables[$component_index]);
    7390    unset($action_variables[$action_index]);
     91
     92    /* Remove the username from action variables if this is not a VHOST install */
     93    if ( VHOST == 'no' && !$is_root_component )
     94        array_shift($action_variables);
    7495   
    7596    /* Reset the keys by merging with an empty array */
  • trunk/bp-core/bp-core-cssjs.php

    r375 r392  
    3838 */
    3939function bp_core_add_css() {
    40     if ( is_user_logged_in() ) {
     40    if ( is_user_logged_in() && bp_core_user_has_home() ) {
    4141        wp_enqueue_style( 'bp-admin-bar', site_url() . '/wp-content/mu-plugins/bp-core/css/admin-bar.css' );
    4242        wp_print_styles();
  • trunk/bp-core/bp-core-templatetags.php

    r391 r392  
    302302
    303303function bp_loggedinuser_link() {
    304     global $bp;
    305     echo bp_core_get_userlink( $bp['loggedin_userid'] );
     304    global $bp, $current_user;
     305   
     306    if ( $link = bp_core_get_userlink( $bp['loggedin_userid'] ) ) {
     307        echo $link;
     308    } else {
     309        $ud = get_userdata($current_user->ID);
     310        echo $ud->user_login;
     311    }
    306312}
    307313
  • trunk/bp-groups.php

    r391 r392  
    237237    bp_core_set_uri_globals();
    238238    $groups_bp = groups_setup_globals(true);
    239    
     239
    240240    if ( $current_component == $groups_bp['groups']['slug'] )
    241241        $is_single_group = BP_Groups_Group::group_exists( $current_action, $groups_bp['groups']['table_name'] );
     
    342342    if ( isset($_COOKIE['group_obj_id']) && !$group_obj && !$no_instantiate )
    343343        $group_obj = new BP_Groups_Group( (int)$_COOKIE['group_obj_id'] );
    344 
     344   
    345345    bp_catch_uri( 'groups/create' );
    346346}
Note: See TracChangeset for help on using the changeset viewer.