Skip to:
Content

BuddyPress.org

Changeset 7088


Ignore:
Timestamp:
05/19/2013 12:26:47 AM (12 years ago)
Author:
boonebgorges
Message:

Add sortable column support for the Groups Administration Dashboard panel

The columns have been marked sortable since they were originall introduced, but
the sorting did not work because of limitations in how bp_has_groups() worked.
As of r7087, bp_has_groups() supports 'order' and 'orderby' params, which
allows us to fix this broken feature.

Fixes #4483

File:
1 edited

Legend:

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

    r7006 r7088  
    983983        $per_page = $this->get_items_per_page( str_replace( '-', '_', "{$screen->id}_per_page" ) );
    984984
    985         // Sort order. Note: not supported in bp_has_groups()
    986         $order = 'ASC';
     985        // Sort order.
     986        $order = 'DESC';
    987987        if ( !empty( $_REQUEST['order'] ) ) {
    988988            $order = ( 'desc' == strtolower( $_REQUEST['order'] ) ) ? 'DESC' : 'ASC';
     
    990990
    991991        // Order by - default to newest
    992         $type = 'newest';
    993         if ( !empty( $_REQUEST['orderby'] ) ) {
     992        $orderby = 'last_activity';
     993        if ( ! empty( $_REQUEST['orderby'] ) ) {
    994994            switch ( $_REQUEST['orderby'] ) {
    995995                case 'name' :
    996                     $type = 'alphabetical';
     996                    $orderby = 'name';
    997997                    break;
    998998                case 'id' :
    999                     $type = 'newest';
     999                    $orderby = 'date_created';
    10001000                    break;
    10011001                case 'members' :
    1002                     $type = 'popular';
     1002                    $orderby = 'total_member_count';
     1003                    break;
     1004                case 'last_active' :
     1005                    $orderby = 'last_activity';
    10031006                    break;
    10041007            }
     
    10411044                'per_page' => $per_page,
    10421045                'page'     => $page,
    1043                 'type'     => $type,
     1046                'orderby'  => $orderby,
    10441047                'order'    => $order
    10451048            );
     
    11931196     * Get the column names for sortable columns
    11941197     *
     1198     * Note: It's not documented in WP, but the second item in the
     1199     * nested arrays below is $desc_first. Normally, we would set
     1200     * last_active to be desc_first (since you're generally interested in
     1201     * the *most* recently active group, not the *least*). But because
     1202     * the default sort for the Groups admin screen is DESC by last_active,
     1203     * we want the first click on the Last Active column header to switch
     1204     * the sort order - ie, to make it ASC. Thus last_active is set to
     1205     * $desc_first = false.
     1206     *
    11951207     * @return array
    11961208     * @since BuddyPress (1.7)
     
    11981210    function get_sortable_columns() {
    11991211        return array(
    1200             'gid'         => array( 'gid',         false ),
    1201             'comment'     => array( 'name',        false ),
    1202             'members'     => array( 'members',     false ),
    1203             'last_active' => array( 'last_active', false )
     1212            'gid'         => array( 'gid', false ),
     1213            'comment'     => array( 'name', false ),
     1214            'members'     => array( 'members', false ),
     1215            'last_active' => array( 'last_active', false ),
    12041216        );
    12051217    }
Note: See TracChangeset for help on using the changeset viewer.