Skip to:
Content

BuddyPress.org

Changeset 9462


Ignore:
Timestamp:
02/09/2015 09:12:01 PM (5 years ago)
Author:
johnjamesjacoby
Message:

Add PHPDoc to some functions in bp-groups-template.php. Also clean-up bp_group_status_message() and check $group->status before comparing.

Location:
trunk/src/bp-groups
Files:
2 edited

Legend:

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

    r9452 r9462  
    6262
    6363// Format numberical output
    64 add_filter( 'bp_get_total_group_count',      'bp_core_number_format' );
    65 add_filter( 'bp_get_group_total_for_member', 'bp_core_number_format' );
    66 add_filter( 'bp_get_group_total_members',    'bp_core_number_format' );
     64add_filter( 'bp_get_total_group_count',          'bp_core_number_format' );
     65add_filter( 'bp_get_group_total_for_member',     'bp_core_number_format' );
     66add_filter( 'bp_get_group_total_members',        'bp_core_number_format' );
     67add_filter( 'bp_get_total_group_count_for_user', 'bp_core_number_format' );
    6768
    6869/**
  • trunk/src/bp-groups/bp-groups-template.php

    r9461 r9462  
    29572957 * hidden or private group, and the user does not have access).
    29582958 *
     2959 * @since BuddyPress (1.0.0)
     2960 *
    29592961 * @global BP_Groups_Template $groups_template Groups template object
    29602962 * @param object $group Group to get status message for. Optional; defaults to current group.
    2961  * @since BuddyPress (1.0.0)
    29622963 */
    29632964function bp_group_status_message( $group = null ) {
    29642965    global $groups_template;
    29652966
    2966     if ( ! $group )
     2967    // Group not passed so look for loop
     2968    if ( empty( $group ) ) {
    29672969        $group =& $groups_template->group;
    2968 
    2969     if ( 'private' == $group->status ) {
    2970         if ( ! bp_group_has_requested_membership() ) {
    2971             if ( is_user_logged_in() && bp_group_is_invited() ) {
    2972                 $message = __( 'You must accept your pending invitation before you can access this private group.', 'buddypress' );
    2973             } elseif ( is_user_logged_in() ) {
    2974                 $message = __( 'This is a private group and you must request group membership in order to join.', 'buddypress' );
    2975             } else {
    2976                 $message = __( 'This is a private group. To join you must be a registered site member and request group membership.', 'buddypress' );
    2977             }
    2978 
    2979         } else {
    2980             $message = __( 'This is a private group. Your membership request is awaiting approval from the group administrator.', 'buddypress' );
    2981         }
    2982 
     2970    }
     2971
     2972    // Group status is not set (maybe outside of group loop?)
     2973    if ( empty( $group->status ) ) {
     2974        $message = __( 'This group is not currently accessible.', 'buddypress' );
     2975
     2976    // Group has a status
    29832977    } else {
    2984         $message = __( 'This is a hidden group and only invited members can join.', 'buddypress' );
     2978        switch( $group->status ) {
     2979
     2980            // Private group
     2981            case 'private' :
     2982                if ( ! bp_group_has_requested_membership() ) {
     2983                    if ( is_user_logged_in() ) {
     2984                        if ( bp_group_is_invited() ) {
     2985                            $message = __( 'You must accept your pending invitation before you can access this private group.', 'buddypress' );
     2986                        } else {
     2987                            $message = __( 'This is a private group and you must request group membership in order to join.', 'buddypress' );
     2988                        }
     2989                    } else {
     2990                        $message = __( 'This is a private group. To join you must be a registered site member and request group membership.', 'buddypress' );
     2991                    }
     2992                } else {
     2993                    $message = __( 'This is a private group. Your membership request is awaiting approval from the group administrator.', 'buddypress' );
     2994                }
     2995
     2996            // Hidden group
     2997            case 'hidden' :
     2998            default :
     2999                $message = __( 'This is a hidden group and only invited members can join.', 'buddypress' );
     3000        }
    29853001    }
    29863002
     
    29883004}
    29893005
     3006/**
     3007 * Output hidden form fields for group.
     3008 *
     3009 * This function is no longer used, but may still be used by older themes.
     3010 *
     3011 * @since BuddyPress (1.0.0)
     3012 */
    29903013function bp_group_hidden_fields() {
    29913014    if ( isset( $_REQUEST['s'] ) ) {
     
    30023025}
    30033026
     3027/**
     3028 * Output the total number of groups
     3029 *
     3030 * @since BuddyPress (1.0.0)
     3031 */
    30043032function bp_total_group_count() {
    30053033    echo bp_get_total_group_count();
    30063034}
     3035    /**
     3036     * Return the total number of groups
     3037     *
     3038     * @since BuddyPress (1.0.0)
     3039     * @return type
     3040     */
    30073041    function bp_get_total_group_count() {
    30083042        return apply_filters( 'bp_get_total_group_count', groups_get_total_group_count() );
    30093043    }
    30103044
     3045/**
     3046 * Output the total number of groups a user belongs to
     3047 *
     3048 * @since BuddyPress (1.0.0)
     3049 *
     3050 * @param int $user_id User ID to get group membership count
     3051 */
    30113052function bp_total_group_count_for_user( $user_id = 0 ) {
    30123053    echo bp_get_total_group_count_for_user( $user_id );
    30133054}
     3055    /**
     3056     * Return the total number of groups a user belongs to
     3057     *
     3058     * Filtered by `bp_core_number_format()` by default
     3059     *
     3060     * @since BuddyPress (1.0.0)
     3061     *
     3062     * @param int $user_id User ID to get group membership count
     3063     */
    30143064    function bp_get_total_group_count_for_user( $user_id = 0 ) {
    3015         return apply_filters( 'bp_get_total_group_count_for_user', groups_total_groups_for_user( $user_id ), $user_id );
    3016     }
    3017     add_filter( 'bp_get_total_group_count_for_user', 'bp_core_number_format' );
    3018 
    3019 
    3020 /***************************************************************************
    3021  * Group Members Template Tags
    3022  **/
     3065        $count = groups_total_groups_for_user( $user_id );
     3066
     3067        return apply_filters( 'bp_get_total_group_count_for_user', $count, $user_id );
     3068    }
     3069
     3070/** Group Members *************************************************************/
    30233071
    30243072class BP_Groups_Group_Members_Template {
Note: See TracChangeset for help on using the changeset viewer.