Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/13/2011 09:54:52 PM (15 years ago)
Author:
boonebgorges
Message:

Introduces bp_do_404() for easy 404ing. Corrects invalid path handling throughout, using bp_do_404(). Fixes #3280. Props DJPaul

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-catchuri.php

    r4490 r4506  
    243243                    $bp->displayed_user->id = (int) bp_core_get_userid_from_nicename( urldecode( $bp_uri[$uri_offset + 1] ) );
    244244
     245                if ( empty( $bp->displayed_user->id ) ) {
     246                    // Prevent components from loading their templates
     247                    $bp->current_component = '';
     248
     249                    bp_do_404();
     250                    return;
     251                }
     252
    245253                // Bump the offset
    246254                if ( isset( $bp_uri[$uri_offset + 2] ) ) {
     
    352360 */
    353361function bp_core_catch_no_access() {
    354     global $bp, $wp_query, $bp_unfiltered_uri, $bp_no_status_set;
     362    global $bp, $bp_no_status_set;
    355363
    356364    // If bp_core_redirect() and $bp_no_status_set is true,
     
    359367        return false;
    360368
    361     // If the displayed user was marked as a spammer and the logged-in user is not a super admin, redirect
     369    // If the displayed user was marked as a spammer and the logged-in user is not a super admin, 404.
    362370    if ( isset( $bp->displayed_user->id ) && bp_core_is_user_spammer( $bp->displayed_user->id ) ) {
    363         if ( !is_super_admin() )
    364             bp_core_redirect( $bp->root_domain );
    365         else
     371        if ( !$bp->loggedin_user->is_super_admin ) {
     372            bp_do_404();
     373            return;
     374
     375        } else {
    366376            bp_core_add_message( __( 'This user has been marked as a spammer. Only site admins can view this profile.', 'buddypress' ), 'error' );
    367     }
    368 
    369     // If BP_ENABLE_ROOT_PROFILES is not defined and the displayed user does not exist, redirect
    370     if ( !$bp->displayed_user->id && isset( $bp_unfiltered_uri[0] ) && $bp_unfiltered_uri[0] == $bp->members->slug && isset( $bp_unfiltered_uri[1] ) )
    371         bp_core_redirect( $bp->root_domain );
    372 
    373     // Access control!
     377        }
     378    }
     379
    374380    if ( !isset( $wp_query->queried_object ) && !bp_is_blog_page() ) {
    375         if ( is_user_logged_in() ) {
    376             bp_core_no_access( array( 'redirect' => false, 'message' => __( 'You do not have access to that page', 'buddypress' ) ) );
    377         } else {
    378             bp_core_no_access();
    379         }
     381        bp_do_404();
    380382    }
    381383}
     
    402404    $r = wp_parse_args( $args, $defaults );
    403405    extract( $r, EXTR_SKIP );
    404 
    405     // Group filtering
    406     // When a user doesn't have access to a group's activity / secondary page, redirect to group's homepage
    407     if ( !$redirect ) {
    408         if ( bp_is_active( 'groups' ) && bp_is_current_component( 'groups' ) ) {
    409             $root = bp_get_group_permalink( $bp->groups->current_group );
    410             $message = false;
    411         }
    412     }
    413406
    414407    // Apply filters to these variables
Note: See TracChangeset for help on using the changeset viewer.