Changeset 2925 for trunk/bp-core/bp-core-classes.php
- Timestamp:
- 04/15/2010 11:59:40 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-classes.php
r2920 r2925 107 107 /* Static Functions */ 108 108 109 function get_users( $type, $limit = null, $page = 1, $user_id = false, $ search_terms = false, $populate_extras = true ) {109 function get_users( $type, $limit = null, $page = 1, $user_id = false, $include = false, $search_terms = false, $populate_extras = true ) { 110 110 global $wpdb, $bp; 111 111 … … 137 137 138 138 if ( 'online' == $type ) 139 $sql['where_online'] = "AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= NOW()";139 $sql['where_online'] = "AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= UTC_TIMESTAMP()"; 140 140 141 141 if ( 'alphabetical' == $type ) 142 142 $sql['where_alpha'] = "AND pd.field_id = 1"; 143 143 144 if ( $user_id && bp_is_active( 'friends' ) ) { 144 if ( $include ) { 145 if ( is_array( $include ) ) 146 $uids = $wpdb->escape( implode( ',', (array)$include ) ); 147 else 148 $uids = $wpdb->escape( $include ); 149 150 if ( !empty( $uids ) ) 151 $sql['where_users'] = "AND u.ID IN ({$uids})"; 152 } 153 154 else if ( $user_id && function_exists( 'friends_install' ) ) { 145 155 $friend_ids = friends_get_friend_user_ids( $user_id ); 146 156 $friend_ids = $wpdb->escape( implode( ',', (array)$friend_ids ) ); … … 254 264 } 255 265 256 function get_specific_users( $user_ids, $limit = null, $page = 1, $populate_extras = true ) {257 global $wpdb, $bp;258 259 if ( $limit && $page )260 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );261 262 $user_sql = " AND user_id IN ( " . $wpdb->escape( $user_ids ) . " ) ";263 $status_sql = bp_core_get_status_sql();264 265 $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 ) );266 $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 ) );267 268 $total_users = $wpdb->get_var( $total_users_sql );269 $paged_users = $wpdb->get_results( $paged_users_sql );270 271 /***272 * Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.273 * 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)274 */275 276 /* Add additional data to the returned results */277 if ( $populate_extras )278 $paged_users = BP_Core_User::get_user_extras( &$paged_users, &$user_ids );279 280 281 return array( 'users' => $paged_users, 'total' => $total_users );282 }283 284 266 function search_users( $search_terms, $limit = null, $page = 1, $populate_extras = true ) { 285 267 global $wpdb, $bp; … … 321 303 /* Fetch the user's full name */ 322 304 if ( bp_is_active( 'xprofile' ) && 'alphabetical' != $type ) { 305 /* Ensure xprofile globals are set */ 306 if ( !defined( 'BP_XPROFILE_FULLNAME_FIELD_NAME' ) ) 307 xprofile_setup_globals(); 308 323 309 $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 ) ); 324 310 for ( $i = 0; $i < count( $paged_users ); $i++ ) {
Note: See TracChangeset
for help on using the changeset viewer.