Skip to:
Content

BuddyPress.org


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

Introduces 'order' and 'orderby' parameters for the bp_has_groups() stack

'order' and 'orderby' are more specific and flexible versions of the existing
'type' parameter ('popular', 'newest', etc). Backward compatibility is
maintained by always obeying 'type' when it is passed, and by internally
converting the legacy 'type' values into the corresponding 'order' and
'orderby' values.

Adds unit tests to ensure that the adjusted default values for functions in
the stack are backward compatibile (in particular, the fact that the 'type'
parameter is now empty by default, replaced with the corresponding default
values for 'order' and 'orderby'). Unit tests are also added for the new
params, as well as some internal utility methods.

See #4483

File:
1 edited

Legend:

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

    r6951 r7087  
    167167            $this->groups = groups_get_groups( array(
    168168                'type'            => $type,
     169                'order'           => $order,
     170                'orderby'         => $orderby,
    169171                'per_page'        => $this->pag_num,
    170172                'page'            => $this->pag_page,
     
    267269}
    268270
     271/**
     272 * Start the Groups Template Loop
     273 *
     274 * See the $defaults definition below for a description of parameters.
     275 *
     276 * Note that the 'type' parameter overrides 'order' and 'orderby'. See
     277 * BP_Groups_Group::get() for more details.
     278 *
     279 * @param array $args
     280 * @return bool True if there are groups to display that match the params
     281 */
    269282function bp_has_groups( $args = '' ) {
    270283    global $groups_template, $bp;
     
    276289     */
    277290    $slug    = false;
    278     $type    = 'active';
     291    $type    = '';
    279292    $user_id = 0;
    280293    $order   = '';
     
    285298
    286299    // Type
     300    // @todo What is $order? At some point it was removed incompletely?
    287301    if ( bp_is_current_action( 'my-groups' ) ) {
    288302        if ( 'most-popular' == $order ) {
     
    299313
    300314    $defaults = array(
    301         'type'            => $type,
     315        'type'            => $type, // 'type' is an override for 'order' and 'orderby'. See docblock.
     316        'order'           => 'DESC',
     317        'orderby'         => 'last_activity',
    302318        'page'            => 1,
    303319        'per_page'        => 20,
     
    314330        'exclude'         => false,    // Pass comma separated list or array of group ID's to exclude these groups
    315331
    316         'populate_extras' => true      // Get extra meta - is_member, is_banned
     332        'populate_extras' => true,     // Get extra meta - is_member, is_banned
    317333    );
    318334
     
    330346    $groups_template = new BP_Groups_Template( array(
    331347        'type'            => $r['type'],
     348        'order'           => $r['order'],
     349        'orderby'         => $r['orderby'],
    332350        'page'            => (int) $r['page'],
    333351        'per_page'        => (int) $r['per_page'],
Note: See TracChangeset for help on using the changeset viewer.