Skip to:
Content

BuddyPress.org

Changeset 11761


Ignore:
Timestamp:
12/06/2017 03:46:07 PM (9 years ago)
Author:
djpaul
Message:

Groups: use class methods to check if user has visibility of a group.

Improves upon existing duplication of logic.

Fixes #7608

Props dcavins

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-screens.php

    r11698 r11761  
    231231                }
    232232
    233                 // Check to see if the group is not public, if so, check the
    234                 // user has access to see this activity.
     233                // Check to see if the user has access to to the activity's parent group.
    235234                if ( $group = groups_get_group( $activity->item_id ) ) {
    236 
    237                         // Group is not public.
    238                         if ( 'public' != $group->status ) {
    239 
    240                                 // User is not a member of group.
    241                                 if ( !groups_is_user_member( bp_loggedin_user_id(), $group->id ) ) {
    242                                         $has_access = false;
    243                                 }
    244                         }
     235                        $has_access = $group->user_has_access;
    245236                }
    246237        }
  • trunk/src/bp-groups/bp-groups-actions.php

    r11393 r11761  
    4242        $current_group   = groups_get_current_group();
    4343        $user_has_access = $current_group->user_has_access;
     44        $is_visible      = $current_group->is_visible;
    4445        $no_access_args  = array();
    4546
    46         if ( ! $user_has_access && 'hidden' !== $current_group->status ) {
     47        // The user can know about the group but doesn't have full access.
     48        if ( ! $user_has_access && $is_visible ) {
    4749                // Always allow access to home and request-membership.
    4850                if ( bp_is_current_action( 'home' ) || bp_is_current_action( 'request-membership' ) ) {
    … …  
    9193        }
    9294
    93         // Hidden groups should return a 404 for non-members.
     95        // Groups that the user cannot know about should return a 404 for non-members.
    9496        // Unset the current group so that you're not redirected
    9597        // to the default group tab.
    96         if ( 'hidden' == $current_group->status ) {
     98        if ( ! $is_visible ) {
    9799                buddypress()->groups->current_group = 0;
    98100                buddypress()->is_single_item        = false;
    … …  
    489491                }
    490492
    491                 $redirect = bp_get_group_permalink( groups_get_current_group() );
    492 
    493                 if( 'hidden' == $bp->groups->current_group->status ) {
     493                $group = groups_get_current_group();
     494                $redirect = bp_get_group_permalink( $group );
     495
     496                if ( ! $group->is_visible ) {
    494497                        $redirect = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() );
    495498                }
  • trunk/src/bp-groups/bp-groups-template.php

    r11703 r11761  
    486486        }
    487487
    488         if ( 'public' == $group->status ) {
     488        if ( ! empty( $group->is_visible ) ) {
    489489                return true;
    490         } else {
    491                 if ( groups_is_user_member( bp_loggedin_user_id(), $group->id ) ) {
    492                         return true;
    493                 }
    494490        }
    495491
Note: See TracChangeset for help on using the changeset viewer.