Skip to:
Content

BuddyPress.org

Changeset 2622


Ignore:
Timestamp:
02/08/2010 12:33:13 PM (14 years ago)
Author:
apeatling
Message:

Fixes #1840

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups.php

    r2618 r2622  
    21742174        return false;
    21752175
     2176    /* Modify group meta */
     2177    groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') + 1 );
     2178    groups_update_groupmeta( $group_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
     2179
    21762180    do_action( 'groups_accept_invite', $user_id, $group_id );
    21772181    return true;
  • trunk/bp-groups/bp-groups-classes.php

    r2619 r2622  
    258258    /* TODO: Merge all these get_() functions into one. */
    259259
    260     function get_newest( $limit = null, $page = null, $user_id = false, $search_terms = false ) {
     260    function get_newest( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) {
    261261        global $wpdb, $bp;
    262262
     
    281281        }
    282282
    283         if ( empty( $user_id ) ) {
     283        if ( !empty( $populate_extras ) ) {
    284284            foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
    285285            $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
     
    290290    }
    291291
    292     function get_active( $limit = null, $page = null, $user_id = false, $search_terms = false ) {
     292    function get_active( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) {
    293293        global $wpdb, $bp;
    294294
     
    313313        }
    314314
    315         if ( empty( $user_id ) ) {
     315        if ( !empty( $populate_extras ) ) {
    316316            foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
    317317            $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
     
    322322    }
    323323
    324     function get_popular( $limit = null, $page = null, $user_id = false, $search_terms = false ) {
     324    function get_popular( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) {
    325325        global $wpdb, $bp;
    326326
     
    346346        }
    347347
    348         if ( empty( $user_id ) ) {
     348        if ( !empty( $populate_extras ) ) {
    349349            foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
    350350            $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
     
    355355    }
    356356
    357     function get_alphabetically( $limit = null, $page = null, $user_id = false, $search_terms = false ) {
     357    function get_alphabetically( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) {
    358358        global $wpdb, $bp;
    359359
     
    378378        }
    379379
    380         if ( empty( $user_id ) ) {
     380        if ( !empty( $populate_extras ) ) {
    381381            foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
    382382            $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
     
    387387    }
    388388
    389     function get_by_most_forum_topics( $limit = null, $page = null, $user_id = false, $search_terms = false ) {
     389    function get_by_most_forum_topics( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) {
    390390        global $wpdb, $bp, $bbdb;
    391391
     
    414414        }
    415415
    416         if ( empty( $user_id ) ) {
     416        if ( !empty( $populate_extras ) ) {
    417417            foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
    418418            $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
     
    423423    }
    424424
    425     function get_by_most_forum_posts( $limit = null, $page = null, $search_terms = false ) {
     425    function get_by_most_forum_posts( $limit = null, $page = null, $search_terms = false, $populate_extras = true ) {
    426426        global $wpdb, $bp, $bbdb;
    427427
     
    450450        }
    451451
    452         if ( empty( $user_id ) ) {
     452        if ( !empty( $populate_extras ) ) {
    453453            foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
    454454            $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
     
    503503    }
    504504
    505     function get_by_letter( $letter, $limit = null, $page = null ) {
     505    function get_by_letter( $letter, $limit = null, $page = null, $populate_extras = true ) {
    506506        global $wpdb, $bp;
    507507
     
    521521        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND g.name LIKE '$letter%%' {$hidden_sql} {$search_sql} ORDER BY g.name ASC {$pag_sql}"  ) );
    522522
    523         if ( empty( $user_id ) ) {
     523        if ( !empty( $populate_extras ) ) {
    524524            foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
    525525            $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
     
    530530    }
    531531
    532     function get_random( $limit = null, $page = null, $user_id = false, $search_terms = false ) {
     532    function get_random( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) {
    533533        global $wpdb, $bp;
    534534
     
    553553        }
    554554
    555         if ( empty( $user_id ) ) {
     555        if ( !empty( $populate_extras ) ) {
    556556            foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
    557557            $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
     
    765765        $this->inviter_id = 0;
    766766        $this->is_confirmed = 1;
    767         $this->date_modified = time();
     767        $this->date_modified = gmdate( "Y-m-d H:i:s" );
    768768    }
    769769
    770770    function accept_request() {
    771771        $this->is_confirmed = 1;
    772         $this->date_modified = time();
     772        $this->date_modified = gmdate( "Y-m-d H:i:s" );
    773773    }
    774774
  • trunk/bp-groups/bp-groups-templatetags.php

    r2580 r2622  
    2323    var $order;
    2424
    25     function bp_groups_template( $user_id, $type, $page, $per_page, $max, $slug, $search_terms ) {
     25    function bp_groups_template( $user_id, $type, $page, $per_page, $max, $slug, $search_terms, $populate_extras ) {
    2626        global $bp;
    2727
     
    3131        switch ( $type ) {
    3232            case 'active': default:
    33                 $this->groups = groups_get_active( $this->pag_num, $this->pag_page, $user_id, $search_terms );
     33                $this->groups = groups_get_active( $this->pag_num, $this->pag_page, $user_id, $search_terms, $populate_extras );
    3434                break;
    3535
    3636            case 'alphabetical': default:
    37                 $this->groups = groups_get_alphabetically( $this->pag_num, $this->pag_page, $user_id, $search_terms );
     37                $this->groups = groups_get_alphabetically( $this->pag_num, $this->pag_page, $user_id, $search_terms, $populate_extras );
    3838                break;
    3939
    4040            case 'random':
    41                 $this->groups = groups_get_random_groups( $this->pag_num, $this->pag_page, $user_id, $search_terms );
     41                $this->groups = groups_get_random_groups( $this->pag_num, $this->pag_page, $user_id, $search_terms, $populate_extras );
    4242                break;
    4343
    4444            case 'newest':
    45                 $this->groups = groups_get_newest( $this->pag_num, $this->pag_page, $user_id, $search_terms );
     45                $this->groups = groups_get_newest( $this->pag_num, $this->pag_page, $user_id, $search_terms, $populate_extras );
    4646                break;
    4747
    4848            case 'popular':
    49                 $this->groups = groups_get_popular( $this->pag_num, $this->pag_page, $user_id, $search_terms );
     49                $this->groups = groups_get_popular( $this->pag_num, $this->pag_page, $user_id, $search_terms, $populate_extras );
    5050                break;
    5151
    5252            case 'most-forum-topics':
    53                 $this->groups = groups_get_by_most_forum_topics( $this->pag_num, $this->pag_page, $user_id, $search_terms );
     53                $this->groups = groups_get_by_most_forum_topics( $this->pag_num, $this->pag_page, $user_id, $search_terms, $populate_extras );
    5454                break;
    5555
    5656            case 'most-forum-posts':
    57                 $this->groups = groups_get_by_most_forum_posts( $this->pag_num, $this->pag_page, $user_id, $search_terms );
     57                $this->groups = groups_get_by_most_forum_posts( $this->pag_num, $this->pag_page, $user_id, $search_terms, $populate_extras );
    5858                break;
     59
     60            case 'invites':
     61                $this->groups = groups_get_invites_for_user( $user_id, $this->pag_num, $this->pag_page );
     62                break;
     63
     64            case 'single-group':
     65                $group = new stdClass;
     66                $group->group_id = BP_Groups_Group::get_id_from_slug($slug);
     67                $this->groups = array( $group );
     68                break;
     69
    5970
    6071            case 'admin-of':
     
    6677                if ( $user_id )
    6778                    $this->groups = groups_get_user_is_mod_of( $user_id, $this->pag_num, $this->pag_page, $filter );
    68                 break;
    69 
    70             case 'invites':
    71                 $this->groups = groups_get_invites_for_user( $user_id, $this->pag_num, $this->pag_page );
    72                 break;
    73 
    74             case 'single-group':
    75                 $group = new stdClass;
    76                 $group->group_id = BP_Groups_Group::get_id_from_slug($slug);
    77                 $this->groups = array( $group );
    7879                break;
    7980        }
     
    215216        'user_id' => $user_id, // Pass a user ID to limit to groups this user has joined
    216217        'slug' => $slug, // Pass a group slug to only return that group
    217         'search_terms' => $search_terms // Pass search terms to return only matching groups
     218        'search_terms' => $search_terms, // Pass search terms to return only matching groups
     219
     220        'populate_extras' => true // Get extra meta - is_member, is_banned
    218221    );
    219222
     
    221224    extract( $r );
    222225
    223     $groups_template = new BP_Groups_Template( $user_id, $type, $page, $per_page, $max, $slug, $search_terms );
     226    $groups_template = new BP_Groups_Template( (int)$user_id, $type, (int)$page, (int)$per_page, (int)$max, $slug, $search_terms, (int)$populate_extras );
    224227    return apply_filters( 'bp_has_groups', $groups_template->has_groups(), &$groups_template );
    225228}
     
    11351138        return false;
    11361139
     1140    if ( 'hidden' == $group->status && !$group->is_member )
     1141        return false;
     1142
    11371143    echo '<div class="generic-button group-button ' . $group->status . '" id="groupbutton-' . $group->id . '">';
    11381144
     
    11541160                    echo '<a class="membership-requested" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>';
    11551161            }
     1162        break;
     1163
     1164        case 'hidden':
     1165            if ( $group->is_member )
     1166                echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
    11561167        break;
    11571168    }
  • trunk/bp-themes/bp-default/activity/post-form.php

    r2552 r2622  
    4141                        <option selected="selected" value="0"><?php _e( 'My Profile', 'buddypress' ) ?></option>
    4242
    43                         <?php if ( bp_has_groups( 'user_id=' . bp_loggedin_user_id() . '&type=alphabetical&max=100&per_page=100' ) ) : while ( bp_groups() ) : bp_the_group(); ?>
     43                        <?php if ( bp_has_groups( 'user_id=' . bp_loggedin_user_id() . '&type=alphabetical&max=100&per_page=100&populate_extras=0' ) ) : while ( bp_groups() ) : bp_the_group(); ?>
    4444                            <option value="<?php bp_group_id() ?>"><?php bp_group_name() ?></option>
    4545                        <?php endwhile; endif; ?>
Note: See TracChangeset for help on using the changeset viewer.