Changeset 3232 for trunk/bp-core/bp-core-classes.php
- Timestamp:
- 09/06/2010 04:24:57 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-classes.php
r3023 r3232 107 107 /* Static Functions */ 108 108 109 function get_users( $type, $limit = null, $page = 1, $user_id = false, $ include = false, $search_terms = false, $populate_extras = true ) {109 function get_users( $type, $limit = null, $page = 1, $user_id = false, $search_terms = false, $populate_extras = true ) { 110 110 global $wpdb, $bp; 111 111 … … 134 134 135 135 if ( 'online' == $type ) 136 $sql['where_online'] = "AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= UTC_TIMESTAMP()";136 $sql['where_online'] = "AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= NOW()"; 137 137 138 138 if ( 'alphabetical' == $type ) 139 139 $sql['where_alpha'] = "AND pd.field_id = 1"; 140 140 141 if ( $include ) { 142 if ( is_array( $include ) ) 143 $uids = $wpdb->escape( implode( ',', (array)$include ) ); 144 else 145 $uids = $wpdb->escape( $include ); 146 147 if ( !empty( $uids ) ) 148 $sql['where_users'] = "AND u.ID IN ({$uids})"; 149 } 150 151 else if ( $user_id && function_exists( 'friends_install' ) ) { 141 if ( $user_id && function_exists( 'friends_install' ) ) { 152 142 $friend_ids = friends_get_friend_user_ids( $user_id ); 153 143 $friend_ids = $wpdb->escape( implode( ',', (array)$friend_ids ) ); … … 261 251 } 262 252 253 function get_specific_users( $user_ids, $limit = null, $page = 1, $populate_extras = true ) { 254 global $wpdb, $bp; 255 256 if ( $limit && $page ) 257 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 258 259 $user_sql = " AND user_id IN ( " . $wpdb->escape( $user_ids ) . " ) "; 260 $status_sql = bp_core_get_status_sql(); 261 262 $total_users_sql = apply_filters( 'bp_core_get_specific_users_count_sql', $wpdb->prepare( "SELECT COUNT(DISTINCT ID) FROM " . CUSTOM_USER_TABLE . " WHERE {$status_sql} AND ID IN ( " . $wpdb->escape( $user_ids ) . " ) " ), $wpdb->escape( $user_ids ) ); 263 $paged_users_sql = apply_filters( 'bp_core_get_specific_users_count_sql', $wpdb->prepare( "SELECT DISTINCT ID as id, user_registered, user_nicename, user_login, user_email FROM " . CUSTOM_USER_TABLE . " WHERE {$status_sql} AND ID IN ( " . $wpdb->escape( $user_ids ) . " ) {$pag_sql}" ), $wpdb->escape( $user_ids ) ); 264 265 $total_users = $wpdb->get_var( $total_users_sql ); 266 $paged_users = $wpdb->get_results( $paged_users_sql ); 267 268 /*** 269 * Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list. 270 * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join) 271 */ 272 273 /* Add additional data to the returned results */ 274 if ( $populate_extras ) 275 $paged_users = BP_Core_User::get_user_extras( &$paged_users, &$user_ids ); 276 277 278 return array( 'users' => $paged_users, 'total' => $total_users ); 279 } 280 263 281 function search_users( $search_terms, $limit = null, $page = 1, $populate_extras = true ) { 264 282 global $wpdb, $bp; … … 300 318 /* Fetch the user's full name */ 301 319 if ( bp_is_active( 'xprofile' ) && 'alphabetical' != $type ) { 302 /* Ensure xprofile globals are set */303 if ( !defined( 'BP_XPROFILE_FULLNAME_FIELD_NAME' ) )304 xprofile_setup_globals();305 306 320 $names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id as id, pd.value as fullname FROM {$bp->profile->table_name_fields} pf, {$bp->profile->table_name_data} pd WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} )", BP_XPROFILE_FULLNAME_FIELD_NAME ) ); 307 321 for ( $i = 0; $i < count( $paged_users ); $i++ ) {
Note: See TracChangeset
for help on using the changeset viewer.