Skip to:
Content

BuddyPress.org

Changeset 2537


Ignore:
Timestamp:
02/02/2010 04:53:40 PM (14 years ago)
Author:
apeatling
Message:

Tweaking single group pages and group class.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups.php

    r2493 r2537  
    298298
    299299            /* Record this in activity streams */
    300             $group = new BP_Groups_Group( $group_id, false, false );
     300            $group = new BP_Groups_Group( $group_id );
    301301
    302302            groups_record_activity( array(
     
    10801080    if ( isset( $_COOKIE['bp_new_group_id'] ) ) {
    10811081        $bp->groups->new_group_id = $_COOKIE['bp_new_group_id'];
    1082         $bp->groups->current_group = new BP_Groups_Group( $bp->groups->new_group_id, false, false );
     1082        $bp->groups->current_group = new BP_Groups_Group( $bp->groups->new_group_id );
    10831083    }
    10841084
     
    13581358            $requesting_user_id = $item_id;
    13591359
    1360             $group = new BP_Groups_Group( $group_id, false, false );
     1360            $group = new BP_Groups_Group( $group_id );
    13611361
    13621362            $group_link = bp_get_group_permalink( $group );
     
    13731373            $group_id = $item_id;
    13741374
    1375             $group = new BP_Groups_Group( $group_id, false, false );
     1375            $group = new BP_Groups_Group( $group_id );
    13761376            $group_link = bp_get_group_permalink( $group );
    13771377
     
    13861386            $group_id = $item_id;
    13871387
    1388             $group = new BP_Groups_Group( $group_id, false, false );
     1388            $group = new BP_Groups_Group( $group_id );
    13891389            $group_link = bp_get_group_permalink( $group );
    13901390
     
    14001400            $group_id = $item_id;
    14011401
    1402             $group = new BP_Groups_Group( $group_id, false, false );
     1402            $group = new BP_Groups_Group( $group_id );
    14031403            $group_link = bp_get_group_permalink( $group );
    14041404
     
    14131413            $group_id = $item_id;
    14141414
    1415             $group = new BP_Groups_Group( $group_id, false, false );
     1415            $group = new BP_Groups_Group( $group_id );
    14161416            $group_link = bp_get_group_permalink( $group );
    14171417
     
    14261426            $group_id = $item_id;
    14271427
    1428             $group = new BP_Groups_Group( $group_id, false, false );
     1428            $group = new BP_Groups_Group( $group_id );
    14291429            $user_url = bp_core_get_user_domain( $user_id );
    14301430
     
    15421542        return false;
    15431543
    1544     $group = new BP_Groups_Group( $group_id, false, false );
     1544    $group = new BP_Groups_Group( $group_id );
    15451545    $group->name = $group_name;
    15461546    $group->description = $group_desc;
     
    15621562    global $bp;
    15631563
    1564     $group = new BP_Groups_Group( $group_id, false, false );
     1564    $group = new BP_Groups_Group( $group_id );
    15651565    $group->enable_forum = $enable_forum;
    15661566    $group->enable_photos = $enable_photos;
     
    16481648
    16491649function groups_get_slug( $group_id ) {
    1650     $group = new BP_Groups_Group( $group_id, false, false );
     1650    $group = new BP_Groups_Group( $group_id );
    16511651    return $group->slug;
    16521652}
     
    16911691
    16921692    if ( !$bp->groups->current_group )
    1693         $bp->groups->current_group = new BP_Groups_Group( $group_id, false, false );
     1693        $bp->groups->current_group = new BP_Groups_Group( $group_id );
    16941694
    16951695    $new_member = new BP_Groups_Member;
     
    22272227    // Send friend invites.
    22282228    $invited_users = groups_get_invites_for_group( $user_id, $group_id );
    2229     $group = new BP_Groups_Group( $group_id, false, false );
     2229    $group = new BP_Groups_Group( $group_id );
    22302230
    22312231    for ( $i = 0; $i < count( $invited_users ); $i++ ) {
     
    23632363
    23642364    /* Record this in activity streams */
    2365     $group = new BP_Groups_Group( $group_id, false, false );
     2365    $group = new BP_Groups_Group( $group_id );
    23662366
    23672367    groups_record_activity( array(
  • trunk/bp-groups/bp-groups-classes.php

    r2534 r2537  
    1111    var $date_created;
    1212
    13     var $user_dataset;
    14 
    1513    var $admins;
    1614    var $total_member_count;
    17     var $random_members;
    18 
    19     function bp_groups_group( $id = null, $single = false, $get_user_dataset = true ) {
     15
     16    function bp_groups_group( $id = null ) {
    2017        if ( $id ) {
    2118            $this->id = $id;
    22             $this->populate( $get_user_dataset );
    23         }
    24 
    25         if ( $single ) {
    26             $this->populate_meta();
    27         }
    28     }
    29 
    30     function populate( $get_user_dataset ) {
    31         global $wpdb, $bp;
    32 
    33         $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} WHERE id = %d", $this->id );
    34         $group = $wpdb->get_row($sql);
    35 
    36         if ( $group ) {
     19            $this->populate();
     20        }
     21    }
     22
     23    function populate() {
     24        global $wpdb, $bp;
     25
     26        if ( $group = $wpdb->get_row( $wpdb->prepare( "SELECT g.*, gm.meta_value as last_activity, gm2.meta_value as total_member_count FROM {$bp->groups->table_name} g, {$bp->groups->table_name_groupmeta} gm, {$bp->groups->table_name_groupmeta} gm2 WHERE g.id = gm.group_id AND g.id = gm2.group_id AND gm.meta_key = 'last_activity' AND gm2.meta_key = 'total_member_count' AND g.id = %d", $this->id ) ) ) {
    3727            $this->id = $group->id;
    3828            $this->creator_id = $group->creator_id;
     
    4333            $this->enable_forum = $group->enable_forum;
    4434            $this->date_created = $group->date_created;
    45             $this->total_member_count = groups_get_groupmeta( $this->id, 'total_member_count' );
    46 
    47             if ( $get_user_dataset ) {
    48                 $this->user_dataset = $this->get_user_dataset();
    49 
    50                 $this->total_member_count = count( $this->user_dataset );
    51                 groups_update_groupmeta( $this->id, 'total_member_count', $this->total_member_count );
     35            $this->last_activity = $group->last_activity;
     36            $this->total_member_count = $group->total_member_count;
     37            $this->is_member = BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $this->id );
     38
     39            /* Get group admins and mods */
     40            $admin_mods = $wpdb->get_results( $wpdb->prepare( "SELECT u.ID as user_id, u.user_login, u.user_email, u.user_nicename, m.is_admin, m.is_mod FROM {$wpdb->users} u, {$bp->groups->table_name_members} m WHERE u.ID = m.user_id AND m.group_id = %d AND ( m.is_admin = 1 OR m.is_mod = 1 )", $this->id ) );
     41            foreach( (array)$admin_mods as $user ) {
     42                if ( (int)$user->is_admin )
     43                    $this->admins[] = $user;
     44                else
     45                    $this->mods[] = $user;
    5246            }
    53 
    54             /* Get group extras */
    55             $this->is_member = BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $this->id );
    56         }
    57     }
    58 
    59     function populate_meta() {
    60         if ( $this->id ) {
    61             $this->admins = $this->get_administrators();
    62             $this->random_members = $this->get_random_members();
    6347        }
    6448    }
     
    134118    }
    135119
    136     function get_user_dataset() {
    137         global $wpdb, $bp;
    138 
    139         return $wpdb->get_results( $wpdb->prepare( "SELECT user_id, is_admin, inviter_id, user_title, is_mod FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 AND is_banned = 0 ORDER BY rand()", $this->id ) );
    140     }
    141 
    142     function get_administrators() {
    143         for ( $i = 0; $i < count($this->user_dataset); $i++ ) {
    144             if ( $this->user_dataset[$i]->is_admin )
    145                 $admins[] = new BP_Groups_Member( $this->user_dataset[$i]->user_id, $this->id );
    146         }
    147 
    148         return $admins;
    149     }
    150 
    151     function get_random_members() {
    152         $total_randoms = ( $this->total_member_count > 5 ) ? 5 : $this->total_member_count;
    153 
    154         for ( $i = 0; $i < $total_randoms; $i++ ) {
    155             if ( !(int)$this->user_dataset[$i]->is_banned )
    156                 $users[] = new BP_Groups_Member( $this->user_dataset[$i]->user_id, $this->id );
    157         }
    158         return $users;
    159     }
    160 
    161     function is_member() {
    162         global $bp;
    163 
    164         for ( $i = 0; $i < count($this->user_dataset); $i++ ) {
    165             if ( $this->user_dataset[$i]->user_id == $bp->loggedin_user->id ) {
    166                 return true;
    167             }
    168         }
    169 
    170         return false;
    171     }
    172 
    173120    function delete() {
    174121        global $wpdb, $bp;
  • trunk/bp-groups/bp-groups-notifications.php

    r2532 r2537  
    44    global $bp;
    55
    6     $group = new BP_Groups_Group( $group_id, false, true );
     6    $group = new BP_Groups_Group( $group_id );
    77    $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . __( 'Group Details Updated', 'buddypress' );
    88
     
    4444
    4545    $requesting_user_name = bp_core_get_user_displayname( $requesting_user_id );
    46     $group = new BP_Groups_Group( $group_id, false, false );
     46    $group = new BP_Groups_Group( $group_id );
    4747
    4848    $ud = bp_core_get_core_userdata($admin_id);
     
    8888        return false;
    8989
    90     $group = new BP_Groups_Group( $group_id, false, false );
     90    $group = new BP_Groups_Group( $group_id );
    9191
    9292    $ud = bp_core_get_core_userdata($requesting_user_id);
     
    142142        return false;
    143143
    144     $group = new BP_Groups_Group( $group_id, false, false );
     144    $group = new BP_Groups_Group( $group_id );
    145145    $ud = bp_core_get_core_userdata($user_id);
    146146
     
    227227        return false;
    228228
    229     $group = new BP_Groups_Group( $group_id, false, false );
     229    $group = new BP_Groups_Group( $group_id );
    230230
    231231    foreach( (array)$usernames as $username ) {
  • trunk/bp-groups/bp-groups-templatetags.php

    r2533 r2537  
    157157
    158158        if ( $this->single_group )
    159             $this->group = new BP_Groups_Group( $this->group->group_id, true, true );
     159            $this->group = new BP_Groups_Group( $this->group->group_id, true );
    160160        else {
    161161            if ( $this->group )
     
    532532}
    533533
    534 function bp_group_list_admins( $full_list = true, $group = false ) {
     534function bp_group_list_admins( $deprecated = true, $group = false ) {
    535535    global $groups_template;
    536536
     
    538538        $group =& $groups_template->group;
    539539
    540     if ( !$admins = &$group->admins )
    541         $admins = $group->get_administrators();
    542 
    543     if ( $admins ) {
    544         if ( $full_list ) { ?>
    545             <ul id="group-admins">
    546             <?php for ( $i = 0; $i < count($admins); $i++ ) { ?>
     540    if ( $group->admins ) { ?>
     541        <ul id="group-admins">
     542            <?php foreach( (array)$group->admins as $admin ) { ?>
    547543                <li>
    548                     <a href="<?php echo $admins[$i]->user->user_url ?>" title="<?php echo $admins[$i]->user->fullname ?>"><?php echo $admins[$i]->user->avatar_mini ?></a>
    549                     <h5><?php echo $admins[$i]->user->user_link ?></h5>
    550                     <span class="activity"><?php echo $admins[$i]->user_title ?></span>
    551                     <hr />
     544                    <a href="<?php echo bp_core_get_user_domain( $admin->user_id, $admin->user_nicename, $admin->user_login ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $admin->user_id, 'email' => $admin->user_email ) ) ?></a>
    552545                </li>
    553546            <?php } ?>
    554             </ul>
    555         <?php } else { ?>
    556             <?php for ( $i = 0; $i < count($admins); $i++ ) { ?>
    557                 <?php echo $admins[$i]->user->user_link ?>
    558             <?php } ?>
    559         <?php } ?>
     547        </ul>
    560548    <?php } else { ?>
    561549        <span class="activity"><?php _e( 'No Admins', 'buddypress' ) ?></span>
    562550    <?php } ?>
    563 
    564551<?php
    565552}
    566553
    567 function bp_group_list_mods( $full_list = true, $group = false ) {
     554function bp_group_list_mods( $deprecated = true, $group = false ) {
    568555    global $groups_template;
    569556
     
    571558        $group =& $groups_template->group;
    572559
    573     $group_mods = groups_get_group_mods( $group->id );
    574 
    575     if ( $group_mods ) {
    576         if ( $full_list ) { ?>
    577             <ul id="group-mods" class="mods-list">
    578             <?php for ( $i = 0; $i < count($group_mods); $i++ ) { ?>
     560    if ( $group->mods ) { ?>
     561        <ul id="group-mods">
     562            <?php foreach( (array)$group->mods as $mod ) { ?>
    579563                <li>
    580                     <a href="<?php echo bp_core_get_userlink( $group_mods[$i]->user_id, false, true ) ?>" title="<?php echo bp_core_get_user_displayname( $group_mods[$i]->user->user_id ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $group_mods[$i]->user_id, 'type' => 'thumb', 'width' => 30, 'height' => 30 ) ) ?></a>
    581                     <h5><?php echo bp_core_get_userlink( $group_mods[$i]->user_id ) ?></h5>
    582                     <span class="activity"><?php _e( 'Group Mod', 'buddypress' ) ?></span>
    583                     <div class="clear"></div>
     564                    <a href="<?php echo bp_core_get_user_domain( $mod->user_id, $mod->user_nicename, $mod->user_login ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $mod->user_id, 'email' => $mod->user_email ) ) ?></a>
    584565                </li>
    585566            <?php } ?>
    586             </ul>
    587         <?php } else { ?>
    588             <?php for ( $i = 0; $i < count($group_mods); $i++ ) { ?>
    589                 <?php echo bp_core_get_userlink( $group_mods[$i]->user_id ) . ' ' ?>
    590             <?php } ?>
    591         <?php } ?>
     567        </ul>
    592568    <?php } else { ?>
    593569        <span class="activity"><?php _e( 'No Mods', 'buddypress' ) ?></span>
    594570    <?php } ?>
    595 
    596571<?php
    597572}
Note: See TracChangeset for help on using the changeset viewer.