Changeset 7700
- Timestamp:
- 12/18/2013 12:01:01 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-classes.php
r7660 r7700 246 246 case 'online' : 247 247 $this->uid_name = 'user_id'; 248 $sql['select'] = "SELECT DISTINCTu.{$this->uid_name} as id FROM {$wpdb->usermeta} u";248 $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$wpdb->usermeta} u"; 249 249 $sql['where'][] = $wpdb->prepare( "u.meta_key = %s", bp_get_user_meta_key( 'last_activity' ) ); 250 250 $sql['where'][] = $wpdb->prepare( "u.meta_value >= DATE_SUB( UTC_TIMESTAMP(), INTERVAL %d MINUTE )", apply_filters( 'bp_user_query_online_interval', 15 ) ); … … 260 260 case 'random' : 261 261 $this->uid_name = 'user_id'; 262 $sql['select'] = "SELECT DISTINCTu.{$this->uid_name} as id FROM {$wpdb->usermeta} u";262 $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$wpdb->usermeta} u"; 263 263 $sql['where'][] = $wpdb->prepare( "u.meta_key = %s", bp_get_user_meta_key( 'last_activity' ) ); 264 264 … … 278 278 case 'popular' : 279 279 $this->uid_name = 'user_id'; 280 $sql['select'] = "SELECT DISTINCTu.{$this->uid_name} as id FROM {$wpdb->usermeta} u";280 $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$wpdb->usermeta} u"; 281 281 $sql['where'][] = $wpdb->prepare( "u.meta_key = %s", bp_get_user_meta_key( 'total_friend_count' ) ); 282 282 $sql['orderby'] = "ORDER BY CONVERT(u.meta_value, SIGNED)"; … … 295 295 if ( ! bp_disable_profile_sync() || ! bp_is_active( 'xprofile' ) ) { 296 296 $this->uid_name = 'ID'; 297 $sql['select'] = "SELECT DISTINCTu.{$this->uid_name} as id FROM {$wpdb->users} u";297 $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$wpdb->users} u"; 298 298 $sql['orderby'] = "ORDER BY u.display_name"; 299 299 $sql['order'] = "ASC"; … … 305 305 306 306 $this->uid_name = 'user_id'; 307 $sql['select'] = "SELECT DISTINCTu.{$this->uid_name} as id FROM {$bp->profile->table_name_data} u";307 $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$bp->profile->table_name_data} u"; 308 308 $sql['where'][] = "u.field_id = {$fullname_field_id}"; 309 309 $sql['orderby'] = "ORDER BY u.value"; … … 314 314 // to infer spam/deleted/non-activated users. To ensure that these users 315 315 // are filtered out, we add an appropriate sub-query. 316 $sql['where'][] = "u.{$this->uid_name} IN ( SELECT IDFROM {$wpdb->users} WHERE " . bp_core_get_status_sql( '' ) . " )";316 $sql['where'][] = "u.{$this->uid_name} IN ( SELECT id FROM {$wpdb->users} WHERE " . bp_core_get_status_sql( '' ) . " )"; 317 317 318 318 break; … … 321 321 default : 322 322 $this->uid_name = 'ID'; 323 $sql['select'] = "SELECT DISTINCTu.{$this->uid_name} as id FROM {$wpdb->users} u";323 $sql['select'] = "SELECT u.{$this->uid_name} as id FROM {$wpdb->users} u"; 324 324 325 325 // In this case, we assume that a plugin is … … 438 438 $this->total_users = $wpdb->get_var( apply_filters( 'bp_found_user_query', "SELECT FOUND_ROWS()", $this ) ); 439 439 } elseif ( 'count_query' == $this->query_vars['count_total'] ) { 440 $count_select = preg_replace( '/^SELECT.*?FROM (\S+) u/', "SELECT COUNT( DISTINCTu.{$this->uid_name}) FROM $1 u", $this->uid_clauses['select'] );440 $count_select = preg_replace( '/^SELECT.*?FROM (\S+) u/', "SELECT COUNT(u.{$this->uid_name}) FROM $1 u", $this->uid_clauses['select'] ); 441 441 $this->total_users = $wpdb->get_var( apply_filters( 'bp_found_user_query', "{$count_select} {$this->uid_clauses['where']}", $this ) ); 442 442 } … … 872 872 $sql = array(); 873 873 874 $sql['select_main'] = "SELECT DISTINCTu.ID as id, u.user_registered, u.user_nicename, u.user_login, u.display_name, u.user_email";874 $sql['select_main'] = "SELECT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.display_name, u.user_email"; 875 875 876 876 if ( 'active' == $type || 'online' == $type || 'newest' == $type ) { … … 1014 1014 } 1015 1015 1016 array_unshift( $sql, "SELECT COUNT( DISTINCTu.ID)" );1016 array_unshift( $sql, "SELECT COUNT(u.ID)" ); 1017 1017 1018 1018 // Get total user results … … 1132 1132 $status_sql = bp_core_get_status_sql(); 1133 1133 1134 $total_users_sql = apply_filters( 'bp_core_get_specific_users_count_sql', "SELECT COUNT( DISTINCTID) FROM {$wpdb->users} WHERE {$status_sql} AND ID IN ({$user_ids})" );1135 $paged_users_sql = apply_filters( 'bp_core_get_specific_users_count_sql', "SELECT DISTINCTID as id, user_registered, user_nicename, user_login, user_email FROM {$wpdb->users} WHERE {$status_sql} AND ID IN ({$user_ids}) {$pag_sql}" );1134 $total_users_sql = apply_filters( 'bp_core_get_specific_users_count_sql', "SELECT COUNT(ID) FROM {$wpdb->users} WHERE {$status_sql} AND ID IN ({$user_ids})" ); 1135 $paged_users_sql = apply_filters( 'bp_core_get_specific_users_count_sql', "SELECT ID as id, user_registered, user_nicename, user_login, user_email FROM {$wpdb->users} WHERE {$status_sql} AND ID IN ({$user_ids}) {$pag_sql}" ); 1136 1136 1137 1137 $total_users = $wpdb->get_var( $total_users_sql );
Note: See TracChangeset
for help on using the changeset viewer.