<!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][6108] trunk: Reinstates 1.5.x integration of bbPress 1.x forum installation and configuration</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/6108">6108</a></dd>
<dt>Author</dt> <dd>boonebgorges</dd>
<dt>Date</dt> <dd>2012-06-18 13:06:13 +0000 (Mon, 18 Jun 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Reinstates 1.5.x integration of bbPress 1.x forum installation and configuration

In anticipation for a full switchover to bbPress 2.x in BuddyPress 1.6, several
aspects of the forum configuration and setup process were modified. Since
the migration to bbPress 2.x is being put off to a later version of BuddyPress,
it's necessary to revert some of these changes back to their BP 1.5.x state.

This changeset also fixes a bug in the bb-config.php creation script, where
a salt containing the string '?&gt;' could result in early termination of the
config file.

Fixes <a href="http://buddypress.trac.wordpress.org/ticket/4269">#4269</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcoreadminbpcorefunctionsphp">trunk/bp-core/admin/bp-core-functions.php</a></li>
<li><a href="#trunkbpcoreadminbpcoreupdatephp">trunk/bp-core/admin/bp-core-update.php</a></li>
<li><a href="#trunkbpforumsbpforumsadminphp">trunk/bp-forums/bp-forums-admin.php</a></li>
<li><a href="#trunkbpforumsbpforumsfunctionsphp">trunk/bp-forums/bp-forums-functions.php</a></li>
<li><a href="#trunkbpforumsbpforumsloaderphp">trunk/bp-forums/bp-forums-loader.php</a></li>
<li><a href="#trunkbpthemesbpdefaultgroupscreatephp">trunk/bp-themes/bp-default/groups/create.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpcoreadminbpcorefunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/admin/bp-core-functions.php (6107 => 6108)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/admin/bp-core-functions.php        2012-06-18 12:43:03 UTC (rev 6107)
+++ trunk/bp-core/admin/bp-core-functions.php        2012-06-18 13:06:13 UTC (rev 6108)
</span><span class="lines">@@ -365,8 +365,8 @@
</span><span class="cx">                 )
</span><span class="cx">         );
</span><span class="cx"> 
</span><del>-        // If forums component is active and bbPress 1.x is in use add additional tab
-        if ( bp_is_active( 'forums' ) &amp;&amp; bp_forums_is_repair() ) {
</del><ins>+        // If forums component is active, add additional tab
+        if ( bp_is_active( 'forums' ) ) {
</ins><span class="cx">                 $tabs['3'] = array(
</span><span class="cx">                         'href' =&gt; bp_get_admin_url( add_query_arg( array( 'page' =&gt; 'bb-forums-setup'  ), 'admin.php' ) ),
</span><span class="cx">                         'name' =&gt; __( 'Forums', 'buddypress' )
</span></span></pre></div>
<a id="trunkbpcoreadminbpcoreupdatephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/admin/bp-core-update.php (6107 => 6108)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/admin/bp-core-update.php        2012-06-18 12:43:03 UTC (rev 6107)
+++ trunk/bp-core/admin/bp-core-update.php        2012-06-18 13:06:13 UTC (rev 6108)
</span><span class="lines">@@ -540,8 +540,8 @@
</span><span class="cx">                 $current_theme = wp_get_theme();
</span><span class="cx">                 $screenshot    = '';
</span><span class="cx"> 
</span><del>-                if ( !empty( $installed_themes[$current_theme]['Screenshot'] ) ) {
-                        $screenshot = trailingslashit( get_stylesheet_directory_uri() ) . $installed_themes[$current_theme]['Screenshot'];
</del><ins>+                if ( !empty( $installed_themes[$current_theme-&gt;stylesheet]['Screenshot'] ) ) {
+                        $screenshot = trailingslashit( get_stylesheet_directory_uri() ) . $installed_themes[$current_theme-&gt;stylesheet]['Screenshot'];
</ins><span class="cx">                 } ?&gt;
</span><span class="cx"> 
</span><span class="cx">                 &lt;script type=&quot;text/javascript&quot;&gt;
</span></span></pre></div>
<a id="trunkbpforumsbpforumsadminphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-forums/bp-forums-admin.php (6107 => 6108)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-forums/bp-forums-admin.php        2012-06-18 12:43:03 UTC (rev 6107)
+++ trunk/bp-forums/bp-forums-admin.php        2012-06-18 13:06:13 UTC (rev 6108)
</span><span class="lines">@@ -1,133 +1,242 @@
</span><span class="cx"> &lt;?php
</span><del>-
</del><span class="cx"> // Exit if accessed directly
</span><span class="cx"> if ( !defined( 'ABSPATH' ) ) exit;
</span><span class="cx"> 
</span><del>-/** UI ************************************************************************/
-
</del><span class="cx"> function bp_forums_add_admin_menu() {
</span><ins>+        global $bp;
</ins><span class="cx"> 
</span><del>-        if ( ! bp_current_user_can( 'bp_moderate' ) )
-                return;
</del><ins>+        if ( !is_super_admin() )
+                return false;
</ins><span class="cx"> 
</span><del>-        if ( ! bp_forums_is_repair() )
-                return;
</del><ins>+        $page  = bp_core_do_network_admin()  ? 'settings.php' : 'options-general.php';
</ins><span class="cx"> 
</span><del>-        // Add the option pages
-        $page = bp_core_do_network_admin()  ? 'settings.php' : 'options-general.php';
-        $hook = add_submenu_page( $page, __( 'BuddyPress Forums', 'buddypress' ), __( 'BuddyPress Forums', 'buddypress' ), 'manage_options', 'bb-forums-setup', 'bp_forums_bbpress_admin' );
</del><ins>+        // Add the administration tab under the &quot;Site Admin&quot; tab for site administrators
+        $hook = add_submenu_page( $page, __( 'Forums', 'buddypress' ), __( 'Forums', 'buddypress' ), 'manage_options', 'bb-forums-setup', &quot;bp_forums_bbpress_admin&quot; );
</ins><span class="cx"> 
</span><del>-        // Fudge the highlighted subnav item when on a BuddyPress admin page
</del><ins>+        // Fudge the highlighted subnav item when on the BuddyPress Forums admin page
</ins><span class="cx">         add_action( &quot;admin_head-$hook&quot;, 'bp_core_modify_admin_menu_highlight' );
</span><span class="cx"> }
</span><span class="cx"> add_action( bp_core_admin_hook(), 'bp_forums_add_admin_menu' );
</span><span class="cx"> 
</span><span class="cx"> function bp_forums_bbpress_admin() {
</span><del>-?&gt;
</del><ins>+        global $bp;
</ins><span class="cx"> 
</span><ins>+        $action = bp_get_admin_url( 'admin.php?page=bb-forums-setup&amp;reinstall=1' ); ?&gt;
+
</ins><span class="cx">         &lt;div class=&quot;wrap&quot;&gt;
</span><del>-
</del><span class="cx">                 &lt;?php screen_icon( 'buddypress' ); ?&gt;
</span><span class="cx"> 
</span><span class="cx">                 &lt;h2 class=&quot;nav-tab-wrapper&quot;&gt;&lt;?php bp_core_admin_tabs( __( 'Forums', 'buddypress' ) ); ?&gt;&lt;/h2&gt;
</span><span class="cx"> 
</span><del>-                &lt;h3&gt;&lt;?php _e( 'Forum Repair', 'buddypress' ); ?&gt;&lt;/h3&gt;
</del><ins>+                &lt;?php if ( isset( $_POST['submit'] ) ) : ?&gt;
</ins><span class="cx"> 
</span><del>-                &lt;?php if ( bp_forums_is_repair() ) : ?&gt;
</del><ins>+                        &lt;div id=&quot;message&quot; class=&quot;updated fade&quot;&gt;
+                                &lt;p&gt;&lt;?php _e( 'Settings Saved.', 'buddypress' ) ?&gt;&lt;/p&gt;
+                        &lt;/div&gt;
</ins><span class="cx"> 
</span><del>-                        &lt;p&gt;&lt;?php printf( __( 'The following configuration was successfully saved to: %s', 'buddypress' ), bp_get_option( 'bb-config-location' ) );?&gt;&lt;/p&gt;
</del><ins>+                &lt;?php endif; ?&gt;
</ins><span class="cx"> 
</span><del>-                        &lt;div id=&quot;template&quot;&gt;
-                                &lt;textarea cols=&quot;70&quot; rows=&quot;25&quot; name=&quot;bb-config&quot; id=&quot;bb-config&quot;&gt;&lt;?php echo bp_forums_bbpress_install( bp_get_option( 'bb-config-location' ) ); ?&gt;&lt;/textarea&gt;
-                        &lt;/div&gt;
</del><ins>+                &lt;?php
</ins><span class="cx"> 
</span><del>-                &lt;?php elseif ( bp_forums_is_migrate() ) : ?&gt;
</del><ins>+                if ( isset( $_REQUEST['reinstall'] ) || !bp_forums_is_installed_correctly() ) :
</ins><span class="cx"> 
</span><del>-                        &lt;?php
-                                add_thickbox();
-                                wp_enqueue_script( 'plugin-install' );
-                                wp_admin_css( 'plugin-install' );
-                        ?&gt;
</del><ins>+                        // Delete the bb-config.php location option
+                        bp_delete_option( 'bb-config-location' );
+                        bp_forums_bbpress_install_wizard();
</ins><span class="cx"> 
</span><del>-                        &lt;a class=&quot;button thickbox button-primary&quot; href=&quot;&lt;?php bp_admin_url( add_query_arg( array( 'tab' =&gt; 'plugin-information', 'plugin' =&gt; 'bbpress', 'TB_iframe' =&gt; 'true', 'width' =&gt; '640', 'height' =&gt; '500' ), 'plugin-install.php' ) ); ?&gt;&quot;&gt;&lt;?php _e( 'Install Site Wide Forums', 'buddypress' ) ?&gt;&lt;/a&gt; &amp;nbsp;
</del><ins>+                else : ?&gt;
</ins><span class="cx"> 
</span><del>-                &lt;?php else : ?&gt;
</del><ins>+                        &lt;div style=&quot;width: 45%; float: left; margin-top: 20px;&quot;&gt;
+                                &lt;h3&gt;&lt;?php _e( '(Installed)', 'buddypress' ); ?&gt; &lt;?php _e( 'Forums for Groups', 'buddypress' ) ?&gt;&lt;/h3&gt;
</ins><span class="cx"> 
</span><ins>+                                &lt;p&gt;&lt;?php _e( 'Give each individual group its own discussion forum. Choose this if you\'d like to keep your members\' conversations separated into distinct areas.' , 'buddypress' ); ?&gt;&lt;/p&gt;
+                                &lt;p class=&quot;description&quot;&gt;&lt;?php _e( 'You may use an existing bbPress installation if you have one.', 'buddypress' ); ?&gt;&lt;/p&gt;
+
+                                &lt;h4 style=&quot;margin-bottom: 10px;&quot;&gt;&lt;?php _e( 'Features', 'buddypress' ); ?&gt;&lt;/h4&gt;
+                                &lt;ul class=&quot;description&quot; style=&quot;list-style: square; margin-left: 30px;&quot;&gt;
+                                        &lt;li&gt;&lt;?php _e( 'Group Integration',           'buddypress' ); ?&gt;&lt;/p&gt;&lt;/li&gt;
+                                        &lt;li&gt;&lt;?php _e( 'Member Profile Integration',  'buddypress' ); ?&gt;&lt;/p&gt;&lt;/li&gt;
+                                        &lt;li&gt;&lt;?php _e( 'Activity Stream Integration', 'buddypress' ); ?&gt;&lt;/p&gt;&lt;/li&gt;
+                                        &lt;li&gt;&lt;?php _e( '@ Mention Integration',       'buddypress' ); ?&gt;&lt;/p&gt;&lt;/li&gt;
+                                &lt;/ul&gt;
+
+                                &lt;div&gt;
+                                        &lt;a class=&quot;button button-primary&quot; href=&quot;&lt;?php echo $action ?&gt;&quot;&gt;&lt;?php _e( 'Uninstall Group Forums', 'buddypress' ) ?&gt;&lt;/a&gt; &amp;nbsp;
+                                &lt;/div&gt;
+                        &lt;/div&gt;
+
+                        &lt;div style=&quot;width: 45%; float: left; margin: 20px 0 20px 20px; padding: 0 20px 20px 20px; border: 1px solid #ddd; background-color: #fff;&quot;&gt;
+                                &lt;h3&gt;&lt;?php _e( 'New! Site Wide Forums', 'buddypress' ) ?&gt;&lt;/h3&gt;
+                                &lt;p&gt;&lt;?php _e( 'Your site will have central forums that are not isolated to any specific group. Choose this if you\'d like to have a central forum area for your members.', 'buddypress' ) ?&gt;&lt;/p&gt;
+                                &lt;p class=&quot;description&quot;&gt;&lt;?php _e( 'You may activate both Group and Site Wide forums, but this may create a poor experience for your members.', 'buddypress' ) ?&gt;&lt;/p&gt;
+
+                                &lt;h4 style=&quot;margin-bottom: 10px;&quot;&gt;&lt;?php _e( 'Features', 'buddypress' ); ?&gt;&lt;/h4&gt;
+                                &lt;ul class=&quot;description&quot; style=&quot;list-style: square; margin-left: 30px;&quot;&gt;
+                                        &lt;li&gt;&lt;?php _e( 'Central Discussion Area',     'buddypress' ); ?&gt;&lt;/p&gt;&lt;/li&gt;
+                                        &lt;li&gt;&lt;?php _e( 'Forum Plugins Available',     'buddypress' ); ?&gt;&lt;/p&gt;&lt;/li&gt;
+                                        &lt;li&gt;&lt;?php _e( 'Activity Stream Integration', 'buddypress' ); ?&gt;&lt;/p&gt;&lt;/li&gt;
+                                        &lt;li&gt;&lt;?php _e( '@ Mention Integration',       'buddypress' ); ?&gt;&lt;/p&gt;&lt;/li&gt;
+                                &lt;/ul&gt;
+                                &lt;div&gt;
+                                        &lt;a class=&quot;button thickbox button-primary&quot; href=&quot;&lt;?php bp_admin_url( add_query_arg( array( 'tab' =&gt; 'plugin-information', 'plugin' =&gt; 'bbpress', 'TB_iframe' =&gt; 'true', 'width' =&gt; '640', 'height' =&gt; '500' ), 'plugin-install.php' ) ); ?&gt;&quot;&gt;&lt;?php _e( 'Install Site Wide Forums', 'buddypress' ) ?&gt;&lt;/a&gt; &amp;nbsp;
+                                &lt;/div&gt;
+                        &lt;/div&gt;
+
</ins><span class="cx">                 &lt;?php endif; ?&gt;
</span><span class="cx"> 
</span><span class="cx">         &lt;/div&gt;
</span><span class="cx"> &lt;?php
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-/** _is_ **********************************************************************/
</del><ins>+function bp_forums_bbpress_install_wizard() {
+        $post_url = network_admin_url( 'admin.php?page=bb-forums-setup' );
</ins><span class="cx"> 
</span><del>-/**
- * Trying to repair a bbPress 1.x installation
- *
- * @since BuddyPress (1.6)
- * @return boolean True if option exists, false if not
- */
-function bp_forums_is_repair() {
</del><ins>+        $step = isset( $_REQUEST['step'] ) ? $_REQUEST['step'] : '';
</ins><span class="cx"> 
</span><del>-        // Bail if bbPress 1.x was never installed
-        if ( isset( $_REQUEST['repair'] ) &amp;&amp; bp_forums_is_installed_correctly() )
-                return true;
</del><ins>+        switch( $step ) {
+                case 'existing':
+                        if ( isset( $_REQUEST['doinstall'] ) &amp;&amp; ( 1 == (int) $_REQUEST['doinstall'] ) ) {
+                                if ( !bp_forums_configure_existing_install() ) {
+                                        _e( 'The bb-config.php file was not found at that location, please try again.', 'buddypress' );
+                                } else {
+                                        ?&gt;
+                                        &lt;h3&gt;&lt;?php _e( 'Forums were set up correctly using your existing bbPress install!', 'buddypress' ) ?&gt;&lt;/h3&gt;
+                                        &lt;p&gt;&lt;?php _e( 'BuddyPress will now use its internal copy of bbPress to run the forums on your site. If you wish, you can remove your old bbPress installation files, as long as you keep the bb-config.php file in the same location.', 'buddypress' ) ?&gt;&lt;/p&gt;&lt;?php
+                                }
+                        } else { ?&gt;
</ins><span class="cx"> 
</span><del>-        return false;
-}
</del><ins>+                                        &lt;form action=&quot;&quot; method=&quot;post&quot;&gt;
+                                                &lt;h3&gt;&lt;?php _e( 'Existing bbPress Installation', 'buddypress' ) ?&gt;&lt;/h3&gt;
+                                                &lt;p&gt;&lt;?php _e( &quot;BuddyPress can make use of your existing bbPress install. Just provide the location of your &lt;code&gt;bb-config.php&lt;/code&gt; file, and BuddyPress will do the rest.&quot;, 'buddypress' ) ?&gt;&lt;/p&gt;
+                                                &lt;p&gt;&lt;label&gt;&lt;code&gt;bb-config.php&lt;/code&gt; file location:&lt;/label&gt;&lt;br /&gt;&lt;input style=&quot;width: 50%&quot; type=&quot;text&quot; name=&quot;bbconfigloc&quot; id=&quot;bbconfigloc&quot; value=&quot;&lt;?php echo str_replace( 'buddypress', '', $_SERVER['DOCUMENT_ROOT'] ) ?&gt;&quot; /&gt;&lt;/p&gt;
+                                                &lt;p&gt;&lt;input type=&quot;submit&quot; class=&quot;button-primary&quot; value=&quot;&lt;?php _e( 'Complete Installation', 'buddypress' ) ?&gt;&quot; /&gt;&lt;/p&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;step&quot; value=&quot;existing&quot; /&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;doinstall&quot; value=&quot;1&quot; /&gt;
+                                                &lt;?php wp_nonce_field( 'bp_forums_existing_install_init' ) ?&gt;
+                                        &lt;/form&gt;
</ins><span class="cx"> 
</span><del>-/**
- * bbPress 1.x is installed, and we're moving to bbPress 2.x
- *
- * @since BuddyPress (1.6)
- * @return boolean True if option exists, false if not
- */
-function bp_forums_is_migrate() {
</del><ins>+                                &lt;?php
+                        }
+                break;
</ins><span class="cx"> 
</span><del>-        // Bail if bbPress 1.x was never installed
-        if ( isset( $_REQUEST['migrate'] ) &amp;&amp; bp_forums_is_installed_correctly() )
-                return true;
</del><ins>+                case 'new':
+                        if ( isset( $_REQUEST['doinstall'] ) &amp;&amp; 1 == (int)$_REQUEST['doinstall'] ) {
+                                $result = bp_forums_bbpress_install();
</ins><span class="cx"> 
</span><del>-        return false;
-}
</del><ins>+                                switch ( $result ) {
+                                        case 1:
+                                                _e( '&lt;p&gt;All done! Configuration settings have been saved to the file &lt;code&gt;bb-config.php&lt;/code&gt; in the root of your WordPress install.&lt;/p&gt;', 'buddypress' );
+                                                break;
+                                        default:
+                                                // Just write the contents to screen
+                                                _e( '&lt;p&gt;A configuration file could not be created. No problem, but you will need to save the text shown below into a file named &lt;code&gt;bb-config.php&lt;/code&gt; in the root directory of your WordPress installation before you can start using the forum functionality.&lt;/p&gt;', 'buddypress' ); ?&gt;
</ins><span class="cx"> 
</span><del>-/**
- * bbPress was never installed before, and bbPress 2.x is not installed yet
- *
- * @since BuddyPress (1.6)
- * @return boolean True if option exists, false if not
- */
-function bp_forums_is_fresh_install() {
</del><ins>+                                                &lt;textarea style=&quot;display:block; margin-top: 30px; width: 80%;&quot; rows=&quot;50&quot;&gt;&lt;?php echo htmlspecialchars( $result ); ?&gt;&lt;/textarea&gt;
</ins><span class="cx"> 
</span><del>-        // Bail if bbPress 1.x was never installed
-        if ( isset( $_REQUEST['install'] ) &amp;&amp; ! bp_forums_is_installed_correctly() )
-                return true;
</del><ins>+                                        &lt;?php
+                                                break;
+                                }
+                        } else { ?&gt;
</ins><span class="cx"> 
</span><del>-        return false;
</del><ins>+                                &lt;h3&gt;&lt;?php _e( 'New bbPress Installation', 'buddypress' ) ?&gt;&lt;/h3&gt;
+                                &lt;p&gt;&lt;?php _e( &quot;You've decided to set up a new installation of bbPress for forum management in BuddyPress. This is very simple and is usually just a one click
+                                process. When you're ready, hit the link below.&quot;, 'buddypress' ) ?&gt;&lt;/p&gt;
+                                &lt;p&gt;&lt;a class=&quot;button-primary&quot; href=&quot;&lt;?php echo wp_nonce_url( $post_url . '&amp;step=new&amp;doinstall=1', 'bp_forums_new_install_init' ) ?&gt;&quot;&gt;&lt;?php _e( 'Complete Installation', 'buddypress' ) ?&gt;&lt;/a&gt;&lt;/p&gt;
+
+                                &lt;?php
+                        }
+                break;
+
+                default:
+                        if ( !file_exists( BP_PLUGIN_DIR . '/bp-forums/bbpress/' ) ) { ?&gt;
+
+                                &lt;div id=&quot;message&quot; class=&quot;error&quot;&gt;
+                                        &lt;p&gt;&lt;?php printf( __( 'bbPress files were not found. To install the forums component you must download a copy of bbPress and make sure it is in the folder: &quot;%s&quot;', 'buddypress' ), 'wp-content/plugins/buddypress/bp-forums/bbpress/' ) ?&gt;&lt;/p&gt;
+                                &lt;/div&gt;
+
+                        &lt;?php } else {
+
+                                // Include the plugin install
+
+                                add_thickbox();
+                                wp_enqueue_script( 'plugin-install' );
+                                wp_admin_css( 'plugin-install' );
+                        ?&gt;
+
+                                &lt;div style=&quot;width: 45%; float: left;  margin-top: 20px;&quot;&gt;
+                                        &lt;h3&gt;&lt;?php _e( 'Forums for Groups', 'buddypress' ) ?&gt;&lt;/h3&gt;
+
+                                        &lt;p&gt;&lt;?php _e( 'Give each individual group its own discussion forum. Choose this if you\'d like to keep your members\' conversations separated into distinct areas.' , 'buddypress' ); ?&gt;&lt;/p&gt;
+                                        &lt;p class=&quot;description&quot;&gt;&lt;?php _e( 'You may use an existing bbPress installation if you have one.', 'buddypress' ); ?&gt;&lt;/p&gt;
+
+                                        &lt;h4 style=&quot;margin-bottom: 10px;&quot;&gt;&lt;?php _e( 'Features', 'buddypress' ); ?&gt;&lt;/h4&gt;
+                                        &lt;ul class=&quot;description&quot; style=&quot;list-style: square; margin-left: 30px;&quot;&gt;
+                                                &lt;li&gt;&lt;?php _e( 'Group Integration',           'buddypress' ); ?&gt;&lt;/p&gt;&lt;/li&gt;
+                                                &lt;li&gt;&lt;?php _e( 'Member Profile Integration',  'buddypress' ); ?&gt;&lt;/p&gt;&lt;/li&gt;
+                                                &lt;li&gt;&lt;?php _e( 'Activity Stream Integration', 'buddypress' ); ?&gt;&lt;/p&gt;&lt;/li&gt;
+                                                &lt;li&gt;&lt;?php _e( '@ Mention Integration',       'buddypress' ); ?&gt;&lt;/p&gt;&lt;/li&gt;
+                                        &lt;/ul&gt;
+
+                                        &lt;div&gt;
+                                                &lt;a class=&quot;button button-primary&quot; href=&quot;&lt;?php echo $post_url . '&amp;step=new' ?&gt;&quot;&gt;&lt;?php _e( 'Install Group Forums', 'buddypress' ) ?&gt;&lt;/a&gt; &amp;nbsp;
+                                                &lt;a class=&quot;button&quot; href=&quot;&lt;?php echo $post_url . '&amp;step=existing' ?&gt;&quot;&gt;&lt;?php _e( 'Use Existing Installation', 'buddypress' ) ?&gt;&lt;/a&gt;
+                                        &lt;/div&gt;
+                                &lt;/div&gt;
+
+                                &lt;div style=&quot;width: 45%; float: left; margin: 20px 0 20px 20px; padding: 0 20px 20px 20px; border: 1px solid #ddd; background-color: #fff;&quot;&gt;
+                                        &lt;h3&gt;&lt;?php _e( 'New! Site Wide Forums', 'buddypress' ) ?&gt;&lt;/h3&gt;
+                                        &lt;p&gt;&lt;?php _e( 'Your site will have central forums that are not isolated to any specific group. Choose this if you\'d like to have a central forum area for your members.', 'buddypress' ) ?&gt;&lt;/p&gt;
+                                        &lt;p class=&quot;description&quot;&gt;&lt;?php _e( 'You may activate both Group and Site Wide forums, but this may create a poor experience for your members.', 'buddypress' ) ?&gt;&lt;/p&gt;
+
+                                        &lt;h4 style=&quot;margin-bottom: 10px;&quot;&gt;&lt;?php _e( 'Features', 'buddypress' ); ?&gt;&lt;/h4&gt;
+                                        &lt;ul class=&quot;description&quot; style=&quot;list-style: square; margin-left: 30px;&quot;&gt;
+                                                &lt;li&gt;&lt;?php _e( 'Central Discussion Area',     'buddypress' ); ?&gt;&lt;/p&gt;&lt;/li&gt;
+                                                &lt;li&gt;&lt;?php _e( 'Forum Plugins Available',     'buddypress' ); ?&gt;&lt;/p&gt;&lt;/li&gt;
+                                                &lt;li&gt;&lt;?php _e( 'Activity Stream Integration', 'buddypress' ); ?&gt;&lt;/p&gt;&lt;/li&gt;
+                                                &lt;li&gt;&lt;?php _e( '@ Mention Integration',       'buddypress' ); ?&gt;&lt;/p&gt;&lt;/li&gt;
+                                        &lt;/ul&gt;
+                                        &lt;div&gt;
+                                                &lt;a class=&quot;button thickbox button-primary&quot; href=&quot;&lt;?php bp_admin_url( add_query_arg( array( 'tab' =&gt; 'plugin-information', 'plugin' =&gt; 'bbpress', 'TB_iframe' =&gt; 'true', 'width' =&gt; '640', 'height' =&gt; '500' ), 'plugin-install.php' ) ); ?&gt;&quot;&gt;&lt;?php _e( 'Install Site Wide Forums', 'buddypress' ) ?&gt;&lt;/a&gt; &amp;nbsp;
+                                        &lt;/div&gt;
+                                &lt;/div&gt;
+
+                        &lt;?php }
+                break;
+        }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-/**
- * Both bbPress 1.x and bbPress 2.x are installed
- *
- * @since BuddyPress (1.6)
- * @return boolean True if option exists, false if not
- */
-function bp_forums_is_hybrid_install() {
</del><ins>+function bp_forums_configure_existing_install() {
+        global $wpdb, $bbdb;
</ins><span class="cx"> 
</span><del>-        // Bail if bbPress 1.x was never installed
-        if ( isset( $_REQUEST['install'] ) &amp;&amp; bp_forums_is_bbpress_active &amp;&amp; bp_forums_is_installed_correctly() )
-                return true;
</del><ins>+        check_admin_referer( 'bp_forums_existing_install_init' );
</ins><span class="cx"> 
</span><del>-        return false;
</del><ins>+        // Sanitize $_REQUEST['bbconfigloc']
+        $_REQUEST['bbconfigloc'] = apply_filters( 'bp_forums_bbconfig_location', $_REQUEST['bbconfigloc'] );
+
+        if ( false === strpos( $_REQUEST['bbconfigloc'], 'bb-config.php' ) ) {
+                if ( '/' != substr( $_REQUEST['bbconfigloc'], -1, 1 ) )
+                        $_REQUEST['bbconfigloc'] .= '/';
+
+                $_REQUEST['bbconfigloc'] .= 'bb-config.php';
+        }
+
+        bp_update_option( 'bb-config-location', $_REQUEST['bbconfigloc'] );
+
+        if ( !file_exists( $_REQUEST['bbconfigloc'] ) ) {
+                return false;
+        }
+
+        return true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-/** Config ********************************************************************/
-
</del><span class="cx"> function bp_forums_bbpress_install( $location = '' ) {
</span><del>-        global $wpdb, $bp;
</del><ins>+        global $wpdb, $bbdb, $bp;
</ins><span class="cx"> 
</span><del>-        if ( empty( $location ) )
</del><ins>+        check_admin_referer( 'bp_forums_new_install_init' );
+
+        if ( empty( $location ) ) {
</ins><span class="cx">                 $location = ABSPATH . 'bb-config.php';
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         // Create the bb-config.php file
</span><span class="cx">         $initial_write = bp_forums_bbpress_write(
</span><span class="lines">@@ -163,7 +272,7 @@
</span><span class="cx"> 
</span><span class="cx">         $file .= &quot;\n&quot; .   '$bb-&gt;custom_user_table = \'' . $wpdb-&gt;users . '\';';
</span><span class="cx">         $file .= &quot;\n&quot; .   '$bb-&gt;custom_user_meta_table = \'' . $wpdb-&gt;usermeta . '\';';
</span><del>-        $file .= &quot;\n\n&quot; . '$bb-&gt;uri = \'' . BP_PLUGIN_URL . 'bp-forums/bbpress/\';';
</del><ins>+        $file .= &quot;\n\n&quot; . '$bb-&gt;uri = \'' . BP_PLUGIN_URL . '/bp-forums/bbpress/\';';
</ins><span class="cx">         $file .= &quot;\n&quot; .   '$bb-&gt;name = \'' . get_blog_option( bp_get_root_blog_id(), 'blogname' ) . ' ' . __( 'Forums', 'buddypress' ) . '\';';
</span><span class="cx"> 
</span><span class="cx">         if ( is_multisite() ) {
</span><span class="lines">@@ -194,8 +303,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         bp_update_option( 'bb-config-location', $location );
</span><del>-
-        return $file;
</del><ins>+        return $initial_write;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function bp_forums_bbpress_write( $file_source, $file_target, $alterations ) {
</span><span class="lines">@@ -254,9 +362,10 @@
</span><span class="cx"> 
</span><span class="cx">         // Write lines one by one to avoid OS specific newline hassles
</span><span class="cx">         foreach ( (array) $modified_lines as $modified_line ) {
</span><del>-                if ( false !== strpos( $modified_line, '?&gt;' ) ) {
</del><ins>+                if ( strlen( $modified_line ) - 2 === strrpos( $modified_line, '?&gt;' ) ) {
</ins><span class="cx">                         $modified_line = '?&gt;';
</span><span class="cx">                 }
</span><ins>+
</ins><span class="cx">                 fwrite( $file_handle, $modified_line );
</span><span class="cx">                 if ( $modified_line == '?&gt;' ) {
</span><span class="cx">                         break;
</span></span></pre></div>
<a id="trunkbpforumsbpforumsfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-forums/bp-forums-functions.php (6107 => 6108)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-forums/bp-forums-functions.php        2012-06-18 12:43:03 UTC (rev 6107)
+++ trunk/bp-forums/bp-forums-functions.php        2012-06-18 13:06:13 UTC (rev 6108)
</span><span class="lines">@@ -34,7 +34,9 @@
</span><span class="cx">  * @return boolean True if option exists, false if not
</span><span class="cx">  */
</span><span class="cx"> function bp_forums_is_installed_correctly() {
</span><del>-        if ( bp_get_option(        'bb-config-location' ) )
</del><ins>+        global $bp;
+
+        if ( isset( $bp-&gt;forums-&gt;bbconfig ) &amp;&amp; is_file( $bp-&gt;forums-&gt;bbconfig ) )
</ins><span class="cx">                 return true;
</span><span class="cx"> 
</span><span class="cx">         return false;
</span></span></pre></div>
<a id="trunkbpforumsbpforumsloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-forums/bp-forums-loader.php (6107 => 6108)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-forums/bp-forums-loader.php        2012-06-18 12:43:03 UTC (rev 6107)
+++ trunk/bp-forums/bp-forums-loader.php        2012-06-18 13:06:13 UTC (rev 6108)
</span><span class="lines">@@ -47,6 +47,10 @@
</span><span class="cx">                 if ( !defined( 'BP_FORUMS_SLUG' ) )
</span><span class="cx">                         define( 'BP_FORUMS_SLUG', $this-&gt;id );
</span><span class="cx"> 
</span><ins>+                // The location of the bbPress stand-alone config file
+                if ( isset( $bp-&gt;site_options['bb-config-location'] ) )
+                        $this-&gt;bbconfig = $bp-&gt;site_options['bb-config-location'];
+
</ins><span class="cx">                 // All globals for messaging component.
</span><span class="cx">                 // Note that global_tables is included in this array.
</span><span class="cx">                 $globals = array(
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultgroupscreatephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/groups/create.php (6107 => 6108)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/groups/create.php        2012-06-18 12:43:03 UTC (rev 6107)
+++ trunk/bp-themes/bp-default/groups/create.php        2012-06-18 13:06:13 UTC (rev 6108)
</span><span class="lines">@@ -107,16 +107,23 @@
</span><span class="cx">                                                 &lt;/label&gt;
</span><span class="cx">                                         &lt;/div&gt;
</span><span class="cx"> 
</span><del>-                                        &lt;?php if ( bp_is_active( 'forums' ) &amp;&amp; bp_forums_is_installed_correctly() ) : ?&gt;
</del><ins>+                                        &lt;?php if ( bp_is_active( 'forums' ) ) : ?&gt;
</ins><span class="cx"> 
</span><span class="cx">                                                 &lt;h4&gt;&lt;?php _e( 'Group Forums', 'buddypress' ); ?&gt;&lt;/h4&gt;
</span><span class="cx"> 
</span><del>-                                                &lt;p&gt;&lt;?php _e( 'Should this group have a forum?', 'buddypress' ); ?&gt;&lt;/p&gt;
</del><ins>+                                                &lt;?php if ( bp_forums_is_installed_correctly() ) : ?&gt;
</ins><span class="cx"> 
</span><del>-                                                &lt;div class=&quot;checkbox&quot;&gt;
-                                                        &lt;label&gt;&lt;input type=&quot;checkbox&quot; name=&quot;group-show-forum&quot; id=&quot;group-show-forum&quot; value=&quot;1&quot;&lt;?php checked( bp_get_new_group_enable_forum(), true, true ); ?&gt; /&gt; &lt;?php _e( 'Enable discussion forum', 'buddypress' ); ?&gt;&lt;/label&gt;
-                                                &lt;/div&gt;
</del><ins>+                                                        &lt;p&gt;&lt;?php _e( 'Should this group have a forum?', 'buddypress' ); ?&gt;&lt;/p&gt;
</ins><span class="cx"> 
</span><ins>+                                                        &lt;div class=&quot;checkbox&quot;&gt;
+                                                                &lt;label&gt;&lt;input type=&quot;checkbox&quot; name=&quot;group-show-forum&quot; id=&quot;group-show-forum&quot; value=&quot;1&quot;&lt;?php checked( bp_get_new_group_enable_forum(), true, true ); ?&gt; /&gt; &lt;?php _e( 'Enable discussion forum', 'buddypress' ); ?&gt;&lt;/label&gt;
+                                                        &lt;/div&gt;
+                                                &lt;?php elseif ( is_super_admin() ) : ?&gt;
+
+                                                        &lt;p&gt;&lt;?php printf( __( '&lt;strong&gt;Attention Site Admin:&lt;/strong&gt; Group forums require the &lt;a href=&quot;%s&quot;&gt;correct setup and configuration&lt;/a&gt; of a bbPress installation.', 'buddypress' ), bp_core_do_network_admin() ? network_admin_url( 'settings.php?page=bb-forums-setup' ) :  admin_url( 'admin.php?page=bb-forums-setup' ) ); ?&gt;&lt;/p&gt;
+
+                                                &lt;?php endif; ?&gt;
+
</ins><span class="cx">                                         &lt;?php endif; ?&gt;
</span><span class="cx"> 
</span><span class="cx">                                         &lt;?php do_action( 'bp_after_group_settings_creation_step' ); ?&gt;
</span></span></pre>
</div>
</div>

</body>
</html>