Skip to:
Content

BuddyPress.org

Changeset 10189


Ignore:
Timestamp:
10/05/2015 10:12:46 PM (5 years ago)
Author:
imath
Message:

Cover Image: Make sure the directory and component for the object type are set the right way.

See #6570

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-attachments.php

    r10154 r10189  
    917917
    918918    // We need it to carry on
    919     if ( ! empty( $_POST['bp_params' ] ) ) {
    920         $bp_params = bp_parse_args( $_POST['bp_params' ], array(
     919    if ( ! empty( $_POST['bp_params'] ) ) {
     920        $bp_params = bp_parse_args( $_POST['bp_params'], array(
    921921            'object'  => 'user',
    922922            'item_id' => bp_loggedin_user_id(),
     
    939939    $needs_reset = array();
    940940
    941     // Default object data
    942     $object_data = array( 'dir' => 'members', 'component' => 'xprofile' );
    943     if ( 'group' === $bp_params['object'] ) {
     941    // Member's cover image
     942    if ( 'user' === $bp_params['object'] ) {
     943        $object_data = array( 'dir' => 'members', 'component' => 'xprofile' );
     944
     945        if ( ! bp_displayed_user_id() && ! empty( $bp_params['item_id'] ) ) {
     946            $needs_reset = array( 'key' => 'displayed_user', 'value' => $bp->displayed_user );
     947            $bp->displayed_user->id = $bp_params['item_id'];
     948        }
     949
     950    // Group's cover image
     951    } elseif ( 'group' === $bp_params['object'] ) {
    944952        $object_data = array( 'dir' => 'groups', 'component' => 'groups' );
    945953
     
    951959            ) );
    952960        }
    953     } elseif ( 'user' !== $bp_params['object'] ) {
    954         $object_data = apply_filters( 'bp_attachments_cover_image_object_dir', $object_data, $bp_params['object'] );
    955 
    956         if ( ! bp_displayed_user_id() && ! empty( $bp_params['item_id'] ) ) {
    957             $needs_reset = array( 'key' => 'displayed_user', 'value' => $bp->displayed_user );
    958             $bp->displayed_user->id = $bp_params['item_id'];
    959         }
     961
     962    // Other object's cover image
     963    } else {
     964        $object_data = apply_filters( 'bp_attachments_cover_image_object_dir', array(), $bp_params['object'] );
     965    }
     966
     967    // Stop here in case of a missing parameter for the object
     968    if ( empty( $object_data['dir'] ) || empty( $object_data['component'] ) ) {
     969        bp_attachments_json_response( false, $is_html4 );
    960970    }
    961971
Note: See TracChangeset for help on using the changeset viewer.