Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/14/2010 05:01:52 PM (16 years ago)
Author:
apeatling
Message:

Fix incorrect hooks in template. Fix issues with ordering when getting specific users via the members loop.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.2/bp-core/bp-core-classes.php

    r2890 r2923  
    107107        /* Static Functions */
    108108
    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 ) {
    110110                global $wpdb, $bp;
    111111
     
    152152                                return false;
    153153                        }
     154                }
     155
     156                if ( $include ) {
     157                        /* Unset previous user restriction SQL */
     158                        unset( $sql['where_friends'] );
     159
     160                        if ( is_array( $include ) )
     161                                $uids = $wpdb->escape( implode( ',', (array)$include ) );
     162                        else
     163                                $uids = $wpdb->escape( $include );
     164
     165                        if ( !empty( $uids ) )
     166                                $sql['where_users'] = "AND u.ID IN ({$uids})";
    154167                }
    155168
     
    254267        }
    255268
    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 
    284269        function search_users( $search_terms, $limit = null, $page = 1, $populate_extras = true ) {
    285270                global $wpdb, $bp;
Note: See TracChangeset for help on using the changeset viewer.