Skip to:
Content

BuddyPress.org

Changeset 6070


Ignore:
Timestamp:
06/09/2012 02:40:37 PM (14 years ago)
Author:
boonebgorges
Message:

Whitespace cleanup in xprofile component and templates

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-themes/bp-default/members/single/profile/edit.php

    r6051 r6070  
    113113
    114114                                <?php endif; ?>
    115                                
     115
    116116                                <?php if ( bp_current_user_can( 'bp_xprofile_change_field_visibility' ) ) : ?>
    117117                                        <p class="field-visibility-settings-toggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>">
    118118                                                <?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"><?php _e( 'Change', 'buddypress' ); ?></a>
    119119                                        </p>
    120                                        
     120
    121121                                        <div class="field-visibility-settings" id="field-visibility-settings-<?php bp_the_profile_field_id() ?>">
    122122                                                <fieldset>
    123123                                                        <legend><?php _e( 'Who can see this field?', 'buddypress' ) ?></legend>
    124                                                
     124
    125125                                                        <?php bp_profile_visibility_radio_buttons() ?>
    126                                                
     126
    127127                                                </fieldset>
    128128                                                <a class="field-visibility-settings-close" href="#"><?php _e( 'Close', 'buddypress' ) ?></a>
     
    131131                                        <div class="field-visibility-settings-notoggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>">
    132132                                                <?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?>
    133                                         </div>                 
     133                                        </div>
    134134                                <?php endif ?>
    135135
  • trunk/bp-xprofile/bp-xprofile-classes.php

    r5961 r6070  
    154154                if ( empty( $group_ids ) )
    155155                        return $groups;
    156                
     156
    157157                // Support arrays and comma-separated strings
    158158                $exclude_fields_cs = wp_parse_id_list( $exclude_fields );
    159                
     159
    160160                // Visibility - Handled here so as not to be overridden by sloppy use of the
    161161                // exclude_fields parameter. See bp_xprofile_get_hidden_fields_for_user()
    162162                $exclude_fields_cs = array_merge( $exclude_fields_cs, bp_xprofile_get_hidden_fields_for_user( $user_id ) );
    163                
     163
    164164                $exclude_fields_cs = implode( ',', $exclude_fields_cs );
    165                
     165
    166166                if ( !empty( $exclude_fields_cs ) ) {
    167                         $exclude_fields_sql = $wpdb->prepare( "AND id NOT IN ({$exclude_fields_cs})" ); 
     167                        $exclude_fields_sql = $wpdb->prepare( "AND id NOT IN ({$exclude_fields_cs})" );
    168168                } else {
    169169                        $exclude_fields_sql = '';
     
    231231                                }
    232232                        }
    233                                                                
     233
    234234                        if ( $fetch_visibility_level ) {
    235235                                $fields = self::fetch_visibility_level( $user_id, $fields );
     
    283283                return $wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_groups} SET group_order = %d WHERE id = %d", $position, $field_group_id ) );
    284284        }
    285        
     285
    286286        /**
    287287         * Fetch the field visibility level for the fields returned by the query
     
    295295        function fetch_visibility_level( $user_id, $fields ) {
    296296                global $wpdb, $bp;
    297                
     297
    298298                // Get the user's visibility level preferences
    299299                $visibility_levels = bp_get_user_meta( $user_id, 'bp_xprofile_visibility_levels', true );
    300                
     300
    301301                // Get the admin-set preferences
    302302                $admin_set_levels  = self::fetch_default_visibility_levels();
    303                
     303
    304304                foreach( (array)$fields as $key => $field ) {
    305305                        // Does the admin allow this field to be customized?
    306306                        $allow_custom = !empty( $admin_set_levels[$field->id]['allow_custom'] ) && 'disabled' != $admin_set_levels[$field->id]['allow_custom'];
    307                        
     307
    308308                        // Look to see if the user has set the visibility for this field
    309309                        if ( $allow_custom && isset( $visibility_levels[$field->id] ) ) {
    310310                                $field_visibility = $visibility_levels[$field->id];
    311                         } else {                               
     311                        } else {
    312312                                // If no admin-set default is saved, fall back on a global default
    313313                                $field_visibility = !empty( $admin_set_levels[$field->id]['default'] ) ? $admin_set_levels[$field->id]['default'] : apply_filters( 'bp_xprofile_default_visibility_level', 'public' );
    314314                        }
    315                        
     315
    316316                        $fields[$key]->visibility_level = $field_visibility;
    317317                }
    318                
     318
    319319                return $fields;
    320320        }
    321        
     321
    322322        /**
    323323         * Fetch the admin-set preferences for all fields
     
    330330        function fetch_default_visibility_levels() {
    331331                global $wpdb, $bp;
    332                
     332
    333333                $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' )" ) );
    334                
     334
    335335                // Arrange so that the field id is the key and the visibility level the value
    336336                $default_visibility_levels = array();
    337337                foreach( $levels as $level ) {
    338338                        if ( 'default_visibility' == $level->meta_key ) {
    339                                 $default_visibility_levels[$level->object_id]['default'] = $level->meta_value;         
     339                                $default_visibility_levels[$level->object_id]['default'] = $level->meta_value;
    340340                        } else if ( 'allow_custom_visibility' == $level->meta_key ) {
    341                                 $default_visibility_levels[$level->object_id]['allow_custom'] = $level->meta_value;             
    342                         }
    343                 }
    344                
     341                                $default_visibility_levels[$level->object_id]['allow_custom'] = $level->meta_value;
     342                        }
     343                }
     344
    345345                return $default_visibility_levels;
    346346        }
    347        
     347
    348348        /* ADMIN AREA HTML.
    349349        * TODO: Get this out of here and replace with standard loops
     
    464464                                $this->data          = $this->get_field_data( $user_id );
    465465                        }
    466                        
     466
    467467                        $this->default_visibility = bp_xprofile_get_meta( $id, 'field', 'default_visibility' );
    468                        
     468
    469469                        if ( empty( $this->default_visibility ) ) {
    470470                                $this->default_visibility = 'public';
    471471                        }
    472                        
     472
    473473                        $this->allow_custom_visibility = 'disabled' == bp_xprofile_get_meta( $id, 'field', 'allow_custom_visibility' ) ? 'disabled' : 'allowed';
    474474                }
     
    728728                        }
    729729
    730                         if ( $this->type != $type ) { 
     730                        if ( $this->type != $type ) {
    731731                                $class = 'display: none;';
    732732                        }
    733                        
     733
    734734                        if ( empty( $this->default_visibility ) ) {
    735735                                $this->default_visibility = 'public';
     
    887887
    888888                                                <div id="titlediv">
    889                                                        
     889
    890890                                                        <div id="titlewrap">
    891891                                                                <h3><label for="default-visibility"><?php _e( "Default Visibility", 'buddypress' ); ?></label></h3>
    892892                                                                <ul>
    893893                                                                <?php foreach( bp_xprofile_get_visibility_levels() as $level ) : ?>
    894                                                                         <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> 
     894                                                                        <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>
    895895                                                                <?php endforeach ?>
    896896                                                                </ul>
    897897                                                        </div>
    898                                                        
     898
    899899                                                        <div id="titlewrap">
    900900                                                                <h3><label for="allow-custom-visibility"><?php _e( "Per-Member Visibility", 'buddypress' ); ?></label></h3>
    901901                                                                <ul>
    902902                                                                        <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>
    903                                                                        
     903
    904904                                                                        <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>
    905905                                                                </ul>
    906906                                                        </div>
    907907                                                </div>
    908                                        
     908
    909909                                        <?php endif ?>
    910910
     
    10891089                return $profile_data;
    10901090        }
    1091        
     1091
    10921092        /**
    10931093         * Get the user's field data id by the id of the xprofile field
     
    10991099        function get_fielddataid_byid( $field_id, $user_id ) {
    11001100                global $wpdb, $bp;
    1101                
     1101
    11021102                if ( empty( $field_id ) || empty( $user_id ) ) {
    11031103                        $fielddata_id = 0;
    11041104                } else {
    1105                         $fielddata_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_data} WHERE field_id = %d AND user_id = %d", $field_id, $user_id ) ); 
    1106                 }
    1107                
     1105                        $fielddata_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_data} WHERE field_id = %d AND user_id = %d", $field_id, $user_id ) );
     1106                }
     1107
    11081108                return $fielddata_id;
    11091109        }
  • trunk/bp-xprofile/bp-xprofile-functions.php

    r6060 r6070  
    152152 * @param mixed $field The ID of the field, or the $name of the field.
    153153 * @param int $user_id The ID of the user
    154  * @param string $multi_format How should array data be returned? 'comma' if you want a 
     154 * @param string $multi_format How should array data be returned? 'comma' if you want a
    155155 *   comma-separated string; 'array' if you want an array
    156156 * @uses BP_XProfile_ProfileData::get_value_byid() Fetches the value based on the params passed.
     
    180180                        $data[] = apply_filters( 'xprofile_get_field_data', $value, $field_id, $user_id );
    181181                }
    182                
     182
    183183                if ( 'comma' == $multi_format ) {
    184184                        $data = implode( ', ', $data );
     
    269269                return false;
    270270        }
    271        
     271
    272272        // Check against a whitelist
    273273        $allowed_values = bp_xprofile_get_visibility_levels();
     
    275275                return false;
    276276        }
    277        
     277
    278278        // Stored in an array in usermeta
    279279        $current_visibility_levels = bp_get_user_meta( $user_id, 'bp_xprofile_visibility_levels', true );
    280        
     280
    281281        if ( !$current_visibility_levels ) {
    282282                $current_visibility_levels = array();
    283283        }
    284        
     284
    285285        $current_visibility_levels[$field_id] = $visibility_level;
    286        
     286
    287287        return bp_update_user_meta( $user_id, 'bp_xprofile_visibility_levels', $current_visibility_levels );
    288288}
     
    637637function bp_xprofile_get_visibility_levels() {
    638638        global $bp;
    639        
     639
    640640        return apply_filters( 'bp_xprofile_get_visibility_levels', $bp->profile->visibility_levels );
    641641}
     
    662662                $displayed_user_id = bp_displayed_user_id();
    663663        }
    664        
     664
    665665        if ( !$displayed_user_id ) {
    666666                return array();
    667667        }
    668        
     668
    669669        if ( !$current_user_id ) {
    670670                $current_user_id = bp_loggedin_user_id();
    671671        }
    672        
     672
    673673        // @todo - This is where you'd swap out for current_user_can() checks
    674        
     674
    675675        if ( $current_user_id ) {
    676676                // Current user is logged in
    677677                if ( $displayed_user_id == $current_user_id ) {
    678678                        // If you're viewing your own profile, nothing's private
    679                         $hidden_fields = array();       
    680                        
     679                        $hidden_fields = array();
     680
    681681                } else if ( bp_is_active( 'friends' ) && friends_check_friendship( $displayed_user_id, $current_user_id ) ) {
    682682                        // If the current user and displayed user are friends, show all
    683683                        $hidden_fields = array();
    684                        
     684
    685685                } else {
    686                         // current user is logged-in but not friends, so exclude friends-only   
    687                         $hidden_levels = array( 'friends' );                   
     686                        // current user is logged-in but not friends, so exclude friends-only
     687                        $hidden_levels = array( 'friends' );
    688688                        $hidden_fields = bp_xprofile_get_fields_by_visibility_levels( $displayed_user_id, $hidden_levels );
    689689                }
    690                
     690
    691691        } else {
    692692                // Current user is not logged in, so exclude friends-only and loggedin
     
    694694                $hidden_fields = bp_xprofile_get_fields_by_visibility_levels( $displayed_user_id, $hidden_levels );
    695695        }
    696        
     696
    697697        return apply_filters( 'bp_xprofile_get_hidden_fields_for_user', $hidden_fields, $displayed_user_id, $current_user_id );
    698698}
     
    713713                $levels = (array)$levels;
    714714        }
    715        
     715
    716716        $user_visibility_levels = bp_get_user_meta( $user_id, 'bp_xprofile_visibility_levels', true );
    717717
     
    734734                }
    735735        }
    736        
     736
    737737        // Never allow the fullname field to be excluded
    738738        if ( in_array( 1, $field_ids ) ) {
     
    740740                unset( $field_ids[$key] );
    741741        }
    742        
     742
    743743        return $field_ids;
    744744}
  • trunk/bp-xprofile/bp-xprofile-screens.php

    r5792 r6070  
    114114                                else
    115115                                        do_action( 'xprofile_profile_field_data_updated', $field_id, $value );
    116                                
     116
    117117                                // Save the visibility level
    118118                                $visibility_level = !empty( $_POST['field_' . $field_id . '_visibility'] ) ? $_POST['field_' . $field_id . '_visibility'] : 'public';
  • trunk/bp-xprofile/bp-xprofile-template.php

    r6069 r6070  
    158158        // or this is a registration page
    159159        $hide_empty_fields_default = ( !is_network_admin() && !is_admin() && !bp_is_user_profile_edit() && !bp_is_register_page() );
    160        
     160
    161161        // We only need to fetch visibility levels when viewing your own profile
    162162        if ( bp_is_my_profile() || bp_current_user_can( 'bp_moderate' ) || bp_is_register_page() ) {
     
    165165                $fetch_visibility_level_default = false;
    166166        }
    167        
     167
    168168        $defaults = array(
    169169                'user_id'             => bp_displayed_user_id(),
     
    425425                $defaults = array(
    426426                        'type'                 => false,
    427                         'null_on_required' => false 
     427                        'null_on_required' => false
    428428                );
    429429
     
    730730        function bp_get_the_profile_field_visibility_level() {
    731731                global $field;
    732                
     732
    733733                $retval = !empty( $field->visibility_level ) ? $field->visibility_level : 'public';
    734                
     734
    735735                return apply_filters( 'bp_get_the_profile_field_visibility_level', $retval );
    736736        }
     
    747747        function bp_get_the_profile_field_visibility_level_label() {
    748748                global $field;
    749                
     749
    750750                $level  = !empty( $field->visibility_level ) ? $field->visibility_level : 'public';
    751751                $fields = bp_xprofile_get_visibility_levels();
    752                
     752
    753753                return apply_filters( 'bp_get_the_profile_field_visibility_level_label', $fields[$level]['label'] );
    754754        }
     
    906906         * Return the field visibility radio buttons
    907907         */
    908         function bp_profile_get_visibility_radio_buttons() {           
     908        function bp_profile_get_visibility_radio_buttons() {
    909909                $html = '<ul class="radio">';
    910                
     910
    911911                foreach( bp_xprofile_get_visibility_levels() as $level ) {
    912912                        $checked = $level['id'] == bp_get_the_profile_field_visibility_level() ? ' checked="checked" ' : '';
    913                        
     913
    914914                        $html .= '<li><label for="see-field_' . esc_attr( $level['id'] ) . '"><input type="radio" id="see-field_' . esc_attr( $level['id'] ) . '" name="field_' . bp_get_the_profile_field_id() . '_visibility" value="' . esc_attr( $level['id'] ) . '"' . $checked . ' /> ' . esc_html( $level['label'] ) . '</label></li>';
    915915                }
    916                
     916
    917917                $html .= '</ul>';
    918                
     918
    919919                return apply_filters( 'bp_profile_get_visibility_radio_buttons', $html );
    920920        }
Note: See TracChangeset for help on using the changeset viewer.