Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/22/2015 04:58:34 AM (9 years ago)
Author:
tw2113
Message:

More docs cleanup for BP-Groups component.

See #6401.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/classes/class-bp-group-member-query.php

    r10248 r10373  
    5858        // Take this early opportunity to set the default 'type' param
    5959        // to 'last_joined', which will ensure that BP_User_Query
    60         // trusts our order and does not try to apply its own
     60        // trusts our order and does not try to apply its own.
    6161        if ( empty( $this->query_vars_raw['type'] ) ) {
    6262            $this->query_vars_raw['type'] = 'last_joined';
    6363        }
    6464
    65         // Set the sort order
     65        // Set the sort order.
    6666        add_action( 'bp_pre_user_query', array( $this, 'set_orderby' ) );
    6767
    68         // Set up our populate_extras method
     68        // Set up our populate_extras method.
    6969        add_action( 'bp_user_query_populate_extras', array( $this, 'populate_group_member_extras' ), 10, 2 );
    7070    }
     
    100100
    101101        // If the group member query returned no users, bail with an
    102         // array that will guarantee no matches for BP_User_Query
     102        // array that will guarantee no matches for BP_User_Query.
    103103        if ( empty( $group_member_ids ) ) {
    104104            return array( 0 );
     
    134134        );
    135135
    136         /** WHERE clauses *****************************************************/
    137 
    138         // Group id
     136        /* WHERE clauses *****************************************************/
     137
     138        // Group id.
    139139        $sql['where'][] = $wpdb->prepare( "group_id = %d", $this->query_vars['group_id'] );
    140140
    141         // is_confirmed
     141        // If is_confirmed.
    142142        $is_confirmed = ! empty( $this->query_vars['is_confirmed'] ) ? 1 : 0;
    143143        $sql['where'][] = $wpdb->prepare( "is_confirmed = %d", $is_confirmed );
    144144
    145         // invite_sent
     145        // If invite_sent.
    146146        if ( ! is_null( $this->query_vars['invite_sent'] ) ) {
    147147            $invite_sent = ! empty( $this->query_vars['invite_sent'] ) ? 1 : 0;
     
    149149        }
    150150
    151         // inviter_id
     151        // If inviter_id.
    152152        if ( ! is_null( $this->query_vars['inviter_id'] ) ) {
    153153            $inviter_id = $this->query_vars['inviter_id'];
    154154
    155             // Empty: inviter_id = 0. (pass false, 0, or empty array)
     155            // Empty: inviter_id = 0. (pass false, 0, or empty array).
    156156            if ( empty( $inviter_id ) ) {
    157157                $sql['where'][] = "inviter_id = 0";
    158158
    159             // The string 'any' matches any non-zero value (inviter_id != 0)
     159            // The string 'any' matches any non-zero value (inviter_id != 0).
    160160            } elseif ( 'any' === $inviter_id ) {
    161161                $sql['where'][] = "inviter_id != 0";
    162162
    163             // Assume that a list of inviter IDs has been passed
     163            // Assume that a list of inviter IDs has been passed.
    164164            } else {
    165                 // Parse and sanitize
     165                // Parse and sanitize.
    166166                $inviter_ids = wp_parse_id_list( $inviter_id );
    167167                if ( ! empty( $inviter_ids ) ) {
     
    180180        }
    181181
    182         // Sanitize: Only 'admin', 'mod', 'member', and 'banned' are valid
     182        // Sanitize: Only 'admin', 'mod', 'member', and 'banned' are valid.
    183183        $allowed_roles = array( 'admin', 'mod', 'member', 'banned' );
    184184        foreach ( $roles as $role_key => $role_value ) {
     
    192192        // When querying for a set of roles containing 'member' (for
    193193        // which there is no dedicated is_ column), figure out a list
    194         // of columns *not* to match
     194        // of columns *not* to match.
    195195        $roles_sql = '';
    196196        if ( in_array( 'member', $roles ) ) {
     
    205205
    206206        // When querying for a set of roles *not* containing 'member',
    207         // simply construct a list of is_* = 1 clauses
     207        // simply construct a list of is_* = 1 clauses.
    208208        } else {
    209209            $role_columns = array();
     
    226226        // of 'type'. If the 'type' value is not 'last_joined' or
    227227        // 'first_joined', the order will be overridden in
    228         // BP_Group_Member_Query::set_orderby()
     228        // BP_Group_Member_Query::set_orderby().
    229229        $sql['orderby'] = "ORDER BY date_modified";
    230230        $sql['order']   = 'first_joined' === $this->query_vars['type'] ? 'ASC' : 'DESC';
     
    272272        if ( in_array( $query->query_vars['type'], array( 'last_joined', 'first_joined', 'group_activity' ) ) ) {
    273273
    274             // Group Activity DESC
     274            // Group Activity DESC.
    275275            if ( 'group_activity' == $query->query_vars['type'] ) {
    276276                $gm_ids = $this->get_gm_ids_ordered_by_activity( $query, $gm_ids );
    277277            }
    278278
    279             // The first param in the FIELD() clause is the sort column id
     279            // The first param in the FIELD() clause is the sort column id.
    280280            $gm_ids = array_merge( array( 'u.id' ), wp_parse_id_list( $gm_ids ) );
    281281            $gm_ids_sql = implode( ',', $gm_ids );
     
    285285
    286286        // Prevent this filter from running on future BP_User_Query
    287         // instances on the same page
     287        // instances on the same page.
    288288        remove_action( 'bp_pre_user_query', array( $this, 'set_orderby' ) );
    289289    }
     
    293293     *
    294294     * Additional data fetched:
    295      *
    296295     *      - is_banned
    297296     *      - date_modified
     
    313312        foreach ( (array) $extras as $extra ) {
    314313            if ( isset( $this->results[ $extra->user_id ] ) ) {
    315                 // user_id is provided for backward compatibility
     314                // The user_id is provided for backward compatibility.
    316315                $this->results[ $extra->user_id ]->user_id       = (int) $extra->user_id;
    317316                $this->results[ $extra->user_id ]->is_admin      = (int) $extra->is_admin;
     
    328327        }
    329328
    330         // Don't filter other BP_User_Query objects on the same page
     329        // Don't filter other BP_User_Query objects on the same page.
    331330        remove_action( 'bp_user_query_populate_extras', array( $this, 'populate_group_member_extras' ), 10, 2 );
    332331    }
     
    339338     * @param BP_User_Query $query  BP_User_Query object.
    340339     * @param array         $gm_ids array of group member ids.
    341      *
    342340     * @return array
    343341     */
Note: See TracChangeset for help on using the changeset viewer.