<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[BuddyPress] [1709] trunk: Updating legacy group avatar support.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>1709</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2009-08-26 18:18:56 +0000 (Wed, 26 Aug 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>Updating legacy group avatar support.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcorebpcoreavatarsphp">trunk/bp-core/bp-core-avatars.php</a></li>
<li><a href="#trunkbpgroupsphp">trunk/bp-groups.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpcorebpcoreavatarsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-avatars.php (1708 => 1709)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-avatars.php        2009-08-26 17:34:00 UTC (rev 1708)
+++ trunk/bp-core/bp-core-avatars.php        2009-08-26 18:18:56 UTC (rev 1709)
</span><span class="lines">@@ -124,7 +124,7 @@
</span><span class="cx">         
</span><span class="cx">         if ( $av_dir = opendir( $avatar_folder_dir ) ) {
</span><span class="cx">          while ( false !== ( $avatar_file = readdir($av_dir) ) ) {
</span><del>-                        if ( preg_match( "/{$avatar_name}/", $avatar_file ) || preg_match( "/{$avatar_name}/", $legacy_user_avatar_file ) || preg_match( "/{$avatar_name}/", $legacy_group_avatar_file ) )
</del><ins>+                        if ( preg_match( "/{$avatar_name}/", $avatar_file ) || preg_match( "/{$legacy_user_avatar_name}/", $avatar_file ) || preg_match( "/{$legacy_group_avatar_name}/", $avatar_file ) )
</ins><span class="cx">                                 $avatar_url = $avatar_folder_url . '/' . $avatar_file;
</span><span class="cx">          }
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkbpgroupsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups.php (1708 => 1709)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups.php        2009-08-26 17:34:00 UTC (rev 1708)
+++ trunk/bp-groups.php        2009-08-26 18:18:56 UTC (rev 1709)
</span><span class="lines">@@ -73,16 +73,24 @@
</span><span class="cx">         $groups = groups_get_all();
</span><span class="cx">         
</span><span class="cx">         foreach ( $groups as $group ) {
</span><del>-                /* Don't fetch and move gravs */
-                if ( strpos( $group->avatar_thumb, 'gravatar.com' ) )
</del><ins>+                /* Don't fetch and move gravs, default images or empties */
+                if ( empty($group->avatar_thumb) || strpos( $group->avatar_thumb, 'gravatar.com' ) || strpos( $group->avatar_thumb, 'identicon' ) || strpos( $group->avatar_thumb, 'none-thumbnail' ) )
</ins><span class="cx">                         continue;
</span><span class="cx">
</span><del>-                $upload_dir = groups_avatar_upload_dir( $group->id );
-                $avatar_thumb = str_replace( $bp->root_domain . '/' . basename( WP_CONTENT_DIR ), WP_CONTENT_PATH, $group->avatar_thumb );
-                $avatar_full = str_replace( $bp->root_domain . '/' . basename( WP_CONTENT_DIR ), WP_CONTENT_PATH, $group->avatar_full );
</del><ins>+                $start = strpos( $group->avatar_thumb, 'blogs.dir' );
</ins><span class="cx">
</span><del>-                copy( $avatar_thumb, $upload_dir['path'] . '/' . basename($avatar_thumb) );
-                copy( $avatar_full, $upload_dir['path'] . '/' . basename($avatar_full) );
</del><ins>+                if ( false !== $start ) {
+                        $avatar_thumb = WP_CONTENT_DIR . '/' . substr( $group->avatar_thumb, $start, strlen( $group->avatar_thumb ) );
+                        $avatar_full = WP_CONTENT_DIR . '/' . substr( $group->avatar_full, $start, strlen( $group->avatar_full ) );
+
+                        if ( !file_exists( $avatar_thumb ) || !file_exists( $avatar_full ) )
+                                continue;
+                        
+                        $upload_dir = groups_avatar_upload_dir( $group->id );
+
+                        copy( $avatar_thumb, $upload_dir['path'] . '/' . basename($avatar_thumb) );
+                        copy( $avatar_full, $upload_dir['path'] . '/' . basename($avatar_full) );
+                }
</ins><span class="cx">         }
</span><span class="cx">         
</span><span class="cx">         if ( function_exists('bp_wire_install') )
</span></span></pre>
</div>
</div>
</body>
</html>