Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/26/2008 10:49:51 PM (17 years ago)
Author:
apeatling
Message:
  • Added group directory to browse newest groups, groups by letter and search all groups. Also shows featured groups in the sidebar.
  • Changed buttons from images to background images and text to provide better translation options
  • Modified member theme to re-use get_header() and get_footer() - custom themes will need to be updated
  • Fixed bug with wp_redirect() and bp_core_do_catch_uri() clashing
File:
1 edited

Legend:

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

    r570 r580  
    1414    var $total_group_count;
    1515   
     16    var $single_group = false;
     17   
    1618    var $sort_by;
    1719    var $order;
     
    2931           
    3032            $this->groups = groups_get_user_groups( $this->pag_num, $this->pag_page );
    31             $this->total_group_count = (int)$this->groups['count'];
     33            $this->total_group_count = (int)$this->groups['total'];
    3234            $this->groups = $this->groups['groups'];
    3335            $this->group_count = count($this->groups);
     
    3638
    3739            $this->groups = groups_filter_user_groups( $_REQUEST['group-filter-box'], $this->pag_num, $this->pag_page );
    38             $this->total_group_count = (int)$this->groups['count'];
     40            $this->total_group_count = (int)$this->groups['total'];
    3941            $this->groups = $this->groups['groups'];
    4042            $this->group_count = count($this->groups);
     
    4345
    4446            $this->groups = groups_search_groups( $_REQUEST['groupfinder-search-box'], $this->pag_num, $this->pag_page );
    45             $this->total_group_count = (int)$this->groups['count'];
     47            $this->total_group_count = (int)$this->groups['total'];
    4648            $this->groups = $this->groups['groups'];
    4749            $this->group_count = count($this->groups);
     
    6062            if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] != '' ) {
    6163                $this->groups = groups_search_groups( $_REQUEST['s'], $this->pag_num, $this->pag_page, $this->sort_by, $this->order );
    62                 $this->total_group_count = (int)$this->groups['count'];
     64                $this->total_group_count = (int)$this->groups['total'];
    6365                $this->groups = $this->groups['groups'];
    6466                $this->group_count = count($this->groups);
    6567            } else {
    66                 $this->groups = BP_Groups_Group::get_all( false, $this->pag_num, $this->pag_page, $this->sort_by, $this->order, true );
     68                $this->groups = BP_Groups_Group::get_all( $this->pag_num, $this->pag_page, false, $this->sort_by, $this->order, true );
    6769                $this->total_group_count = count(BP_Groups_Group::get_all( false )); // TODO: not ideal
    6870                $this->group_count = count($this->groups);
     
    7072           
    7173        } else if ( $group_slug ) {
    72        
    73             $this->groups = array( new BP_Groups_Group( BP_Groups_Group::get_id_from_slug($group_slug), true ) );
     74            $this->single_group = true;
     75           
     76            $group = new stdClass();
     77            $group->group_id = BP_Groups_Group::get_id_from_slug($group_slug);
     78           
     79            $this->groups = array( $group );
    7480            $this->total_group_count = 1;
    7581            $this->group_count = 1;
     
    100106        $this->group = $this->groups[$this->current_group];
    101107       
     108        // If this is a single group then instantiate group meta when creating the object.
     109        if ( $this->single_group )
     110            $this->group = new BP_Groups_Group( $this->group->group_id, true );
     111        else
     112            $this->group = new BP_Groups_Group( $this->group->group_id, false );
     113           
    102114        return $this->group;
    103115    }
     
    212224}
    213225
    214 function bp_group_last_active() {
     226function bp_group_last_active( $echo = true ) {
    215227    global $groups_template;
    216228   
     
    220232        _e( 'not yet active', 'buddypress' );
    221233    else
    222         echo bp_core_time_since( groups_get_groupmeta( $groups_template->group->id, 'last_activity' ) );
     234        echo bp_core_time_since( $last_active );
    223235}
    224236
     
    530542    <?php } else { ?>
    531543        <div id="message" class="info">
    532             <?php _e( 'This group has no administrators', 'buddypress' ); ?>
     544            <p><?php _e( 'This group has no administrators', 'buddypress' ); ?></p>
    533545        </div>
    534546    <?php }
     
    643655}
    644656
    645 function bp_group_has_requested_membership() {
     657function bp_group_has_requested_membership( $group = false ) {
    646658    global $bp, $groups_template;
    647659   
    648     if ( groups_check_for_membership_request( $bp['loggedin_userid'], $groups_template->group->id ) )
     660    if ( !$group )
     661        $group = $groups_template->group;
     662   
     663    if ( groups_check_for_membership_request( $bp['loggedin_userid'], $group->id ) )
    649664        return true;
    650665   
     
    889904?>
    890905    <div class="left-menu">
    891         <h4>Select Friends <img id="ajax-loader" src="<?php echo $bp['groups']['image_base'] ?>/ajax-loader.gif" height="7" alt="Loading" style="display: none;" /></h4>
     906        <h4><?php _e( 'Select Friends', 'buddypress' ) ?> <img id="ajax-loader" src="<?php echo $bp['groups']['image_base'] ?>/ajax-loader.gif" height="7" alt="Loading" style="display: none;" /></h4>
    892907        <?php bp_group_list_invite_friends() ?>
    893908        <?php if ( function_exists('wp_nonce_field') )
     
    930945}
    931946
    932 function bp_group_join_button() {
     947function bp_group_join_button( $group = false ) {
    933948    global $bp, $groups_template;
    934949   
    935     if ( !is_user_logged_in() || BP_Groups_Member::check_is_member( $bp['loggedin_userid'], $groups_template->group->id ) || groups_is_user_banned( $bp['loggedin_userid'], $groups_template->group->id ) )
     950    if ( !$group )
     951        $group =& $groups_template->group;
     952   
     953    // If they're not logged in or are banned from the group, no join button.
     954    if ( !is_user_logged_in() || groups_is_user_banned( $bp['loggedin_userid'], $group->id ) )
    936955        return false;
    937        
    938     switch ( $groups_template->group->status ) {
     956   
     957    echo '<div class="group-button ' . $group->status . '" id="groupbutton-' . $group->id . '">';
     958   
     959    switch ( $group->status ) {
    939960        case 'public':
    940             echo '<a class="join-group" href="' . bp_group_permalink( false, false ) . '/join">' . __('Join Group', 'buddypress') . '</a>';                 
     961            if ( BP_Groups_Member::check_is_member( $bp['loggedin_userid'], $group->id ) )
     962                echo '<a class="leave-group" href="' . bp_group_permalink( $group, false ) . '/leave-group">' . __('Leave Group', 'buddypress') . '</a>';                                   
     963            else
     964                echo '<a class="join-group" href="' . bp_group_permalink( $group, false ) . '/join">' . __('Join Group', 'buddypress') . '</a>';                   
    941965        break;
    942966       
    943967        case 'private':
    944             if ( !bp_group_has_requested_membership() )
    945                 echo '<a class="request-membership" href="' . bp_group_permalink( false, false ) . '/request-membership">' . __('Request Membership', 'buddypress') . '</a>';       
    946             else
    947                 echo 'Membership Requested';
     968            if ( BP_Groups_Member::check_is_member( $bp['loggedin_userid'], $group->id ) ) {
     969                echo '<a class="leave-group" href="' . bp_group_permalink( $group, false ) . '/leave-group">' . __('Leave Group', 'buddypress') . '</a>';                                       
     970            } else {
     971                if ( !bp_group_has_requested_membership( $group ) )
     972                    echo '<a class="request-membership" href="' . bp_group_permalink( $group, false ) . '/request-membership">' . __('Request Membership', 'buddypress') . '</a>';     
     973                else
     974                    echo '<a class="membership-requested" href="' . bp_group_permalink( $group, false ) . '">' . __('Membership Requested', 'buddypress') . '</a>';             
     975            }
    948976        break;
    949977    }
     978   
     979    echo '</div>';
    950980}
    951981
Note: See TracChangeset for help on using the changeset viewer.