Changeset 5792 for trunk/bp-xprofile/bp-xprofile-functions.php
- Timestamp:
- 02/15/2012 08:44:52 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/bp-xprofile/bp-xprofile-functions.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-xprofile/bp-xprofile-functions.php
r5789 r5792 252 252 253 253 /** 254 * Set the privacy level for this field254 * Set the visibility level for this field 255 255 * 256 256 * @param int $field_id The ID of the xprofile field 257 257 * @param int $user_id The ID of the user to whom the data belongs 258 * @param string $ privacy_level258 * @param string $visibility_level 259 259 * @return bool True on success 260 260 */ 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 ) ) {261 function xprofile_set_field_visibility_level( $field_id = 0, $user_id = 0, $visibility_level = '' ) { 262 if ( empty( $field_id ) || empty( $user_id ) || empty( $visibility_level ) ) { 263 263 return false; 264 264 } … … 272 272 273 273 // 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 ) ) { 276 276 return false; 277 277 } 278 278 279 279 // 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 ); 289 289 } 290 290 … … 645 645 646 646 /** 647 * Get privacy levels out of the $bp global647 * Get visibility levels out of the $bp global 648 648 * 649 649 * @return array 650 650 */ 651 function bp_xprofile_get_ privacy_levels() {651 function bp_xprofile_get_visibility_levels() { 652 652 global $bp; 653 653 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 ); 655 655 } 656 656 … … 658 658 * Get the ids of fields that are hidden for this displayed/loggedin user pair 659 659 * 660 * This is the function primarily responsible for profile field privacy. It works by determining660 * This is the function primarily responsible for profile field visibility. It works by determining 661 661 * the relationship between the displayed_user (ie the profile owner) and the current_user (ie the 662 662 * profile viewer). Then, based on that relationship, we query for the set of fields that should … … 665 665 * @since 1.6 666 666 * @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, 668 668 * or if you have added your own custom levels 669 669 * … … 700 700 // current user is logged-in but not friends, so exclude friends-only 701 701 $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 ); 703 703 } 704 704 … … 706 706 // Current user is not logged in, so exclude friends-only and loggedin 707 707 $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 ); 709 709 } 710 710 … … 713 713 714 714 /** 715 * Fetch an array of the xprofile fields that a given user has marked with certain privacy levels715 * Fetch an array of the xprofile fields that a given user has marked with certain visibility levels 716 716 * 717 717 * @since 1.6 … … 719 719 * 720 720 * @param int $user_id The id of the profile owner 721 * @param array $levels An array of privacy levels ('public', 'friends', 'loggedin', etc) to be721 * @param array $levels An array of visibility levels ('public', 'friends', 'loggedin', etc) to be 722 722 * checked against 723 * @return array $field_ids The fields that match the requested privacy levels for the given user724 */ 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 */ 725 function bp_xprofile_get_fields_by_visibility_levels( $user_id, $levels = array() ) { 726 726 if ( !is_array( $levels ) ) { 727 727 $levels = (array)$levels; 728 728 } 729 729 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 ); 731 731 732 732 $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 ) ) { 735 735 $field_ids[] = $field_id; 736 736 }
Note: See TracChangeset
for help on using the changeset viewer.