Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/09/2008 04:37:49 AM (17 years ago)
Author:
apeatling
Message:
  • Moved all group pages to the root, rather than using a member URL
  • Introduced groupmeta support - groups_update_groupmeta / groups_delete_groupmeta / groups_get_groupmeta
  • Added widgets for site wide activity and who's online
  • Updated home theme to support display of new BuddyPress widgets
  • Added site wide activity feed support
  • Fixed bug where ajax functions would only work when logged in
  • Various other bug fixes
File:
1 edited

Legend:

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

    r373 r375  
    5656            $this->enable_photos = $group->enable_photos;
    5757            $this->photos_admin_only = $group->photos_admin_only;
    58             $this->date_created = $group->date_created;
     58            $this->date_created = strtotime($group->date_created);
     59            $this->total_member_count = groups_get_groupmeta( $this->id, 'total_member_count' );
    5960           
    6061            if ( !$group->avatar_thumb )
     
    7071            if ( $get_user_dataset ) {
    7172                $this->user_dataset = $this->get_user_dataset();
    72                 $this->total_member_count = count( $this->user_dataset );
     73               
     74                if ( !$this->total_member_count ) {
     75                    $this->total_member_count = count( $this->user_dataset );
     76                    groups_update_groupmeta( $this->id, 'total_member_count', $this->total_member_count );
     77                }
    7378            }
    7479        }   
     
    159164            );
    160165        }
    161 
     166       
    162167        $result = $wpdb->query($sql);
    163168       
     
    221226            return false;
    222227       
     228        /* Remove groupmeta */
     229        groups_delete_groupmeta( $group_id );
     230       
    223231        return true;
    224232    }
    225233   
    226     function group_exists( $slug ) {
    227         global $wpdb, $bp;
    228         return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM " . $bp['groups']['table_name'] . " WHERE slug = %s", $slug ) );
     234    function group_exists( $slug, $table_name = false ) {
     235        global $wpdb, $bp;
     236       
     237        if ( !$table_name )
     238            $table_name = $bp['groups']['table_name'];
     239           
     240        return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $table_name WHERE slug = %s", $slug ) );
    229241    }
    230242
     
    313325            $limit = 5;
    314326
    315         return $wpdb->get_results( $wpdb->prepare( "SELECT id FROM " . $bp['groups']['table_name'] . " ORDER BY date_created DESC LIMIT %d", $limit ) );
     327        return $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM " . $bp['groups']['table_name'] . " ORDER BY date_created DESC LIMIT %d", $limit ) );
     328    }
     329   
     330    function get_active( $limit = 5 ) {
     331        global $wpdb, $bp;
     332       
     333        if ( !$limit )
     334            $limit = 5;
     335
     336        return $wpdb->get_results( $wpdb->prepare( "SELECT group_id FROM " . $bp['groups']['table_name_groupmeta'] . " WHERE meta_key = 'last_activity' ORDER BY meta_value DESC LIMIT %d", $limit ) );
     337    }
     338   
     339    function get_popular( $limit = 5 ) {
     340        global $wpdb, $bp;
     341       
     342        if ( !$limit )
     343            $limit = 5;
     344
     345        return $wpdb->get_results( $wpdb->prepare( "SELECT group_id FROM " . $bp['groups']['table_name_groupmeta'] . " WHERE meta_key = 'total_member_count' ORDER BY meta_value DESC LIMIT %d", $limit ) );
    316346    }
    317347}
Note: See TracChangeset for help on using the changeset viewer.