Skip to:
Content

BuddyPress.org

Changeset 7949


Ignore:
Timestamp:
02/21/2014 02:06:53 PM (10 years ago)
Author:
boonebgorges
Message:

Enable member sorting and pagination on group Members pages

Fixes #921

Props imath, boonebgorges

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-template.php

    r7948 r7949  
    20292029        $this->pag_num  = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    20302030
     2031        // Assemble the base URL for pagination
     2032        $base_url = trailingslashit( bp_get_group_permalink( groups_get_current_group() ) . bp_current_action() );
     2033        if ( bp_action_variable() ) {
     2034            $base_url = trailingslashit( $base_url . bp_action_variable() );
     2035        }
     2036
    20312037        $members_args = $r;
    20322038
     
    20532059
    20542060        $this->pag_links = paginate_links( array(
    2055             'base' => add_query_arg( 'mlpage', '%#%' ),
     2061            'base' => add_query_arg( array( 'mlpage' => '%#%' ), $base_url ),
    20562062            'format' => '',
    20572063            'total' => !empty( $this->pag_num ) ? ceil( $this->total_member_count / $this->pag_num ) : $this->total_member_count,
     
    21332139    global $members_template;
    21342140
     2141    $exclude_admins_mods = 1;
     2142
     2143    if ( bp_is_group_members() ) {
     2144        $exclude_admins_mods = 0;
     2145    }
     2146
    21352147    $r = wp_parse_args( $args, array(
    21362148        'group_id'            => bp_get_current_group_id(),
     
    21392151        'max'                 => false,
    21402152        'exclude'             => false,
    2141         'exclude_admins_mods' => 1,
     2153        'exclude_admins_mods' => $exclude_admins_mods,
    21422154        'exclude_banned'      => 1,
    21432155        'group_role'          => false,
     
    23252337    }
    23262338
     2339/**
     2340 * Output the Group members template
     2341 *
     2342 * @since BuddyPress (?)
     2343 *
     2344 * @return string html output
     2345 */
     2346function bp_groups_members_template_part() {
     2347    ?>
     2348    <div class="item-list-tabs" id="subnav" role="navigation">
     2349        <ul>
     2350            <li class="groups-members-search" role="search">
     2351                <?php bp_directory_members_search_form(); ?>
     2352            </li>
     2353
     2354            <?php bp_groups_members_filter(); ?>
     2355            <?php do_action( 'bp_members_directory_member_sub_types' ); ?>
     2356
     2357        </ul>
     2358    </div>
     2359
     2360    <div id="members-group-list" class="group_members dir-list">
     2361
     2362        <?php bp_get_template_part( 'groups/single/members' ); ?>
     2363
     2364    </div>
     2365    <?php
     2366}
     2367
     2368/**
     2369 * Output the Group members filters
     2370 *
     2371 * @since BuddyPress (?)
     2372 *
     2373 * @return string html output
     2374 */
     2375function bp_groups_members_filter() {
     2376    ?>
     2377    <li id="group_members-order-select" class="last filter">
     2378        <label for="group_members-order-by"><?php _e( 'Order By:', 'buddypress' ); ?></label>
     2379        <select id="group_members-order-by">
     2380            <option value="last_joined"><?php _e( 'Newest', 'buddypress' ); ?></option>
     2381            <option value="first_joined"><?php _e( 'Oldest', 'buddypress' ); ?></option>
     2382            <option value="alphabetical"><?php _e( 'Alphabetical', 'buddypress' ); ?></option>
     2383
     2384            <?php do_action( 'bp_groups_members_order_options' ); ?>
     2385
     2386        </select>
     2387    </li>
     2388    <?php
     2389}
    23272390
    23282391/***************************************************************************
  • trunk/bp-templates/bp-legacy/buddypress-functions.php

    r7942 r7949  
    573573        bp_update_is_directory( true, bp_current_component() );
    574574
     575    $template_part = $object . '/' . $object . '-loop';
     576
     577    // The template part can be overridden by the calling JS function
     578    if ( ! empty( $_POST['template'] ) ) {
     579        $template_part = sanitize_option( 'upload_path', $_POST['template'] );
     580    }
     581
    575582    // Locate the object template
    576     bp_get_template_part( "$object/$object-loop" );
     583    bp_get_template_part( $template_part );
    577584    exit();
    578585}
  • trunk/bp-templates/bp-legacy/buddypress/groups/single/home.php

    r6516 r7949  
    4848
    4949                // Otherwise show members
    50                 elseif ( bp_is_active( 'members'  ) ) : bp_get_template_part( 'groups/single/members'  );
     50                elseif ( bp_is_active( 'members'  ) ) : bp_groups_members_template_part();
    5151
    5252                endif;
     
    6262
    6363                // Group Members
    64                 elseif ( bp_is_group_members()    ) : bp_get_template_part( 'groups/single/members'      );
     64                elseif ( bp_is_group_members()    ) : bp_groups_members_template_part();
    6565
    6666                // Group Invitations
  • trunk/bp-templates/bp-legacy/buddypress/groups/single/members.php

    r6284 r7949  
    1 <?php if ( bp_group_has_members( 'exclude_admins_mods=0' ) ) : ?>
     1<?php if ( bp_group_has_members( bp_ajax_querystring( 'group_members' ) ) ) : ?>
    22
    33    <?php do_action( 'bp_before_group_members_content' ); ?>
    44
    5     <div class="item-list-tabs" id="subnav" role="navigation">
    6         <ul>
    7 
    8             <?php do_action( 'bp_members_directory_member_sub_types' ); ?>
    9 
    10         </ul>
    11     </div>
    12 
    13     <div id="pag-top" class="pagination no-ajax">
     5    <div id="pag-top" class="pagination">
    146
    157        <div class="pag-count" id="member-count-top">
     
    6456    <?php do_action( 'bp_after_group_members_list' ); ?>
    6557
    66     <div id="pag-bottom" class="pagination no-ajax">
     58    <div id="pag-bottom" class="pagination">
    6759
    6860        <div class="pag-count" id="member-count-bottom">
  • trunk/bp-templates/bp-legacy/css/buddypress.css

    r7679 r7949  
    487487    margin: -39px 0 0 0;
    488488}
    489 #buddypress div.dir-search input[type=text] {
     489#buddypress div.dir-search input[type=text],
     490#buddypress li.groups-members-search input[type=text] {
    490491    font-size: 90%;
    491492    padding: 1px 3px;
     
    582583#buddypress .standard-form input[type=password],
    583584#buddypress .dir-search input[type=search],
    584 #buddypress .dir-search input[type=text] {
     585#buddypress .dir-search input[type=text],
     586#buddypress .groups-members-search input[type=search],
     587#buddypress .groups-members-search input[type=text] {
    585588    border: 1px solid #ccc;
    586589    background: #fafafa;
  • trunk/bp-templates/bp-legacy/js/buddypress.js

    r7946 r7949  
    1818
    1919    /* Object filter and scope set. */
    20     var objects = [ 'members', 'groups', 'blogs', 'forums' ];
     20    var objects = [ 'members', 'groups', 'blogs', 'forums', 'group_members' ];
    2121    bp_init_objects( objects );
    2222
     
    666666
    667667    /* The search form on all directory pages */
    668     jq('.dir-search').on( 'click', function(event) {
     668    jq( '.dir-search, .groups-members-search' ).on( 'click', function(event) {
    669669        if ( jq(this).hasClass('no-ajax') )
    670670            return;
     
    675675            var css_id = jq('.item-list-tabs li.selected').attr('id').split( '-' );
    676676            var object = css_id[0];
    677 
    678             bp_filter_request( object, jq.cookie('bp-' + object + '-filter'), jq.cookie('bp-' + object + '-scope') , 'div.' + object, target.parent().children('label').children('input').val(), 1, jq.cookie('bp-' + object + '-extras') );
     677            var template = null;
     678
     679            // The Group Members page specifies its own template
     680            if ( 'members' == object && 'groups' == css_id[1] ) {
     681                object = 'group_members';
     682                template = 'groups/single/members';
     683            }
     684
     685            bp_filter_request( object, jq.cookie('bp-' + object + '-filter'), jq.cookie('bp-' + object + '-scope') , 'div.' + object, target.parent().children('label').children('input').val(), 1, jq.cookie('bp-' + object + '-extras'), null, template );
    679686
    680687            return false;
     
    720727        var filter = jq(this).val();
    721728        var search_terms = false;
     729        var template = null;
    722730
    723731        if ( jq('.dir-search input').length )
    724732            search_terms = jq('.dir-search input').val();
    725733
     734        // The Group Members page has a different selector for its
     735        // search terms box
     736        var $gm_search = jq( '.groups-members-search input' );
     737        if ( $gm_search.length ) {
     738            search_terms = $gm_search.val();
     739        }
     740
     741        // On the Groups Members page, we specify a template
     742        if ( 'members' == object && 'groups' == scope ) {
     743            object = 'group_members';
     744            template = 'groups/single/members';
     745        }
     746
    726747        if ( 'friends' == object )
    727748            object = 'members';
    728749
    729         bp_filter_request( object, filter, scope, 'div.' + object, search_terms, 1, jq.cookie('bp-' + object + '-extras') );
     750        bp_filter_request( object, filter, scope, 'div.' + object, search_terms, 1, jq.cookie('bp-' + object + '-extras'), null, template );
    730751
    731752        return false;
     
    752773            var search_terms = false;
    753774            var pagination_id = jq(target).closest('.pagination-links').attr('id');
     775            var template = null;
    754776
    755777            var page_number = target.attr('href').split( '=' );
    756778            page_number = page_number[1];
    757779
     780            // Search terms
    758781            if ( jq('div.dir-search input').length )
    759782                search_terms = jq('.dir-search input').val();
     783   
     784            // The Group Members page has a different selector for
     785            // its search terms box
     786            var $gm_search = jq( '.groups-members-search input' );
     787            if ( $gm_search.length ) {
     788                search_terms = $gm_search.val();
     789            }
     790
     791            // On the Groups Members page, we specify a template
     792            if ( 'members' == object && 'groups' == css_id[1] ) {
     793                object = 'group_members';
     794                template = 'groups/single/members';
     795            }
    760796
    761797            if ( pagination_id.indexOf( 'pag-bottom' ) !== -1 ) {
     
    765801            }
    766802
    767             bp_filter_request( object, jq.cookie('bp-' + object + '-filter'), jq.cookie('bp-' + object + '-scope'), 'div.' + object, search_terms, page_number, jq.cookie('bp-' + object + '-extras'), caller );
     803            bp_filter_request( object, jq.cookie('bp-' + object + '-filter'), jq.cookie('bp-' + object + '-scope'), 'div.' + object, search_terms, page_number, jq.cookie('bp-' + object + '-extras'), caller, template );
    768804
    769805            return false;
     
    9641000
    9651001    /* Add / Remove friendship buttons */
    966     jq('#members-dir-list').on('click', '.friendship-button a', function() {
     1002    jq( '#members-dir-list, #members-group-list' ).on('click', '.friendship-button a', function() {
    9671003        jq(this).parent().addClass('loading');
    9681004        var fid = jq(this).attr('id');
     
    13811417
    13821418/* Filter the current content list (groups/members/blogs/topics) */
    1383 function bp_filter_request( object, filter, scope, target, search_terms, page, extras, caller ) {
     1419function bp_filter_request( object, filter, scope, target, search_terms, page, extras, caller, template ) {
    13841420    if ( 'activity' == object )
    13851421        return false;
     
    14101446    jq('.item-list-tabs select option[value="' + filter + '"]').prop( 'selected', true );
    14111447
    1412     if ( 'friends' == object )
     1448    if ( 'friends' == object || 'group_members' == object ) {
    14131449        object = 'members';
     1450    }
    14141451
    14151452    if ( bp_ajax_request )
     
    14241461        'scope': scope,
    14251462        'page': page,
    1426         'extras': extras
     1463        'extras': extras,
     1464        'template': template
    14271465    },
    14281466    function(response)
Note: See TracChangeset for help on using the changeset viewer.