Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/10/2012 12:52:16 PM (14 years ago)
Author:
johnjamesjacoby
Message:

Avatars:

  • Clean up avatar code.
  • When uploading a png, use the correct file extension.
  • Fixes #4705.
  • Enqueue Jcrop styling.
File:
1 edited

Legend:

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

    r6395 r6600  
    3737 */
    3838function xprofile_screen_edit_profile() {
    39     global $bp;
    4039
    4140    if ( !bp_is_my_profile() && !bp_current_user_can( 'bp_moderate' ) )
    4241        return false;
     42
     43    $bp = buddypress();
    4344
    4445    // Make sure a group is set.
     
    105106
    106107                // Certain types of fields (checkboxes, multiselects) may come through empty. Save them as an empty array so that they don't get overwritten by the default on the next edit.
    107                 if ( empty( $_POST['field_' . $field_id] ) )
     108                if ( empty( $_POST['field_' . $field_id] ) ) {
    108109                    $value = array();
    109                 else
     110                } else {
    110111                    $value = $_POST['field_' . $field_id];
    111 
    112                 if ( !xprofile_set_field_data( $field_id, bp_displayed_user_id(), $value, $is_required[$field_id] ) )
     112                }
     113
     114                if ( !xprofile_set_field_data( $field_id, bp_displayed_user_id(), $value, $is_required[$field_id] ) ) {
    113115                    $errors = true;
    114                 else
     116                } else {
    115117                    do_action( 'xprofile_profile_field_data_updated', $field_id, $value );
     118                }
    116119
    117120                // Save the visibility level
     
    123126
    124127            // Set the feedback messages
    125             if ( !empty( $errors ) )
     128            if ( !empty( $errors ) ) {
    126129                bp_core_add_message( __( 'There was a problem updating some of your profile information, please try again.', 'buddypress' ), 'error' );
    127             else
     130            } else {
    128131                bp_core_add_message( __( 'Changes saved.', 'buddypress' ) );
     132            }
    129133
    130134            // Redirect back to the edit screen to display the updates and message
     
    145149 */
    146150function xprofile_screen_change_avatar() {
    147     global $bp;
    148 
     151
     152    // Bail if not the correct screen
    149153    if ( !bp_is_my_profile() && !bp_current_user_can( 'bp_moderate' ) )
    150154        return false;
    151155
     156    // Bail if there are action variables
    152157    if ( bp_action_variables() ) {
    153158        bp_do_404();
     
    155160    }
    156161
     162    $bp = buddypress();
     163
    157164    if ( ! isset( $bp->avatar_admin ) )
    158165        $bp->avatar_admin = new stdClass();
     
    180187        check_admin_referer( 'bp_avatar_cropstore' );
    181188
    182         if ( !bp_core_avatar_handle_crop( array( 'item_id' => bp_displayed_user_id(), 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ) )
    183             bp_core_add_message( __( 'There was a problem cropping your avatar, please try uploading it again', 'buddypress' ), 'error' );
    184         else {
    185             bp_core_add_message( __( 'Your new avatar was uploaded successfully!', 'buddypress' ) );
     189        $args = array(
     190            'item_id'       => bp_displayed_user_id(),
     191            'original_file' => $_POST['image_src'],
     192            'crop_x'        => $_POST['x'],
     193            'crop_y'        => $_POST['y'],
     194            'crop_w'        => $_POST['w'],
     195            'crop_h'        => $_POST['h']
     196        );
     197
     198        if ( ! bp_core_avatar_handle_crop( $args ) ) {
     199            bp_core_add_message( __( 'There was a problem cropping your avatar.', 'buddypress' ), 'error' );
     200        } else {
     201            bp_core_add_message( __( 'Your new avatar was uploaded successfully.', 'buddypress' ) );
    186202            do_action( 'xprofile_avatar_uploaded' );
    187203        }
Note: See TracChangeset for help on using the changeset viewer.