<!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" />
<title>[BuddyPress][4203] trunk: Keeps bp-default from loading during MS upgrade process.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { 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 #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#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>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd>4203</dd>
<dt>Author</dt> <dd>boonebgorges</dd>
<dt>Date</dt> <dd>2011-04-14 13:36:19 +0000 (Thu, 14 Apr 2011)</dd>
</dl>
<h3>Log Message</h3>
<pre>Keeps bp-default from loading during MS upgrade process. Fixes #3015. Refactors parts of the upgrade wizard to make MS upgrades recognize previous installations of BP. Refactors parts of the upgrade wizard to use bp-active-components rather than the deprecated bp-deactivated-components. Ensures that MS upgrades are seen as upgrades rather than new installations.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcoreadminbpcoreupdatephp">trunk/bp-core/admin/bp-core-update.php</a></li>
<li><a href="#trunkbpcorebpcorefunctionsphp">trunk/bp-core/bp-core-functions.php</a></li>
<li><a href="#trunkbploaderphp">trunk/bp-loader.php</a></li>
<li><a href="#trunkbpthemesbpdefaultfunctionsphp">trunk/bp-themes/bp-default/functions.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpcoreadminbpcoreupdatephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/admin/bp-core-update.php (4202 => 4203)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/admin/bp-core-update.php        2011-04-13 19:30:33 UTC (rev 4202)
+++ trunk/bp-core/admin/bp-core-update.php        2011-04-14 13:36:19 UTC (rev 4203)
</span><span class="lines">@@ -252,6 +252,8 @@
</span><span class="cx">                 if ( !current_user_can( 'activate_plugins' ) )
</span><span class="cx">                         return false;
</span><span class="cx">
</span><ins>+                $active_components = get_site_option( 'bp-active-components' );
+
</ins><span class="cx">                 if ( defined( 'BP_BLOGS_SLUG' ) )
</span><span class="cx">                         $blogs_slug = constant( 'BP_BLOGS_SLUG' );
</span><span class="cx">                 else
</span><span class="lines">@@ -276,9 +278,9 @@
</span><span class="cx">                         });
</span><span class="cx">                 </script>
</span><span class="cx">
</span><del>-                <p><?php printf( __( 'BuddyPress has detected a recent change to WordPress Multisite, which allows members of your community to have their own WordPress blogs. You can enable or disable this feature at any time at <a href="%s">Network Options</a>.', 'buddypress' ), admin_url( 'ms-options.php' ) ); ?></p>
</del><ins>+                <p><?php printf( __( 'BuddyPress has detected a recent change to WordPress Multisite, which allows members of your community to have their own WordPress blogs. You can enable or disable this feature at any time at <a href="%s">Network Options</a>.', 'buddypress' ), network_admin_url( 'settings.php' ) ); ?></p>
</ins><span class="cx">
</span><del>-                <p><?php _e( "Please select the WordPress page you would like to use to display the blog directory. You can either choose an existing page or let BuddyPress auto-create a page for you. If you'd like to manually create pages, please go ahead and do that now, you can come back to this step once you are finished.", 'buddypress' ) ?></p>
</del><ins>+                <p><?php __( "Please select the WordPress page you would like to use to display the blog directory. You can either choose an existing page or let BuddyPress auto-create a page for you. If you'd like, you can go to manually create pages now, and return to this step when you are finished.", 'buddypress' ) ?></p>
</ins><span class="cx">
</span><span class="cx">                 <p><strong><?php _e( 'Please Note:', 'buddypress' ) ?></strong> <?php _e( "If you have manually added BuddyPress navigation links in your theme you may need to remove these from your header.php to avoid duplicate links.", 'buddypress' ) ?></p>
</span><span class="cx">
</span><span class="lines">@@ -305,8 +307,8 @@
</span><span class="cx">                                 <h5><?php _e( "Blog Tracking", 'buddypress' ); ?></h5>
</span><span class="cx">
</span><span class="cx">                                 <div class="radio">
</span><del>-                                        <input type="radio" name="bp_components[bp-blogs.php]" value="1"<?php if ( !isset( $disabled_components['bp-blogs.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> &nbsp;
-                                        <input type="radio" name="bp_components[bp-blogs.php]" value="0"<?php if ( isset( $disabled_components['bp-blogs.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
</del><ins>+                                        <input type="radio" name="bp_components[blogs]" value="1"<?php if ( isset( $active_components['blogs'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> &nbsp;
+                                        <input type="radio" name="bp_components[blogs]" value="0"<?php if ( !isset( $active_components['blogs'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
</ins><span class="cx">                                 </div>
</span><span class="cx">
</span><span class="cx">                                 <img src="<?php echo plugins_url( 'buddypress/screenshot-7.gif' ) ?>" alt="Activity Streams" />
</span><span class="lines">@@ -332,10 +334,8 @@
</span><span class="cx">                         return false;
</span><span class="cx">
</span><span class="cx">                 if ( !function_exists( 'bp_core_admin_component_options' ) )
</span><del>-                        require ( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-admin.php' );
</del><ins>+                        require ( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-admin.php' ); ?>
</ins><span class="cx">
</span><del>-                $disabled_components = apply_filters( 'bp_deactivated_components', get_site_option( 'bp-deactivated-components' ) ); ?>
-
</del><span class="cx">                 <p><?php _e( "BuddyPress bundles several individual social components together, each one adding a distinct feature. This first step decides which features are enabled on your site; all features are enabled by default. Don't worry, you can change your mind at any point in the future.", 'buddypress' ); ?></p>
</span><span class="cx">
</span><span class="cx">                 <?php bp_core_admin_component_options(); ?>
</span><span class="lines">@@ -363,8 +363,8 @@
</span><span class="cx">                 else
</span><span class="cx">                         $existing_pages = get_option( 'bp-pages' );
</span><span class="cx">
</span><del>-                // Get disabled components
-                $disabled_components = apply_filters( 'bp_deactivated_components', get_site_option( 'bp-deactivated-components' ) );
</del><ins>+                // Get active components
+                $active_components = apply_filters( 'bp_active_components', get_site_option( 'bp-active-components' ) );
</ins><span class="cx">
</span><span class="cx">                 // Check for defined slugs
</span><span class="cx">                 $members_slug = !empty( $bp->members->slug ) ? $bp->members->slug : __( 'members', 'buddypress' );
</span><span class="lines">@@ -416,7 +416,7 @@
</span><span class="cx">                                 </td>
</span><span class="cx">                         </tr>
</span><span class="cx">
</span><del>-                        <?php if ( !isset( $disabled_components['bp-activity.php'] ) ) : ?>
</del><ins>+                        <?php if ( isset( $active_components['activity'] ) ) : ?>
</ins><span class="cx">
</span><span class="cx">                                 <tr valign="top">
</span><span class="cx">                                         <th scope="row">
</span><span class="lines">@@ -431,7 +431,7 @@
</span><span class="cx">
</span><span class="cx">                         <?php endif; ?>
</span><span class="cx">
</span><del>-                        <?php if ( !isset( $disabled_components['bp-groups.php'] ) ) : ?>
</del><ins>+                        <?php if ( isset( $active_components['groups'] ) ) : ?>
</ins><span class="cx">
</span><span class="cx">                                 <tr valign="top">
</span><span class="cx">                                         <th scope="row">
</span><span class="lines">@@ -446,7 +446,7 @@
</span><span class="cx">
</span><span class="cx">                         <?php endif; ?>
</span><span class="cx">
</span><del>-                        <?php if ( !isset( $disabled_components['bp-forums.php'] ) ) : ?>
</del><ins>+                        <?php if ( isset( $active_components['forums'] ) ) : ?>
</ins><span class="cx">
</span><span class="cx">                                 <tr valign="top">
</span><span class="cx">                                         <th scope="row">
</span><span class="lines">@@ -461,7 +461,7 @@
</span><span class="cx">
</span><span class="cx">                         <?php endif; ?>
</span><span class="cx">
</span><del>-                        <?php if ( is_multisite() && !isset( $disabled_components['bp-blogs.php'] ) ) : ?>
</del><ins>+                        <?php if ( is_multisite() && isset( $active_components['blogs'] ) ) : ?>
</ins><span class="cx">
</span><span class="cx">                                 <tr valign="top">
</span><span class="cx">                                         <th scope="row">
</span><span class="lines">@@ -751,26 +751,20 @@
</span><span class="cx">                 if ( isset( $_POST['submit'] ) ) {
</span><span class="cx">                         check_admin_referer( 'bpwizard_ms_update' );
</span><span class="cx">
</span><del>-                        if ( !$disabled = get_option( 'bp-deactivated-components' ) )
-                                $disabled = array();
</del><ins>+                        if ( !$active_components = get_option( 'bp-active-components' ) )
+                                $active_components = array();
</ins><span class="cx">
</span><span class="cx">                         // Transfer important settings from blog options to site options
</span><span class="cx">                         $options = array(
</span><del>-                                'bp-db-version' => $this->database_version,
-                                'bp-deactivated-components' => $disabled,
-                                'avatar-default' => get_option( 'avatar-default' )
</del><ins>+                                'bp-db-version'                => $this->database_version,
+                                'bp-active-components'        => $active_components,
+                                '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><del>-                        if ( !(int) $_POST['bp_components']['bp-blogs.php'] ) {
-                                if ( empty( $disabled ) ) {
-                                        $disabled = array();
-                                }
</del><ins>+                        if ( isset( $_POST['bp_components']['blogs'] ) ) {
+                                $active_components['blogs'] = 1;
</ins><span class="cx">
</span><del>-                                $disabled['bp-blogs.php'] = 1;
-
-                        } else {
-
</del><span class="cx">                                 // Make sure that the pages are created on the BP_ROOT_BLOG, no matter which Dashboard the setup is being run on
</span><span class="cx">                                 if ( !empty( $wpdb->blogid ) && ( $wpdb->blogid != BP_ROOT_BLOG ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) )
</span><span class="cx">                                         switch_to_blog( BP_ROOT_BLOG );
</span><span class="lines">@@ -784,12 +778,10 @@
</span><span class="cx">                                 if ( !empty( $wpdb->blogid ) && ( $wpdb->blogid != BP_ROOT_BLOG ) && ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) )
</span><span class="cx">                                         restore_current_blog();
</span><span class="cx">
</span><del>-                                unset( $disabled['bp-blogs.php'] );
-
-                                bp_core_install( $disabled );
</del><ins>+                                bp_core_install( $active_components );
</ins><span class="cx">                         }
</span><span class="cx">
</span><del>-                        update_site_option( 'bp-deactivated-components', $disabled );
</del><ins>+                        update_site_option( 'bp-active-components', $active_components );
</ins><span class="cx">
</span><span class="cx">                         return true;
</span><span class="cx">                 }
</span><span class="lines">@@ -1060,39 +1052,39 @@
</span><span class="cx"> }
</span><span class="cx"> add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_core_setup_wizard_init', 7 );
</span><span class="cx">
</span><del>-function bp_core_install( $disabled = false ) {
</del><ins>+function bp_core_install( $active_components = false ) {
</ins><span class="cx">         global $wpdb;
</span><span class="cx">
</span><del>-        if ( empty( $disabled ) )
-                $disabled = apply_filters( 'bp_deactivated_components', get_site_option( 'bp-deactivated-components' ) );
</del><ins>+        if ( empty( $active_components ) )
+                $active_components = apply_filters( 'bp_active_components', get_site_option( 'bp-active-components' ) );
</ins><span class="cx">
</span><span class="cx">         require_once( dirname( __FILE__ ) . '/bp-core-schema.php' );
</span><del>-
</del><ins>+        
</ins><span class="cx">         // Core DB Tables
</span><span class="cx">         bp_core_install_notifications();
</span><span class="cx">
</span><span class="cx">         // Activity Streams
</span><del>-        if ( empty( $disabled['bp-activity.php'] ) )
</del><ins>+        if ( !empty( $active_components['activity'] ) )
</ins><span class="cx">                 bp_core_install_activity_streams();
</span><span class="cx">
</span><span class="cx">         // Friend Connections
</span><del>-        if ( empty( $disabled['bp-friends.php'] ) )
</del><ins>+        if ( !empty( $active_components['friends'] ) )
</ins><span class="cx">                 bp_core_install_friends();
</span><span class="cx">
</span><span class="cx">         // Extensible Groups
</span><del>-        if ( empty( $disabled['bp-groups.php'] ) )
</del><ins>+        if ( !empty( $active_components['groups'] ) )
</ins><span class="cx">                 bp_core_install_groups();
</span><span class="cx">
</span><span class="cx">         // Private Messaging
</span><del>-        if ( empty( $disabled['bp-messages.php'] ) )
</del><ins>+        if ( !empty( $active_components['messages'] ) )
</ins><span class="cx">                 bp_core_install_private_messaging();
</span><span class="cx">
</span><span class="cx">         // Extended Profiles
</span><del>-        if ( empty( $disabled['bp-xprofile.php'] ) )
</del><ins>+        if ( !empty( $active_components['xprofile'] ) )
</ins><span class="cx">                 bp_core_install_extended_profiles();
</span><span class="cx">
</span><span class="cx">         // Only install blog tables if this is a multisite installation
</span><del>-        if ( is_multisite() && empty( $disabled['bp-blogs.php'] ) )
</del><ins>+        if ( is_multisite() && !empty( $active_components['blogs'] ) )
</ins><span class="cx">                 bp_core_install_blog_tracking();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1319,5 +1311,6 @@
</span><span class="cx">         echo '<div class="update-nag">' . $msg . '</div>';
</span><span class="cx"> }
</span><span class="cx"> add_action( 'admin_notices', 'bp_core_update_nag', 5 );
</span><ins>+add_action( 'network_admin_notices', 'bp_core_update_nag', 5 );
</ins><span class="cx">
</span><span class="cx"> ?>
</span></span></pre></div>
<a id="trunkbpcorebpcorefunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-functions.php (4202 => 4203)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-functions.php        2011-04-13 19:30:33 UTC (rev 4202)
+++ trunk/bp-core/bp-core-functions.php        2011-04-14 13:36:19 UTC (rev 4203)
</span><span class="lines">@@ -256,6 +256,10 @@
</span><span class="cx">         // On multisite installs, don't log on a non-root blog
</span><span class="cx">         if ( !bp_is_root_blog() )
</span><span class="cx">                 return;
</span><ins>+                
+        // Don't show these messages during setup or upgrade
+        if ( isset( $bp->maintenence_mode ) )
+                return;
</ins><span class="cx">
</span><span class="cx">         /**
</span><span class="cx">          * Are pretty permalinks enabled?
</span><span class="lines">@@ -941,7 +945,7 @@
</span><span class="cx"> */
</span><span class="cx"> function bp_core_add_root_component( $slug ) {
</span><span class="cx">         global $bp;
</span><del>-
</del><ins>+        
</ins><span class="cx">         if ( empty( $bp->pages ) )
</span><span class="cx">                 $bp->pages = bp_core_get_page_names();
</span><span class="cx">
</span></span></pre></div>
<a id="trunkbploaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-loader.php (4202 => 4203)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-loader.php        2011-04-13 19:30:33 UTC (rev 4202)
+++ trunk/bp-loader.php        2011-04-14 13:36:19 UTC (rev 4203)
</span><span class="lines">@@ -56,8 +56,13 @@
</span><span class="cx"> require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-wpabstraction.php' );
</span><span class="cx">
</span><span class="cx"> // Test to see whether this is a new installation or an upgraded version of BuddyPress
</span><del>-if ( !$bp->database_version = get_site_option( 'bp-db-version' ) )
-        $bp->database_version = get_site_option( 'bp-core-db-version' ); // BP 1.2 option name
</del><ins>+if ( !$bp->database_version = get_site_option( 'bp-db-version' ) ) {
+        if ( $bp->database_version = get_option( 'bp-db-version' ) ) {
+                $bp->is_ms_activate = 1;
+        } else {
+                $bp->database_version = get_site_option( 'bp-core-db-version' ); // BP 1.2 option
+        }
+}
</ins><span class="cx">
</span><span class="cx"> // This is a new installation.
</span><span class="cx"> if ( empty( $bp->database_version ) ) {
</span><span class="lines">@@ -70,7 +75,7 @@
</span><span class="cx">         require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/bp-core-loader.php' );
</span><span class="cx">
</span><span class="cx">         // Check if an update is required
</span><del>-        if ( (int)$bp->database_version < (int)constant( 'BP_DB_VERSION' ) ) {
</del><ins>+        if ( (int)$bp->database_version < (int)constant( 'BP_DB_VERSION' ) || isset( $bp->is_ms_activate ) ) {
</ins><span class="cx">                 $bp->maintenence_mode = 'update';
</span><span class="cx">                 require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-update.php' );
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/functions.php (4202 => 4203)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/functions.php        2011-04-13 19:30:33 UTC (rev 4202)
+++ trunk/bp-themes/bp-default/functions.php        2011-04-14 13:36:19 UTC (rev 4203)
</span><span class="lines">@@ -27,6 +27,9 @@
</span><span class="cx"> * @since 1.2
</span><span class="cx"> */
</span><span class="cx">
</span><ins>+if ( !function_exists( 'bp_is_active' ) )
+        return;
+
</ins><span class="cx"> // If BuddyPress is not activated, switch back to the default WP theme
</span><span class="cx"> if ( !defined( 'BP_VERSION' ) )
</span><span class="cx">         switch_theme( WP_DEFAULT_THEME, WP_DEFAULT_THEME );
</span></span></pre>
</div>
</div>
</body>
</html>