Skip to:
Content

BuddyPress.org

Changeset 1268


Ignore:
Timestamp:
03/26/2009 04:38:40 PM (17 years ago)
Author:
apeatling
Message:

Added alphabetical ordering option to member listing.

Location:
trunk/bp-core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-classes.php

    r1252 r1268  
    185185    }
    186186   
     187    function get_alphabetical_users( $limit = null, $page = 1 ) {
     188        global $wpdb, $bp;
     189
     190        if ( !function_exists( 'xprofile_install' ) )
     191            return BP_Core_User::get_active_users( $limit, $page );
     192       
     193        if ( $limit && $page )
     194            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     195
     196        $total_users = count( $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT u.ID user_id FROM {$wpdb->base_prefix}users u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pf.name = %s ORDER BY pd.value ASC", BP_XPROFILE_FULLNAME_FIELD_NAME ) ) );
     197        $paged_users = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT u.ID as user_id FROM {$wpdb->base_prefix}users u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pf.name = %s ORDER BY pd.value ASC{$pag_sql}", BP_XPROFILE_FULLNAME_FIELD_NAME ) );
     198
     199        return array( 'users' => $paged_users, 'total' => $total_users );
     200    }
     201   
    187202    function get_users_by_letter( $letter, $limit = null, $page = 1 ) {
    188203        global $wpdb, $bp;
    189204       
    190205        if ( !function_exists('xprofile_install') )
    191             return false;
     206            return BP_Core_User::get_active_users( $limit, $page );
    192207       
    193208        if ( $limit && $page )
     
    209224       
    210225        if ( !function_exists('xprofile_install') )
    211             return false;
     226            return BP_Core_User::get_active_users( $limit, $page );
    212227       
    213228        if ( $limit && $page )
  • trunk/bp-core/bp-core-templatetags.php

    r1254 r1268  
    741741                case 'online':
    742742                    $this->members = BP_Core_User::get_online_users( $this->pag_num, $this->pag_page );
    743                     break; 
     743                    break;
     744                   
     745                case 'alphabetical':
     746                    $this->members = BP_Core_User::get_alphabetical_users( $this->pag_num, $this->pag_page );
     747                    break;
    744748               
    745749                case 'active': default:
     
    837841    extract( $r, EXTR_SKIP );
    838842
    839     // type: active ( default ) | random | newest | popular | online
     843    // type: active ( default ) | random | newest | popular | online | alphabetical
    840844   
    841845    if ( $max ) {
     
    843847            $per_page = $max;
    844848    }
    845    
     849
    846850    $site_members_template = new BP_Core_Members_Template( $type, $per_page, $max );
    847851   
Note: See TracChangeset for help on using the changeset viewer.