<!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] [3463] trunk: Adds Upgrade routine for WP MS activation.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>3463</dd>
<dt>Author</dt> <dd>boonebgorges</dd>
<dt>Date</dt> <dd>2010-11-21 16:06:48 +0000 (Sun, 21 Nov 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Adds Upgrade routine for WP MS activation. Fixes #2732. Moves site options loading functions to ensure that they're loaded at activation. Fixes #2717, props DJPaul. Modifies the way that bp-pages data is stored in and fetched from options tables on multisite. References #2518. The only thing this patch does not do is bake pie.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcoreadminbpcoreupgradephp">trunk/bp-core/admin/bp-core-upgrade.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 (3462 => 3463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/admin/bp-core-upgrade.php        2010-11-21 13:30:07 UTC (rev 3462)
+++ trunk/bp-core/admin/bp-core-upgrade.php        2010-11-21 16:06:48 UTC (rev 3463)
</span><span class="lines">@@ -1,19 +1,61 @@
</span><span class="cx"> <?php
</span><span class="cx">
</span><ins>+if ( !defined( 'BP_ROOT_BLOG' ) )
+        define( 'BP_ROOT_BLOG', 1 );
+
</ins><span class="cx"> require_once( dirname( dirname( __FILE__ ) ) . '/bp-core-wpabstraction.php' );
</span><span class="cx">
</span><span class="cx"> register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' );
</span><span class="cx">
</span><ins>+// Install site options on activation
+bp_core_activate_site_options( array( 'bp-disable-account-deletion' => 0, 'bp-disable-avatar-uploads' => 0, 'bp-disable-blogforum-comments' => 0, 'bp-disable-forum-directory' => 0, 'bp-disable-profile-sync' => 0 ) );
+
+/**
+ * bp_core_activate_site_options()
+ *
+ * When switching from single to multisite we need to copy blog options to
+ * site options.
+ *
+ * @package BuddyPress Core
+ */
+function bp_core_activate_site_options( $keys = array() ) {
+        global $bp;
+
+        $bp->site_options = bp_core_get_site_options();
+
+        if ( !empty( $keys ) && is_array( $keys ) ) {
+                $errors = false;
+
+                foreach ( $keys as $key => $default ) {
+                        if ( empty( $bp->site_options[ $key ] ) ) {
+                                $bp->site_options[ $key ] = get_blog_option( BP_ROOT_BLOG, $key, $default );
+
+                                if ( !update_site_option( $key, $bp->site_options[ $key ] ) )
+                                        $errors = true;
+                        }
+                }
+
+                if ( empty( $errors ) )
+                        return true;
+        }
+
+        return false;
+}
+
</ins><span class="cx"> class BP_Core_Setup_Wizard {
</span><span class="cx">         var $current_step;
</span><span class="cx">         var $steps;
</span><span class="cx">
</span><span class="cx">         var $current_version;
</span><ins>+        var $is_network_activate;
</ins><span class="cx">         var $new_version;
</span><span class="cx">         var $setup_type;
</span><span class="cx">
</span><span class="cx">         function bp_core_setup_wizard() {
</span><del>-                $this->current_version = get_site_option( 'bp-db-version' );
</del><ins>+                if ( !$this->current_version = get_site_option( 'bp-db-version' ) )
+                        if ( $this->current_version = get_option( 'bp-db-version' ) )
+                                $this->is_network_activate = true;
+                
</ins><span class="cx">                 $this->new_version = constant( 'BP_DB_VERSION' );
</span><span class="cx">                 $this->setup_type = ( empty( $this->current_version ) && !(int)get_site_option( 'bp-core-db-version' ) ) ? 'new' : 'upgrade';
</span><span class="cx">                 $this->current_step = $this->current_step();
</span><span class="lines">@@ -43,7 +85,7 @@
</span><span class="cx">                 global $wp_rewrite;
</span><span class="cx">
</span><span class="cx">                 if ( 'new' == $this->setup_type ) {
</span><del>-                        /* Setup wizard steps */
</del><ins>+                        // Setup wizard steps
</ins><span class="cx">                         $steps = array(
</span><span class="cx">                                 __( 'Components', 'buddypress' ),
</span><span class="cx">                                 __( 'Pages', 'buddypress' ),
</span><span class="lines">@@ -60,8 +102,13 @@
</span><span class="cx">                                 $steps = array_merge( array(), $steps );
</span><span class="cx">                         }
</span><span class="cx">                 } else {
</span><del>-                        /* Upgrade wizard steps */
-                        $steps[] = __( 'Database Upgrade', 'buddypress' );
</del><ins>+                        // Upgrade wizard steps
+                        
+                        if ( $this->is_network_activate )
+                                $steps[] = __( 'Multisite Upgrade', 'buddypress' );
+                        
+                        if ( $this->current_version < $this->new_version )
+                                $steps[] = __( 'Database Upgrade', 'buddypress' );
</ins><span class="cx">
</span><span class="cx">                         if ( $this->current_version < 1225 )
</span><span class="cx">                                 $steps[] = __( 'Pages', 'buddypress' );
</span><span class="lines">@@ -78,6 +125,12 @@
</span><span class="cx">                         case 'db_upgrade': default:
</span><span class="cx">                                 $result = $this->step_db_upgrade_save();
</span><span class="cx">                                 break;
</span><ins>+                        case 'ms_upgrade': default:
+                                $result = $this->step_ms_upgrade_save();
+                                break;
+                        case 'ms_pages': default:
+                                $result = $this->step_ms_upgrade_save();
+                                break;
</ins><span class="cx">                         case 'components': default:
</span><span class="cx">                                 $result = $this->step_components_save();
</span><span class="cx">                                 break;
</span><span class="lines">@@ -139,6 +192,12 @@
</span><span class="cx">                                                 case __( 'Database Upgrade', 'buddypress'):
</span><span class="cx">                                                         $this->step_db_upgrade();
</span><span class="cx">                                                         break;
</span><ins>+                                                case __( 'Multisite Upgrade', 'buddypress'):
+                                                        $this->step_ms_upgrade();
+                                                        break;
+                                                case __( 'Blog Directory', 'buddypress'):
+                                                        $this->step_ms_upgrade();
+                                                        break;
</ins><span class="cx">                                                 case __( 'Components', 'buddypress'):
</span><span class="cx">                                                         $this->step_components();
</span><span class="cx">                                                         break;
</span><span class="lines">@@ -183,7 +242,81 @@
</span><span class="cx">                 </div>
</span><span class="cx">         <?php
</span><span class="cx">         }
</span><ins>+        
+        function step_ms_upgrade() {
+                if ( !current_user_can( 'activate_plugins' ) )
+                        return false;
</ins><span class="cx">
</span><ins>+                if ( defined( 'BP_BLOGS_SLUG' ) )
+                        $blogs_slug = constant( 'BP_BLOGS_SLUG' );
+                else
+                        $blogs_slug = __( 'blogs', 'buddypress' );
+                
+                if ( !defined( 'BP_ENABLE_MULTIBLOG' ) && is_multisite() )
+                        $existing_pages = get_blog_option( BP_ROOT_BLOG, 'bp-pages' );
+                else
+                        $existing_pages = get_option( 'bp-pages' );
+
+        ?>
+                <div class="prev-next submit clear">
+                        <p><input type="submit" value="<?php _e( 'Save &amp; Next &rarr;', 'buddypress' ) ?>" name="submit" /></p>
+                </div>
+                
+                <p><?php printf( __( 'It looks like you have just activated WordPress Multisite mode, which allows members of your BuddyPress 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>
+                
+                <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>
+
+                <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>
+
+                <table class="form-table">
+
+                        <tr valign="top">
+                                <th scope="row">
+                                        <h5><?php _e( 'Blogs', 'buddypress' ) ?></h5>
+                                        <p><?php _e( 'Displays individual groups as well as a directory of groups.', 'buddypress' ) ?></p>
+                                </th>
+                                <td>
+                                        <p><input type="radio" name="bp_pages[blogs]" value="page" /> <?php _e( 'Use an existing page:', 'buddypress' ) ?> <?php echo wp_dropdown_pages("name=bp-blogs-page&echo=0&show_option_none=".__('- Select -')."&selected=" . $existing_pages['blogs'] ) ?></p>
+                                        <p><input type="radio" name="bp_pages[blogs]" checked="checked" value="<?php echo $blogs_slug ?>" /> <?php _e( 'Automatically create a page at:', 'buddypress' ) ?> <?php echo site_url( $blogs_slug ) ?>/</p>
+                                </td>
+                        </tr>
+                        
+                </table>
+                
+                <p><?php _e( 'Would you like to enable blog tracking, which tracks blog activity across your network?', 'buddypress' ); ?></p>
+                
+                <div class="left-col">
+                        
+                        <div class="component">
+                                <h5><?php _e( "Blog Tracking", 'buddypress' ) ?></h5>
+
+                                <div class="radio">
+                                        <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' ) ?>
+                                </div>
+
+                                <img src="<?php echo plugins_url( 'buddypress/screenshot-7.gif' ) ?>" alt="Activity Streams" />
+                                        <p><?php _e( "Track new blogs, new posts and new comments across your entire blog network.", 'buddypress' ) ?></p>
+                        </div>                
+                </div>
+                
+                <div class="submit clear">
+                        <p><input type="submit" value="<?php _e( 'Save &amp; Next &rarr;', 'buddypress' ) ?>" name="submit" /></p>
+
+                        <input type="hidden" name="save" value="ms_upgrade" />
+                        <input type="hidden" name="step" value="<?php echo esc_attr( $this->current_step ) ?>" />
+                        <?php wp_nonce_field( 'bpwizard_ms_upgrade' ) ?>
+                </div>
+                
+                <script type="text/javascript">
+                        jQuery('select').click( function() {
+                                jQuery(this).parent().children('input').attr( 'checked', 'checked' );
+                        });
+                </script>
+        <?php
+        }
+
+
</ins><span class="cx">         function step_components() {
</span><span class="cx">                 if ( !current_user_can( 'activate_plugins' ) )
</span><span class="cx">                         return false;
</span><span class="lines">@@ -306,7 +439,11 @@
</span><span class="cx">                 if ( !current_user_can( 'activate_plugins' ) )
</span><span class="cx">                         return false;
</span><span class="cx">
</span><del>-                $existing_pages = get_site_option( 'bp-pages' );
</del><ins>+                if ( !defined( 'BP_ENABLE_MULTIBLOG' ) && is_multisite() )
+                        $existing_pages = get_blog_option( BP_ROOT_BLOG, 'bp-pages' );
+                else
+                        $existing_pages = get_option( 'bp-pages' );
+
</ins><span class="cx">                 $disabled_components = apply_filters( 'bp_deactivated_components', get_site_option( 'bp-deactivated-components' ) );
</span><span class="cx">
</span><span class="cx">                 /* Check for defined slugs */
</span><span class="lines">@@ -644,7 +781,6 @@
</span><span class="cx">                         <h2>Upgrade Complete!</h2>
</span><span class="cx">                 <?php endif; ?>
</span><span class="cx">
</span><del>-                <?php?>
</del><span class="cx">                 <p><?php printf( __( "You've now completed all of the %s steps and BuddyPress is ready to be activated. Please hit the 'Finish &amp; Activate' button to complete the %s procedure.", 'buddypress' ), $type, $type ) ?></p>
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -676,6 +812,56 @@
</span><span class="cx">                 return false;
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        function step_ms_upgrade_save() {
+                global $current_blog;
+
+                if ( isset( $_POST['submit'] ) ) {
+                        check_admin_referer( 'bpwizard_ms_upgrade' );
+
+                        if ( !$disabled = get_option( 'bp-deactivated-components' ) )
+                                $disabled = array();
+
+                        // Transfer important settings from blog options to site options
+                        $options = array(
+                                'bp-db-version' => $this->current_version,
+                                'bp-deactivated-components' => $disabled
+                        );
+                        bp_core_activate_site_options( $options );
+
+                        if ( !(int) $_POST['bp_components']['bp-blogs.php'] ) {
+                                if ( !$disabled )
+                                        $disabled = array();
+                                $disabled['bp-blogs.php'] = 1;
+                        } else {
+                                // Make sure that the pages are created on the BP_ROOT_BLOG, no matter which Dashboard the setup is being run on
+                                if ( $current_blog->blog_id != BP_ROOT_BLOG && !defined( 'BP_ENABLE_MULTIBLOG' ) )
+                                        switch_to_blog( BP_ROOT_BLOG );
+        
+                                $existing_pages = get_option( 'bp-pages' );
+
+                                $bp_pages = $this->setup_pages( (array)$_POST['bp_pages'] );
+                                
+                                $bp_pages = array_merge( (array)$existing_pages, (array)$bp_pages );
+        
+                                update_option( 'bp-pages', $bp_pages );
+
+                                if ( $current_blog->blog_id != BP_ROOT_BLOG )
+                                        restore_current_blog();
+                        
+                                unset( $disabled['bp-blogs.php'] );
+                                
+                                bp_core_install( $disabled );
+                        }
+                        
+                        update_site_option( 'bp-deactivated-components', $disabled );
+
+                        return true;
+                }
+
+                return false;
+        }
+
+
</ins><span class="cx">         function step_components_save() {
</span><span class="cx">                 if ( isset( $_POST['submit'] ) && isset( $_POST['bp_components'] ) ) {
</span><span class="cx">                         check_admin_referer( 'bpwizard_components' );
</span><span class="lines">@@ -697,30 +883,28 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         function step_pages_save() {
</span><ins>+                global $current_blog;
+
</ins><span class="cx">                 if ( isset( $_POST['submit'] ) && isset( $_POST['bp_pages'] ) ) {
</span><span class="cx">                         check_admin_referer( 'bpwizard_pages' );
</span><span class="cx">
</span><del>-                        /* Delete any existing pages */
-                        $existing_pages = get_site_option( 'bp-pages' );
</del><ins>+                        // Make sure that the pages are created on the BP_ROOT_BLOG, no matter which Dashboard the setup is being run on
+                        if ( $current_blog->blog_id != BP_ROOT_BLOG && !defined( 'BP_ENABLE_MULTIBLOG' ) )
+                                switch_to_blog( BP_ROOT_BLOG );
</ins><span class="cx">
</span><ins>+                        // Delete any existing pages
+                        $existing_pages = get_option( 'bp-pages' );
+
</ins><span class="cx">                         foreach ( (array)$existing_pages as $page_id )
</span><span class="cx">                                 wp_delete_post( $page_id, true );
</span><span class="cx">
</span><del>-                        // Settings form submitted, now save the settings.
-                        foreach ( (array)$_POST['bp_pages'] as $key => $value ) {
-                                if ( 'page' == $value ) {
-                                        /* Check for the selected page */
-                                        if ( !empty( $_POST['bp-' . $key . '-page'] ) )
-                                                $bp_pages[$key] = (int)$_POST['bp-' . $key . '-page'];
-                                        else
-                                                $bp_pages[$key] = wp_insert_post( array( 'post_title' => ucwords( $key ), 'post_status' => 'publish', 'post_type' => 'page' ) );
-                                } else {
-                                        /* Create a new page */
-                                        $bp_pages[$key] = wp_insert_post( array( 'post_title' => ucwords( $value ), 'post_status' => 'publish', 'post_type' => 'page' ) );
-                                }
-                        }
-                        update_site_option( 'bp-pages', $bp_pages );
</del><ins>+                        $bp_pages = $this->setup_pages( (array)$_POST['bp_pages'] );
</ins><span class="cx">
</span><ins>+                        update_option( 'bp-pages', $bp_pages );
+
+                        if ( $current_blog->blog_id != BP_ROOT_BLOG )
+                                restore_current_blog();
+
</ins><span class="cx">                         return true;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -850,13 +1034,30 @@
</span><span class="cx">                         @setcookie( 'bp-wizard-step', '', time() - 3600, COOKIEPATH );
</span><span class="cx">
</span><span class="cx">                         /* Redirect to the BuddyPress dashboard */
</span><del>-                        wp_redirect( site_url( 'wp-admin/admin.php?page=bp-general-settings' ) );
</del><ins>+                        wp_redirect( admin_url( 'admin.php?page=bp-general-settings' ) );
</ins><span class="cx">
</span><span class="cx">                         return true;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 return false;
</span><span class="cx">         }
</span><ins>+        
+        function setup_pages( $pages ) {
+                foreach ( $pages as $key => $value ) {
+                        if ( 'page' == $value ) {
+                                /* Check for the selected page */
+                                if ( !empty( $_POST['bp-' . $key . '-page'] ) )
+                                        $bp_pages[$key] = (int)$_POST['bp-' . $key . '-page'];
+                                else
+                                        $bp_pages[$key] = wp_insert_post( array( 'post_title' => ucwords( $key ), 'post_status' => 'publish', 'post_type' => 'page' ) );
+                        } else {
+                                /* Create a new page */
+                                $bp_pages[$key] = wp_insert_post( array( 'post_title' => ucwords( $value ), 'post_status' => 'publish', 'post_type' => 'page' ) );
+                        }
+                }
+                
+                return $bp_pages;
+        }
</ins><span class="cx">
</span><span class="cx">         /* Database upgrade methods based on version numbers */
</span><span class="cx">         function upgrade_1_3() {
</span><span class="lines">@@ -1051,7 +1252,7 @@
</span><span class="cx">         if ( !current_user_can( 'activate_plugins' ) )
</span><span class="cx">                 return false;
</span><span class="cx">
</span><del>-        if ( '' == get_site_option( 'bp-db-version' ) && !(int)get_site_option( 'bp-core-db-version' ) )
</del><ins>+        if ( '' == get_site_option( 'bp-db-version' ) && !(int)get_site_option( 'bp-core-db-version' ) && !$bp_wizard->is_network_activate )
</ins><span class="cx">                 $status = __( 'Setup', 'buddypress' );
</span><span class="cx">         else
</span><span class="cx">                 $status = __( 'Upgrade', 'buddypress' );
</span><span class="lines">@@ -1084,5 +1285,4 @@
</span><span class="cx">         </style>
</span><span class="cx"> <?php
</span><span class="cx"> }
</span><del>-
</del><span class="cx"> ?>
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpcorephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core.php (3462 => 3463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core.php        2010-11-21 13:30:07 UTC (rev 3462)
+++ trunk/bp-core.php        2010-11-21 16:06:48 UTC (rev 3463)
</span><span class="lines">@@ -82,6 +82,7 @@
</span><span class="cx">
</span><span class="cx">         // Set up the members id and active components entry
</span><span class="cx">         $bp->members->id = 'members';
</span><ins>+
</ins><span class="cx">         $bp->members->slug = $bp->pages->members->slug;
</span><span class="cx">         $bp->active_components[$bp->members->slug] = $bp->members->id;
</span><span class="cx">
</span><span class="lines">@@ -211,14 +212,43 @@
</span><span class="cx"> }
</span><span class="cx"> add_action( 'bp_setup_globals', 'bp_core_define_slugs' );
</span><span class="cx">
</span><del>-function bp_core_get_page_names() {
-        global $wpdb, $current_blog;
</del><span class="cx">
</span><del>-        if ( defined( 'BP_ENABLE_MULTIBLOG' ) )
-                $page_ids = get_blog_option( $current_blog->blog_id, 'bp-pages' );
-        else
</del><ins>+/**
+ * bp_core_get_page_meta()
+ *
+ * Fetches BP pages from the meta table, depending on setup
+ *
+ * @package BuddyPress Core Core
+ */
+function bp_core_get_page_meta() {
+        if ( !defined( 'BP_ENABLE_MULTIBLOG' ) && is_multisite() )
</ins><span class="cx">                 $page_ids = get_blog_option( BP_ROOT_BLOG, 'bp-pages' );
</span><ins>+        else
+                $page_ids = get_option( 'bp-pages' );
</ins><span class="cx">
</span><ins>+        return $page_ids;
+}
+
+/**
+ * bp_core_update_page_meta()
+ *
+ * Stores BP pages in the meta table, depending on setup
+ *
+ * @package BuddyPress Core Core
+ */
+function bp_core_update_page_meta( $page_ids ) {
+        if ( !defined( 'BP_ENABLE_MULTIBLOG' ) && is_multisite() )
+                update_blog_option( BP_ROOT_BLOG, 'bp-pages', $page_ids );
+        else
+                update_option( 'bp-pages', $page_ids );
+}
+
+
+function bp_core_get_page_names() {
+        global $wpdb;
+
+        $page_ids = bp_core_get_page_meta();
+
</ins><span class="cx">         if ( empty( $page_ids ) )
</span><span class="cx">                 return false;
</span><span class="cx">
</span><span class="lines">@@ -632,7 +662,6 @@
</span><span class="cx"> * eg: http://andy.domain.com/ or http://domain.com/andy/
</span><span class="cx"> *
</span><span class="cx"> * @package BuddyPress Core
</span><del>- * @global $current_blog WordPress global containing information and settings for the current blog being viewed.
</del><span class="cx"> * @uses bp_core_get_userid_from_user_login() Returns the user id for the username passed
</span><span class="cx"> * @return The user id for the user that is currently being displayed, return zero if this is not a user home and just a normal blog.
</span><span class="cx"> */
</span><span class="lines">@@ -1555,55 +1584,6 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * bp_core_get_site_options()
- *
- * BuddyPress uses site options to store configuration settings. Many of these settings are needed
- * at run time. Instead of fetching them all and adding many initial queries to each page load, let's fetch
- * them all in one go.
- *
- * @package BuddyPress Core
- */
-function bp_core_get_site_options() {
-        global $bp, $wpdb;
-
-        $options = apply_filters( 'bp_core_site_options', array(
-                'bp-deactivated-components',
-                'bp-blogs-first-install',
-                'bp-disable-blog-forum-comments',
-                'bp-xprofile-base-group-name',
-                'bp-xprofile-fullname-field-name',
-                'bp-disable-profile-sync',
-                'bp-disable-avatar-uploads',
-                'bp-disable-account-deletion',
-                'bp-disable-forum-directory',
-                'bp-disable-blogforum-comments',
-                'bb-config-location',
-                'hide-loggedout-adminbar',
-
-                // Useful WordPress settings used often
-                'avatar_default',
-                'tags_blog_id',
-                'registration',
-                'fileupload_maxk'
-        ) );
-
-        $meta_keys = "'" . implode( "','", (array)$options ) ."'";
-
-        if ( is_multisite() )
-                $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}" );
-        else
-                $meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" );
-
-        $site_options = array();
-        if ( !empty( $meta ) ) {
-                foreach( (array)$meta as $meta_item )
-                        $site_options[$meta_item->name] = $meta_item->value;
-        }
-
-        return apply_filters( 'bp_core_get_site_options', $site_options );
-}
-
-/**
</del><span class="cx"> * bp_core_redirect()
</span><span class="cx"> *
</span><span class="cx"> * Performs a status safe wp_redirect() that is compatible with bp_catch_uri()
</span><span class="lines">@@ -2163,9 +2143,11 @@
</span><span class="cx">         foreach ( (array)$bp->add_root as $slug )
</span><span class="cx">                 $new_page_ids[$slug] = wp_insert_post( array( 'post_title' => ucwords( $slug ), 'post_status' => 'publish', 'post_type' => 'page' ) );
</span><span class="cx">
</span><del>-        $page_ids = get_site_option( 'bp-pages' );
</del><ins>+        $page_ids = bp_core_get_page_meta();
+
</ins><span class="cx">         $page_ids = (array) $page_ids;
</span><span class="cx">         $page_ids = array_merge( (array) $new_page_ids, (array) $page_ids );
</span><del>-        update_site_option( 'bp-pages', $page_ids );
</del><ins>+
+        bp_core_update_page_meta( $page_ids );
</ins><span class="cx"> }
</span><span class="cx"> ?>
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbploaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-loader.php (3462 => 3463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-loader.php        2010-11-21 13:30:07 UTC (rev 3462)
+++ trunk/bp-loader.php        2010-11-21 16:06:48 UTC (rev 3463)
</span><span class="lines">@@ -76,6 +76,55 @@
</span><span class="cx">         do_action( 'bp_loaded' );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/**
+ * bp_core_get_site_options()
+ *
+ * BuddyPress uses site options to store configuration settings. Many of these settings are needed
+ * at run time. Instead of fetching them all and adding many initial queries to each page load, let's fetch
+ * them all in one go.
+ *
+ * @package BuddyPress Core
+ */
+function bp_core_get_site_options() {
+        global $bp, $wpdb;
+
+        $options = apply_filters( 'bp_core_site_options', array(
+                'bp-deactivated-components',
+                'bp-blogs-first-install',
+                'bp-disable-blog-forum-comments',
+                'bp-xprofile-base-group-name',
+                'bp-xprofile-fullname-field-name',
+                'bp-disable-profile-sync',
+                'bp-disable-avatar-uploads',
+                'bp-disable-account-deletion',
+                'bp-disable-forum-directory',
+                'bp-disable-blogforum-comments',
+                'bb-config-location',
+                'hide-loggedout-adminbar',
+
+                /* Useful WordPress settings used often */
+                'user-avatar-default',
+                'tags_blog_id',
+                'registration',
+                'fileupload_maxk'
+        ) );
+
+        $meta_keys = "'" . implode( "','", (array)$options ) ."'";
+
+        if ( is_multisite() )
+                $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}" );
+        else
+                $meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" );
+
+        $site_options = array();
+        if ( !empty( $meta ) ) {
+                foreach( (array)$meta as $meta_item )
+                        $site_options[$meta_item->name] = $meta_item->value;
+        }
+
+        return apply_filters( 'bp_core_get_site_options', $site_options );
+}
+
</ins><span class="cx"> /* Activation Function */
</span><span class="cx"> function bp_loader_activate() {
</span><span class="cx">         /* Force refresh theme roots. */
</span><span class="lines">@@ -85,10 +134,6 @@
</span><span class="cx">         if ( 'bp-sn-parent' == get_blog_option( BP_ROOT_BLOG, 'template' ) && 'bp-default' == get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) )
</span><span class="cx">                 switch_theme( 'bp-default', 'bp-default' );
</span><span class="cx">
</span><del>-        /* Install site options on activation */
-        //TODO: Find where to put this back. Here is no good because bp-core.php isn't loaded on new installation.
-        //bp_core_activate_site_options( array( 'bp-disable-account-deletion' => 0, 'bp-disable-avatar-uploads' => 0, 'bp-disable-blogforum-comments' => 0, 'bp-disable-forum-directory' => 0, 'bp-disable-profile-sync' => 0 ) );
-
</del><span class="cx">         do_action( 'bp_loader_activate' );
</span><span class="cx"> }
</span><span class="cx"> register_activation_hook( 'buddypress/bp-loader.php', 'bp_loader_activate' );
</span><span class="lines">@@ -107,7 +152,6 @@
</span><span class="cx">         delete_site_option( 'bp-xprofile-db-version' );
</span><span class="cx">         delete_site_option( 'bp-deactivated-components' );
</span><span class="cx">         delete_site_option( 'bp-blogs-first-install' );
</span><del>-        delete_site_option( 'bp-pages' );
</del><span class="cx">
</span><span class="cx">         do_action( 'bp_loader_deactivate' );
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>