Changeset 9178 for trunk/src/bp-core/bp-core-classes.php
- Timestamp:
- 11/25/2014 04:40:27 PM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-core/bp-core-classes.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-classes.php
r9119 r9178 13 13 * BuddyPress User Query class. 14 14 * 15 * Used for querying users in a BuddyPress context, in situations where 16 * WP_User_Query won't do the trick: Member directories, the Friends component, 17 * etc. 15 * Used for querying users in a BuddyPress context, in situations where WP_User_Query won't do the trick: 16 * Member directories, the Friends component, etc. 18 17 * 19 18 * @since BuddyPress (1.7.0) … … 21 20 * @param array $query { 22 21 * Query arguments. All items are optional. 23 * @type string $type Determines sort order. Select from 'newest', 'active', 24 * 'online', 'random', 'popular', 'alphabetical'. Default: 'newest'. 25 * @type int $per_page Number of results to return. Default: 0 (no limit). 26 * @type int $page Page offset (together with $per_page). Default: 1. 27 * @type int $user_id ID of a user. If present, and if the friends 28 * component is activated, results will be limited to the friends of 29 * that user. Default: 0. 30 * @type string|bool $search_terms Terms to search by. Search happens 31 * across xprofile fields. Requires XProfile component. 32 * Default: false. 33 * @type string $search_wildcard When searching with $search_terms, 34 * set where wildcards around the term should be positioned. 35 * Default: 'both'. Other values: 'left', 'right'. 36 * @type array|string|bool $include An array or comma-separated list of 37 * user IDs to which query should be limited. 38 * Default: false. 39 * @type array|string|bool $exclude An array or comma-separated list of 40 * user IDs that will be excluded from query results. Default: false. 41 * @type array|string|bool $user_ids An array or comma-separated list of 42 * IDs corresponding to the users that should be returned. When this 43 * parameter is passed, it will override all others; BP User objects 44 * will be constructed using these IDs only. Default: false. 45 * @type string|bool $meta_key Limit results to users that have usermeta 46 * associated with this meta_key. Usually used with $meta_value. 47 * Default: false. 48 * @type string|bool $meta_value When used with $meta_key, limits results 49 * to users whose usermeta value associated with $meta_key matches 50 * $meta_value. Default: false. 51 * @type bool $populate_extras True if you want to fetch extra metadata 52 * about returned users, such as total group and friend counts. 53 * @type string $count_total Determines how BP_User_Query will do a count 54 * of total users matching the other filter criteria. Default value 55 * is 'count_query', which does a separate SELECT COUNT query to 56 * determine the total. 'sql_count_found_rows' uses 57 * SQL_COUNT_FOUND_ROWS and SELECT FOUND_ROWS(). Pass an empty string 58 * to skip the total user count query. 22 * @type string $type Determines sort order. Select from 'newest', 'active', 'online', 23 * 'random', 'popular', 'alphabetical'. Default: 'newest'. 24 * @type int $per_page Number of results to return. Default: 0 (no limit). 25 * @type int $page Page offset (together with $per_page). Default: 1. 26 * @type int $user_id ID of a user. If present, and if the friends component is activated, 27 * results will be limited to the friends of that user. Default: 0. 28 * @type string|bool $search_terms Terms to search by. Search happens across xprofile fields. Requires 29 * XProfile component. Default: false. 30 * @type string $search_wildcard When searching with $search_terms, set where wildcards around the term 31 * should be positioned. Accepts 'both', 'left', 'right'. Default: 'both'. 32 * @type array|string|bool $include An array or comma-separated list of user IDs to which query should 33 * be limited. Default: false. 34 * @type array|string|bool $exclude An array or comma-separated list of user IDs that will be excluded from 35 * query results. Default: false. 36 * @type array|string|bool $user_ids An array or comma-separated list of IDs corresponding to the users 37 * that should be returned. When this parameter is passed, it will 38 * override all others; BP User objects will be constructed using these 39 * IDs only. Default: false. 40 * @type string|bool $meta_key Limit results to users that have usermeta associated with this meta_key. 41 * Usually used with $meta_value. Default: false. 42 * @type string|bool $meta_value When used with $meta_key, limits results to users whose usermeta value 43 * associated with $meta_key matches $meta_value. Default: false. 44 * @type array $xprofile_query Filter results by xprofile data. Requires the xprofile component. See 45 * {@see BP_XProfile_Query} for details. 46 * @type bool $populate_extras True if you want to fetch extra metadata 47 * about returned users, such as total group and friend counts. 48 * @type string $count_total Determines how BP_User_Query will do a count of total users matching 49 * the other filter criteria. Default value is 'count_query', which does 50 * a separate SELECT COUNT query to determine the total. 51 * 'sql_count_found_rows' uses SQL_COUNT_FOUND_ROWS and 52 * SELECT FOUND_ROWS(). Pass an empty string to skip the total user 53 * count query. 59 54 * } 60 55 */ … … 114 109 */ 115 110 public $uid_clauses = array(); 111 112 /** 113 * SQL table where the user ID is being fetched from. 114 * 115 * @since BuddyPress (2.2.0) 116 * @access public 117 * @var string 118 */ 119 public $uid_table = ''; 116 120 117 121 /** … … 163 167 'meta_key' => false, 164 168 'meta_value' => false, 169 'xprofile_query' => false, 165 170 'populate_extras' => true, 166 171 'count_total' => 'count_query' … … 250 255 case 'online' : 251 256 $this->uid_name = 'user_id'; 252 $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$bp->members->table_name_last_activity} u"; 257 $this->uid_table = $bp->members->table_name_last_activity; 258 $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u"; 253 259 $sql['where'][] = $wpdb->prepare( "u.component = %s AND u.type = 'last_activity'", buddypress()->members->id ); 254 260 $sql['where'][] = $wpdb->prepare( "u.date_recorded >= DATE_SUB( UTC_TIMESTAMP(), INTERVAL %d MINUTE )", apply_filters( 'bp_user_query_online_interval', 15 ) ); … … 264 270 case 'random' : 265 271 $this->uid_name = 'user_id'; 266 $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$bp->members->table_name_last_activity} u"; 272 $this->uid_table = $bp->members->table_name_last_activity; 273 $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u"; 267 274 $sql['where'][] = $wpdb->prepare( "u.component = %s AND u.type = 'last_activity'", buddypress()->members->id ); 268 275 … … 282 289 case 'popular' : 283 290 $this->uid_name = 'user_id'; 284 $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$wpdb->usermeta} u"; 291 $this->uid_table = $wpdb->usermeta; 292 $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u"; 285 293 $sql['where'][] = $wpdb->prepare( "u.meta_key = %s", bp_get_user_meta_key( 'total_friend_count' ) ); 286 294 $sql['orderby'] = "ORDER BY CONVERT(u.meta_value, SIGNED)"; … … 299 307 if ( ! bp_disable_profile_sync() || ! bp_is_active( 'xprofile' ) ) { 300 308 $this->uid_name = 'ID'; 301 $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$wpdb->users} u"; 309 $this->uid_table = $wpdb->users; 310 $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u"; 302 311 $sql['orderby'] = "ORDER BY u.display_name"; 303 312 $sql['order'] = "ASC"; … … 307 316 } else { 308 317 $this->uid_name = 'user_id'; 309 $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$bp->profile->table_name_data} u"; 318 $this->uid_table = $bp->profile->table_name_data; 319 $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u"; 310 320 $sql['where'][] = $wpdb->prepare( "u.field_id = %d", bp_xprofile_fullname_field_id() ); 311 321 $sql['orderby'] = "ORDER BY u.value"; … … 323 333 default : 324 334 $this->uid_name = 'ID'; 325 $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$wpdb->users} u"; 335 $this->uid_table = $wpdb->users; 336 $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u"; 326 337 327 338 // In this case, we assume that a plugin is
Note: See TracChangeset
for help on using the changeset viewer.