Changeset 11544
- Timestamp:
- 04/28/2017 02:36:15 PM (8 years ago)
- Location:
- trunk/src/bp-groups/classes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/classes/class-bp-groups-component.php
r11405 r11544 241 241 if ( ! bp_is_item_admin() ) { 242 242 bp_update_is_item_mod ( groups_is_user_mod ( bp_loggedin_user_id(), $this->current_group->id ), 'groups' ); 243 }244 245 // Is the logged in user a member of the group?246 if ( ( is_user_logged_in() && groups_is_user_member( bp_loggedin_user_id(), $this->current_group->id ) ) ) {247 $this->current_group->is_user_member = true;248 } else {249 $this->current_group->is_user_member = false;250 }251 252 // Should this group be visible to the logged in user?253 if ( 'public' == $this->current_group->status || $this->current_group->is_user_member ) {254 $this->current_group->is_visible = true;255 } else {256 $this->current_group->is_visible = false;257 243 } 258 244 … … 558 544 // show a "Request Membership" nav item. 559 545 if ( is_user_logged_in() && 560 ! $this->current_group->is_ user_member &&546 ! $this->current_group->is_member && 561 547 ! groups_check_for_membership_request( bp_loggedin_user_id(), $this->current_group->id ) && 562 548 $this->current_group->status == 'private' && -
trunk/src/bp-groups/classes/class-bp-groups-group.php
r11533 r11544 127 127 128 128 /** 129 * Is the current user a member of this group? 130 * Alias of $is_member for backward compatibility. 131 * 132 * @since 2.9.0 133 * @var bool 134 */ 135 protected $is_user_member; 136 137 /** 129 138 * Does the current user have an outstanding invitation to this group? 130 139 * … … 157 166 */ 158 167 protected $user_has_access; 168 169 /** 170 * Can the current user know that this group exists? 171 * 172 * @since 2.9.0 173 * @var bool 174 */ 175 protected $is_visible; 159 176 160 177 /** … … 417 434 418 435 case 'is_member' : 436 case 'is_user_member' : 419 437 return $this->get_is_member(); 420 438 … … 427 445 case 'user_has_access' : 428 446 return $this->get_user_has_access(); 447 448 case 'is_visible' : 449 return $this->is_visible(); 429 450 430 451 default : … … 449 470 case 'is_invited' : 450 471 case 'is_member' : 472 case 'is_user_member' : 451 473 case 'is_pending' : 452 474 case 'last_activity' : … … 454 476 case 'total_member_count' : 455 477 case 'user_has_access' : 478 case 'is_visible' : 456 479 case 'forum_id' : 457 480 return true; … … 606 629 607 630 return $this->user_has_access; 631 } 632 633 /** 634 * Checks whether the current user can know the group exists. 635 * 636 * @since 2.9.0 637 * 638 * @return bool 639 */ 640 protected function is_visible() { 641 if ( isset( $this->is_visible ) ) { 642 return $this->is_visible; 643 } 644 645 if ( 'hidden' === $this->status ) { 646 647 // Assume user can not know about hidden groups. 648 $this->is_visible = false; 649 650 // Group members or community moderators have access. 651 if ( ( is_user_logged_in() && $this->get_is_member() ) || bp_current_user_can( 'bp_moderate' ) ) { 652 $this->is_visible = true; 653 } 654 } else { 655 $this->is_visible = true; 656 } 657 658 return $this->is_visible; 608 659 } 609 660
Note: See TracChangeset
for help on using the changeset viewer.