Skip to:
Content

BuddyPress.org

Ticket #7608: 7608.01.diff

File 7608.01.diff, 3.1 KB (added by dcavins, 4 years ago)

Use BP_Groups_Group properties in some cases.

  • src/bp-activity/bp-activity-screens.php

    diff --git src/bp-activity/bp-activity-screens.php src/bp-activity/bp-activity-screens.php
    index 472b4e5..7de6980 100644
    function bp_activity_screen_single_activity_permalink() { 
    230230                        return;
    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        }
    247238
  • src/bp-groups/bp-groups-actions.php

    diff --git src/bp-groups/bp-groups-actions.php src/bp-groups/bp-groups-actions.php
    index 4f80495..7d84f39 100644
    function bp_groups_group_access_protection() { 
    4141
    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' ) ) {
    4951                        $user_has_access = true;
    function bp_groups_group_access_protection() { 
    9092                return;
    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;
    99101                bp_do_404();
    function groups_action_leave_group() { 
    488490                        bp_core_add_message( __( 'You successfully left the group.', 'buddypress' ) );
    489491                }
    490492
    491                 $redirect = bp_get_group_permalink( groups_get_current_group() );
     493                $group = groups_get_current_group();
     494                $redirect = bp_get_group_permalink( $group );
    492495
    493                 if( 'hidden' == $bp->groups->current_group->status ) {
     496                if ( ! $group->is_visible ) {
    494497                        $redirect = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() );
    495498                }
    496499
  • src/bp-groups/bp-groups-template.php

    diff --git src/bp-groups/bp-groups-template.php src/bp-groups/bp-groups-template.php
    index ac0d315..8ae0baa 100644
    function bp_group_is_visible( $group = null ) { 
    485485                $group =& $groups_template->group;
    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
    496492        return false;