Skip to:
Content

BuddyPress.org

Changeset 6060


Ignore:
Timestamp:
06/06/2012 07:26:17 PM (12 years ago)
Author:
boonebgorges
Message:

Ensures that admin-enforced visibility settings are actually enforced. Fixes #4233

File:
1 edited

Legend:

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

    r5962 r6060  
    715715   
    716716    $user_visibility_levels = bp_get_user_meta( $user_id, 'bp_xprofile_visibility_levels', true );
    717    
     717
     718    // Parse the user-provided visibility levels with the default levels, which may take
     719    // precedence
     720    $default_visibility_levels = BP_XProfile_Group::fetch_default_visibility_levels();
     721
     722    foreach( (array) $default_visibility_levels as $d_field_id => $defaults ) {
     723        // If the admin has forbidden custom visibility levels for this field, replace
     724        // the user-provided setting with the default specified by the admin
     725        if ( isset( $defaults['allow_custom'] ) && isset( $defaults['default'] ) && 'disabled' == $defaults['allow_custom'] && isset( $user_visibility_levels[$d_field_id] ) ) {
     726            $user_visibility_levels[$d_field_id] = $defaults['default'];
     727        }
     728    }
     729
    718730    $field_ids = array();
    719     foreach( (array)$user_visibility_levels as $field_id => $field_visibility ) {
     731    foreach( (array) $user_visibility_levels as $field_id => $field_visibility ) {
    720732        if ( in_array( $field_visibility, $levels ) ) {
    721733            $field_ids[] = $field_id;
Note: See TracChangeset for help on using the changeset viewer.