- Timestamp:
- 11/03/2024 10:01:19 PM (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/classes/class-bp-group-member-query.php
r13372 r14076 46 46 * 47 47 * @since 1.8.1 48 * @var null|array Null if not yet defined, otherwise an array of int s.48 * @var null|array Null if not yet defined, otherwise an array of integers. 49 49 */ 50 50 protected $group_member_ids; … … 101 101 public function do_wp_user_query() { 102 102 if ( ! $this->query_vars_raw['count'] ) { 103 returnparent::do_wp_user_query();103 parent::do_wp_user_query(); 104 104 } 105 105 … … 109 109 * @since 10.3.0 110 110 * 111 * @param array $ valueArray of arguments for the user query.111 * @param array $arguments Array of arguments for the user query. 112 112 * @param BP_User_Query $user_query Current BP_User_Query instance. 113 113 */ … … 122 122 // Overrides 123 123 '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. 125 125 126 126 ), … … 145 145 * @since 1.8.0 146 146 * 147 * @param array $include Existing group IDs in the $includeparameter,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. 149 149 * @return array 150 150 */ 151 public function get_include_ids( $include = array() ) {151 public function get_include_ids( $include_ids = array() ) { 152 152 // The following args are specific to group member queries, and 153 153 // are not present in the query_vars of a normal BP_User_Query. … … 176 176 } 177 177 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 ); 180 180 } 181 181 … … 187 187 * 188 188 * @since 1.8.0 189 * 190 * @global wpdb $wpdb WordPress database abstraction object. 189 191 * 190 192 * @return array $ids User IDs of relevant group member ids. … … 208 210 209 211 // 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 ); 212 214 $sql['where'][] = "group_id IN ({$group_ids})"; 213 215 214 216 // 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 ); 217 219 218 220 // If invite_sent. 219 221 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 ); 222 224 } 223 225 … … 228 230 // Empty: inviter_id = 0. (pass false, 0, or empty array). 229 231 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). 233 235 } 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. 237 239 } else { 238 240 // Parse and sanitize. … … 240 242 if ( ! empty( $inviter_ids ) ) { 241 243 $inviter_ids_sql = implode( ',', $inviter_ids ); 242 $sql['where'][] = "inviter_id IN ({$inviter_ids_sql})";244 $sql['where'][] = "inviter_id IN ({$inviter_ids_sql})"; 243 245 } 244 246 } … … 248 250 // is_admin = 1, mods have is_mod = 1, banned have is_banned = 249 251 // 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(); 251 253 if ( is_string( $roles ) ) { 252 254 $roles = explode( ',', $roles ); … … 277 279 } 278 280 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. 281 283 } else { 282 284 $role_columns = array(); … … 300 302 // 'first_joined', the order will be overridden in 301 303 // BP_Group_Member_Query::set_orderby(). 302 $sql['orderby'] = "ORDER BY date_modified";304 $sql['orderby'] = 'ORDER BY date_modified'; 303 305 $sql['order'] = 'first_joined' === $this->query_vars['type'] ? 'ASC' : 'DESC'; 304 306 … … 327 329 $invite_args['type'] = 'request'; 328 330 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 */ 333 335 } elseif ( 'any' === $inviter_id ) { 334 336 $invite_args['type'] = 'invite'; 335 337 336 // Assume that a list of inviter IDs has been passed.338 // Assume that a list of inviter IDs has been passed. 337 339 } else { 338 340 $invite_args['type'] = 'invite'; … … 407 409 408 410 // 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 ) ); 410 412 $gm_ids_sql = implode( ',', $gm_ids ); 411 413 412 $query->uid_clauses['orderby'] = "ORDER BY FIELD(" . $gm_ids_sql . ")";414 $query->uid_clauses['orderby'] = 'ORDER BY FIELD(' . $gm_ids_sql . ')'; 413 415 } 414 416 … … 422 424 * 423 425 * Additional data fetched: 424 * 425 * 426 * - is_banned 427 * - date_modified 426 428 * 427 429 * @since 1.8.0 430 * 431 * @global wpdb $wpdb WordPress database abstraction object. 428 432 * 429 433 * @param BP_User_Query $query BP_User_Query object. Because we're 430 434 * filtering the current object, we use 431 * $this inside ofthe method instead.435 * $this inside the method instead. 432 436 * @param string $user_ids_sql Sanitized, comma-separated string of 433 437 * the user ids returned by the main query. … … 457 461 458 462 // 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 ); 464 470 foreach ( $invites as $invite ) { 465 471 if ( isset( $this->results[ $invite->user_id ] ) ) { … … 504 510 * @since 2.1.0 505 511 * 512 * @global wpdb $wpdb WordPress database abstraction object. 513 * 506 514 * @param BP_User_Query $query BP_User_Query object. 507 515 * @param array $gm_ids array of group member ids. … … 532 540 'user_id IN (' . implode( ',', wp_parse_id_list( $gm_ids ) ) . ')', 533 541 'item_id = ' . absint( $query->query_vars['group_id'] ), 534 $wpdb->prepare( "component = %s", buddypress()->groups->id ),542 $wpdb->prepare( 'component = %s', buddypress()->groups->id ), 535 543 ); 536 544 … … 552 560 public function populate_extras() { 553 561 if ( ! $this->query_vars_raw['count'] ) { 554 returnparent::populate_extras();562 parent::populate_extras(); 555 563 } 556 564
Note: See TracChangeset
for help on using the changeset viewer.