Ticket #5114: 5114.diff
File 5114.diff, 2.2 KB (added by , 12 years ago) |
---|
-
bp-core/bp-core-classes.php
281 281 // 'alphabetical' sorts depend on the xprofile setup 282 282 case 'alphabetical' : 283 283 284 // Even if it penalizes performance, the use of last_activity is interesting to 285 // - neutralize the display of spammers and to avoid 404 for non admins 286 // - have a count that is coherent with the tab "All Members" 287 $this->uid_name = 'user_id'; 288 $sql['select'] = "SELECT DISTINCT u.{$this->uid_name} as id FROM {$wpdb->usermeta} u"; 289 $sql['where'][] = $wpdb->prepare( "u.meta_key = %s", bp_get_user_meta_key( 'last_activity' ) ); 290 284 291 // We prefer to do alphabetical sorts against the display_name field 285 292 // of wp_users, because the table is smaller and better indexed. We 286 293 // can do so if xprofile sync is enabled, or if xprofile is inactive. 287 294 // 288 295 // @todo remove need for bp_is_active() check 289 296 if ( ! bp_disable_profile_sync() || ! bp_is_active( 'xprofile' ) ) { 290 $this->uid_name = 'ID'; 291 $sql['select'] = "SELECT DISTINCT u.{$this->uid_name} as id FROM {$wpdb->users} u"; 292 $sql['orderby'] = "ORDER BY u.display_name"; 297 $sql['select'] .= " LEFT JOIN {$wpdb->users} us ON( u.{$this->uid_name} = us.ID )"; 298 $sql['orderby'] = "ORDER BY us.display_name"; 293 299 $sql['order'] = "ASC"; 294 300 295 301 // When profile sync is disabled, alphabetical sorts must happen against … … 297 303 } else { 298 304 $fullname_field_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s", bp_xprofile_fullname_field_name() ) ); 299 305 300 $this->uid_name = 'user_id'; 301 $sql['select'] = "SELECT DISTINCT u.{$this->uid_name} as id FROM {$bp->profile->table_name_data} u"; 302 $sql['where'][] = "u.field_id = {$fullname_field_id}"; 303 $sql['orderby'] = "ORDER BY u.value"; 306 $sql['select'] .= " LEFT JOIN {$bp->profile->table_name_data} us ON( u.{$this->uid_name} = us.{$this->uid_name} )"; 307 $sql['where'][] = "us.field_id = {$fullname_field_id}"; 308 $sql['orderby'] = "ORDER BY us.value"; 304 309 $sql['order'] = "ASC"; 305 310 } 306 311