Changeset 6610
- Timestamp:
- 12/10/2012 03:02:27 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-xprofile/bp-xprofile-classes.php
r6518 r6610 116 116 117 117 $defaults = array( 118 'profile_group_id' => false,119 'user_id' => bp_displayed_user_id(),120 'hide_empty_groups' => false,121 'hide_empty_fields' => false,122 'fetch_fields' => false,123 'fetch_field_data' => false,118 'profile_group_id' => false, 119 'user_id' => bp_displayed_user_id(), 120 'hide_empty_groups' => false, 121 'hide_empty_fields' => false, 122 'fetch_fields' => false, 123 'fetch_field_data' => false, 124 124 'fetch_visibility_level' => false, 125 'exclude_groups' => false,126 'exclude_fields' => false125 'exclude_groups' => false, 126 'exclude_fields' => false 127 127 ); 128 128 … … 176 176 return $groups; 177 177 178 if ( ! empty( $fetch_field_data ) && ! empty( $user_id )) {178 if ( ! empty( $fetch_field_data ) ) { 179 179 180 180 // Fetch the field data for the user. … … 185 185 $field_ids_sql = implode( ',', (array) $field_ids ); 186 186 187 if ( ! empty( $field_ids ) )187 if ( ! empty( $field_ids ) && ! empty( $user_id ) ) { 188 188 $field_data = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_id, value FROM {$bp->profile->table_name_data} WHERE field_id IN ( {$field_ids_sql} ) AND user_id = %d", $user_id ) ); 189 } 189 190 190 191 // Remove data-less fields, if necessary … … 233 234 } 234 235 235 if ( $fetch_visibility_level) {236 if ( !empty( $fetch_visibility_level ) ) { 236 237 $fields = self::fetch_visibility_level( $user_id, $fields ); 237 238 } … … 294 295 * @return array $fields The database results, with field_visibility added 295 296 */ 296 function fetch_visibility_level( $user_id , $fields) {297 function fetch_visibility_level( $user_id = 0, $fields = array() ) { 297 298 298 299 // Get the user's visibility level preferences … … 302 303 $admin_set_levels = self::fetch_default_visibility_levels(); 303 304 304 foreach( (array)$fields as $key => $field ) { 305 foreach( (array) $fields as $key => $field ) { 306 305 307 // Does the admin allow this field to be customized? 306 308 $allow_custom = empty( $admin_set_levels[$field->id]['allow_custom'] ) || 'allowed' == $admin_set_levels[$field->id]['allow_custom']; … … 309 311 if ( $allow_custom && isset( $visibility_levels[$field->id] ) ) { 310 312 $field_visibility = $visibility_levels[$field->id]; 313 314 // If no admin-set default is saved, fall back on a global default 311 315 } else { 312 // If no admin-set default is saved, fall back on a global default313 316 $field_visibility = !empty( $admin_set_levels[$field->id]['default'] ) ? $admin_set_levels[$field->id]['default'] : apply_filters( 'bp_xprofile_default_visibility_level', 'public' ); 314 317 }
Note: See TracChangeset
for help on using the changeset viewer.