Skip to:
Content

BuddyPress.org

Changeset 1709 for trunk/bp-groups.php


Ignore:
Timestamp:
08/26/2009 06:18:56 PM (15 years ago)
Author:
apeatling
Message:

Updating legacy group avatar support.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups.php

    r1708 r1709  
    7474   
    7575    foreach ( $groups as $group ) {
    76         /* Don't fetch and move gravs */
    77         if ( strpos( $group->avatar_thumb, 'gravatar.com' ) )
     76        /* Don't fetch and move gravs, default images or empties */
     77        if ( empty($group->avatar_thumb) || strpos( $group->avatar_thumb, 'gravatar.com' ) || strpos( $group->avatar_thumb, 'identicon' ) || strpos( $group->avatar_thumb, 'none-thumbnail' ) )
    7878            continue;
    7979
    80         $upload_dir = groups_avatar_upload_dir( $group->id );
    81         $avatar_thumb = str_replace( $bp->root_domain . '/' . basename( WP_CONTENT_DIR ), WP_CONTENT_PATH, $group->avatar_thumb );
    82         $avatar_full = str_replace( $bp->root_domain . '/' . basename( WP_CONTENT_DIR ), WP_CONTENT_PATH, $group->avatar_full );
    83 
    84         copy( $avatar_thumb, $upload_dir['path'] . '/' . basename($avatar_thumb) );
    85         copy( $avatar_full, $upload_dir['path'] . '/' . basename($avatar_full) );
     80        $start = strpos( $group->avatar_thumb, 'blogs.dir' );
     81
     82        if ( false !== $start ) {
     83            $avatar_thumb = WP_CONTENT_DIR . '/' . substr( $group->avatar_thumb, $start, strlen( $group->avatar_thumb ) );
     84            $avatar_full = WP_CONTENT_DIR . '/' . substr( $group->avatar_full, $start, strlen( $group->avatar_full ) );
     85
     86            if ( !file_exists( $avatar_thumb ) || !file_exists( $avatar_full ) )
     87                continue;
     88           
     89            $upload_dir = groups_avatar_upload_dir( $group->id );
     90
     91            copy( $avatar_thumb, $upload_dir['path'] . '/' . basename($avatar_thumb) );
     92            copy( $avatar_full, $upload_dir['path'] . '/' . basename($avatar_full) );
     93        }
    8694    }
    8795   
Note: See TracChangeset for help on using the changeset viewer.