Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/23/2008 12:56:37 PM (17 years ago)
Author:
apeatling
Message:

Removed home base requirement

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-avatars.php

    r391 r394  
    1919
    2020function bp_core_get_avatar( $user, $version = 1, $no_tag = false, $width = null, $height = null ) {
     21    global $bp, $current_blog;
     22   
    2123    if ( !is_int($version) )
    2224        $version = (int) $version;
     
    2527        $version = 1;
    2628   
    27     if ( $home_base_id = get_usermeta( $user, 'home_base' ) )
    28         $url = get_blog_option($home_base_id, 'siteurl');
    29        
    3029    if ( !$width )
    3130        $width = constant('CORE_AVATAR_V' . $version . '_W');
     
    3433        $height = constant('CORE_AVATAR_V' . $version . '_H');     
    3534   
    36     $str = get_usermeta( $user, "bp_core_avatar_v$version" );
    37    
    38     if ( strlen($str) ) {
     35
     36    $avatar_file = get_usermeta( $user, "bp_core_avatar_v$version" );
     37    $url = $bp['root_domain'] . '/' . $avatar_file;
     38   
     39    if ( strlen($avatar_file) ) {
    3940        if ( $no_tag )
    40             return $str;
     41            return $url;
    4142        else
    42             return '<img src="' . $url . '/' . $str . '" alt="" class="avatar" width="' . $width . '" height="' . $height . '" />';
     43            return '<img src="' . $url . '" alt="" class="avatar" width="' . $width . '" height="' . $height . '" />';
    4344    } else {
     45        $identicon = 'http://www.gravatar.com/avatar/' . md5( $user . '@buddypress.org') . '?d=wavatar&amp;s=';
    4446        if ( $no_tag )
    45             return CORE_DEFAULT_AVATAR_THUMB;
     47            return $identicon . constant('CORE_AVATAR_V' . $version . '_W');
    4648        else
    47             return '<img src="' . CORE_DEFAULT_AVATAR . '" alt="" class="avatar" width="' . $width . '" height="' . $height . '" />';
     49            return '<img src="' . $identicon . constant('CORE_AVATAR_V' . $version . '_W') . '" alt="" class="avatar" width="' . $width . '" height="' . $height . '" />';
    4850    }
    4951}
     
    7274
    7375// Main UI Rendering
    74 function bp_core_avatar_admin( $message = null, $action = null, $delete_action = null ) {
     76function bp_core_avatar_admin( $message = null ) {
    7577    global $wp_upload_error;
    7678    ?> 
     
    9092       
    9193        <?php
    92         if ( !$action )
    93             $action = site_url() . '/wp-admin/admin.php?page=bp-xprofile.php';
    94        
    95         if ( !$delete_action )
    96             $delete_action = site_url() . '/wp-admin/admin.php?page=bp-xprofile.php&slick_avatars_action=delete';
    97        
     94
    9895        bp_core_render_avatar_upload_form($action);
    9996
     
    132129       
    133130        if ( !bp_core_check_avatar_size($_FILES) )
    134             bp_core_ap_die( 'The file you uploaded is too big. Please upload a file under ' . size_format(1024 * CORE_MAX_FILE_SIZE) );
     131            bp_core_ap_die( 'The file you uploaded is too big. Please upload a file under ' . size_format(CORE_MAX_FILE_SIZE) );
    135132
    136133        if ( !bp_core_check_avatar_type($_FILES) )
     
    148145            $canvas = $original;
    149146       
    150         // Render the cropper UI
    151         if ( !$action )
    152             $action = get_option('home') .'/wp-admin/admin.php?page=bp-xprofile.php';
    153        
     147        // Render the cropper UI       
    154148        bp_core_render_avatar_cropper($original, $canvas, $action);
    155149       
     
    258252        $user_id = $bp['loggedin_userid'];
    259253
    260     if ( !$url ) {
    261         $home_base_id = get_usermeta( $user_id, 'home_base' );
    262         $url = get_blog_option($home_base_id, 'siteurl');
    263     }
    264 
    265     $src = str_replace( array(ABSPATH), array($url . '/'), $new );
     254    $src = str_replace( array(ABSPATH), array(site_url() . '/'), $new );
    266255
    267256    // Load cropper details
     
    401390}
    402391
    403 function bp_core_avatar_save( $vars, $user_id = false, $upload_dir = false, $url = false ) {
     392function bp_core_avatar_save( $vars, $user_id = false ) {
    404393    if ( !$user_id )
    405394        $user_id = get_current_user_id();
    406        
    407     if ( !$url ) {
    408         $home_base_id = get_usermeta( $user_id, 'home_base' );
    409         $url = get_blog_option($home_base_id, 'siteurl');
    410     }
    411395   
    412396    $old = get_usermeta( $user_id, 'bp_core_avatar_v1_path' );
     
    458442function bp_core_ap_die( $msg ) {
    459443    echo '<p><strong>' . $msg . '</strong></p>';
    460     echo '<p><a href="' . get_option('home') .'/wp-admin/admin.php?page=bp-xprofile.php">' . __('Try Again', 'buddypress') . '</a></p>';
     444    echo '<p><a href="' . $bp['loggedin_domain'] . '/' . $bp['profile']['slug'] . '/change-avatar">' . __('Try Again', 'buddypress') . '</a></p>';
    461445    echo '</div>';
    462446    exit;
Note: See TracChangeset for help on using the changeset viewer.