Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/03/2024 10:01:19 PM (3 months ago)
Author:
espellcaste
Message:

WPCS - Part I: miscellaneous fixes for some of the files of the groups component.

See #9173
See #9174

File:
1 edited

Legend:

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

    r13372 r14076  
    4646     *
    4747     * @since 1.8.1
    48      * @var null|array Null if not yet defined, otherwise an array of ints.
     48     * @var null|array Null if not yet defined, otherwise an array of integers.
    4949     */
    5050    protected $group_member_ids;
     
    101101    public function do_wp_user_query() {
    102102        if ( ! $this->query_vars_raw['count'] ) {
    103             return parent::do_wp_user_query();
     103            parent::do_wp_user_query();
    104104        }
    105105
     
    109109         * @since 10.3.0
    110110         *
    111          * @param array         $value      Array of arguments for the user query.
     111         * @param array         $arguments  Array of arguments for the user query.
    112112         * @param BP_User_Query $user_query Current BP_User_Query instance.
    113113         */
     
    122122                    // Overrides
    123123                    'blog_id'     => 0,    // BP does not require blog roles.
    124                     'count_total' => false // We already have a count.
     124                    'count_total' => false, // We already have a count.
    125125
    126126                ),
     
    145145     * @since 1.8.0
    146146     *
    147      * @param array $include Existing group IDs in the $include parameter,
    148      *                       as calculated in BP_User_Query.
     147     * @param array $include_ids Existing group IDs in the `$include_ids` parameter,
     148     *                           as calculated in BP_User_Query.
    149149     * @return array
    150150     */
    151     public function get_include_ids( $include = array() ) {
     151    public function get_include_ids( $include_ids = array() ) {
    152152        // The following args are specific to group member queries, and
    153153        // are not present in the query_vars of a normal BP_User_Query.
     
    176176        }
    177177
    178         if ( ! empty( $include ) ) {
    179             $group_member_ids = array_intersect( $include, $group_member_ids );
     178        if ( ! empty( $include_ids ) ) {
     179            $group_member_ids = array_intersect( $include_ids, $group_member_ids );
    180180        }
    181181
     
    187187     *
    188188     * @since 1.8.0
     189     *
     190     * @global wpdb $wpdb WordPress database abstraction object.
    189191     *
    190192     * @return array $ids User IDs of relevant group member ids.
     
    208210
    209211        // Group id.
    210         $group_ids = wp_parse_id_list( $this->query_vars['group_id'] );
    211         $group_ids = implode( ',', $group_ids );
     212        $group_ids      = wp_parse_id_list( $this->query_vars['group_id'] );
     213        $group_ids      = implode( ',', $group_ids );
    212214        $sql['where'][] = "group_id IN ({$group_ids})";
    213215
    214216        // If is_confirmed.
    215         $is_confirmed = ! empty( $this->query_vars['is_confirmed'] ) ? 1 : 0;
    216         $sql['where'][] = $wpdb->prepare( "is_confirmed = %d", $is_confirmed );
     217        $is_confirmed   = ! empty( $this->query_vars['is_confirmed'] ) ? 1 : 0;
     218        $sql['where'][] = $wpdb->prepare( 'is_confirmed = %d', $is_confirmed );
    217219
    218220        // If invite_sent.
    219221        if ( ! is_null( $this->query_vars['invite_sent'] ) ) {
    220             $invite_sent = ! empty( $this->query_vars['invite_sent'] ) ? 1 : 0;
    221             $sql['where'][] = $wpdb->prepare( "invite_sent = %d", $invite_sent );
     222            $invite_sent    = ! empty( $this->query_vars['invite_sent'] ) ? 1 : 0;
     223            $sql['where'][] = $wpdb->prepare( 'invite_sent = %d', $invite_sent );
    222224        }
    223225
     
    228230            // Empty: inviter_id = 0. (pass false, 0, or empty array).
    229231            if ( empty( $inviter_id ) ) {
    230                 $sql['where'][] = "inviter_id = 0";
    231 
    232             // The string 'any' matches any non-zero value (inviter_id != 0).
     232                $sql['where'][] = 'inviter_id = 0';
     233
     234                // The string 'any' matches any non-zero value (inviter_id != 0).
    233235            } elseif ( 'any' === $inviter_id ) {
    234                 $sql['where'][] = "inviter_id != 0";
    235 
    236             // Assume that a list of inviter IDs has been passed.
     236                $sql['where'][] = 'inviter_id != 0';
     237
     238                // Assume that a list of inviter IDs has been passed.
    237239            } else {
    238240                // Parse and sanitize.
     
    240242                if ( ! empty( $inviter_ids ) ) {
    241243                    $inviter_ids_sql = implode( ',', $inviter_ids );
    242                     $sql['where'][] = "inviter_id IN ({$inviter_ids_sql})";
     244                    $sql['where'][]  = "inviter_id IN ({$inviter_ids_sql})";
    243245                }
    244246            }
     
    248250        // is_admin = 1, mods have is_mod = 1, banned have is_banned =
    249251        // 1, and members have all three set to 0.
    250         $roles = !empty( $this->query_vars['group_role'] ) ? $this->query_vars['group_role'] : array();
     252        $roles = ! empty( $this->query_vars['group_role'] ) ? $this->query_vars['group_role'] : array();
    251253        if ( is_string( $roles ) ) {
    252254            $roles = explode( ',', $roles );
     
    277279            }
    278280
    279         // When querying for a set of roles *not* containing 'member',
    280         // simply construct a list of is_* = 1 clauses.
     281            // When querying for a set of roles *not* containing 'member',
     282            // simply construct a list of is_* = 1 clauses.
    281283        } else {
    282284            $role_columns = array();
     
    300302        // 'first_joined', the order will be overridden in
    301303        // BP_Group_Member_Query::set_orderby().
    302         $sql['orderby'] = "ORDER BY date_modified";
     304        $sql['orderby'] = 'ORDER BY date_modified';
    303305        $sql['order']   = 'first_joined' === $this->query_vars['type'] ? 'ASC' : 'DESC';
    304306
     
    327329                    $invite_args['type'] = 'request';
    328330
    329                 /*
    330                 * The string 'any' matches any non-zero value (inviter_id != 0).
    331                 * These are invitations, not requests.
    332                 */
     331                    /*
     332                    * The string 'any' matches any non-zero value (inviter_id != 0).
     333                    * These are invitations, not requests.
     334                    */
    333335                } elseif ( 'any' === $inviter_id ) {
    334336                    $invite_args['type'] = 'invite';
    335337
    336                 // Assume that a list of inviter IDs has been passed.
     338                    // Assume that a list of inviter IDs has been passed.
    337339                } else {
    338340                    $invite_args['type'] = 'invite';
     
    407409
    408410            // The first param in the FIELD() clause is the sort column id.
    409             $gm_ids = array_merge( array( 'u.id' ), wp_parse_id_list( $gm_ids ) );
     411            $gm_ids     = array_merge( array( 'u.id' ), wp_parse_id_list( $gm_ids ) );
    410412            $gm_ids_sql = implode( ',', $gm_ids );
    411413
    412             $query->uid_clauses['orderby'] = "ORDER BY FIELD(" . $gm_ids_sql . ")";
     414            $query->uid_clauses['orderby'] = 'ORDER BY FIELD(' . $gm_ids_sql . ')';
    413415        }
    414416
     
    422424     *
    423425     * Additional data fetched:
    424      *      - is_banned
    425      *      - date_modified
     426     *  - is_banned
     427     *  - date_modified
    426428     *
    427429     * @since 1.8.0
     430     *
     431     * @global wpdb $wpdb WordPress database abstraction object.
    428432     *
    429433     * @param BP_User_Query $query        BP_User_Query object. Because we're
    430434     *                                    filtering the current object, we use
    431      *                                    $this inside of the method instead.
     435     *                                    $this inside the method instead.
    432436     * @param string        $user_ids_sql Sanitized, comma-separated string of
    433437     *                                    the user ids returned by the main query.
     
    457461
    458462        // Add accurate invitation info from the invitations table.
    459         $invites = groups_get_invites( array(
    460             'user_id' => $user_ids_sql,
    461             'item_id' => $this->query_vars['group_id'],
    462             'type'    => 'all',
    463         ) );
     463        $invites = groups_get_invites(
     464            array(
     465                'user_id' => $user_ids_sql,
     466                'item_id' => $this->query_vars['group_id'],
     467                'type'    => 'all',
     468            )
     469        );
    464470        foreach ( $invites as $invite ) {
    465471            if ( isset( $this->results[ $invite->user_id ] ) ) {
     
    504510     * @since 2.1.0
    505511     *
     512     * @global wpdb $wpdb WordPress database abstraction object.
     513     *
    506514     * @param BP_User_Query $query  BP_User_Query object.
    507515     * @param array         $gm_ids array of group member ids.
     
    532540            'user_id IN (' . implode( ',', wp_parse_id_list( $gm_ids ) ) . ')',
    533541            'item_id = ' . absint( $query->query_vars['group_id'] ),
    534             $wpdb->prepare( "component = %s", buddypress()->groups->id ),
     542            $wpdb->prepare( 'component = %s', buddypress()->groups->id ),
    535543        );
    536544
     
    552560    public function populate_extras() {
    553561        if ( ! $this->query_vars_raw['count'] ) {
    554             return parent::populate_extras();
     562            parent::populate_extras();
    555563        }
    556564
Note: See TracChangeset for help on using the changeset viewer.