Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/28/2014 11:24:06 PM (12 years ago)
Author:
johnjamesjacoby
Message:

Backwards compatibility for querying single groups via the slug argument. Props r-a-y. Fixes #5596. (trunk)

File:
1 edited

Legend:

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

    r8244 r8329  
    160160                        $this->groups = groups_get_invites_for_user( $user_id, $this->pag_num, $this->pag_page, $exclude );
    161161                } else if ( 'single-group' == $type ) {
    162                         $group           = new stdClass;
    163                         $group->group_id = bp_get_current_group_id();
    164                         $this->groups    = array( $group );
     162                        $this->single_group = true;
     163
     164                        if ( groups_get_current_group() ) {
     165                                $group = groups_get_current_group();
     166
     167                        } else {
     168                                $group = groups_get_group( array(
     169                                        'group_id'        => BP_Groups_Group::get_id_from_slug( $r['slug'] ),
     170                                        'populate_extras' => $r['populate_extras'],
     171                                ) );
     172                        }
     173
     174                        // backwards compatibility - the 'group_id' variable is not part of the
     175                        // BP_Groups_Group object, but we add it here for devs doing checks against it
     176                        //
     177                        // @see https://buddypress.trac.wordpress.org/changeset/3540
     178                        //
     179                        // this is subject to removal in a future release; devs should check against
     180                        // $group->id instead
     181                        $group->group_id = $group->id;
     182
     183                        $this->groups = array( $group );
     184
    165185                } else {
    166186                        $this->groups = groups_get_groups( array(
     
    186206                        $this->groups            = $this->groups['groups'];
    187207                } else if ( 'single-group' == $type ) {
    188                         $this->single_group      = true;
    189                         $this->total_group_count = 1;
    190                         $this->group_count       = 1;
     208                        if ( empty( $group->id ) ) {
     209                                $this->total_group_count = 0;
     210                                $this->group_count       = 0;
     211                        } else {
     212                                $this->total_group_count = 1;
     213                                $this->group_count       = 1;
     214                        }
    191215                } else {
    192216                        if ( empty( $max ) || $max >= (int) $this->groups['total'] ) {
     
    260284                $this->in_the_loop = true;
    261285                $this->group       = $this->next_group();
    262 
    263                 if ( $this->single_group )
    264                         $this->group = groups_get_current_group();
    265286
    266287                if ( 0 == $this->current_group ) // loop has just started
Note: See TracChangeset for help on using the changeset viewer.