Changeset 8531 for trunk/src/bp-groups/bp-groups-template.php
- Timestamp:
- 06/15/2014 08:00:53 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-template.php
r8503 r8531 1669 1669 1670 1670 /** 1671 * Checks if a user is banned from a group. 1672 * 1673 * If this function is invoked inside the groups template loop (e.g. the group directory), then 1674 * check $groups_template->group->is_banned instead of making another SQL query. 1675 * However, if used in a single group's pages, we must use groups_is_user_banned(). 1671 * Check if a user is banned from a group. 1672 * 1673 * If this function is invoked inside the groups template loop, then we check 1674 * $groups_template->group->is_banned instead of using {@link groups_is_user_banned()} 1675 * and making another SQL query. 1676 * 1677 * In BuddyPress 2.1, to standardize this function, we are defaulting the 1678 * return value to a boolean. In previous versions, using this function would 1679 * return either a string of the integer (0 or 1) or null if a result couldn't 1680 * be found from the database. If the logged-in user had the 'bp_moderate' 1681 * capability, the return value would be boolean false. 1682 * 1683 * @since BuddyPress (1.5.0) 1676 1684 * 1677 1685 * @global BP_Groups_Template $groups_template Group template loop object 1678 * @param object $group Group to check if user is banned from the group 1679 * @param int $user_id 1680 * @return bool If user is banned from the group or not 1681 * @since BuddyPress (1.5) 1686 * @param BP_Groups_Group $group Group to check if user is banned 1687 * @param int $user_id The user ID to check 1688 * @return bool True if user is banned. False if user isn't banned. 1682 1689 */ 1683 1690 function bp_group_is_user_banned( $group = false, $user_id = 0 ) { … … 1685 1692 1686 1693 // Site admins always have access 1687 if ( bp_current_user_can( 'bp_moderate' ) ) 1694 if ( bp_current_user_can( 'bp_moderate' ) ) { 1688 1695 return false; 1689 1690 if ( empty( $group ) ) { 1691 $group =& $groups_template->group; 1692 1693 if ( !$user_id && isset( $group->is_banned ) ) 1694 return apply_filters( 'bp_group_is_user_banned', $group->is_banned ); 1695 } 1696 1697 if ( !$user_id ) 1698 $user_id = bp_loggedin_user_id(); 1699 1700 return apply_filters( 'bp_group_is_user_banned', groups_is_user_banned( $user_id, $group->id ) ); 1696 } 1697 1698 // check groups loop first 1699 // @see BP_Groups_Group::get_group_extras() 1700 if ( ! empty( $groups_template->in_the_loop ) && isset( $groups_template->group->is_banned ) ) { 1701 $retval = $groups_template->group->is_banned; 1702 1703 // not in loop 1704 } else { 1705 // Default to not banned 1706 $retval = false; 1707 1708 if ( empty( $group ) ) { 1709 $group = $groups_template->group; 1710 } 1711 1712 if ( empty( $user_id ) ) { 1713 $user_id = bp_loggedin_user_id(); 1714 } 1715 1716 if ( ! empty( $user_id ) && ! empty( $group->id ) ) { 1717 $retval = groups_is_user_banned( $user_id, $group->id ); 1718 } 1719 } 1720 1721 return (bool) apply_filters( 'bp_group_is_user_banned', $retval ); 1701 1722 } 1702 1723
Note: See TracChangeset
for help on using the changeset viewer.