Ticket #4440: 4440.001.patch
File 4440.001.patch, 3.5 KB (added by , 13 years ago) |
---|
-
bp-xprofile/bp-xprofile-functions.php
function bp_xprofile_get_hidden_fields_for_user( $displayed_user_id = 0, $curren 671 671 } 672 672 673 673 // @todo - This is where you'd swap out for current_user_can() checks 674 $hidden_levels = array(); 674 675 676 // Current user is logged in 675 677 if ( $current_user_id ) { 676 // Current user is logged in 678 679 // If you're viewing your own profile, nothing's private 677 680 if ( $displayed_user_id == $current_user_id ) { 678 // If you're viewing your own profile, nothing's private679 $hidden_fields = array();680 681 681 } else if ( bp_is_active( 'friends' ) && friends_check_friendship( $displayed_user_id, $current_user_id ) ) { 682 // If the current user and displayed user are friends, show all 683 $hidden_fields = array(); 682 // If the current user and displayed user are friends, show all 683 } elseif ( bp_is_active( 'friends' ) && friends_check_friendship( $displayed_user_id, $current_user_id ) ) { 684 if ( ! bp_current_user_can( 'bp_moderate' ) ) 685 $hidden_levels[] = 'adminsonly'; 686 687 $hidden_fields = bp_xprofile_get_fields_by_visibility_levels( $displayed_user_id, $hidden_levels ); 684 688 689 // current user is logged-in but not friends, so exclude friends-only 685 690 } else { 686 // current user is logged-in but not friends, so exclude friends-only687 691 $hidden_levels = array( 'friends' ); 692 693 if ( ! bp_current_user_can( 'bp_moderate' ) ) 694 $hidden_levels[] = 'adminsonly'; 695 688 696 $hidden_fields = bp_xprofile_get_fields_by_visibility_levels( $displayed_user_id, $hidden_levels ); 689 697 } 690 698 699 // Current user is not logged in, so exclude friends-only, loggedin, and adminsonly. 691 700 } else { 692 // Current user is not logged in, so exclude friends-only and loggedin 693 $hidden_levels = array( 'friends', 'loggedin' ); 701 $hidden_levels = array( 'friends', 'loggedin', 'adminsonly', ); 694 702 $hidden_fields = bp_xprofile_get_fields_by_visibility_levels( $displayed_user_id, $hidden_levels ); 695 703 } 696 704 … … function bp_xprofile_get_hidden_fields_for_user( $displayed_user_id = 0, $curren 704 712 * @see bp_xprofile_get_hidden_fields_for_user() 705 713 * 706 714 * @param int $user_id The id of the profile owner 707 * @param array $levels An array of visibility levels ('public', 'friends', 'loggedin', etc) to be715 * @param array $levels An array of visibility levels ('public', 'friends', 'loggedin', 'adminsonly' etc) to be 708 716 * checked against 709 717 * @return array $field_ids The fields that match the requested visibility levels for the given user 710 718 */ -
bp-xprofile/bp-xprofile-loader.php
class BP_XProfile_Component extends BP_Component { 101 101 102 102 // Register the visibility levels. See bp_xprofile_get_visibility_levels() to filter 103 103 $this->visibility_levels = array( 104 'public' 105 'id' => 'public',104 'public' => array( 105 'id' => 'public', 106 106 'label' => __( 'Anyone', 'buddypress' ) 107 107 ), 108 108 'loggedin' => array( 109 'id' => 'loggedin',109 'id' => 'loggedin', 110 110 'label' => __( 'Logged In Users', 'buddypress' ) 111 ) 111 ), 112 'adminsonly' => array( 113 'id' => 'adminsonly', 114 'label' => __( 'Admins Only', 'buddypress' ) 115 ), 112 116 ); 113 117 114 118 if ( bp_is_active( 'friends' ) ) {