Skip to:
Content

BuddyPress.org

Changeset 9461


Ignore:
Timestamp:
02/09/2015 08:54:26 PM (5 years ago)
Author:
johnjamesjacoby
Message:

Add PHPDoc to bp_get_group_join_button() functions, and some non-function code clean up.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-template.php

    r9460 r9461  
    27212721    }
    27222722
     2723/**
     2724 * Output button to join a group
     2725 *
     2726 * @since BuddyPress (1.0.0)
     2727 *
     2728 * @param object $group Single group object
     2729 */
    27232730function bp_group_join_button( $group = false ) {
    27242731    echo bp_get_group_join_button( $group );
    27252732}
     2733    /**
     2734     * Return button to join a group
     2735     *
     2736     * @since BuddyPress (1.0.0)
     2737     *
     2738     * @param object $group Single group object
     2739     */
    27262740    function bp_get_group_join_button( $group = false ) {
    27272741        global $groups_template;
    27282742
    2729         if ( empty( $group ) )
     2743        // Set group to current loop group if none passed
     2744        if ( empty( $group ) ) {
    27302745            $group =& $groups_template->group;
    2731 
    2732         if ( !is_user_logged_in() || bp_group_is_user_banned( $group ) )
     2746        }
     2747
     2748        // Don't show button if not logged in or previously banned
     2749        if ( ! is_user_logged_in() || bp_group_is_user_banned( $group ) ) {
    27332750            return false;
     2751        }
    27342752
    27352753        // Group creation was not completed or status is unknown
    2736         if ( !$group->status )
     2754        if ( empty( $group->status ) ) {
    27372755            return false;
     2756        }
    27382757
    27392758        // Already a member
    2740         if ( isset( $group->is_member ) && $group->is_member ) {
     2759        if ( ! empty( $group->is_member ) ) {
    27412760
    27422761            // Stop sole admins from abandoning their group
    27432762            $group_admins = groups_get_group_admins( $group->id );
    2744             if ( 1 == count( $group_admins ) && $group_admins[0]->user_id == bp_loggedin_user_id() )
     2763            if ( ( 1 == count( $group_admins ) ) && ( bp_loggedin_user_id() === (int) $group_admins[0]->user_id ) ) {
    27452764                return false;
    2746 
     2765            }
     2766
     2767            // Setup button attributes
    27472768            $button = array(
    27482769                'id'                => 'leave_group',
Note: See TracChangeset for help on using the changeset viewer.