Skip to:
Content

BuddyPress.org

Changeset 1441


Ignore:
Timestamp:
04/29/2009 01:50:26 PM (17 years ago)
Author:
apeatling
Message:

Adding parameter support to the bp_has_profile() template loop.

Location:
trunk/bp-xprofile
Files:
2 edited

Legend:

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

    r1366 r1441  
    148148
    149149        if ( $hide_empty ) {
    150             $sql = $wpdb->prepare( "SELECT DISTINCT g.* FROM {$bp->profile->table_name_groups} g INNER JOIN {$bp->profile->table_name_fields} f ON g.id = f.group_id ORDER BY g.id ASC" );
    151         } else {
    152             $sql = $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_groups} ORDER BY id ASC" );
     150            $sql = $wpdb->prepare( "SELECT DISTINCT g.id FROM {$bp->profile->table_name_groups} g INNER JOIN {$bp->profile->table_name_fields} f ON g.id = f.group_id ORDER BY g.id ASC" );
     151        } else {
     152            $sql = $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_groups} ORDER BY id ASC" );
    153153        }
    154154
  • trunk/bp-xprofile/bp-xprofile-templatetags.php

    r1408 r1441  
    1616    var $user_id;
    1717
    18     function bp_xprofile_template($user_id) {
    19         if ( !$this->groups = wp_cache_get( 'xprofile_groups', 'bp' ) ) {
    20             $this->groups = BP_XProfile_Group::get_all(true);
    21             wp_cache_set( 'xprofile_groups', $this->groups, 'bp' );
    22         }
    23 
     18    function bp_xprofile_template( $user_id, $group_id ) {
     19       
     20        if ( !$group_id ) {
     21            if ( !$this->groups = wp_cache_get( 'xprofile_groups', 'bp' ) ) {
     22                $this->groups = BP_XProfile_Group::get_all(true);
     23                wp_cache_set( 'xprofile_groups', $this->groups, 'bp' );
     24            }
     25        } else {
     26            if ( !$this->groups = wp_cache_get( 'xprofile_group_' . $group_id, 'bp' ) ) {
     27                $this->groups = new BP_XProfile_Group( $group_id );
     28                wp_cache_set( 'xprofile_group_' . $group_id, 'bp' );
     29            }
     30           
     31            /* We need to put this single group into the same format as multiple group (an array) */
     32            $this->groups = array( $this->groups );
     33        }
     34       
    2435        $this->group_count = count($this->groups);
    2536        $this->user_id = $user_id;
     
    148159}
    149160
    150 function bp_has_profile() {
     161function bp_has_profile( $args = '' ) {
    151162    global $bp, $profile_template;
    152 
    153     $profile_template = new BP_XProfile_Template($bp->displayed_user->id);
     163   
     164    $defaults = array(
     165        'user_id' => $bp->displayed_user->id,
     166        'group_id' => false
     167    );
     168
     169    $r = wp_parse_args( $args, $defaults );
     170    extract( $r, EXTR_SKIP );
     171   
     172    $profile_template = new BP_XProfile_Template( $user_id, $group_id );
    154173   
    155174    return $profile_template->has_groups();
Note: See TracChangeset for help on using the changeset viewer.