Skip to:
Content

BuddyPress.org

Changeset 2923


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

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

Location:
branches/1.2
Files:
5 edited

Legend:

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

    r2903 r2923  
    532532        'search_terms' => false, // Limit to users that match these search terms
    533533
     534        'include' => false, // Pass comma separated list of user_ids to limit to only these users
    534535        'per_page' => 20, // The number of results to return per page
    535536        'page' => 1, // The page to return if limiting per page
     
    540541    extract( $params, EXTR_SKIP );
    541542
    542     return apply_filters( 'bp_core_get_users', BP_Core_User::get_users( $type, $per_page, $page, $user_id, $search_terms, $populate_extras ), &$params );
     543    return apply_filters( 'bp_core_get_users', BP_Core_User::get_users( $type, $per_page, $page, $user_id, $include, $search_terms, $populate_extras ), &$params );
    543544}
    544545
  • 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;
  • branches/1.2/bp-core/bp-core-templatetags.php

    r2839 r2923  
    2727        if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) {
    2828            $this->members = BP_Core_User::get_users_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page, $populate_extras );
    29         }
    30         else if ( false !== $include ) {
    31             $this->members = BP_Core_User::get_specific_users( $include, $this->pag_num, $this->pag_page, $populate_extras );
    32         }
    33         else {
    34             $this->members = bp_core_get_users( array( 'type' => $this->type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras ) );
     29        } else {
     30            $this->members = bp_core_get_users( array( 'type' => $this->type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'include' => $include, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras ) );
    3531        }
    3632
     
    160156
    161157    $members_template = new BP_Core_Members_Template( $type, $page, $per_page, $max, $user_id, $search_terms, $include, (bool)$populate_extras );
    162 
    163     return $members_template->has_members();
     158    return apply_filters( 'bp_has_members', $members_template->has_members(), &$members_template );
    164159}
    165160
  • branches/1.2/bp-core/bp-core-wpabstraction.php

    r2832 r2923  
    6969
    7070if ( !function_exists( 'is_site_admin' ) ) {
    71     function is_site_admin() {
     71    function is_site_admin( $user_id = false ) {
    7272        if ( current_user_can( 'manage_options' ) )
    7373            return true;
  • branches/1.2/bp-themes/bp-default/members/single/home.php

    r2695 r2923  
    1515                        <?php bp_get_displayed_user_nav() ?>
    1616
    17                         <?php do_action( 'bp_members_directory_member_types' ) ?>
     17                        <?php do_action( 'bp_member_options_nav' ) ?>
    1818                    </ul>
    1919                </div>
Note: See TracChangeset for help on using the changeset viewer.