<!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][5309] trunk: bp-loader.php is a real boy! Introduce BuddyPress class to handle the loading of BuddyPress core and provide declarations to the $bp global variables.</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><a href="http://buddypress.trac.wordpress.org/changeset/5309">5309</a></dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2011-11-08 20:39:23 +0000 (Tue, 08 Nov 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>bp-loader.php is a real boy! Introduce BuddyPress class to handle the loading of BuddyPress core and provide declarations to the $bp global variables. Ports several functions and methods from bbPress 2.0 into bp-core-update.php to manage the hand-off into the update routine. See <a href="http://buddypress.trac.wordpress.org/ticket/3739">#3739</a>.</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="#trunkbpcorebpcorehooksphp">trunk/bp-core/bp-core-hooks.php</a></li>
<li><a href="#trunkbpcorebpcoreloaderphp">trunk/bp-core/bp-core-loader.php</a></li>
<li><a href="#trunkbploaderphp">trunk/bp-loader.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkbpcorebpcoreupdatephp">trunk/bp-core/bp-core-update.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 (5308 => 5309)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/admin/bp-core-update.php        2011-11-08 17:31:09 UTC (rev 5308)
+++ trunk/bp-core/admin/bp-core-update.php        2011-11-08 20:39:23 UTC (rev 5309)
</span><span class="lines">@@ -3,14 +3,40 @@
</span><span class="cx"> if ( !defined( 'ABSPATH' ) ) exit;
</span><span class="cx"> 
</span><span class="cx"> class BP_Core_Setup_Wizard {
</span><ins>+
+        /**
+         * @var int The current step of the updater
+         */
</ins><span class="cx">         var $current_step;
</span><ins>+
+        /**
+         *
+         * @var array The total steps to be completed
+         */
</ins><span class="cx">         var $steps;
</span><span class="cx"> 
</span><del>-        var $database_version;
</del><ins>+        /**
+         * @var int Database version of current BuddyPress files
+         */
+        var $db_version;
+
+        /**
+         * @var int Database version raw from the database connection
+         */
+        var $db_version_raw;
+
+        /**
+         * @var int Are we currently network activated
+         */
</ins><span class="cx">         var $is_network_activate;
</span><del>-        var $new_version;
</del><ins>+
+        /**
+         * @var string What kind of setup/update are we performing
+         */
</ins><span class="cx">         var $setup_type;
</span><span class="cx"> 
</span><ins>+        /** Functions *************************************************************/
+
</ins><span class="cx">         function bp_core_setup_wizard() {
</span><span class="cx">                 $this-&gt;__construct();
</span><span class="cx">         }
</span><span class="lines">@@ -23,7 +49,7 @@
</span><span class="cx">                 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' );
</span><span class="cx"> 
</span><span class="cx">                 // Get current DB version
</span><del>-                $this-&gt;database_version = !empty( $bp-&gt;database_version ) ? (int) $bp-&gt;database_version : 0;
</del><ins>+                $this-&gt;db_version_raw = !empty( $bp-&gt;db_version_raw ) ? (int) $bp-&gt;db_version_raw : 0;
</ins><span class="cx"> 
</span><span class="cx">                 if ( !empty( $bp-&gt;is_network_activate ) ) {
</span><span class="cx">                         $this-&gt;is_network_activate = $bp-&gt;is_network_activate;
</span><span class="lines">@@ -33,7 +59,7 @@
</span><span class="cx">                         $_COOKIE['bp-wizard-step'] = 0;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                $this-&gt;new_version  = constant( 'BP_DB_VERSION' );
</del><ins>+                $this-&gt;db_version   = bp_get_db_version();
</ins><span class="cx">                 $this-&gt;setup_type   = !empty( $bp-&gt;maintenance_mode ) ? $bp-&gt;maintenance_mode : '';
</span><span class="cx">                 $this-&gt;current_step = $this-&gt;current_step();
</span><span class="cx"> 
</span><span class="lines">@@ -81,17 +107,17 @@
</span><span class="cx">                         if ( $this-&gt;is_network_activate )
</span><span class="cx">                                 $steps[] = __( 'Multisite Update', 'buddypress' );
</span><span class="cx"> 
</span><del>-                        if ( $this-&gt;database_version &lt; (int) $this-&gt;new_version )
</del><ins>+                        if ( $this-&gt;db_version_raw &lt; (int) $this-&gt;db_version )
</ins><span class="cx">                                 $steps[] = __( 'Database Update', 'buddypress' );
</span><span class="cx"> 
</span><span class="cx">                         // New for BP 1.5
</span><del>-                        if ( $this-&gt;database_version &lt; 1801 || !bp_core_get_directory_page_ids() ) {
</del><ins>+                        if ( $this-&gt;db_version_raw &lt; 1801 || !bp_core_get_directory_page_ids() ) {
</ins><span class="cx">                                 $steps[] = __( 'Components', 'buddypress' );
</span><span class="cx">                                 $steps[] = __( 'Pages', 'buddypress' );
</span><span class="cx">                         }
</span><span class="cx"> 
</span><span class="cx">                         // New for BP 1.6
</span><del>-                        if ( $this-&gt;database_version &lt; 5222 &amp;&amp; !defined( 'BP_USE_WP_ADMIN_BAR' ) )
</del><ins>+                        if ( $this-&gt;db_version_raw &lt; 5222 &amp;&amp; !defined( 'BP_USE_WP_ADMIN_BAR' ) )
</ins><span class="cx">                                 $steps[] = __( 'Admin Bar', 'buddypress' );
</span><span class="cx"> 
</span><span class="cx">                         $steps[] = __( 'Finish', 'buddypress' );
</span><span class="lines">@@ -804,7 +830,7 @@
</span><span class="cx">                         // Run the schema install to update tables
</span><span class="cx">                         bp_core_install();
</span><span class="cx"> 
</span><del>-                        if ( $this-&gt;database_version &lt; 1801 )
</del><ins>+                        if ( $this-&gt;db_version_raw &lt; 1801 )
</ins><span class="cx">                                 $this-&gt;update_1_5();
</span><span class="cx"> 
</span><span class="cx">                         // Update the active components option early if we're updating
</span><span class="lines">@@ -828,7 +854,7 @@
</span><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'        =&gt; $this-&gt;database_version,
</del><ins>+                                '_bp_db_version'       =&gt; $this-&gt;db_version,
</ins><span class="cx">                                 'bp-active-components' =&gt; $active_components,
</span><span class="cx">                                 'avatar-default'       =&gt; get_option( 'avatar-default' )
</span><span class="cx">                         );
</span><span class="lines">@@ -843,7 +869,6 @@
</span><span class="cx"> 
</span><span class="cx">                                 // Move bp-pages data from the blog options table to site options
</span><span class="cx">                                 $existing_pages        = bp_get_option( 'bp-pages' );
</span><del>-
</del><span class="cx">                                 $bp_pages       = $this-&gt;setup_pages( (array)$_POST['bp_pages'] );
</span><span class="cx">                                 $bp_pages       = array_merge( (array)$existing_pages, (array)$bp_pages );
</span><span class="cx"> 
</span><span class="lines">@@ -855,6 +880,10 @@
</span><span class="cx">                                 bp_core_install( $active_components );
</span><span class="cx">                         }
</span><span class="cx"> 
</span><ins>+                        // Delete the old site option
+                        delete_site_option( 'bp-db-version' );
+
+                        // Update the active components
</ins><span class="cx">                         bp_update_option( 'bp-active-components', $active_components );
</span><span class="cx"> 
</span><span class="cx">                         return true;
</span><span class="lines">@@ -1091,7 +1120,7 @@
</span><span class="cx"> 
</span><span class="cx">                         // Update the DB version in the database
</span><span class="cx">                         // Stored in sitemeta. Do not use bp_update_option()
</span><del>-                        update_site_option( 'bp-db-version', $this-&gt;new_version );
</del><ins>+                        update_site_option( 'bp-db-version', $this-&gt;db_version );
</ins><span class="cx">                         delete_site_option( 'bp-core-db-version' );
</span><span class="cx"> 
</span><span class="cx">                         // Delete the setup cookie
</span></span></pre></div>
<a id="trunkbpcorebpcorefunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-functions.php (5308 => 5309)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-functions.php        2011-11-08 17:31:09 UTC (rev 5308)
+++ trunk/bp-core/bp-core-functions.php        2011-11-08 20:39:23 UTC (rev 5309)
</span><span class="lines">@@ -1,8 +1,62 @@
</span><span class="cx"> &lt;?php
</span><ins>+
+/**
+ * BuddyPress Common Functions
+ *
+ * @package BuddyPress
+ * @subpackage Functions
+ */
+
</ins><span class="cx"> // Exit if accessed directly
</span><span class="cx"> if ( !defined( 'ABSPATH' ) ) exit;
</span><span class="cx"> 
</span><ins>+/** Versions ******************************************************************/
+
</ins><span class="cx"> /**
</span><ins>+ * Output the BuddyPress version
+ *
+ * @since BuddyPress (1.6)
+ * @uses bp_get_version() To get the BuddyPress version
+ */
+function bp_version() {
+        echo bp_get_version();
+}
+        /**
+         * Return the BuddyPress version
+         *
+         * @since BuddyPress (1.6)
+         * @global BuddyPress $bp
+         * @retrun string The BuddyPress version
+         */
+        function bp_get_version() {
+                global $bp;
+                return $bp-&gt;version;
+        }
+
+/**
+ * Output the BuddyPress database version
+ *
+ * @since BuddyPress (1.6)
+ * @uses bp_get_version() To get the BuddyPress version
+ */
+function bp_db_version() {
+        echo bp_get_db_version();
+}
+        /**
+         * Return the BuddyPress database version
+         *
+         * @since BuddyPress (1.6)
+         * @global BuddyPress $bp
+         * @retrun string The BuddyPress version
+         */
+        function bp_get_db_version() {
+                global $bp;
+                return $bp-&gt;db_version;
+        }
+
+/** Functions *****************************************************************/
+
+/**
</ins><span class="cx">  * Retrieve an option
</span><span class="cx">  *
</span><span class="cx">  * This is a wrapper for get_blog_option(), which in turn stores settings data (such as bp-pages)
</span><span class="lines">@@ -1119,6 +1173,7 @@
</span><span class="cx">  * @return bool $is_root_blog Returns true if this is bp_get_root_blog_id().
</span><span class="cx">  */
</span><span class="cx"> function bp_is_root_blog( $blog_id = 0 ) {
</span><ins>+
</ins><span class="cx">         // Assume false
</span><span class="cx">         $is_root_blog = false;
</span><span class="cx"> 
</span><span class="lines">@@ -1139,11 +1194,13 @@
</span><span class="cx">  * @package BuddyPress
</span><span class="cx">  * @since 1.5
</span><span class="cx">  *
</span><del>- * @param int $blog_id Optional. Defaults to the current blog id.
</del><span class="cx">  * @return bool $is_root_blog Returns true if this is bp_get_root_blog_id().
</span><span class="cx">  */
</span><del>-function bp_get_root_blog_id( $blog_id = false ) {
</del><ins>+function bp_get_root_blog_id() {
</ins><span class="cx"> 
</span><ins>+        // Default to 1
+        $root_blog_id = 1;
+
</ins><span class="cx">         // Define on which blog ID BuddyPress should run
</span><span class="cx">         if ( !defined( 'BP_ROOT_BLOG' ) ) {
</span><span class="cx"> 
</span><span class="lines">@@ -1155,10 +1212,6 @@
</span><span class="cx">                 // Root blog is whatever the current site is (could be any site on the network)
</span><span class="cx">                 } elseif ( is_multisite() &amp;&amp; bp_is_multiblog_mode() ) {
</span><span class="cx">                         $root_blog_id = get_current_blog_id();
</span><del>-
-                // Root blog is the only blog on this network
-                } elseif( !is_multisite() ) {
-                        $root_blog_id = 1;
</del><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 define( 'BP_ROOT_BLOG', $root_blog_id );
</span></span></pre></div>
<a id="trunkbpcorebpcorehooksphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-hooks.php (5308 => 5309)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-hooks.php        2011-11-08 17:31:09 UTC (rev 5308)
+++ trunk/bp-core/bp-core-hooks.php        2011-11-08 20:39:23 UTC (rev 5309)
</span><span class="lines">@@ -159,4 +159,39 @@
</span><span class="cx">         do_action( 'bp_screens' );
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/** Activation Actions ********************************************************/
+
+/**
+ * Runs on BuddyPress activation
+ *
+ * @since BuddyPress (1.6)
+ *
+ * @uses do_action() Calls 'bp_activation' hook
+ */
+function bp_activation() {
+        do_action( 'bp_activation' );
+}
+
+/**
+ * Runs on BuddyPress deactivation
+ *
+ * @since BuddyPress (1.6)
+ *
+ * @uses do_action() Calls 'bp_deactivation' hook
+ */
+function bp_deactivation() {
+        do_action( 'bp_deactivation' );
+}
+
+/**
+ * Runs when uninstalling BuddyPress
+ *
+ * @since BuddyPress (1.6)
+ *
+ * @uses do_action() Calls 'bp_uninstall' hook
+ */
+function bp_uninstall() {
+        do_action( 'bp_uninstall' );
+}
+
</ins><span class="cx"> ?&gt;
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpcorebpcoreloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-loader.php (5308 => 5309)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-loader.php        2011-11-08 17:31:09 UTC (rev 5308)
+++ trunk/bp-core/bp-core-loader.php        2011-11-08 20:39:23 UTC (rev 5309)
</span><span class="lines">@@ -6,6 +6,7 @@
</span><span class="cx"> require( BP_PLUGIN_DIR . '/bp-core/bp-core-cache.php'      );
</span><span class="cx"> require( BP_PLUGIN_DIR . '/bp-core/bp-core-hooks.php'      );
</span><span class="cx"> require( BP_PLUGIN_DIR . '/bp-core/bp-core-cssjs.php'      );
</span><ins>+require( BP_PLUGIN_DIR . '/bp-core/bp-core-update.php'     );
</ins><span class="cx"> require( BP_PLUGIN_DIR . '/bp-core/bp-core-classes.php'    );
</span><span class="cx"> require( BP_PLUGIN_DIR . '/bp-core/bp-core-filters.php'    );
</span><span class="cx"> require( BP_PLUGIN_DIR . '/bp-core/bp-core-avatars.php'    );
</span><span class="lines">@@ -29,8 +30,6 @@
</span><span class="cx"> if ( is_multisite() &amp;&amp; $active_components = get_site_option( 'bp-active-components' ) )
</span><span class="cx">         bp_update_option( 'bp-active-components', $active_components );
</span><span class="cx"> 
</span><del>-/** &quot;And now for something completely different&quot; ******************************/
-
</del><span class="cx"> class BP_Core extends BP_Component {
</span><span class="cx"> 
</span><span class="cx">         function __construct() {
</span></span></pre></div>
<a id="trunkbpcorebpcoreupdatephp"></a>
<div class="addfile"><h4>Added: trunk/bp-core/bp-core-update.php (0 => 5309)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-update.php                                (rev 0)
+++ trunk/bp-core/bp-core-update.php        2011-11-08 20:39:23 UTC (rev 5309)
</span><span class="lines">@@ -0,0 +1,145 @@
</span><ins>+&lt;?php
+
+/**
+ * BuddyPress Updater
+ *
+ * @package BuddyPress
+ * @subpackage Updater
+ */
+
+// Exit if accessed directly
+if ( !defined( 'ABSPATH' ) ) exit;
+
+/**
+ * Compare the BuddyPress version to the DB version to determine if updating
+ *
+ * @since BuddyPress (1.6)
+ *
+ * @uses get_option()
+ * @uses bp_get_db_version() To get BuddyPress's database version
+ * @return bool True if update, False if not
+ */
+function bp_is_update() {
+
+        // Current DB version of this site (per site in a multisite network)
+        $current_db   = get_option( '_bp_db_version' );
+        $current_live = bp_get_db_version();
+
+        // Compare versions (cast as int and bool to be safe)
+        $is_update = (bool) ( (int) $current_db &lt; (int) $current_live );
+
+        // Return the product of version comparison
+        return $is_update;
+}
+
+/**
+ * Determine if BuddyPress is being activated
+ *
+ * @since BuddyPress (1.6)
+ *
+ * @global BuddyPress $bp
+ * @return bool True if activating BuddyPress, false if not
+ */
+function bp_is_activation( $basename = '' ) {
+        global $bp;
+
+        // Baif if action or plugin are empty
+        if ( empty( $_GET['action'] ) || empty( $_GET['plugin'] ) )
+                return false;
+
+        // Bail if not activating
+        if ( 'activate' !== $_GET['action'] )
+                return false;
+
+        // The plugin being activated
+        $plugin = isset( $_GET['plugin'] ) ? $_GET['plugin'] : '';
+
+        // Set basename if empty
+        if ( empty( $basename ) &amp;&amp; !empty( $bp-&gt;basename ) )
+                $basename = $bp-&gt;basename;
+
+        // Bail if no basename
+        if ( empty( $basename ) )
+                return false;
+
+        // Bail if plugin is not BuddyPress
+        if ( $basename !== $_GET['plugin'] )
+                return false;
+
+        return true;
+}
+
+/**
+ * Determine if BuddyPress is being deactivated
+ *
+ * @since BuddyPress (1.6)
+ *
+ * @global BuddyPress $bp
+ * @return bool True if deactivating BuddyPress, false if not
+ */
+function bp_is_deactivation( $basename = '' ) {
+        global $bp;
+
+        // Baif if action or plugin are empty
+        if ( empty( $_GET['action'] ) || empty( $_GET['plugin'] ) )
+                return false;
+
+        // Bail if not deactivating
+        if ( 'deactivate' !== $_GET['action'] )
+                return false;
+
+        // The plugin being deactivated
+        $plugin = isset( $_GET['plugin'] ) ? $_GET['plugin'] : '';
+
+        // Set basename if empty
+        if ( empty( $basename ) &amp;&amp; !empty( $bp-&gt;basename ) )
+                $basename = $bp-&gt;basename;
+
+        // Bail if no basename
+        if ( empty( $basename ) )
+                return false;
+
+        // Bail if plugin is not BuddyPress
+        if ( $basename !== $plugin )
+                return false;
+
+        return true;
+}
+
+/**
+ * Update the DB to the latest version
+ *
+ * @since BuddyPress (1.6)
+ *
+ * @uses update_option()
+ * @uses bp_get_db_version() To get BuddyPress's database version
+ */
+function bp_version_bump() {
+        $db_version = bbp_get_db_version();
+        update_option( '_bp_db_version', $db_version );
+}
+
+/**
+ * Setup the BuddyPress updater
+ *
+ * @since BuddyPress (1.6)
+ *
+ * @uses BBP_Updater
+ */
+function bp_setup_updater() {
+
+        // Are we running an outdated version of BuddyPress?
+        if ( bp_is_update() ) {
+
+                // Bump the version
+                bp_version_bump();
+
+                // Run the deactivation function to wipe roles, caps, and rewrite rules
+                bp_deactivation();
+
+                // Run the activation function to reset roles, caps, and rewrite rules
+                bp_activation();
+        }
+}
+
+?&gt;
</ins><span class="cx">Property changes on: trunk/bp-core/bp-core-update.php
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkbploaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-loader.php (5308 => 5309)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-loader.php        2011-11-08 17:31:09 UTC (rev 5308)
+++ trunk/bp-loader.php        2011-11-08 20:39:23 UTC (rev 5309)
</span><span class="lines">@@ -1,11 +1,23 @@
</span><span class="cx"> &lt;?php
</span><ins>+
</ins><span class="cx"> /**
</span><ins>+ * The BuddyPress Plugin
+ *
+ * BuddyPress is social networking software with a twist from the creators of WordPress.
+ *
+ * @package BuddyPress
+ * @subpackage Main
+ */
+
+/**
</ins><span class="cx">  * Plugin Name: BuddyPress
</span><span class="cx">  * Plugin URI:  http://buddypress.org
</span><span class="cx">  * Description: Social networking in a box. Build a social network for your company, school, sports team or niche community all based on the power and flexibility of WordPress.
</span><span class="cx">  * Author:      The BuddyPress Community
</span><ins>+ * Author URI:  http://buddypress.org/community/members/
</ins><span class="cx">  * Version:     1.6-bleeding
</span><del>- * Author URI:  http://buddypress.org/community/members/
</del><ins>+ * Text Domain: buddypress
+ * Domain Path: /bp-languages/
</ins><span class="cx">  * Network:     true
</span><span class="cx">  */
</span><span class="cx"> 
</span><span class="lines">@@ -13,89 +25,420 @@
</span><span class="cx"> if ( !defined( 'ABSPATH' ) ) exit;
</span><span class="cx"> 
</span><span class="cx"> /** Constants *****************************************************************/
</span><del>-global $wpdb;
</del><span class="cx"> 
</span><del>-// Define the BuddyPress version
-if ( !defined( 'BP_VERSION' ) )
-        define( 'BP_VERSION', '1.6-bleeding' );
</del><ins>+if ( !class_exists( 'BuddyPress' ) ) :
+/**
+ * Main BuddyPress Class
+ *
+ * Tap tap tap... Is this thing on?
+ *
+ * @since BuddyPress (1.6)
+ */
+class BuddyPress {
</ins><span class="cx"> 
</span><del>-// Define the database version
-if ( !defined( 'BP_DB_VERSION' ) )
-        define( 'BP_DB_VERSION', 5249 );
</del><ins>+        /**
+         * Note to Plugin and Theme authors:
+         *
+         * Do not directly reference the variables below in your code. Their names
+         * and locations in the BuddyPress class are subject to change at any time.
+         *
+         * Most of them have reference functions located in bp-core-functions.php.
+         * The ones that don't can be accessed via their respective WordPress API's.
+         * 
+         * Components are encouraged to store their data in the $bp global rather
+         * than new globals to keep all BuddyPress data in one place.
+         */
</ins><span class="cx"> 
</span><del>-// Place your custom code (actions/filters) in a file called
-// '/plugins/bp-custom.php' and it will be loaded before anything else.
-if ( file_exists( WP_PLUGIN_DIR . '/bp-custom.php' ) )
-        require( WP_PLUGIN_DIR . '/bp-custom.php' );
</del><ins>+        /** Version ***************************************************************/
</ins><span class="cx"> 
</span><del>-// Define on which blog ID BuddyPress should run
-if ( !defined( 'BP_ROOT_BLOG' ) ) {
</del><ins>+        /**
+         * @var string BuddyPress version
+         */
+        public $version = '1.6-bleeding';
</ins><span class="cx"> 
</span><del>-        // Root blog is the main site on this network
-        if ( is_multisite() &amp;&amp; !defined( 'BP_ENABLE_MULTIBLOG' ) ) {
-                $current_site = get_current_site();
-                $root_blog_id = $current_site-&gt;blog_id;
</del><ins>+        /**
+         * @var int Database version of current BuddyPress files
+         */
+        public $db_version = 5249;
+        
+        /**
+         * @var int Database version raw from database connection
+         */
+        public $db_version_raw = 0;
+        
+        /**
+         * @var string State of BuddyPress installation
+         */
+        public $maintenance_mode = '';
</ins><span class="cx"> 
</span><del>-        // Root blog is every site on this network
-        } elseif ( is_multisite() &amp;&amp; defined( 'BP_ENABLE_MULTIBLOG' ) ) {
-                $root_blog_id = get_current_blog_id();
</del><ins>+        /** Paths *****************************************************************/
</ins><span class="cx"> 
</span><del>-        // Root blog is the only blog on this network
-        } elseif( !is_multisite() ) {
-                $root_blog_id = 1;
</del><ins>+        /**
+         * @var string Basename of the BuddyPress plugin directory
+         */
+        public $basename = '';
+
+        /**
+         * @var string Absolute path to the BuddyPress plugin directory
+         */
+        public $plugin_dir = '';
+
+        /**
+         * @var string Absolute path to the BuddyPress themes directory
+         */
+        public $themes_dir = '';
+
+        /**
+         * @var string Absolute path to the BuddyPress language directory
+         */
+        public $lang_dir = '';
+
+        /** URLs ******************************************************************/
+
+        /**
+         * @var string URL to the BuddyPress plugin directory
+         */
+        public $plugin_url = '';
+
+        /**
+         * @var string URL to the BuddyPress themes directory
+         */
+        public $themes_url = '';
+
+        /** Users *****************************************************************/
+
+        /**
+         * @var object Current user
+         */
+        public $current_user = array();
+
+        /**
+         * @var object Displayed user
+         */
+        public $displayed_user = array();
+
+        /** Errors ****************************************************************/
+
+        /**
+         * @var WP_Error Used to log and display errors
+         */
+        public $errors = array();
+
+        /** Forms *****************************************************************/
+
+        /**
+         * @var int The current tab index for form building
+         */
+        public $tab_index = 0;
+
+        /** Theme Compat **********************************************************/
+
+        /**
+         * @var string Theme to use for theme compatibility
+         */
+        public $theme_compat = '';
+
+        /** Extensions ************************************************************/
+
+        /**
+         * @var mixed BuddyPress add-ons should append globals to this
+         */
+        public $extend = false;
+
+        /** Option Overload *******************************************************/
+
+        /**
+         * @var array Optional Overloads default options retrieved from get_option()
+         */
+        public $options = array();
+
+        /** Permastructs **********************************************************/
+
+        /**
+         * @var string User struct
+         */
+        public $user_id = '';
+
+        /**
+         * @var string Edit struct
+         */
+        public $edit_id = '';
+
+        /** Statuses **************************************************************/
+
+        /**
+         * @var string Public post status id. Used by forums, topics, and replies.
+         */
+        public $public_status_id = '';
+
+        /**
+         * @var string Pending post status id. Used by topics and replies
+         */
+        public $pending_status_id = '';
+
+        /**
+         * @var string Private post status id. Used by forums and topics.
+         */
+        public $private_status_id = '';
+
+        /**
+         * @var string Closed post status id. Used by topics.
+         */
+        public $closed_status_id = '';
+
+        /**
+         * @var string Spam post status id. Used by topics and replies.
+         */
+        public $spam_status_id = '';
+
+        /**
+         * @var string Trash post status id. Used by topics and replies.
+         */
+        public $trash_status_id = '';
+
+        /**
+         * @var string Orphan post status id. Used by topics and replies.
+         */
+        public $orphan_status_id = '';
+
+        /**
+         * @var string Hidden post status id. Used by forums.
+         */
+        public $hidden_status_id = '';
+
+        /** Functions *************************************************************/
+
+        /**
+         * The main BuddyPress loader
+         *
+         * @since BuddyPress (1.6)
+         *
+         * @uses BuddyPress::constants() Setup legacy constants
+         * @uses BuddyPress::setup_globals() Setup globals needed
+         * @uses BuddyPress::includes() Includ required files
+         * @uses BuddyPress::setup_actions() Setup hooks and actions
+         */
+        public function __construct() {
+                $this-&gt;constants();
+                $this-&gt;setup_globals();
+                $this-&gt;includes();
+                $this-&gt;setup_actions();
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        define( 'BP_ROOT_BLOG', $root_blog_id );
-}
</del><ins>+        /**
+         * Legacy BuddyPress constants
+         * 
+         * Try to avoid using these. Their values have been moved into variables
+         * in the $bp global, and have matching functions to get/set their value.
+         *
+         * @since BuddyPress (1.6)
+         *
+         * @uses is_multisite()
+         * @uses get_current_site()
+         * @uses get_current_blog_id()
+         * @uses plugin_dir_path()
+         * @uses plugin_dir_url()
+         */
+        public function constants() {
</ins><span class="cx"> 
</span><del>-// Path and URL
-if ( !defined( 'BP_PLUGIN_DIR' ) )
-        define( 'BP_PLUGIN_DIR', WP_PLUGIN_DIR . '/buddypress' );
</del><ins>+                // Define the BuddyPress version
+                if ( !defined( 'BP_VERSION' ) )
+                        define( 'BP_VERSION', $this-&gt;version );
</ins><span class="cx"> 
</span><del>-if ( !defined( 'BP_PLUGIN_URL' ) )
-        define( 'BP_PLUGIN_URL', plugins_url( 'buddypress' ) );
</del><ins>+                // Define the database version
+                if ( !defined( 'BP_DB_VERSION' ) )
+                        define( 'BP_DB_VERSION', $this-&gt;db_version );
</ins><span class="cx"> 
</span><del>-// The search slug has to be defined nice and early because of the way search requests are loaded
-if ( !defined( 'BP_SEARCH_SLUG' ) )
-        define( 'BP_SEARCH_SLUG', 'search' );
</del><ins>+                // Place your custom code (actions/filters) in a file called
+                // '/plugins/bp-custom.php' and it will be loaded before anything else.
+                if ( file_exists( WP_PLUGIN_DIR . '/bp-custom.php' ) )
+                        require( WP_PLUGIN_DIR . '/bp-custom.php' );
</ins><span class="cx"> 
</span><del>-/** Loader ********************************************************************/
</del><ins>+                // Define on which blog ID BuddyPress should run
+                if ( !defined( 'BP_ROOT_BLOG' ) ) {
</ins><span class="cx"> 
</span><del>-// Load the WP abstraction file so BuddyPress can run on all WordPress setups.
-require( BP_PLUGIN_DIR . '/bp-core/bp-core-wpabstraction.php' );
</del><ins>+                        // Default to 1
+                        $root_blog_id = 1;
+                        
+                        // Root blog is the main site on this network
+                        if ( is_multisite() &amp;&amp; !defined( 'BP_ENABLE_MULTIBLOG' ) ) {
+                                $current_site = get_current_site();
+                                $root_blog_id = $current_site-&gt;blog_id;
</ins><span class="cx"> 
</span><del>-// Test to see whether this is a new installation or an upgraded version of BuddyPress
-if ( !$bp-&gt;database_version = get_site_option( 'bp-db-version' ) ) {
-        if ( $bp-&gt;database_version = get_option( 'bp-db-version' ) ) {
-                $bp-&gt;is_network_activate = 1;
-        } else {
-                $bp-&gt;database_version = get_site_option( 'bp-core-db-version' );  // BP 1.2 option
</del><ins>+                        // Root blog is every site on this network
+                        } elseif ( is_multisite() &amp;&amp; defined( 'BP_ENABLE_MULTIBLOG' ) ) {
+                                $root_blog_id = get_current_blog_id();
+                        }
+
+                        define( 'BP_ROOT_BLOG', $root_blog_id );
+                }
+
+                // Path and URL
+                if ( !defined( 'BP_PLUGIN_DIR' ) )
+                        define( 'BP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
+
+                if ( !defined( 'BP_PLUGIN_URL' ) )
+                        define( 'BP_PLUGIN_URL', plugin_dir_url ( __FILE__ ) );
+
+                // The search slug has to be defined nice and early because of the way
+                // search requests are loaded
+                //
+                // @todo Maxe this better
+                if ( !defined( 'BP_SEARCH_SLUG' ) )
+                        define( 'BP_SEARCH_SLUG', 'search' );        
</ins><span class="cx">         }
</span><del>-}
</del><span class="cx"> 
</span><del>-// This is a new installation.
-if ( empty( $bp-&gt;database_version ) ) {
-        $bp-&gt;maintenance_mode = 'install';
-        require( BP_PLUGIN_DIR . '/bp-core/admin/bp-core-update.php' );
</del><ins>+        /**
+         * Component global variables
+         *
+         * @since BuddyPress (1.6)
+         * @access private
+         *
+         * @uses plugin_dir_path() To generate BuddyPress plugin path
+         * @uses plugin_dir_url() To generate BuddyPress plugin url
+         * @uses apply_filters() Calls various filters
+         */
+        private function setup_globals() {
</ins><span class="cx"> 
</span><del>-// There is a previous installation
-} else {
</del><ins>+                /** Paths *************************************************************/
</ins><span class="cx"> 
</span><del>-        // Setup the BuddyPress theme directory
-        register_theme_directory( BP_PLUGIN_DIR . '/bp-themes' );
</del><ins>+                // BuddyPress root directory
+                $this-&gt;file       = __FILE__;
+                $this-&gt;basename   = plugin_basename( $this-&gt;file );
+                $this-&gt;plugin_dir = plugin_dir_path( $this-&gt;file );
+                $this-&gt;plugin_url = plugin_dir_url ( $this-&gt;file );
</ins><span class="cx"> 
</span><del>-        // Load core
-        require( BP_PLUGIN_DIR . '/bp-core/bp-core-loader.php' );
</del><ins>+                // Themes
+                $this-&gt;themes_dir = $this-&gt;plugin_dir . 'bp-themes';
+                $this-&gt;themes_url = $this-&gt;plugin_url . 'bp-themes';
</ins><span class="cx"> 
</span><del>-        // Check if an update is required
-        if ( (int)$bp-&gt;database_version &lt; (int)constant( 'BP_DB_VERSION' ) || isset( $bp-&gt;is_network_activate ) ) {
-                $bp-&gt;maintenance_mode = 'update';
-                require( BP_PLUGIN_DIR . '/bp-core/admin/bp-core-update.php' );
</del><ins>+                // Languages
+                $this-&gt;lang_dir   = $this-&gt;plugin_dir . 'bp-languages';
+
+                /** Identifiers *******************************************************/
+
+                // Status identifiers
+                $this-&gt;spam_status_id     = apply_filters( 'bp_spam_post_status',    'spam'    );
+                $this-&gt;closed_status_id   = apply_filters( 'bp_closed_post_status',  'closed'  );
+                $this-&gt;orphan_status_id   = apply_filters( 'bp_orphan_post_status',  'orphan'  );
+                $this-&gt;public_status_id   = apply_filters( 'bp_public_post_status',  'publish' );
+                $this-&gt;pending_status_id  = apply_filters( 'bp_pending_post_status', 'pending' );
+                $this-&gt;private_status_id  = apply_filters( 'bp_private_post_status', 'private' );
+                $this-&gt;hidden_status_id   = apply_filters( 'bp_hidden_post_status',  'hidden'  );
+                $this-&gt;trash_status_id    = apply_filters( 'bp_trash_post_status',   'trash'   );
+
+                // Other identifiers
+                $this-&gt;user_id            = apply_filters( 'bp_user_id', 'bp_user' );
+                $this-&gt;edit_id            = apply_filters( 'bp_edit_id', 'edit'     );
+
+                /** Misc **************************************************************/
+
+                // Errors
+                $this-&gt;errors             = new WP_Error();
+
+                // Tab Index
+                $this-&gt;tab_index          = apply_filters( 'bp_default_tab_index', 100 );
</ins><span class="cx">         }
</span><ins>+
+        /**
+         * Include required files
+         *
+         * @since BuddyPress (1.6)
+         * @access private
+         *
+         * @uses is_admin() If in WordPress admin, load additional file
+         */
+        private function includes() {
+
+                // Load the WP abstraction file so BuddyPress can run on all WordPress setups.
+                require( BP_PLUGIN_DIR . '/bp-core/bp-core-wpabstraction.php' );
+
+                // Get the possible DB versions
+                $versions               = array();
+                $versions['1.2']        = get_site_option( 'bp-core-db-version' );
+                $versions['1.5-single'] = get_site_option( 'bp-db-version'      );
+                $versions['1.5-multi']  = get_option     ( 'bp-db-version'      );
+                $versions['1.6']        = get_option     ( '_bp_db_version'     );
+
+                // Remove empty array items
+                $versions = array_filter( $versions );
+
+                // Get the largest version
+                $this-&gt;db_version_raw      = (int) max( $versions );
+
+                // Are we network activated?
+                $this-&gt;is_network_activate = !empty( $versions['1.5-multi'] );
+                        
+                // This is a new installation
+                if ( empty( $this-&gt;db_version_raw ) ) {
+                        $this-&gt;maintenance_mode = 'install';
+                        require( $this-&gt;plugin_dir . '/bp-core/admin/bp-core-update.php' );
+
+                // There is a previous installation
+                } else {
+
+                        // Setup the BuddyPress theme directory
+                        register_theme_directory( $this-&gt;themes_dir );
+
+                        // Load core
+                        require( $this-&gt;plugin_dir . '/bp-core/bp-core-loader.php' );
+
+                        // Check if an update is required
+                        if ( (int) $this-&gt;db_version_raw &lt; (int) $this-&gt;db_version || ( !empty( $this-&gt;is_network_activate ) ) ) {
+                                $this-&gt;maintenance_mode = 'update';
+                                require( $this-&gt;plugin_dir . '/bp-core/admin/bp-core-update.php' );
+                        }
+                }                
+        }
+
+        /**
+         * Setup the default hooks and actions
+         *
+         * @since BuddyPress (1.6)
+         * @access private
+         *
+         * @uses register_activation_hook() To register the activation hook
+         * @uses register_deactivation_hook() To register the deactivation hook
+         * @uses add_action() To add various actions
+         */
+        private function setup_actions() {
+
+                // Add actions to plugin activation and deactivation hooks
+                add_action( 'activate_'   . $this-&gt;basename, 'bp_activation'   );
+                add_action( 'deactivate_' . $this-&gt;basename, 'bp_deactivation' );
+
+                // If BuddyPress is being deactivated, do not add any actions
+                if ( bp_is_deactivation( $this-&gt;basename ) )
+                        return;
+
+                // Array of BuddyPress core actions
+                $actions = array(
+                        'setup_current_user',       // Setup currently logged in user
+                        'register_post_types',      // Register post types
+                        'register_post_statuses',   // Register post statuses
+                        'register_taxonomies',      // Register taxonomies
+                        'register_views',           // Register the views
+                        'register_theme_directory', // Register the theme directory
+                        'load_textdomain',          // Load textdomain
+                        'add_rewrite_tags',         // Add rewrite tags
+                        'generate_rewrite_rules'    // Generate rewrite rules
+                );
+
+                // Add the actions
+                foreach( $actions as $class_action )
+                        add_action( 'bp_' . $class_action, array( $this, $class_action ), 5 );
+        }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// &quot;And now for something completely different&quot;
+$_GLOBALS['bp'] = new BuddyPress;
+
+endif;
+
</ins><span class="cx"> /** Activation ****************************************************************/
</span><span class="cx"> 
</span><ins>+// @todo Move this code into bp-core-update.php
+
</ins><span class="cx"> if ( !function_exists( 'bp_loader_activate' ) ) :
</span><span class="cx"> /**
</span><span class="cx">  * Defines BP's activation routine.
</span></span></pre>
</div>
</div>

</body>
</html>