<!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] [1887] trunk: Fixes for subdirectory WPMU installations.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>1887</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2009-09-16 19:46:47 +0000 (Wed, 16 Sep 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fixes for subdirectory WPMU installations.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcorebpcorecatchuriphp">trunk/bp-core/bp-core-catchuri.php</a></li>
<li><a href="#trunkbpcorephp">trunk/bp-core.php</a></li>
<li><a href="#trunkbpforumsbpforumsbbpressphp">trunk/bp-forums/bp-forums-bbpress.php</a></li>
<li><a href="#trunkbpforumsbpforumstemplatetagsphp">trunk/bp-forums/bp-forums-templatetags.php</a></li>
<li><a href="#trunkbpforumsphp">trunk/bp-forums.php</a></li>
<li><a href="#trunkbpthemesbpsnparentdirectoriesforumsforumsloopphp">trunk/bp-themes/bp-sn-parent/directories/forums/forums-loop.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpcorebpcorecatchuriphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-catchuri.php (1886 => 1887)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-catchuri.php        2009-09-16 14:11:08 UTC (rev 1886)
+++ trunk/bp-core/bp-core-catchuri.php        2009-09-16 19:46:47 UTC (rev 1887)
</span><span class="lines">@@ -54,8 +54,8 @@
</span><span class="cx">         $bp_uri = explode( &quot;/&quot;, $path );
</span><span class="cx"> 
</span><span class="cx">         /* Loop and remove empties */
</span><del>-        for ( $i = 0; $i &lt;= count( $bp_uri ); $i++ )
-                if ( empty( $bp_uri[$i] ) ) unset( $bp_uri[$i] );
</del><ins>+        foreach ( (array)$bp_uri as $key =&gt; $uri_chunk )
+                if ( empty( $bp_uri[$key] ) ) unset( $bp_uri[$key] );
</ins><span class="cx"> 
</span><span class="cx">         if ( defined( 'BP_ENABLE_MULTIBLOG' ) || 1 != BP_ROOT_BLOG ) {
</span><span class="cx">                 /* If we are running BuddyPress on any blog, not just a root blog, we need to first
</span><span class="lines">@@ -63,10 +63,6 @@
</span><span class="cx">                 if ( $current_blog-&gt;path != '/' )
</span><span class="cx">                         array_shift( $bp_uri );
</span><span class="cx">         }
</span><del>-
-        /* Get total URI segment count */
-        $bp_uri_count = count( $bp_uri ) - 1;
-        $is_member_page = false;
</del><span class="cx">         
</span><span class="cx">         /* Set the indexes, these are incresed by one if we are not on a VHOST install */
</span><span class="cx">         $component_index = 0;
</span><span class="lines">@@ -87,9 +83,9 @@
</span><span class="cx">         if ( empty( $paths[0] ) )
</span><span class="cx">                 array_shift( $paths );
</span><span class="cx"> 
</span><del>-        for ( $i = 0; $i &lt; $bp_uri_count; $i++ ) {
-                if ( in_array( $bp_uri[$i], $paths )) {
-                        unset( $bp_uri[$i] );
</del><ins>+        foreach ( (array)$bp_uri as $key =&gt; $uri_chunk ) {
+                if ( in_array( $uri_chunk, $paths )) {
+                        unset( $bp_uri[$key] );
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -104,11 +100,11 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /* Catch a member page and set the current member ID */
</span><del>-        if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) ) {
</del><ins>+        if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) ) {                
</ins><span class="cx">                 if ( ( $bp_uri[0] == BP_MEMBERS_SLUG &amp;&amp; !empty( $bp_uri[1] ) ) || in_array( 'wp-load.php', $bp_uri ) ) {        
</span><span class="cx">                         // We are within a member page, set up user id globals
</span><span class="cx">                         $displayed_user_id = bp_core_get_displayed_userid( $bp_uri[1] );
</span><del>-                                
</del><ins>+
</ins><span class="cx">                         unset($bp_uri[0]);
</span><span class="cx">                         unset($bp_uri[1]);
</span><span class="cx">                 
</span><span class="lines">@@ -205,9 +201,11 @@
</span><span class="cx">         $page = $bp_path;
</span><span class="cx">         
</span><span class="cx">         /* Don't hijack any URLs on blog pages */
</span><del>-        if ( !$bp_skip_blog_check ) {
-                if ( bp_is_blog_page() )
</del><ins>+        if ( bp_is_blog_page() ) {
+                if ( !$bp_skip_blog_check )
</ins><span class="cx">                         return false;
</span><ins>+        } else {
+                $wp_query-&gt;is_home = false;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /* Make sure this is not reported as a 404 */
</span><span class="lines">@@ -254,7 +252,7 @@
</span><span class="cx"> 
</span><span class="cx">         if ( !$bp_path &amp;&amp; !bp_is_blog_page() ) {
</span><span class="cx">                 if ( is_user_logged_in() ) {
</span><del>-                        wp_redirect( $bp-&gt;loggedin_user-&gt;domain );
</del><ins>+                        wp_redirect( $bp-&gt;root_domain );
</ins><span class="cx">                 } else {
</span><span class="cx">                         wp_redirect( site_url( 'wp-login.php?redirect_to=' . site_url() . $_SERVER['REQUEST_URI'] ) );
</span><span class="cx">                 }
</span></span></pre></div>
<a id="trunkbpcorephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core.php (1886 => 1887)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core.php        2009-09-16 14:11:08 UTC (rev 1886)
+++ trunk/bp-core.php        2009-09-16 19:46:47 UTC (rev 1887)
</span><span class="lines">@@ -387,7 +387,7 @@
</span><span class="cx"> function bp_core_action_directory_members() {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><del>-        if ( !is_home() &amp;&amp; is_null( $bp-&gt;displayed_user-&gt;id ) &amp;&amp; $bp-&gt;current_component == BP_MEMBERS_SLUG ) {
</del><ins>+        if ( is_null( $bp-&gt;displayed_user-&gt;id ) &amp;&amp; $bp-&gt;current_component == BP_MEMBERS_SLUG ) {
</ins><span class="cx">                 $bp-&gt;is_directory = true;
</span><span class="cx"> 
</span><span class="cx">                 do_action( 'bp_core_action_directory_members' );
</span></span></pre></div>
<a id="trunkbpforumsbpforumsbbpressphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-forums/bp-forums-bbpress.php (1886 => 1887)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-forums/bp-forums-bbpress.php        2009-09-16 14:11:08 UTC (rev 1886)
+++ trunk/bp-forums/bp-forums-bbpress.php        2009-09-16 19:46:47 UTC (rev 1887)
</span><span class="lines">@@ -66,9 +66,8 @@
</span><span class="cx">         /* This must be loaded before functionss.bb-admin.php otherwise we get a function conflict. */
</span><span class="cx">         if ( !$tables_installed = (boolean) $bbdb-&gt;get_results( 'DESCRIBE `' . $bbdb-&gt;forums . '`;', ARRAY_A ) )
</span><span class="cx">                 require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
</span><del>-                
</del><ins>+        
</ins><span class="cx">         require_once( BB_PATH . 'bb-admin/includes/functions.bb-admin.php' );
</span><del>-
</del><span class="cx">         
</span><span class="cx">         if ( is_object( $wp_roles ) ) {
</span><span class="cx">                 $bb_roles =&amp; $wp_roles;
</span><span class="lines">@@ -91,7 +90,6 @@
</span><span class="cx">         if ( !isset( $bb-&gt;site_id ) )
</span><span class="cx">                 $bb-&gt;site_id = BP_ROOT_BLOG;
</span><span class="cx"> 
</span><del>-
</del><span class="cx">         /* Check if the tables are installed, if not, install them */
</span><span class="cx">         if ( !$tables_installed ) {
</span><span class="cx">                 require_once( BB_PATH . 'bb-admin/includes/defaults.bb-schema.php' );
</span></span></pre></div>
<a id="trunkbpforumsbpforumstemplatetagsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-forums/bp-forums-templatetags.php (1886 => 1887)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-forums/bp-forums-templatetags.php        2009-09-16 14:11:08 UTC (rev 1886)
+++ trunk/bp-forums/bp-forums-templatetags.php        2009-09-16 19:46:47 UTC (rev 1887)
</span><span class="lines">@@ -294,7 +294,7 @@
</span><span class="cx"> 
</span><span class="cx">                 return apply_filters( 'bp_get_the_topic_object_name', $forum_template-&gt;topic-&gt;object_name );
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx"> function bp_the_topic_object_slug() {
</span><span class="cx">         echo bp_get_the_topic_object_slug();
</span><span class="cx"> }
</span><span class="lines">@@ -308,10 +308,10 @@
</span><span class="cx">         echo bp_get_the_topic_object_permalink();
</span><span class="cx"> }
</span><span class="cx">         function bp_get_the_topic_object_permalink() {
</span><del>-                global $forum_template;
-                                
</del><ins>+                global $bp, $forum_template;
+                
</ins><span class="cx">                 /* Currently this will only work with group forums, extended support in the future */
</span><del>-                return apply_filters( 'bp_get_the_topic_object_permalink', $bp-&gt;root_domain . '/' . BP_GROUPS_SLUG . '/' . $forum_template-&gt;topic-&gt;object_slug . '/' );
</del><ins>+                return apply_filters( 'bp_get_the_topic_object_permalink', $bp-&gt;root_domain . '/' . BP_GROUPS_SLUG . '/' . $forum_template-&gt;topic-&gt;object_slug . '/forum/' );
</ins><span class="cx">         }
</span><span class="cx">         
</span><span class="cx"> function bp_the_topic_last_poster_name() {
</span><span class="lines">@@ -322,7 +322,7 @@
</span><span class="cx"> 
</span><span class="cx">                 return apply_filters( 'bp_get_the_topic_last_poster_name', bp_core_get_userlink( $forum_template-&gt;topic-&gt;topic_last_poster ) );
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx"> function bp_the_topic_object_avatar( $args = '' ) {
</span><span class="cx">         echo bp_get_the_topic_object_avatar( $args );
</span><span class="cx"> }
</span><span class="lines">@@ -340,7 +340,7 @@
</span><span class="cx"> 
</span><span class="cx">                 return apply_filters( 'bp_get_the_topic_object_avatar', bp_core_fetch_avatar( array( 'item_id' =&gt; $forum_template-&gt;topic-&gt;object_id, 'type' =&gt; $type, 'object' =&gt; 'group', 'width' =&gt; $width, 'height' =&gt; $height ) ) );                 
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx"> function bp_the_topic_last_poster_avatar( $args = '' ) {
</span><span class="cx">         echo bp_get_the_topic_last_poster_avatar( $args );
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkbpforumsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-forums.php (1886 => 1887)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-forums.php        2009-09-16 14:11:08 UTC (rev 1886)
+++ trunk/bp-forums.php        2009-09-16 19:46:47 UTC (rev 1887)
</span><span class="lines">@@ -50,6 +50,11 @@
</span><span class="cx">                 if ( (int) get_site_option( 'bp-disable-forum-directory' ) )
</span><span class="cx">                         return false;
</span><span class="cx">                         
</span><ins>+                if ( !bp_forums_is_installed_correctly() ) {
+                        bp_core_add_message( 'The forums component has not been set up yet.', 'buddypress' );
+                        bp_core_redirect( $bp-&gt;root_domain );
+                }
+                
</ins><span class="cx">                 $bp-&gt;is_directory = true;
</span><span class="cx">                 
</span><span class="cx">                 do_action( 'bbpress_init' ); 
</span></span></pre></div>
<a id="trunkbpthemesbpsnparentdirectoriesforumsforumsloopphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-sn-parent/directories/forums/forums-loop.php (1886 => 1887)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-sn-parent/directories/forums/forums-loop.php        2009-09-16 14:11:08 UTC (rev 1886)
+++ trunk/bp-themes/bp-sn-parent/directories/forums/forums-loop.php        2009-09-16 19:46:47 UTC (rev 1887)
</span><span class="lines">@@ -39,8 +39,8 @@
</span><span class="cx">                                 &lt;?php bp_the_topic_last_poster_name() ?&gt;
</span><span class="cx">                         &lt;/td&gt;
</span><span class="cx">                         &lt;td class=&quot;td-group&quot;&gt;
</span><del>-                                &lt;a href=&quot;&lt;?php bp_the_topic_object_permalink() ?&gt;forum/&quot;&gt;&lt;?php bp_the_topic_object_avatar( 'type=thumb&amp;width=20&amp;height=20' ) ?&gt;&lt;/a&gt; 
-                                &lt;a href=&quot;&lt;?php bp_the_topic_object_permalink() ?&gt;forum/&quot; title=&quot;&lt;?php bp_the_topic_object_name() ?&gt;&quot;&gt;&lt;?php bp_the_topic_object_name() ?&gt;&lt;/a&gt;
</del><ins>+                                &lt;a href=&quot;&lt;?php bp_the_topic_object_permalink() ?&gt;&quot;&gt;&lt;?php bp_the_topic_object_avatar( 'type=thumb&amp;width=20&amp;height=20' ) ?&gt;&lt;/a&gt; 
+                                &lt;a href=&quot;&lt;?php bp_the_topic_object_permalink() ?&gt;&quot; title=&quot;&lt;?php bp_the_topic_object_name() ?&gt;&quot;&gt;&lt;?php bp_the_topic_object_name() ?&gt;&lt;/a&gt;
</ins><span class="cx">                         &lt;/td&gt;
</span><span class="cx">                         &lt;td class=&quot;td-postcount&quot;&gt;
</span><span class="cx">                                 &lt;?php bp_the_topic_total_posts() ?&gt;
</span></span></pre>
</div>
</div>

</body>
</html>