Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/15/2012 08:44:52 PM (14 years ago)
Author:
boonebgorges
Message:

Changes 'privacy' to 'visibility' throughout, when referencing xprofile fields. See #3695. Props DJPaul.

File:
1 edited

Legend:

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

    r5789 r5792  
    252252
    253253/**
    254  * Set the privacy level for this field
     254 * Set the visibility level for this field
    255255 *
    256256 * @param int $field_id The ID of the xprofile field
    257257 * @param int $user_id The ID of the user to whom the data belongs
    258  * @param string $privacy_level
     258 * @param string $visibility_level
    259259 * @return bool True on success
    260260 */
    261 function xprofile_set_field_privacy_level( $field_id = 0, $user_id = 0, $privacy_level = '' ) {
    262     if ( empty( $field_id ) || empty( $user_id ) || empty( $privacy_level ) ) {
     261function xprofile_set_field_visibility_level( $field_id = 0, $user_id = 0, $visibility_level = '' ) {
     262    if ( empty( $field_id ) || empty( $user_id ) || empty( $visibility_level ) ) {
    263263        return false;
    264264    }
     
    272272   
    273273    // Check against a whitelist
    274     $allowed_values = bp_xprofile_get_privacy_levels();
    275     if ( !array_key_exists( $privacy_level, $allowed_values ) ) {
     274    $allowed_values = bp_xprofile_get_visibility_levels();
     275    if ( !array_key_exists( $visibility_level, $allowed_values ) ) {
    276276        return false;
    277277    }
    278278   
    279279    // Stored in an array in usermeta
    280     $current_privacy_levels = get_user_meta( $user_id, 'bp_xprofile_privacy_levels', true );
    281    
    282     if ( !$current_privacy_levels ) {
    283         $current_privacy_levels = array();
    284     }
    285    
    286     $current_privacy_levels[$field_id] = $privacy_level;
    287    
    288     return update_user_meta( $user_id, 'bp_xprofile_privacy_levels', $current_privacy_levels );
     280    $current_visibility_levels = get_user_meta( $user_id, 'bp_xprofile_visibility_levels', true );
     281   
     282    if ( !$current_visibility_levels ) {
     283        $current_visibility_levels = array();
     284    }
     285   
     286    $current_visibility_levels[$field_id] = $visibility_level;
     287   
     288    return update_user_meta( $user_id, 'bp_xprofile_visibility_levels', $current_visibility_levels );
    289289}
    290290
     
    645645
    646646/**
    647  * Get privacy levels out of the $bp global
     647 * Get visibility levels out of the $bp global
    648648 *
    649649 * @return array
    650650 */
    651 function bp_xprofile_get_privacy_levels() {
     651function bp_xprofile_get_visibility_levels() {
    652652    global $bp;
    653653   
    654     return apply_filters( 'bp_xprofile_get_privacy_levels', $bp->profile->privacy_levels );
     654    return apply_filters( 'bp_xprofile_get_visibility_levels', $bp->profile->visibility_levels );
    655655}
    656656
     
    658658 * Get the ids of fields that are hidden for this displayed/loggedin user pair
    659659 *
    660  * This is the function primarily responsible for profile field privacy. It works by determining
     660 * This is the function primarily responsible for profile field visibility. It works by determining
    661661 * the relationship between the displayed_user (ie the profile owner) and the current_user (ie the
    662662 * profile viewer). Then, based on that relationship, we query for the set of fields that should
     
    665665 * @since 1.6
    666666 * @see BP_XProfile_Group::get()
    667  * @uses apply_filters() Filter bp_xprofile_get_hidden_fields_for_user to modify privacy levels,
     667 * @uses apply_filters() Filter bp_xprofile_get_hidden_fields_for_user to modify visibility levels,
    668668 *   or if you have added your own custom levels
    669669 *
     
    700700            // current user is logged-in but not friends, so exclude friends-only   
    701701            $hidden_levels = array( 'friends' );           
    702             $hidden_fields = bp_xprofile_get_fields_by_privacy_levels( $displayed_user_id, $hidden_levels );
     702            $hidden_fields = bp_xprofile_get_fields_by_visibility_levels( $displayed_user_id, $hidden_levels );
    703703        }
    704704       
     
    706706        // Current user is not logged in, so exclude friends-only and loggedin
    707707        $hidden_levels = array( 'friends', 'loggedin' );
    708         $hidden_fields = bp_xprofile_get_fields_by_privacy_levels( $displayed_user_id, $hidden_levels );
     708        $hidden_fields = bp_xprofile_get_fields_by_visibility_levels( $displayed_user_id, $hidden_levels );
    709709    }
    710710   
     
    713713
    714714/**
    715  * Fetch an array of the xprofile fields that a given user has marked with certain privacy levels
     715 * Fetch an array of the xprofile fields that a given user has marked with certain visibility levels
    716716 *
    717717 * @since 1.6
     
    719719 *
    720720 * @param int $user_id The id of the profile owner
    721  * @param array $levels An array of privacy levels ('public', 'friends', 'loggedin', etc) to be
     721 * @param array $levels An array of visibility levels ('public', 'friends', 'loggedin', etc) to be
    722722 *    checked against
    723  * @return array $field_ids The fields that match the requested privacy levels for the given user
    724  */
    725 function bp_xprofile_get_fields_by_privacy_levels( $user_id, $levels = array() ) {
     723 * @return array $field_ids The fields that match the requested visibility levels for the given user
     724 */
     725function bp_xprofile_get_fields_by_visibility_levels( $user_id, $levels = array() ) {
    726726    if ( !is_array( $levels ) ) {
    727727        $levels = (array)$levels;
    728728    }
    729729   
    730     $user_privacy_levels = get_user_meta( $user_id, 'bp_xprofile_privacy_levels', true );
     730    $user_visibility_levels = get_user_meta( $user_id, 'bp_xprofile_visibility_levels', true );
    731731   
    732732    $field_ids = array();
    733     foreach( (array)$user_privacy_levels as $field_id => $field_privacy ) {
    734         if ( in_array( $field_privacy, $levels ) ) {
     733    foreach( (array)$user_visibility_levels as $field_id => $field_visibility ) {
     734        if ( in_array( $field_visibility, $levels ) ) {
    735735            $field_ids[] = $field_id;
    736736        }
Note: See TracChangeset for help on using the changeset viewer.