Skip to:
Content

BuddyPress.org

Changeset 1922


Ignore:
Timestamp:
09/22/2009 10:19:03 PM (15 years ago)
Author:
apeatling
Message:

Updating select groups by forum activity SQL and adding a get groups by most forum posts function.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups.php

    r1921 r1922  
    18691869}
    18701870
     1871function groups_get_by_most_forum_posts( $limit = null, $page = 1 ) {
     1872    return BP_Groups_Group::get_by_most_forum_posts( $limit, $page );
     1873}
     1874
    18711875function groups_get_user_groups( $user_id = false, $pag_num = false, $pag_page = false ) {
    18721876    global $bp;
  • trunk/bp-groups/bp-groups-classes.php

    r1921 r1922  
    374374        }
    375375           
    376         $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT gm.group_id FROM {$bbdb->topics} AS t, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = t.forum_id) AND g.status = 'public' AND t.topic_status = '0' AND t.topic_sticky = '0' GROUP BY t.forum_id ORDER BY COUNT(t.topic_posts) DESC {$pag_sql}" ) );
    377         $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT COUNT(gm.group_id) FROM {$bbdb->topics} AS t, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = t.forum_id) AND g.status = 'public' AND t.topic_status = '0' AND t.topic_sticky = '0' GROUP BY t.forum_id ORDER BY COUNT(t.topic_posts) DESC" ) );
     376        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT gm.group_id FROM {$bbdb->forums} AS f, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND g.status = 'public' ORDER BY f.topics DESC {$pag_sql}" ) );
     377        $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT COUNT(gm.group_id) FROM {$bbdb->forums} AS f, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND g.status = 'public' ORDER BY f.topics DESC" ) );
    378378
    379379        return array( 'groups' => $paged_groups, 'total' => $total_groups );       
    380380    }
     381
     382    function get_by_most_forum_posts( $limit = null, $page = null ) {
     383        global $wpdb, $bp, $bbdb;
     384       
     385        if ( $limit && $page ) {
     386            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     387        }
     388           
     389        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT gm.group_id FROM {$bbdb->forums} AS f, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND g.status = 'public' ORDER BY f.posts DESC {$pag_sql}" ) );
     390        $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT COUNT(gm.group_id) FROM {$bbdb->forums} AS f, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND g.status = 'public' ORDER BY f.posts DESC" ) );
     391
     392        return array( 'groups' => $paged_groups, 'total' => $total_groups );       
     393    }
     394
    381395   
    382396    function get_all( $limit = null, $page = null, $only_public = true, $sort_by = false, $order = false ) {
  • trunk/bp-groups/bp-groups-templatetags.php

    r1921 r1922  
    18361836                    $this->groups = groups_get_by_most_forum_topics( $this->pag_num, $this->pag_page );
    18371837                    break;
     1838               
     1839                case 'most-forum-posts':
     1840                    $this->groups = groups_get_by_most_forum_posts( $this->pag_num, $this->pag_page );
     1841                    break;
    18381842            }
    18391843        }
Note: See TracChangeset for help on using the changeset viewer.