Changeset 5797
- Timestamp:
- 02/16/2012 10:07:10 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-hooks.php
r5774 r5797 77 77 add_action( 'admin_bar_menu', 'bp_setup_admin_bar', 11 ); 78 78 79 /** Roles and Capabilities ****************************************************/ 80 81 // Map our custom capabilities onto WP's 82 add_filter( 'map_meta_cap', 'bp_map_meta_caps', 10, 4 ); 83 79 84 /** The hooks *****************************************************************/ 80 85 -
trunk/bp-themes/bp-default/_inc/css/default.css
r5792 r5797 2385 2385 font-weight: bold; 2386 2386 } 2387 .field-visibility-settings, 2388 .field-visibility-settings-toggle, 2389 .field-visibility-settings-notoggle { 2390 color: #888; 2391 } 2387 2392 .field-visibility-settings-toggle a, 2388 2393 .field-visibility-settings a { -
trunk/bp-themes/bp-default/members/single/profile/edit.php
r5792 r5797 114 114 <?php endif; ?> 115 115 116 <?php /* The fullname field is always public */ ?> 117 <?php if ( 1 != bp_get_the_profile_field_id() ) : ?> 116 <?php if ( bp_current_user_can( 'bp_xprofile_change_field_visibility' ) ) : ?> 118 117 <div class="field-visibility-settings-toggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>"> 119 118 <?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?> <a href="#" class="visibility-toggle-link">Change</a> … … 127 126 <a class="field-visibility-settings-close" href="#"><?php _e( 'Close', 'buddypress' ) ?></a> 128 127 </div> 128 <?php else : ?> 129 <div class="field-visibility-settings-notoggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>"> 130 <?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?> 131 </div> 129 132 <?php endif ?> 130 133 -
trunk/bp-xprofile/bp-xprofile-admin.php
r5792 r5797 274 274 if ( !empty( $_POST['default-visibility'] ) ) { 275 275 bp_xprofile_update_field_meta( $field_id, 'default_visibility', $_POST['default-visibility'] ); 276 } 277 278 if ( !empty( $_POST['allow-custom-visibility'] ) ) { 279 bp_xprofile_update_field_meta( $field_id, 'allow_custom_visibility', $_POST['allow-custom-visibility'] ); 276 280 } 277 281 -
trunk/bp-xprofile/bp-xprofile-classes.php
r5796 r5797 284 284 285 285 /** 286 * Fetch the field visibility level for the returned fielddata 286 * Fetch the field visibility level for the fields returned by the query 287 * 288 * @since 1.6 289 * 290 * @param int $user_id The profile owner's user_id 291 * @param array $fields The database results returned by the get() query 292 * @return array $fields The database results, with field_visibility added 287 293 */ 288 294 function fetch_visibility_level( $user_id, $fields ) { … … 292 298 $visibility_levels = bp_get_user_meta( $user_id, 'bp_xprofile_visibility_levels', true ); 293 299 300 // Get the admin-set preferences 301 $admin_set_levels = self::fetch_default_visibility_levels(); 302 294 303 foreach( (array)$fields as $key => $field ) { 304 // Does the admin allow this field to be customized? 305 $allow_custom = !empty( $admin_set_levels[$field->id]['allow_custom'] ) && 'disabled' != $admin_set_levels[$field->id]['allow_custom']; 306 295 307 // Look to see if the user has set the visibility for this field 296 if ( isset( $visibility_levels[$field->id] ) ) {308 if ( $allow_custom && isset( $visibility_levels[$field->id] ) ) { 297 309 $field_visibility = $visibility_levels[$field->id]; 298 } else { 299 // If not, bring up the admin-set defaults 300 if ( !isset( $default_visibility_levels ) ) { 301 $default_visibility_levels = self::fetch_default_visibility_levels(); 302 } 303 310 } else { 304 311 // If no admin-set default is saved, fall back on a global default 305 $field_visibility = !empty( $ default_visibility_levels[$field->id] ) ? $default_visibility_levels[$field->id] : apply_filters( 'bp_xprofile_default_visibility_level', 'public' );312 $field_visibility = !empty( $admin_set_levels[$field->id]['default'] ) ? $admin_set_levels[$field->id]['default'] : apply_filters( 'bp_xprofile_default_visibility_level', 'public' ); 306 313 } 307 314 … … 313 320 314 321 /** 315 * Fetch the admin-set default visibility levels for all fields 322 * Fetch the admin-set preferences for all fields 323 * 324 * @since 1.6 325 * 326 * @return array $default_visibility_levels An array, keyed by field_id, of default 327 * visibility level + allow_custom (whether the admin allows this field to be set by user) 316 328 */ 317 329 function fetch_default_visibility_levels() { 318 330 global $wpdb, $bp; 319 331 320 $levels = $wpdb->get_results( $wpdb->prepare( "SELECT object_id, meta_ value FROM {$bp->profile->table_name_meta} WHERE object_type = 'field' AND meta_key = 'default_visibility'" ) );332 $levels = $wpdb->get_results( $wpdb->prepare( "SELECT object_id, meta_key, meta_value FROM {$bp->profile->table_name_meta} WHERE object_type = 'field' AND ( meta_key = 'default_visibility' OR meta_key = 'allow_custom_visibility' )" ) ); 321 333 322 334 // Arrange so that the field id is the key and the visibility level the value 323 335 $default_visibility_levels = array(); 324 336 foreach( $levels as $level ) { 325 $default_visibility_levels[$level->object_id] = $level->meta_value; 337 if ( 'default_visibility' == $level->meta_key ) { 338 $default_visibility_levels[$level->object_id]['default'] = $level->meta_value; 339 } else if ( 'allow_custom_visibility' == $level->meta_key ) { 340 $default_visibility_levels[$level->object_id]['allow_custom'] = $level->meta_value; 341 } 326 342 } 327 343 … … 409 425 var $is_default_option; 410 426 var $default_visibility; 427 var $allow_custom_visibility; 411 428 412 429 var $data; … … 452 469 $this->default_visibility = 'public'; 453 470 } 471 472 $this->allow_custom_visibility = 'disabled' == bp_xprofile_get_meta( $id, 'field', 'allow_custom_visibility' ) ? 'disabled' : 'allowed'; 454 473 } 455 474 } … … 867 886 868 887 <div id="titlediv"> 869 <h3><label for="default-visibility"><?php _e( "Default Visibility Level", 'buddypress' ); ?></label></h3>888 870 889 <div id="titlewrap"> 890 <h3><label for="default-visibility"><?php _e( "Default Visibility", 'buddypress' ); ?></label></h3> 871 891 <ul> 872 892 <?php foreach( bp_xprofile_get_visibility_levels() as $level ) : ?> 873 893 <li><input type="radio" name="default-visibility" value="<?php echo esc_attr( $level['id'] ) ?>" <?php checked( $this->default_visibility, $level['id'] ) ?>> <?php echo esc_html( $level['label'] ) ?></li> 874 894 <?php endforeach ?> 895 </ul> 896 </div> 897 898 <div id="titlewrap"> 899 <h3><label for="allow-custom-visibility"><?php _e( "Per-Member Visibility", 'buddypress' ); ?></label></h3> 900 <ul> 901 <li><input type="radio" name="allow-custom-visibility" value="allowed" <?php checked( $this->allow_custom_visibility, 'allowed' ) ?>> <?php _e( "Let members change the this field's visibility", 'buddypress' ) ?></li> 902 903 <li><input type="radio" name="allow-custom-visibility" value="disabled" <?php checked( $this->allow_custom_visibility, 'disabled' ) ?>> <?php _e( 'Enforce the default visibility for all members', 'buddypress' ) ?></li> 875 904 </ul> 876 905 </div> -
trunk/bp-xprofile/bp-xprofile-filters.php
r5729 r5797 212 212 add_filter( 'comments_array', 'xprofile_filter_comments', 10, 2 ); 213 213 214 215 214 216 ?> -
trunk/bp-xprofile/bp-xprofile-loader.php
r5792 r5797 45 45 'activity', 46 46 'screens', 47 'caps', 47 48 'classes', 48 49 'filters',
Note: See TracChangeset
for help on using the changeset viewer.