Skip to:
Content

BuddyPress.org

Ticket #6612: 6612.03.patch

File 6612.03.patch, 5.1 KB (added by imath, 9 years ago)
  • src/bp-core/bp-core-avatars.php

    diff --git src/bp-core/bp-core-avatars.php src/bp-core/bp-core-avatars.php
    index 98f2a3a..4180784 100644
    function bp_avatar_ajax_upload() { 
    991991        $name_parts = pathinfo( $name );
    992992        $name = trim( substr( $name, 0, - ( 1 + strlen( $name_parts['extension'] ) ) ) );
    993993
    994         if ( 'user' === $bp_params['object'] ) {
    995                 do_action( 'xprofile_avatar_uploaded' );
    996         }
    997 
    998994        // Finally return the avatar to the editor
    999995        bp_attachments_json_response( true, $is_html4, array(
    1000996                'name'      => $name,
    function bp_avatar_handle_capture( $data = '', $item_id = 0 ) { 
    10571053                // Crop to default values
    10581054                $crop_args = array( 'item_id' => $item_id, 'original_file' => $avatar_to_crop, 'crop_x' => 0, 'crop_y' => 0 );
    10591055
    1060                 /**
    1061                  * Fires if the new avatar was successfully captured.
    1062                  *
    1063                  * @since 2.3.0
    1064                  */
    1065                 do_action( 'xprofile_avatar_uploaded' );
    1066 
    10671056                return bp_core_avatar_handle_crop( $crop_args );
    10681057        } else {
    10691058                return false;
    function bp_avatar_ajax_set() { 
    12001189                                'item_id'       => $avatar_data['item_id'],
    12011190                        );
    12021191
    1203                         do_action( 'xprofile_screen_change_avatar' );
     1192                        /**
     1193                         * Fires if the new avatar was successfully captured.
     1194                         *
     1195                         * @since 1.1.0 Used to inform the avatar was successfully cropped
     1196                         * @since 2.3.4 Add two new parameters to inform about the user id and
     1197                         *              about the way the avatar was set (eg: 'crop' or 'camera')
     1198                         *              Move the action at the right place, once the avatar is set
     1199                         *
     1200                         * @param string $item_id Inform about the user id the avatar was set for
     1201                         * @param string $type    Inform about the way the avatar was set ('camera')
     1202                         */
     1203                        do_action( 'xprofile_avatar_uploaded', (int) $avatar_data['item_id'], $avatar_data['type'] );
    12041204
    12051205                        wp_send_json_success( $return );
    12061206                }
    function bp_avatar_ajax_set() { 
    12451245                );
    12461246
    12471247                if ( 'user' === $avatar_data['object'] ) {
    1248                         do_action( 'xprofile_screen_change_avatar' );
     1248                        /**
     1249                         * Fires if the new avatar was successfully cropped.
     1250                         *
     1251                         * @since 1.1.0 Used to inform the avatar was successfully cropped
     1252                         * @since 2.3.4 Add two new parameters to inform about the user id and
     1253                         *              about the way the avatar was set (eg: 'crop' or 'camera')
     1254                         *              Move the action at the right place, once the avatar is set
     1255                         *
     1256                         * @param string $item_id Inform about the user id the avatar was set for
     1257                         * @param string $type Inform about the way the avatar was set ('crop')
     1258                         */
     1259                        do_action( 'xprofile_avatar_uploaded', (int) $avatar_data['item_id'], $avatar_data['type'] );
    12491260                }
    12501261
    12511262                wp_send_json_success( $return );
  • src/bp-xprofile/bp-xprofile-activity.php

    diff --git src/bp-xprofile/bp-xprofile-activity.php src/bp-xprofile/bp-xprofile-activity.php
    index 5cc90f2..b27a0f4 100644
    function xprofile_register_activity_action( $key, $value ) { 
    202202/**
    203203 * Adds an activity stream item when a user has uploaded a new avatar.
    204204 *
    205  * @since BuddyPress (1.0.0)
     205 * @since 1.0.0
     206 * @since 2.3.4 Add new parameter to get the user id the avatar was set for
    206207 *
    207208 * @package BuddyPress XProfile
    208209 * @uses bp_activity_add() Adds an entry to the activity component tables for a
    209210 *                         specific activity
     211 *
     212 * @param  int $user_id The user id the avatar was set for
    210213 */
    211 function bp_xprofile_new_avatar_activity() {
     214function bp_xprofile_new_avatar_activity( $user_id = 0 ) {
    212215
    213216        // Bail if activity component is not active
    214217        if ( ! bp_is_active( 'activity' ) ) {
    215218                return false;
    216219        }
    217220
     221        if ( empty( $user_id ) ) {
     222                $user_id = bp_displayed_user_id();
     223        }
     224
    218225        /**
    219226         * Filters the user ID when a user has uploaded a new avatar.
    220227         *
    221          * @since BuddyPress (1.5.0)
     228         * @since 1.5.0
    222229         *
    223          * @param int $value ID of the displayed user.
     230         * @param int $user_id ID of the user the avatar was set for.
    224231         */
    225         $user_id = apply_filters( 'bp_xprofile_new_avatar_user_id', bp_displayed_user_id() );
     232        $user_id = apply_filters( 'bp_xprofile_new_avatar_user_id', $user_id );
    226233
    227234        // Add the activity
    228235        bp_activity_add( array(
  • src/bp-xprofile/bp-xprofile-screens.php

    diff --git src/bp-xprofile/bp-xprofile-screens.php src/bp-xprofile/bp-xprofile-screens.php
    index afb4604..a78c0e0 100644
    function xprofile_screen_change_avatar() { 
    266266                        /**
    267267                         * Fires right before the redirect, after processing a new avatar.
    268268                         *
    269                          * @since BuddyPress (1.1.0)
     269                         * @since 1.1.0
     270                         * @since 2.3.4 Add two new parameters to inform about the user id and
     271                         *              about the way the avatar was set (eg: 'crop' or 'camera')
     272                         *
     273                         * @param string $item_id Inform about the user id the avatar was set for
     274                         * @param string $value Inform about the way the avatar was set ('crop')
    270275                         */
    271                         do_action( 'xprofile_avatar_uploaded' );
     276                        do_action( 'xprofile_avatar_uploaded', (int) $args['item_id'], 'crop' );
    272277                        bp_core_add_message( __( 'Your new profile photo was uploaded successfully.', 'buddypress' ) );
    273278                        bp_core_redirect( bp_displayed_user_domain() );
    274279                }