Skip to:
Content

BuddyPress.org

Changeset 1929


Ignore:
Timestamp:
09/23/2009 01:18:49 AM (16 years ago)
Author:
apeatling
Message:

Added ability to loop groups alphabetically by using 'type=alphabetical' in the site groups loop. Fixes #764

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups.php

    r1922 r1929  
    18651865}
    18661866
     1867function groups_get_alphabetically( $limit = null, $page = 1 ) {
     1868    return BP_Groups_Group::get_alphabetically( $limit, $page );   
     1869}
     1870
    18671871function groups_get_by_most_forum_topics( $limit = null, $page = 1 ) {
    18681872    return BP_Groups_Group::get_by_most_forum_topics( $limit, $page );
  • trunk/bp-groups/bp-groups-classes.php

    r1924 r1929  
    377377    }
    378378   
     379    function get_alphabetically( $limit = null, $page = null ) {
     380        global $wpdb, $bp;
     381               
     382        if ( $limit && $page )
     383            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     384       
     385        if ( !is_site_admin() )
     386            $hidden_sql = "WHERE status != 'hidden'";
     387       
     388        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} {$hidden_sql} ORDER BY name ASC {$pag_sql}" ) );
     389        $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name} {$hidden_sql} ORDER BY name ASC", $limit ) );
     390
     391        return array( 'groups' => $paged_groups, 'total' => $total_groups );
     392    }
     393   
    379394    function get_by_most_forum_topics( $limit = null, $page = null ) {
    380395        global $wpdb, $bp, $bbdb;
  • trunk/bp-groups/bp-groups-templatetags.php

    r1922 r1929  
    18201820                    $this->groups = groups_get_active( $this->pag_num, $this->pag_page );
    18211821                    break; 
     1822
     1823                case 'alphabetical': default:
     1824                    $this->groups = groups_get_alphabetically( $this->pag_num, $this->pag_page );
     1825                    break; 
    18221826               
    18231827                case 'random':     
Note: See TracChangeset for help on using the changeset viewer.