Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/13/2010 04:01:07 PM (14 years ago)
Author:
apeatling
Message:

Replacing function_exists() checks with bp_is_active() checks.

File:
1 edited

Legend:

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

    r2770 r2919  
    2323    var $order;
    2424
    25     function bp_groups_template( $user_id, $type, $page, $per_page, $max, $slug, $search_terms, $populate_extras ) {
     25    function bp_groups_template( $user_id, $type, $page, $per_page, $max, $slug, $search_terms, $include, $populate_extras ) {
    2626        global $bp;
    2727
     
    3636            $this->groups = array( $group );
    3737        } else
    38             $this->groups = groups_get_groups( array( 'type' => $type, 'per_page' => $this->pag_num, 'page' =>$this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras ) );
     38            $this->groups = groups_get_groups( array( 'type' => $type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'include' => $include, 'populate_extras' => $populate_extras ) );
    3939
    4040        if ( 'invites' == $type ) {
     
    169169        'slug' => $slug, // Pass a group slug to only return that group
    170170        'search_terms' => $search_terms, // Pass search terms to return only matching groups
     171        'include' => false, // Pass comma separated list of group ID's to return only these groups
    171172
    172173        'populate_extras' => true // Get extra meta - is_member, is_banned
     
    176177    extract( $r );
    177178
    178     $groups_template = new BP_Groups_Template( (int)$user_id, $type, (int)$page, (int)$per_page, (int)$max, $slug, $search_terms, (bool)$populate_extras );
     179    $groups_template = new BP_Groups_Template( (int)$user_id, $type, (int)$page, (int)$per_page, (int)$max, $slug, $search_terms, $include, (bool)$populate_extras );
    179180    return apply_filters( 'bp_has_groups', $groups_template->has_groups(), &$groups_template );
    180181}
     
    726727                <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $admin->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span>
    727728
    728                 <?php if ( function_exists( 'friends_install' ) ) : ?>
     729                <?php if ( bp_is_active( 'friends' ) ) : ?>
    729730                    <div class="action">
    730731                        <?php bp_add_friend_button( $admin->user_id ) ?>
     
    764765                    <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $mod->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span>
    765766
    766                     <?php if ( function_exists( 'friends_install' ) ) : ?>
     767                    <?php if ( bp_is_active( 'friends' ) ) : ?>
    767768                        <div class="action">
    768769                            <?php bp_add_friend_button( $mod->user_id ) ?>
     
    10341035    global $groups_template, $bp;
    10351036
    1036     if ( !function_exists('friends_install') )
     1037    if ( !bp_is_active( 'friends' ) )
    10371038        return false;
    10381039
     
    10471048
    10481049function bp_group_join_button( $group = false ) {
    1049     global $bp, $groups_template;
    1050 
    1051     if ( !$group )
    1052         $group =& $groups_template->group;
    1053 
    1054     // If they're not logged in or are banned from the group, no join button.
    1055     if ( !is_user_logged_in() || $group->is_banned )
    1056         return false;
    1057 
    1058     if ( !$group->status )
    1059         return false;
    1060 
    1061     if ( 'hidden' == $group->status && !$group->is_member )
    1062         return false;
    1063 
    1064     echo '<div class="generic-button group-button ' . $group->status . '" id="groupbutton-' . $group->id . '">';
    1065 
    1066     switch ( $group->status ) {
    1067         case 'public':
    1068             if ( $group->is_member )
    1069                 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
    1070             else
    1071                 echo '<a class="join-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>';
    1072         break;
    1073 
    1074         case 'private':
    1075             if ( $group->is_member ) {
    1076                 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
    1077             } else {
    1078                 if ( !bp_group_has_requested_membership( $group ) )
    1079                     echo '<a class="request-membership" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'request-membership', 'groups_request_membership' ) . '">' . __('Request Membership', 'buddypress') . '</a>';
     1050    echo bp_get_group_join_button( $group );
     1051}
     1052    function bp_get_group_join_button( $group = false ) {
     1053        global $bp, $groups_template;
     1054
     1055        if ( !$group )
     1056            $group =& $groups_template->group;
     1057
     1058        // If they're not logged in or are banned from the group, no join button.
     1059        if ( !is_user_logged_in() || $group->is_banned )
     1060            return false;
     1061
     1062        if ( !$group->status )
     1063            return false;
     1064
     1065        if ( 'hidden' == $group->status && !$group->is_member )
     1066            return false;
     1067
     1068        $button = '<div class="generic-button group-button ' . $group->status . '" id="groupbutton-' . $group->id . '">';
     1069
     1070        switch ( $group->status ) {
     1071            case 'public':
     1072                if ( $group->is_member )
     1073                    $button .= '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
    10801074                else
    1081                     echo '<a class="membership-requested" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>';
    1082             }
    1083         break;
    1084 
    1085         case 'hidden':
    1086             if ( $group->is_member )
    1087                 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
    1088         break;
    1089     }
    1090 
    1091     echo '</div>';
    1092 }
     1075                    $button .= '<a class="join-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>';
     1076            break;
     1077
     1078            case 'private':
     1079                if ( $group->is_member ) {
     1080                    $button .= '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
     1081                } else {
     1082                    if ( !bp_group_has_requested_membership( $group ) )
     1083                        $button .= '<a class="request-membership" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'request-membership', 'groups_request_membership' ) . '">' . __('Request Membership', 'buddypress') . '</a>';
     1084                    else
     1085                        $button .= '<a class="membership-requested" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>';
     1086                }
     1087            break;
     1088
     1089            case 'hidden':
     1090                if ( $group->is_member )
     1091                    $button .= '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
     1092            break;
     1093        }
     1094
     1095        $button .= '</div>';
     1096
     1097        return apply_filters( 'bp_get_group_join_button', $button );
     1098    }
    10931099
    10941100function bp_group_status_message( $group = false ) {
     
    16401646        global $bp;
    16411647
    1642         if ( !function_exists('friends_install') )
     1648        if ( !bp_is_active( 'friends' ) )
    16431649            return false;
    16441650
Note: See TracChangeset for help on using the changeset viewer.