Skip to:
Content

BuddyPress.org

Changeset 8168


Ignore:
Timestamp:
03/26/2014 11:35:32 PM (13 years ago)
Author:
r-a-y
Message:

Groups: Add backward compatibility when fetching list of admins/mods.

In r8056, the change was made so a group does not fetch its extra data
like grabbing the list of group admins and mods by default.

However, if a group template loop was created with the 'populate_extras'
parameter set to false and either the bp_group_list_admins() and
bp_group_list_mods() functions were used in the loop, these functions
would not output the correct list.

To solve this, this commit manually fetches the group admins / mods if
the 'populate_extras' flag in the group template loop is set to false.

Fixes #5411

Location:
trunk/bp-groups
Files:
2 edited

Legend:

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

    r8157 r8168  
    152152         * @var array
    153153         */
    154         protected $args;
     154        public $args;
    155155
    156156        /**
  • trunk/bp-groups/bp-groups-template.php

    r8150 r8168  
    777777        global $groups_template;
    778778
    779         if ( empty( $group ) )
     779        if ( empty( $group ) ) {
    780780                $group =& $groups_template->group;
    781 
    782         if ( !empty( $group->admins ) ) { ?>
     781        }
     782
     783        // fetch group admins if 'populate_extras' flag is false
     784        if ( empty( $group->args['populate_extras'] ) ) {
     785                $query = new BP_Group_Member_Query( array(
     786                        'group_id'   => $group->id,
     787                        'group_role' => 'admin',
     788                        'type'       => 'first_joined',
     789                ) );
     790
     791                if ( ! empty( $query->results ) ) {
     792                        $group->admins = $query->results;
     793                }
     794        }
     795
     796        if ( ! empty( $group->admins ) ) { ?>
    783797                <ul id="group-admins">
    784798                        <?php foreach( (array) $group->admins as $admin ) { ?>
    … …  
    797811        global $groups_template;
    798812
    799         if ( empty( $group ) )
     813        if ( empty( $group ) ) {
    800814                $group =& $groups_template->group;
    801 
    802         if ( !empty( $group->mods ) ) : ?>
     815        }
     816
     817        // fetch group mods if 'populate_extras' flag is false
     818        if ( empty( $group->args['populate_extras'] ) ) {
     819                $query = new BP_Group_Member_Query( array(
     820                        'group_id'   => $group->id,
     821                        'group_role' => 'mod',
     822                        'type'       => 'first_joined',
     823                ) );
     824
     825                if ( ! empty( $query->results ) ) {
     826                        $group->mods = $query->results;
     827                }
     828        }
     829
     830        if ( ! empty( $group->mods ) ) : ?>
    803831
    804832                <ul id="group-mods">
Note: See TracChangeset for help on using the changeset viewer.