Skip to:
Content

BuddyPress.org

Ticket #3280: 3280-3.patch

File 3280-3.patch, 11.5 KB (added by DJPaul, 14 years ago)
  • bp-xprofile/bp-xprofile-screens.php

     
    1313 * @uses bp_core_load_template() Looks for and loads a template file within the current member theme (folder/filename)
    1414 */
    1515function xprofile_screen_display_profile() {
     16        global $bp, $wp_query;
     17       
     18        if ( empty( $bp->displayed_user->id ) ) {
     19                $wp_query->set_404();
     20                status_header( 404 );
     21                nocache_headers();
     22                return;
     23        }
     24       
    1625        $new = isset( $_GET['new'] ) ? $_GET['new'] : '';
    1726
    1827        do_action( 'xprofile_screen_display_profile', $new );
     
    2837 * @uses bp_core_load_template() Looks for and loads a template file within the current member theme (folder/filename)
    2938 */
    3039function xprofile_screen_edit_profile() {
    31         global $bp;
     40        global $bp, $wp_query;
    3241
    3342        if ( !bp_is_my_profile() && !is_super_admin() )
    3443                return false;
     
    3847                bp_core_redirect( $bp->displayed_user->domain . $bp->profile->slug . '/edit/group/1' );
    3948
    4049        // Check the field group exists
    41         if ( !xprofile_get_field_group( $bp->action_variables[1] ) )
    42                 bp_core_redirect( bp_get_root_domain() );
     50        if ( !xprofile_get_field_group( $bp->action_variables[1] ) ) {
     51                $wp_query->set_404();
     52                status_header( 404 );
     53                nocache_headers();
     54                return;
     55        }
    4356
    4457        // Check to see if any new information has been submitted
    4558        if ( isset( $_POST['field_ids'] ) ) {
  • bp-core/bp-core-template.php

     
    246246
    247247        // A single group
    248248        } elseif ( bp_is_active( 'groups' ) && !empty( $bp->groups->current_group ) && !empty( $bp->bp_options_nav[$bp->groups->current_group->slug] ) ) {
     249                $subnav = isset( $bp->bp_options_nav[$bp->groups->current_group->slug][$bp->current_action]['name'] ) ? $bp->bp_options_nav[$bp->groups->current_group->slug][$bp->current_action]['name'] : '';
    249250                // translators: "group name | group nav section name"
    250                 $title = sprintf( __( '%1$s | %2$s', 'buddypress' ), $bp->bp_options_title, $bp->bp_options_nav[$bp->groups->current_group->slug][$bp->current_action]['name'] );
     251                $title = sprintf( __( '%1$s | %2$s', 'buddypress' ), $bp->bp_options_title, $subnav );
    251252
    252253        // A single item from a component other than groups
    253254        } elseif ( bp_is_single_item() ) {
  • bp-core/bp-core-catchuri.php

     
    2727 */
    2828function bp_core_set_uri_globals() {
    2929        global $bp, $bp_unfiltered_uri, $bp_unfiltered_uri_offset;
    30         global $current_blog, $wpdb;
     30        global $current_blog, $wpdb, $wp_query;
    3131
    3232        // Create global component, action, and item variables
    3333        $bp->current_component = $bp->current_action = $bp->current_item ='';
     
    242242                                else
    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                                        $wp_query->set_404();
     247                                        status_header( 404 );
     248                                        nocache_headers();
     249                                       
     250                                        // Prevent components from loading their templates
     251                                        $bp->current_component = '';
     252                                       
     253                                        // Prevent WP from guessing on a redirect
     254                                        remove_action( 'template_redirect', 'redirect_canonical' );
     255                                        return;
     256                                }
     257
    245258                                // Bump the offset
    246259                                if ( isset( $bp_uri[$uri_offset + 2] ) ) {
    247260                                        $bp_uri                = array_merge( array(), array_slice( $bp_uri, $uri_offset + 2 ) );
     
    351364 * @since 1.3
    352365 */
    353366function bp_core_catch_no_access() {
    354         global $bp, $wp_query, $bp_unfiltered_uri, $bp_no_status_set;
     367        global $bp, $bp_no_status_set, $wp_query;
    355368
    356369        // If bp_core_redirect() and $bp_no_status_set is true,
    357370        // we are redirecting to an accessible page, so skip this check.
    358371        if ( $bp_no_status_set )
    359372                return false;
    360373
    361         // If the displayed user was marked as a spammer and the logged-in user is not a super admin, redirect
     374        // If the displayed user was marked as a spammer and the logged-in user is not a super admin, 404.
    362375        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
     376                if ( !$bp->loggedin_user->is_super_admin ) {
     377                        $wp_query->set_404();
     378                        status_header( 404 );
     379                        nocache_headers();
     380                        return;
     381
     382                } else {
    366383                        bp_core_add_message( __( 'This user has been marked as a spammer. Only site admins can view this profile.', 'buddypress' ), 'error' );
     384                }
    367385        }
    368386
    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!
    374387        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                 }
     388                $wp_query->set_404();
     389                status_header( 404 );
     390                nocache_headers();
    380391        }
    381392}
    382393add_action( 'wp', 'bp_core_catch_no_access' );
     
    402413        $r = wp_parse_args( $args, $defaults );
    403414        extract( $r, EXTR_SKIP );
    404415
    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         }
    413 
    414416        // Apply filters to these variables
    415417        $mode           = apply_filters( 'bp_no_access_mode', $mode, $root, $redirect, $message );
    416418        $redirect       = apply_filters( 'bp_no_access_redirect', $redirect, $root, $message, $mode );
  • bp-core/bp-core-component.php

     
    9898         * @param arr $args Used to
    9999         */
    100100        function _setup_globals( $args = '' ) {
    101                 global $bp;
     101                global $bp, $wp_query;
    102102
    103103                /** Slugs *************************************************************/
    104104
     
    127127                if ( !empty( $r['global_tables'] ) )
    128128                        foreach ( $r['global_tables'] as $global_name => $table_name )
    129129                                $this->$global_name = $table_name;
    130                
     130                               
     131/*              if ( empty( $bp->displayed_user->id ) ) {
     132                        $wp_query->set_404();
     133                        status_header( 404 );
     134                        nocache_headers();
     135                        return;
     136                }*/
     137
    131138                /** BuddyPress ********************************************************/
    132139
    133140                // Register this component in the active components array
  • bp-activity/bp-activity-actions.php

     
    1313add_action( 'bp_init', 'bp_register_activity_actions', 8 );
    1414
    1515function bp_activity_action_permalink_router() {
    16         global $bp;
     16        global $bp, $wp_query;
    1717
    1818        // Not viewing activity
    1919        if ( ( $bp->activity->slug != bp_current_component() ) || !bp_is_current_action( 'p' ) )
     
    2626        // Get the activity details
    2727        $activity = bp_activity_get_specific( array( 'activity_ids' => $bp->action_variables[0] ) );
    2828
    29         // Redirect to root if activity does not exist
    30         if ( !$activity = $activity['activities'][0] )
    31                 bp_core_redirect( bp_get_root_domain() );
     29        // 404 if activity does not exist
     30        if ( !$activity = $activity['activities'][0] ) {
     31                $wp_query->set_404();
     32                status_header( 404 );
     33                nocache_headers();
     34                return;
     35        }
    3236
    3337        // Do not redirect at default
    3438        $redirect = false;
  • bp-activity/bp-activity-screens.php

     
    8383add_action( 'bp_activity_screen_mentions', 'bp_activity_reset_my_new_mentions' );
    8484
    8585function bp_activity_screen_single_activity_permalink() {
    86         global $bp;
     86        global $bp, $wp_query;
    8787
    8888        // No displayed user or not viewing activity component
    8989        if ( !bp_is_activity_component() )
     
    9595        // Get the activity details
    9696        $activity = bp_activity_get_specific( array( 'activity_ids' => bp_current_action() ) );
    9797
    98         if ( !$activity = $activity['activities'][0] )
    99                 bp_core_redirect( bp_get_root_domain() );
     98        // 404 if activity does not exist
     99        if ( !$activity = $activity['activities'][0] ) {
     100                $wp_query->set_404();
     101                status_header( 404 );
     102                nocache_headers();
     103                return;
     104        }
    100105
    101106        // Default access is true
    102107        $has_access = true;
     
    105110        if ( isset( $bp->groups->id ) && $activity->component == $bp->groups->id ) {
    106111
    107112                // Activity is from a group, but groups is currently disabled
    108                 if ( !bp_is_active( 'groups') )
    109                         bp_core_redirect( bp_get_root_domain() );
     113                if ( !bp_is_active( 'groups') ) {
     114                        $wp_query->set_404();
     115                        status_header( 404 );
     116                        nocache_headers();
     117                        return;
     118                }
    110119
    111120                // Check to see if the group is not public, if so, check the
    112121                // user has access to see this activity
  • bp-groups/bp-groups-screens.php

     
    107107
    108108        if ( !bp_is_active( 'forums' ) || !bp_forums_is_installed_correctly() )
    109109                return false;
     110               
     111        if ( !$bp->groups->current_group->user_has_access ) {
     112                bp_core_no_access();
     113                return;
     114        }
    110115
    111         if ( bp_is_single_item() && $bp->groups->current_group->user_has_access ) {
     116        if ( bp_is_single_item() ) {
    112117
    113118                // Fetch the details we need
    114119                $topic_slug     = !empty( $bp->action_variables[1] ) ? $bp->action_variables[1] : false;
  • bp-groups/bp-groups-loader.php

     
    6161         * @global obj $bp
    6262         */
    6363        function _setup_globals() {
    64                 global $bp;
     64                global $bp, $wp_query;
    6565
    6666                // Define a slug, if necessary
    6767                if ( !defined( 'BP_GROUPS_SLUG' ) )
     
    155155                        $this->root_slug,
    156156                ) );
    157157
     158                // If the user was attempting to access a group, but no group by that name was
     159                // found, 404
     160                if ( empty( $this->current_group ) && !empty( $bp->current_action ) && !in_array( $bp->current_action, $this->forbidden_names ) ) {
     161                        $wp_query->set_404();
     162                        status_header( 404 );
     163                        nocache_headers();
     164                }
     165               
     166                // Group access control
     167                if ( !empty( $this->current_group ) && !$this->current_group->user_has_access ) {
     168                        bp_core_no_access();
     169                }
     170
    158171                // Preconfigured group creation steps
    159172                $this->group_creation_steps = apply_filters( 'groups_create_group_steps', array(
    160173                        'group-details'  => array(
  • bp-groups/bp-groups-filters.php

     
    105105        elseif ( is_super_admin() )
    106106                unset( $parts['private'] );
    107107
    108         // Are we a member of this group
    109         elseif ( bp_is_single_item() && bp_group_is_member( $bp->groups->current_group->id ) )
     108        // No need to filter on a single item
     109        elseif ( bp_is_single_item() )
    110110                unset( $parts['private'] );
    111111
    112112        // Check the SQL filter that was passed