- Timestamp:
- 10/06/2022 10:31:49 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/classes/class-bp-activity-activity.php
r13312 r13337 343 343 * @since 2.9.0 Introduced the `$order_by` parameter. 344 344 * @since 10.0.0 Introduced the `$count_total_only` parameter. 345 * @since 11.0.0 Introduced the `$user_id__in` and `$user_id__not_in` parameters. 345 346 * 346 347 * @see BP_Activity_Activity::get_filter_sql() for a description of the … … 367 368 * @type string|array $scope Pre-determined set of activity arguments. 368 369 * @type array $filter See BP_Activity_Activity::get_filter_sql(). 370 * @type array $user_id__in An array of user ids to include. Activity posted by users matching one of these 371 * user ids will be included in results. Default empty array. 372 * @type array $user_id__not_in An array of user ids to exclude. Activity posted by users matching one of these 373 * user ids will not be included in results. Default empty array. 369 374 * @type string $search_terms Limit results by a search term. Default: false. 370 375 * @type bool $display_comments Whether to include activity comments. Default: false. … … 431 436 'date_query' => false, // Filter by date. 432 437 'filter_query' => false, // Advanced filtering - see BP_Activity_Query. 438 'user_id__in' => array(), // Array of user ids to include. 439 'user_id__not_in' => array(), // Array of user ids to excluce. 433 440 'filter' => false, // See self::get_filter_sql(). 434 441 'scope' => false, // Preset activity arguments. … … 482 489 if ( $r['filter'] && $filter_sql = BP_Activity_Activity::get_filter_sql( $r['filter'] ) ) { 483 490 $where_conditions['filter_sql'] = $filter_sql; 491 } 492 493 // User IDs filtering. 494 $user_ids_clause = array(); 495 $user_ids_filters = array_filter( 496 array_intersect_key( 497 $r, 498 array( 499 'user_id__in' => true, 500 'user_id__not_in' => true, 501 ) 502 ) 503 ); 504 505 foreach ( $user_ids_filters as $user_ids_filter_key => $user_ids_filter ) { 506 $user_ids_operator = 'IN'; 507 if ( 'user_id__not_in' === $user_ids_filter_key ) { 508 $user_ids_operator = 'NOT IN'; 509 } 510 511 if ( $user_ids_clause ) { 512 $user_ids_clause[] = array( 513 'column' => 'user_id', 514 'compare' => $user_ids_operator, 515 'value' => (array) $user_ids_filter, 516 ); 517 } else { 518 $user_ids_clause = array( 519 'relation' => 'AND', 520 array( 521 'column' => 'user_id', 522 'compare' => $user_ids_operator, 523 'value' => (array) $user_ids_filter, 524 ), 525 ); 526 } 527 } 528 529 if ( $user_ids_clause ) { 530 $user_ids_query = new BP_Activity_Query( $user_ids_clause ); 531 $user_ids_sql = $user_ids_query->get_sql(); 532 if ( ! empty( $user_ids_sql ) ) { 533 $where_conditions['user_ids_query_sql'] = $user_ids_sql; 534 } 484 535 } 485 536
Note: See TracChangeset
for help on using the changeset viewer.