Ticket #2655: 2655.patch
File 2655.patch, 4.2 KB (added by , 14 years ago) |
---|
-
bp-xprofile/bp-xprofile-templatetags.php
18 18 var $in_the_loop; 19 19 var $user_id; 20 20 21 function bp_xprofile_data_template( $user_id, $profile_group_id ) {21 function bp_xprofile_data_template( $user_id, $profile_group_id, $hide_empty_groups = false, $fetch_fields = false, $fetch_field_data = false, $exclude_groups = false, $exclude_fields = false ) { 22 22 $this->groups = BP_XProfile_Group::get( array( 23 23 'profile_group_id' => $profile_group_id, 24 24 'user_id' => $user_id, 25 'hide_empty_groups' => true, 26 'fetch_fields' => true, 27 'fetch_field_data' => true 25 'hide_empty_groups' => $hide_empty_groups, 26 'fetch_fields' => $fetch_fields, 27 'fetch_field_data' => $fetch_field_data, 28 'exclude_groups' => $exclude_groups, 29 'exclude_fields' => $exclude_fields 28 30 ) ); 29 31 30 32 $this->group_count = count( $this->groups ); … … 142 144 143 145 $defaults = array( 144 146 'user_id' => $bp->displayed_user->id, 145 'profile_group_id' => false 147 'profile_group_id' => false, 148 'hide_empty_groups' => true, 149 'fetch_fields' => true, 150 'fetch_field_data' => true, 151 'exclude_groups' => false, // Comma-separated list of profile field group IDs to exclude 152 'exclude_fields' => false // Comma-separated list of profile field IDs to exclude 146 153 ); 147 154 148 155 $r = wp_parse_args( $args, $defaults ); 149 156 extract( $r, EXTR_SKIP ); 150 157 151 $profile_template = new BP_XProfile_Data_Template( $user_id, $profile_group_id );158 $profile_template = new BP_XProfile_Data_Template( $user_id, $profile_group_id, $hide_empty_groups, $fetch_fields, $fetch_field_data, $exclude_groups, $exclude_fields ); 152 159 return apply_filters( 'bp_has_profile', $profile_template->has_groups(), &$profile_template ); 153 160 } 154 161 -
bp-xprofile/bp-xprofile-classes.php
87 87 'user_id' => $bp->displayed_user->id, 88 88 'hide_empty_groups' => false, 89 89 'fetch_fields' => false, 90 'fetch_field_data' => false 90 'fetch_field_data' => false, 91 'exclude_groups' => false, 92 'exclude_fields' => false 91 93 ); 92 94 93 95 $r = wp_parse_args( $args, $defaults ); 94 96 extract( $r, EXTR_SKIP ); 95 97 96 98 if ( $profile_group_id ) 97 $group_id_sql = $wpdb->prepare( 'WHERE g.id = %d', $profile_group_id ); 98 99 $where_sql = $wpdb->prepare( 'WHERE g.id = %d', $profile_group_id ); 100 else if ( $exclude_groups ) 101 $where_sql = $wpdb->prepare( "WHERE g.id NOT IN ({$exclude_groups})"); 102 99 103 if ( $hide_empty_groups ) 100 $groups = $wpdb->get_results( $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 {$ group_id_sql} ORDER BY g.group_order ASC" ) );104 $groups = $wpdb->get_results( $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 {$where_sql} ORDER BY g.group_order ASC" ) ); 101 105 else 102 $groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT g.* FROM {$bp->profile->table_name_groups} g {$ group_id_sql} ORDER BY g.group_order ASC" ) );106 $groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT g.* FROM {$bp->profile->table_name_groups} g {$where_sql} ORDER BY g.group_order ASC" ) ); 103 107 104 108 if ( !$fetch_fields ) 105 109 return $groups; … … 114 118 if ( empty( $group_ids ) ) 115 119 return $groups; 116 120 121 if ( $exclude_fields ) 122 $exclude_fields_sql = $wpdb->prepare( "AND id NOT IN ({$exclude_fields})" ); 123 117 124 /* Fetch the fields */ 118 $fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, name, description, type, group_id, is_required FROM {$bp->profile->table_name_fields} WHERE group_id IN ( {$group_ids} ) AND parent_id = 0 ORDER BY field_order" ) );125 $fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, name, description, type, group_id, is_required FROM {$bp->profile->table_name_fields} WHERE group_id IN ( {$group_ids} ) AND parent_id = 0 {$exclude_fields_sql} ORDER BY field_order" ) ); 119 126 120 127 if ( empty( $fields ) ) 121 128 return $groups;