<!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] [3464] trunk: Modifies bp_core_get_site_options()
to fetch options that are blog-specific even when Network is activated.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>3464</dd>
<dt>Author</dt> <dd>boonebgorges</dd>
<dt>Date</dt> <dd>2010-11-21 16:58:53 +0000 (Sun, 21 Nov 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Modifies bp_core_get_site_options() to fetch options that are blog-specific even when Network is activated. Fixes #2756</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcoreadminbpcoreupgradephp">trunk/bp-core/admin/bp-core-upgrade.php</a></li>
<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="#trunkbploaderphp">trunk/bp-loader.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpcoreadminbpcoreupgradephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/admin/bp-core-upgrade.php (3463 => 3464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/admin/bp-core-upgrade.php        2010-11-21 16:06:48 UTC (rev 3463)
+++ trunk/bp-core/admin/bp-core-upgrade.php        2010-11-21 16:58:53 UTC (rev 3464)
</span><span class="lines">@@ -824,7 +824,8 @@
</span><span class="cx">                         // Transfer important settings from blog options to site options
</span><span class="cx">                         $options = array(
</span><span class="cx">                                 'bp-db-version' => $this->current_version,
</span><del>-                                'bp-deactivated-components' => $disabled
</del><ins>+                                'bp-deactivated-components' => $disabled,
+                                'avatar-default' => get_option( 'avatar-default' )
</ins><span class="cx">                         );
</span><span class="cx">                         bp_core_activate_site_options( $options );
</span><span class="cx">
</span></span></pre></div>
<a id="trunkbpcorebpcorecatchuriphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-catchuri.php (3463 => 3464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-catchuri.php        2010-11-21 16:06:48 UTC (rev 3463)
+++ trunk/bp-core/bp-core-catchuri.php        2010-11-21 16:58:53 UTC (rev 3464)
</span><span class="lines">@@ -194,7 +194,7 @@
</span><span class="cx">         $action_variables = $bp_uri;
</span><span class="cx">
</span><span class="cx">         // Remove the username from action variables if this is not a VHOST install
</span><del>-        if ( defined( 'VHOST' ) && 'no' == VHOST && !$is_root_component )
</del><ins>+        if ( defined( 'VHOST' ) && 'no' == VHOST && empty( $is_root_component ) )
</ins><span class="cx">                 array_shift($bp_uri);
</span><span class="cx">
</span><span class="cx">         // Reset the keys by merging with an empty array
</span></span></pre></div>
<a id="trunkbpcorephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core.php (3463 => 3464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core.php        2010-11-21 16:06:48 UTC (rev 3463)
+++ trunk/bp-core.php        2010-11-21 16:58:53 UTC (rev 3464)
</span><span class="lines">@@ -15,10 +15,6 @@
</span><span class="cx"> if ( file_exists( WP_PLUGIN_DIR . '/bp-custom.php' ) )
</span><span class="cx">         require( WP_PLUGIN_DIR . '/bp-custom.php' );
</span><span class="cx">
</span><del>-/* Define on which blog ID BuddyPress should run */
-if ( !defined( 'BP_ROOT_BLOG' ) )
-        define( 'BP_ROOT_BLOG', 1 );
-
</del><span class="cx"> /* Define the user and usermeta table names, useful if you are using custom or shared tables. */
</span><span class="cx"> if ( !defined( 'CUSTOM_USER_TABLE' ) )
</span><span class="cx">         define( 'CUSTOM_USER_TABLE', $wpdb->base_prefix . 'users' );
</span></span></pre></div>
<a id="trunkbploaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-loader.php (3463 => 3464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-loader.php        2010-11-21 16:06:48 UTC (rev 3463)
+++ trunk/bp-loader.php        2010-11-21 16:58:53 UTC (rev 3464)
</span><span class="lines">@@ -12,6 +12,10 @@
</span><span class="cx"> define( 'BP_VERSION', '1.3-bleeding' );
</span><span class="cx"> define( 'BP_DB_VERSION', 1225 );
</span><span class="cx">
</span><ins>+// Define on which blog ID BuddyPress should run
+if ( !defined( 'BP_ROOT_BLOG' ) )
+        define( 'BP_ROOT_BLOG', 1 );
+
</ins><span class="cx"> /***
</span><span class="cx"> * Check if this is the first time BuddyPress has been loaded, or the first time
</span><span class="cx"> * since an upgrade. If so, load the install/upgrade routine only.
</span><span class="lines">@@ -88,7 +92,8 @@
</span><span class="cx"> function bp_core_get_site_options() {
</span><span class="cx">         global $bp, $wpdb;
</span><span class="cx">
</span><del>-        $options = apply_filters( 'bp_core_site_options', array(
</del><ins>+        // These options come from the options table in WP single, and sitemeta in MS
+        $site_options = apply_filters( 'bp_core_site_options', array(
</ins><span class="cx">                 'bp-deactivated-components',
</span><span class="cx">                 'bp-blogs-first-install',
</span><span class="cx">                 'bp-disable-blog-forum-comments',
</span><span class="lines">@@ -102,26 +107,36 @@
</span><span class="cx">                 'bb-config-location',
</span><span class="cx">                 'hide-loggedout-adminbar',
</span><span class="cx">
</span><del>-                /* Useful WordPress settings used often */
-                'user-avatar-default',
</del><ins>+                // Useful WordPress settings used often
</ins><span class="cx">                 'tags_blog_id',
</span><span class="cx">                 'registration',
</span><span class="cx">                 'fileupload_maxk'
</span><span class="cx">         ) );
</span><ins>+        
+        // These options always come from the options table of BP_ROOT_BLOG
+        $root_blog_options = apply_filters( 'bp_core_root_blog_options', array(
+                'avatar_default'
+        ) );
</ins><span class="cx">
</span><del>-        $meta_keys = "'" . implode( "','", (array)$options ) ."'";
</del><ins>+        $meta_keys = "'" . implode( "','", (array)$site_options ) ."'";
</ins><span class="cx">
</span><span class="cx">         if ( is_multisite() )
</span><del>-                $meta = $wpdb->get_results( "SELECT meta_key AS name, meta_value AS value FROM {$wpdb->sitemeta} WHERE meta_key IN ({$meta_keys}) AND site_id = {$wpdb->siteid}" );
</del><ins>+                $site_meta = $wpdb->get_results( "SELECT meta_key AS name, meta_value AS value FROM {$wpdb->sitemeta} WHERE meta_key IN ({$meta_keys}) AND site_id = {$wpdb->siteid}" );
</ins><span class="cx">         else
</span><del>-                $meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" );
</del><ins>+                $site_meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" );
+                
+        $root_blog_meta_keys = "'" . implode( "','", (array)$root_blog_options ) ."'";
+        
+        $root_blog_meta_table = BP_ROOT_BLOG == 1 ? $wpdb->base_prefix . 'options' : $wpdb->base_prefix . BP_ROOT_BLOG . '_options';
+        $root_blog_meta = $wpdb->get_results( $wpdb->prepare( "SELECT option_name AS name, option_value AS value FROM {$root_blog_meta_table} WHERE option_name IN ({$root_blog_meta_keys})" ) );
</ins><span class="cx">
</span><span class="cx">         $site_options = array();
</span><del>-        if ( !empty( $meta ) ) {
-                foreach( (array)$meta as $meta_item )
-                        $site_options[$meta_item->name] = $meta_item->value;
</del><ins>+        foreach( array( $site_meta, $root_blog_meta ) as $meta ) {
+                if ( !empty( $meta ) ) {
+                        foreach( (array)$meta as $meta_item )
+                                $site_options[$meta_item->name] = $meta_item->value;
+                }
</ins><span class="cx">         }
</span><del>-
</del><span class="cx">         return apply_filters( 'bp_core_get_site_options', $site_options );
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>