Skip to:
Content

BuddyPress.org

Ticket #3430: 3430.patch

File 3430.patch, 2.5 KB (added by imath, 11 years ago)
  • src/bp-groups/bp-groups-classes.php

    diff --git src/bp-groups/bp-groups-classes.php src/bp-groups/bp-groups-classes.php
    index c036b62..5bfd2f5 100644
    class BP_Group_Member_Query extends BP_User_Query { 
    17021702         * @param BP_User_Query $query BP_User_Query object.
    17031703         */
    17041704        public function set_orderby( $query ) {
     1705                global $wpdb;
     1706
    17051707                $gm_ids = $this->get_group_member_ids();
    17061708                if ( empty( $gm_ids ) ) {
    17071709                        $gm_ids = array( 0 );
    class BP_Group_Member_Query extends BP_User_Query { 
    17111713                // the order according to the query performed in
    17121714                // BP_Group_Member_Query::get_group_members(). Otherwise, fall
    17131715                // through and let BP_User_Query do its own ordering.
    1714                 if ( in_array( $query->query_vars['type'], array( 'last_joined', 'first_joined' ) ) ) {
     1716                if ( in_array( $query->query_vars['type'], array( 'last_joined', 'first_joined', 'group_activity' ) ) ) {
     1717
     1718                        // Group Activity DESC
     1719                        if ( 'group_activity' == $query->query_vars['type'] ) {
     1720                                $activity_table = buddypress()->activity->table_name;
     1721                                $group_activity_where = array(
     1722                                        'user_id IN (' . implode( ',', $gm_ids ) . ')',
     1723                                        'item_id = ' . absint( $query->query_vars['group_id'] ),
     1724                                        "component = 'groups'",
     1725                                );
     1726                                $group_activity_where  = implode( ' AND ', $group_activity_where );
     1727                                $group_user_ids = $wpdb->get_results( "SELECT user_id, max( date_recorded ) as date_recorded FROM {$activity_table} WHERE {$group_activity_where} GROUP BY user_id ORDER BY date_recorded DESC" );
     1728                                $gm_ids = wp_list_pluck( $group_user_ids, 'user_id' );
     1729                        }
    17151730
    17161731                        // The first param in the FIELD() clause is the sort column id
    17171732                        $gm_ids = array_merge( array( 'u.id' ), wp_parse_id_list( $gm_ids ) );
  • src/bp-groups/bp-groups-template.php

    diff --git src/bp-groups/bp-groups-template.php src/bp-groups/bp-groups-template.php
    index bca272a..d7b752f 100644
    function bp_groups_members_filter() { 
    24372437                <select id="group_members-order-by">
    24382438                        <option value="last_joined"><?php _e( 'Newest', 'buddypress' ); ?></option>
    24392439                        <option value="first_joined"><?php _e( 'Oldest', 'buddypress' ); ?></option>
     2440
     2441                        <?php if ( bp_is_active( 'activity' ) ) : ?>
     2442                                <option value="group_activity"><?php _e( 'Group Activity', 'buddypress' ); ?></option>
     2443                        <?php endif; ?>
     2444
    24402445                        <option value="alphabetical"><?php _e( 'Alphabetical', 'buddypress' ); ?></option>
    24412446
    24422447                        <?php do_action( 'bp_groups_members_order_options' ); ?>