Skip to:
Content

BuddyPress.org

Ticket #4258: 4258.02.patch

File 4258.02.patch, 24.8 KB (added by DJPaul, 13 years ago)
  • bp-core/admin/bp-core-functions.php

    function bp_core_admin_tabs( $active_tab = '' ) { 
    365365                )
    366366        );
    367367
    368         // If forums component is active and bbPress 1.x is in use add additional tab
    369         if ( bp_is_active( 'forums' ) && bp_forums_is_repair() ) {
     368        // If forums component is active, add additional tab
     369        if ( bp_is_active( 'forums' ) ) {
    370370                $tabs['3'] = array(
    371371                        'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bb-forums-setup'  ), 'admin.php' ) ),
    372372                        'name' => __( 'Forums', 'buddypress' )
  • bp-core/admin/bp-core-update.php

    class BP_Core_Setup_Wizard { 
    542542                $current_theme = wp_get_theme();
    543543                $screenshot    = '';
    544544
    545                 if ( !empty( $installed_themes[$current_theme]['Screenshot'] ) ) {
    546                         $screenshot = trailingslashit( get_stylesheet_directory_uri() ) . $installed_themes[$current_theme]['Screenshot'];
     545                if ( !empty( $installed_themes[$current_theme->stylesheet]['Screenshot'] ) ) {
     546                        $screenshot = trailingslashit( get_stylesheet_directory_uri() ) . $installed_themes[$current_theme->stylesheet]['Screenshot'];
    547547                } ?>
    548548
    549549                <script type="text/javascript">
  • bp-forums/bp-forums-admin.php

     
    11<?php
    2 
    32// Exit if accessed directly
    43if ( !defined( 'ABSPATH' ) ) exit;
    54
    6 /** UI ************************************************************************/
    7 
    85function bp_forums_add_admin_menu() {
     6        global $bp;
    97
    10         if ( ! bp_current_user_can( 'bp_moderate' ) )
    11                 return;
     8        if ( !is_super_admin() )
     9                return false;
    1210
    13         if ( ! bp_forums_is_repair() )
    14                 return;
     11        $page  = bp_core_do_network_admin()  ? 'settings.php' : 'options-general.php';
    1512
    16         // Add the option pages
    17         $page = bp_core_do_network_admin()  ? 'settings.php' : 'options-general.php';
    18         $hook = add_submenu_page( $page, __( 'BuddyPress Forums', 'buddypress' ), __( 'BuddyPress Forums', 'buddypress' ), 'manage_options', 'bb-forums-setup', 'bp_forums_bbpress_admin' );
     13        // Add the administration tab under the "Site Admin" tab for site administrators
     14        $hook = add_submenu_page( $page, __( 'Forums', 'buddypress' ), __( 'Forums', 'buddypress' ), 'manage_options', 'bb-forums-setup', "bp_forums_bbpress_admin" );
    1915
    20         // Fudge the highlighted subnav item when on a BuddyPress admin page
     16        // Fudge the highlighted subnav item when on the BuddyPress Forums admin page
    2117        add_action( "admin_head-$hook", 'bp_core_modify_admin_menu_highlight' );
    2218}
    2319add_action( bp_core_admin_hook(), 'bp_forums_add_admin_menu' );
    2420
    2521function bp_forums_bbpress_admin() {
    26 ?>
     22        global $bp;
    2723
    28         <div class="wrap">
     24        $action = bp_get_admin_url( 'admin.php?page=bb-forums-setup&reinstall=1' ); ?>
    2925
     26        <div class="wrap">
    3027                <?php screen_icon( 'buddypress' ); ?>
    3128
    3229                <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Forums', 'buddypress' ) ); ?></h2>
    3330
    34                 <h3><?php _e( 'Forum Repair', 'buddypress' ); ?></h3>
     31                <?php if ( isset( $_POST['submit'] ) ) : ?>
    3532
    36                 <?php if ( bp_forums_is_repair() ) : ?>
     33                        <div id="message" class="updated fade">
     34                                <p><?php _e( 'Settings Saved.', 'buddypress' ) ?></p>
     35                        </div>
    3736
    38                         <p><?php printf( __( 'The following configuration was successfully saved to: %s', 'buddypress' ), bp_get_option( 'bb-config-location' ) );?></p>
     37                <?php endif; ?>
    3938
    40                         <div id="template">
    41                                 <textarea cols="70" rows="25" name="bb-config" id="bb-config"><?php echo bp_forums_bbpress_install( bp_get_option( 'bb-config-location' ) ); ?></textarea>
    42                         </div>
     39                <?php
    4340
    44                 <?php elseif ( bp_forums_is_migrate() ) : ?>
     41                if ( isset( $_REQUEST['reinstall'] ) || !bp_forums_is_installed_correctly() ) :
    4542
    46                         <?php
    47                                 add_thickbox();
    48                                 wp_enqueue_script( 'plugin-install' );
    49                                 wp_admin_css( 'plugin-install' );
    50                         ?>
     43                        // Delete the bb-config.php location option
     44                        bp_delete_option( 'bb-config-location' );
     45                        bp_forums_bbpress_install_wizard();
     46
     47                else : ?>
     48
     49                        <div style="width: 45%; float: left; margin-top: 20px;">
     50                                <h3><?php _e( '(Installed)', 'buddypress' ); ?> <?php _e( 'Forums for Groups', 'buddypress' ) ?></h3>
    5151
    52                         <a class="button thickbox button-primary" href="<?php bp_admin_url( add_query_arg( array( 'tab' => 'plugin-information', 'plugin' => 'bbpress', 'TB_iframe' => 'true', 'width' => '640', 'height' => '500' ), 'plugin-install.php' ) ); ?>"><?php _e( 'Install Site Wide Forums', 'buddypress' ) ?></a> &nbsp;
     52                                <p><?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' ); ?></p>
     53                                <p class="description"><?php _e( 'You may use an existing bbPress installation if you have one.', 'buddypress' ); ?></p>
    5354
    54                 <?php else : ?>
     55                                <h4 style="margin-bottom: 10px;"><?php _e( 'Features', 'buddypress' ); ?></h4>
     56                                <ul class="description" style="list-style: square; margin-left: 30px;">
     57                                        <li><?php _e( 'Group Integration',           'buddypress' ); ?></p></li>
     58                                        <li><?php _e( 'Member Profile Integration',  'buddypress' ); ?></p></li>
     59                                        <li><?php _e( 'Activity Stream Integration', 'buddypress' ); ?></p></li>
     60                                        <li><?php _e( '@ Mention Integration',       'buddypress' ); ?></p></li>
     61                                </ul>
     62
     63                                <div>
     64                                        <a class="button button-primary" href="<?php echo $action ?>"><?php _e( 'Uninstall Group Forums', 'buddypress' ) ?></a> &nbsp;
     65                                </div>
     66                        </div>
     67
     68                        <div style="width: 45%; float: left; margin: 20px 0 20px 20px; padding: 0 20px 20px 20px; border: 1px solid #ddd; background-color: #fff;">
     69                                <h3><?php _e( 'New! Site Wide Forums', 'buddypress' ) ?></h3>
     70                                <p><?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' ) ?></p>
     71                                <p class="description"><?php _e( 'You may activate both Group and Site Wide forums, but this may create a poor experience for your members.', 'buddypress' ) ?></p>
     72
     73                                <h4 style="margin-bottom: 10px;"><?php _e( 'Features', 'buddypress' ); ?></h4>
     74                                <ul class="description" style="list-style: square; margin-left: 30px;">
     75                                        <li><?php _e( 'Central Discussion Area',     'buddypress' ); ?></p></li>
     76                                        <li><?php _e( 'Forum Plugins Available',     'buddypress' ); ?></p></li>
     77                                        <li><?php _e( 'Activity Stream Integration', 'buddypress' ); ?></p></li>
     78                                        <li><?php _e( '@ Mention Integration',       'buddypress' ); ?></p></li>
     79                                </ul>
     80                                <div>
     81                                        <a class="button thickbox button-primary" href="<?php bp_admin_url( add_query_arg( array( 'tab' => 'plugin-information', 'plugin' => 'bbpress', 'TB_iframe' => 'true', 'width' => '640', 'height' => '500' ), 'plugin-install.php' ) ); ?>"><?php _e( 'Install Site Wide Forums', 'buddypress' ) ?></a> &nbsp;
     82                                </div>
     83                        </div>
    5584
    5685                <?php endif; ?>
    5786
    function bp_forums_bbpress_admin() { 
    5988<?php
    6089}
    6190
    62 /** _is_ **********************************************************************/
     91function bp_forums_bbpress_install_wizard() {
     92        $post_url = network_admin_url( 'admin.php?page=bb-forums-setup' );
     93
     94        $step = isset( $_REQUEST['step'] ) ? $_REQUEST['step'] : '';
     95
     96        switch( $step ) {
     97                case 'existing':
     98                        if ( isset( $_REQUEST['doinstall'] ) && ( 1 == (int) $_REQUEST['doinstall'] ) ) {
     99                                if ( !bp_forums_configure_existing_install() ) {
     100                                        _e( 'The bb-config.php file was not found at that location, please try again.', 'buddypress' );
     101                                } else {
     102                                        ?>
     103                                        <h3><?php _e( 'Forums were set up correctly using your existing bbPress install!', 'buddypress' ) ?></h3>
     104                                        <p><?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' ) ?></p><?php
     105                                }
     106                        } else { ?>
     107
     108                                        <form action="" method="post">
     109                                                <h3><?php _e( 'Existing bbPress Installation', 'buddypress' ) ?></h3>
     110                                                <p><?php _e( "BuddyPress can make use of your existing bbPress install. Just provide the location of your <code>bb-config.php</code> file, and BuddyPress will do the rest.", 'buddypress' ) ?></p>
     111                                                <p><label><code>bb-config.php</code> file location:</label><br /><input style="width: 50%" type="text" name="bbconfigloc" id="bbconfigloc" value="<?php echo str_replace( 'buddypress', '', $_SERVER['DOCUMENT_ROOT'] ) ?>" /></p>
     112                                                <p><input type="submit" class="button-primary" value="<?php _e( 'Complete Installation', 'buddypress' ) ?>" /></p>
     113                                                <input type="hidden" name="step" value="existing" />
     114                                                <input type="hidden" name="doinstall" value="1" />
     115                                                <?php wp_nonce_field( 'bp_forums_existing_install_init' ) ?>
     116                                        </form>
     117
     118                                <?php
     119                        }
     120                break;
    63121
    64 /**
    65  * Trying to repair a bbPress 1.x installation
    66  *
    67  * @since BuddyPress (1.6)
    68  * @return boolean True if option exists, false if not
    69  */
    70 function bp_forums_is_repair() {
     122                case 'new':
     123                        if ( isset( $_REQUEST['doinstall'] ) && 1 == (int)$_REQUEST['doinstall'] ) {
     124                                $result = bp_forums_bbpress_install();
    71125
    72         // Bail if bbPress 1.x was never installed
    73         if ( isset( $_REQUEST['repair'] ) && bp_forums_is_installed_correctly() )
    74                 return true;
     126                                switch ( $result ) {
     127                                        case 1:
     128                                                _e( '<p>All done! Configuration settings have been saved to the file <code>bb-config.php</code> in the root of your WordPress install.</p>', 'buddypress' );
     129                                                break;
     130                                        default:
     131                                                // Just write the contents to screen
     132                                                _e( '<p>A configuration file could not be created. No problem, but you will need to save the text shown below into a file named <code>bb-config.php</code> in the root directory of your WordPress installation before you can start using the forum functionality.</p>', 'buddypress' ); ?>
    75133
    76         return false;
    77 }
     134                                                <textarea style="display:block; margin-top: 30px; width: 80%;" rows="50"><?php echo htmlspecialchars( $result ); ?></textarea>
    78135
    79 /**
    80  * bbPress 1.x is installed, and we're moving to bbPress 2.x
    81  *
    82  * @since BuddyPress (1.6)
    83  * @return boolean True if option exists, false if not
    84  */
    85 function bp_forums_is_migrate() {
     136                                        <?php
     137                                                break;
     138                                }
     139                        } else { ?>
    86140
    87         // Bail if bbPress 1.x was never installed
    88         if ( isset( $_REQUEST['migrate'] ) && bp_forums_is_installed_correctly() )
    89                 return true;
     141                                <h3><?php _e( 'New bbPress Installation', 'buddypress' ) ?></h3>
     142                                <p><?php _e( "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
     143                                process. When you're ready, hit the link below.", 'buddypress' ) ?></p>
     144                                <p><a class="button-primary" href="<?php echo wp_nonce_url( $post_url . '&step=new&doinstall=1', 'bp_forums_new_install_init' ) ?>"><?php _e( 'Complete Installation', 'buddypress' ) ?></a></p>
    90145
    91         return false;
    92 }
     146                                <?php
     147                        }
     148                break;
    93149
    94 /**
    95  * bbPress was never installed before, and bbPress 2.x is not installed yet
    96  *
    97  * @since BuddyPress (1.6)
    98  * @return boolean True if option exists, false if not
    99  */
    100 function bp_forums_is_fresh_install() {
     150                default:
     151                        if ( !file_exists( BP_PLUGIN_DIR . '/bp-forums/bbpress/' ) ) { ?>
    101152
    102         // Bail if bbPress 1.x was never installed
    103         if ( isset( $_REQUEST['install'] ) && ! bp_forums_is_installed_correctly() )
    104                 return true;
     153                                <div id="message" class="error">
     154                                        <p><?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: "%s"', 'buddypress' ), 'wp-content/plugins/buddypress/bp-forums/bbpress/' ) ?></p>
     155                                </div>
    105156
    106         return false;
    107 }
     157                        <?php } else {
    108158
    109 /**
    110  * Both bbPress 1.x and bbPress 2.x are installed
    111  *
    112  * @since BuddyPress (1.6)
    113  * @return boolean True if option exists, false if not
    114  */
    115 function bp_forums_is_hybrid_install() {
     159                                // Include the plugin install
    116160
    117         // Bail if bbPress 1.x was never installed
    118         if ( isset( $_REQUEST['install'] ) && bp_forums_is_bbpress_active && bp_forums_is_installed_correctly() )
    119                 return true;
     161                                add_thickbox();
     162                                wp_enqueue_script( 'plugin-install' );
     163                                wp_admin_css( 'plugin-install' );
     164                        ?>
    120165
    121         return false;
     166                                <div style="width: 45%; float: left;  margin-top: 20px;">
     167                                        <h3><?php _e( 'Forums for Groups', 'buddypress' ) ?></h3>
     168
     169                                        <p><?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' ); ?></p>
     170                                        <p class="description"><?php _e( 'You may use an existing bbPress installation if you have one.', 'buddypress' ); ?></p>
     171
     172                                        <h4 style="margin-bottom: 10px;"><?php _e( 'Features', 'buddypress' ); ?></h4>
     173                                        <ul class="description" style="list-style: square; margin-left: 30px;">
     174                                                <li><?php _e( 'Group Integration',           'buddypress' ); ?></p></li>
     175                                                <li><?php _e( 'Member Profile Integration',  'buddypress' ); ?></p></li>
     176                                                <li><?php _e( 'Activity Stream Integration', 'buddypress' ); ?></p></li>
     177                                                <li><?php _e( '@ Mention Integration',       'buddypress' ); ?></p></li>
     178                                        </ul>
     179
     180                                        <div>
     181                                                <a class="button button-primary" href="<?php echo $post_url . '&step=new' ?>"><?php _e( 'Install Group Forums', 'buddypress' ) ?></a> &nbsp;
     182                                                <a class="button" href="<?php echo $post_url . '&step=existing' ?>"><?php _e( 'Use Existing Installation', 'buddypress' ) ?></a>
     183                                        </div>
     184                                </div>
     185
     186                                <div style="width: 45%; float: left; margin: 20px 0 20px 20px; padding: 0 20px 20px 20px; border: 1px solid #ddd; background-color: #fff;">
     187                                        <h3><?php _e( 'New! Site Wide Forums', 'buddypress' ) ?></h3>
     188                                        <p><?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' ) ?></p>
     189                                        <p class="description"><?php _e( 'You may activate both Group and Site Wide forums, but this may create a poor experience for your members.', 'buddypress' ) ?></p>
     190
     191                                        <h4 style="margin-bottom: 10px;"><?php _e( 'Features', 'buddypress' ); ?></h4>
     192                                        <ul class="description" style="list-style: square; margin-left: 30px;">
     193                                                <li><?php _e( 'Central Discussion Area',     'buddypress' ); ?></p></li>
     194                                                <li><?php _e( 'Forum Plugins Available',     'buddypress' ); ?></p></li>
     195                                                <li><?php _e( 'Activity Stream Integration', 'buddypress' ); ?></p></li>
     196                                                <li><?php _e( '@ Mention Integration',       'buddypress' ); ?></p></li>
     197                                        </ul>
     198                                        <div>
     199                                                <a class="button thickbox button-primary" href="<?php bp_admin_url( add_query_arg( array( 'tab' => 'plugin-information', 'plugin' => 'bbpress', 'TB_iframe' => 'true', 'width' => '640', 'height' => '500' ), 'plugin-install.php' ) ); ?>"><?php _e( 'Install Site Wide Forums', 'buddypress' ) ?></a> &nbsp;
     200                                        </div>
     201                                </div>
     202
     203                        <?php }
     204                break;
     205        }
    122206}
    123207
    124 /** Config ********************************************************************/
     208function bp_forums_configure_existing_install() {
     209        global $wpdb, $bbdb;
     210
     211        check_admin_referer( 'bp_forums_existing_install_init' );
     212
     213        // Sanitize $_REQUEST['bbconfigloc']
     214        $_REQUEST['bbconfigloc'] = apply_filters( 'bp_forums_bbconfig_location', $_REQUEST['bbconfigloc'] );
     215
     216        if ( false === strpos( $_REQUEST['bbconfigloc'], 'bb-config.php' ) ) {
     217                if ( '/' != substr( $_REQUEST['bbconfigloc'], -1, 1 ) )
     218                        $_REQUEST['bbconfigloc'] .= '/';
     219
     220                $_REQUEST['bbconfigloc'] .= 'bb-config.php';
     221        }
    125222
    126 function bp_forums_bbpress_install( $location = '' ) {
    127         global $wpdb, $bp;
     223        bp_update_option( 'bb-config-location', $_REQUEST['bbconfigloc'] );
    128224
    129         if ( empty( $location ) )
    130                 $location = ABSPATH . 'bb-config.php';
     225        if ( !file_exists( $_REQUEST['bbconfigloc'] ) )
     226                return false;
     227
     228        return true;
     229}
     230
     231function bp_forums_bbpress_install() {
     232        global $wpdb, $bbdb, $bp;
     233
     234        check_admin_referer( 'bp_forums_new_install_init' );
    131235
    132236        // Create the bb-config.php file
    133237        $initial_write = bp_forums_bbpress_write(
    134238                BP_PLUGIN_DIR . '/bp-forums/bbpress/bb-config-sample.php',
    135                 $location,
     239                ABSPATH . 'bb-config.php',
    136240                array(
    137241                        "define( 'BBDB_NAME',"  => array( "'bbpress'",                          "'" . DB_NAME . "'" ),
    138242                        "define( 'BBDB_USER',"  => array( "'username'",                         "'" . DB_USER . "'" ),
    function bp_forums_bbpress_install( $location = '' ) { 
    150254        );
    151255
    152256        // Add the custom user and usermeta entries to the config file
    153         if ( $initial_write == 1 ) {
    154                 $file = file_get_contents( $location );
    155         } else {
     257        if ( $initial_write == 1 )
     258                $file = file_get_contents( ABSPATH . 'bb-config.php' );
     259        else
    156260                $file = &$initial_write;
    157         }
    158261
    159262        $file = trim( $file );
    160         if ( '?>' == substr( $file, -2, 2 ) ) {
     263        if ( '?>' == substr( $file, -2, 2 ) )
    161264                $file = substr( $file, 0, -2 );
    162         }
    163265
    164266        $file .= "\n" .   '$bb->custom_user_table = \'' . $wpdb->users . '\';';
    165267        $file .= "\n" .   '$bb->custom_user_meta_table = \'' . $wpdb->usermeta . '\';';
    166         $file .= "\n\n" . '$bb->uri = \'' . BP_PLUGIN_URL . 'bp-forums/bbpress/\';';
     268        $file .= "\n\n" . '$bb->uri = \'' . BP_PLUGIN_URL . '/bp-forums/bbpress/\';';
    167269        $file .= "\n" .   '$bb->name = \'' . get_blog_option( bp_get_root_blog_id(), 'blogname' ) . ' ' . __( 'Forums', 'buddypress' ) . '\';';
    168270
    169         if ( is_multisite() ) {
     271        if ( is_multisite() )
    170272                $file .= "\n" .   '$bb->wordpress_mu_primary_blog_id = ' . bp_get_root_blog_id() . ';';
    171         }
    172273
    173         if ( defined( 'AUTH_SALT' ) ) {
     274        if ( defined( 'AUTH_SALT' ) )
    174275                $file .= "\n\n" . 'define(\'BB_AUTH_SALT\', \'' . addslashes( AUTH_SALT ) . '\');';
    175         }
    176276
    177         if ( defined( 'LOGGED_IN_SALT' ) ) {
     277        if ( defined( 'LOGGED_IN_SALT' ) )
    178278                $file .= "\n" .   'define(\'BB_LOGGED_IN_SALT\', \'' . addslashes( LOGGED_IN_SALT ) . '\');';
    179         }
    180279
    181         if ( defined( 'SECURE_AUTH_SALT' ) ) {
     280        if ( defined( 'SECURE_AUTH_SALT' ) )
    182281                $file .= "\n" .   'define(\'BB_SECURE_AUTH_SALT\', \'' . addslashes( SECURE_AUTH_SALT ) . '\');';
    183         }
    184282
    185283        $file .= "\n\n" . 'define(\'WP_AUTH_COOKIE_VERSION\', 2);';
    186284        $file .= "\n\n" . '?>';
    187285
    188286        if ( $initial_write == 1 ) {
    189                 $file_handle = fopen( $location, 'w' );
     287                $file_handle = fopen( ABSPATH . 'bb-config.php', 'w' );
    190288                fwrite( $file_handle, $file );
    191289                fclose( $file_handle );
    192290        } else {
    193291                $initial_write = $file;
    194292        }
    195293
    196         bp_update_option( 'bb-config-location', $location );
    197 
    198         return $file;
     294        bp_update_option( 'bb-config-location', ABSPATH . 'bb-config.php' );
     295        return $initial_write;
    199296}
    200297
    201298function bp_forums_bbpress_write( $file_source, $file_target, $alterations ) {
    202299
    203         if ( empty( $file_source ) || !file_exists( $file_source ) || !is_file( $file_source ) ) {
     300        if ( !$file_source || !file_exists( $file_source ) || !is_file( $file_source ) )
    204301                return -1;
    205         }
    206302
    207         if ( empty( $file_target ) ) {
     303        if ( !$file_target )
    208304                $file_target = $file_source;
    209         }
    210305
    211         if ( empty( $alterations ) || !is_array( $alterations ) ) {
     306        if ( !$alterations || !is_array( $alterations ) )
    212307                return -2;
    213         }
    214308
    215309        // Get the existing lines in the file
    216310        $lines = file( $file_source );
    function bp_forums_bbpress_write( $file_source, $file_target, $alterations ) { 
    219313        $modified_lines = array();
    220314
    221315        // Loop through the lines and modify them
    222         foreach ( (array) $lines as $line ) {
     316        foreach ( (array)$lines as $line ) {
    223317                if ( isset( $alterations[substr( $line, 0, 20 )] ) ) {
    224318                        $alteration = $alterations[substr( $line, 0, 20 )];
    225319                        $modified_lines[] = str_replace( $alteration[0], $alteration[1], $line );
    function bp_forums_bbpress_write( $file_source, $file_target, $alterations ) { 
    245339                }
    246340        }
    247341
    248         if ( empty( $writable ) ) {
     342        if ( empty( $writable ) )
    249343                return trim( join( null, $modified_lines ) );
    250         }
    251344
    252345        // Open the file for writing - rewrites the whole file
    253346        $file_handle = fopen( $file_target, 'w' );
    254347
    255348        // Write lines one by one to avoid OS specific newline hassles
    256         foreach ( (array) $modified_lines as $modified_line ) {
    257                 if ( false !== strpos( $modified_line, '?>' ) ) {
     349        foreach ( (array)$modified_lines as $modified_line ) {
     350                if ( strlen( $modified_line ) - 2 === strrpos( $modified_line, '?>' ) ) {
    258351                        $modified_line = '?>';
    259352                }
     353
    260354                fwrite( $file_handle, $modified_line );
    261355                if ( $modified_line == '?>' ) {
    262356                        break;
  • bp-forums/bp-forums-functions.php

    function bp_forums_is_bbpress_active() { 
    3434 * @return boolean True if option exists, false if not
    3535 */
    3636function bp_forums_is_installed_correctly() {
    37         if ( bp_get_option(     'bb-config-location' ) )
     37        global $bp;
     38
     39        if ( isset( $bp->forums->bbconfig ) && is_file( $bp->forums->bbconfig ) )
    3840                return true;
    3941
    4042        return false;
    function bp_forums_update_topic( $args = '' ) { 
    240242        $r = wp_parse_args( $args, $defaults );
    241243        extract( $r, EXTR_SKIP );
    242244
    243         // Check if the user is a spammer 
    244         if ( bp_is_user_inactive( bp_loggedin_user_id() ) ) 
     245        // Check if the user is a spammer
     246        if ( bp_is_user_inactive( bp_loggedin_user_id() ) )
    245247                return false;
    246248
    247249        // bb_insert_topic() will append tags, but not remove them. So we remove all existing tags.
    function bp_forums_total_topic_count() { 
    351353 */
    352354function bp_forums_reply_exists( $text = '', $topic_id = 0, $user_id = 0 ) {
    353355        $reply_exists = false;
    354        
     356
    355357        if ( $text && $topic_id && $user_id ) {
    356358                do_action( 'bbpress_init' );
    357                
     359
    358360                $args = array(
    359361                        'post_author_id' => $user_id,
    360362                        'topic_id'       => $topic_id
    361363                );
    362                
     364
    363365                // BB_Query's post_text parameter does a MATCH, while we need exact matches
    364366                add_filter( 'get_posts_where', create_function( '$q', 'return $q . " AND p.post_text = \'' . $text . '\'";' ) );
    365                
     367
    366368                $query = new BB_Query( 'post', $args );
    367                
     369
    368370                $reply_exists = !empty( $query->results );
    369371        }
    370        
     372
    371373        return apply_filters( 'bp_forums_reply_exists', $reply_exists, $text, $topic_id, $user_id );
    372374}
    373375
  • bp-forums/bp-forums-loader.php

    class BP_Forums_Component extends BP_Component { 
    4747                if ( !defined( 'BP_FORUMS_SLUG' ) )
    4848                        define( 'BP_FORUMS_SLUG', $this->id );
    4949
     50                // The location of the bbPress stand-alone config file
     51                if ( isset( $bp->site_options['bb-config-location'] ) )
     52                        $this->bbconfig = $bp->site_options['bb-config-location'];
     53
    5054                // All globals for messaging component.
    5155                // Note that global_tables is included in this array.
    5256                $globals = array(
  • bp-themes/bp-default/groups/create.php

    get_header( 'buddypress' ); ?> 
    1111
    1212        <div id="content">
    1313                <div class="padder">
    14                
     14
    1515                <?php do_action( 'bp_before_create_group_content_template' ); ?>
    1616
    1717                <form action="<?php bp_group_creation_form_action(); ?>" method="post" id="create-group-form" class="standard-form" enctype="multipart/form-data">
    get_header( 'buddypress' ); ?> 
    107107                                                </label>
    108108                                        </div>
    109109
    110                                         <?php if ( bp_is_active( 'forums' ) && bp_forums_is_installed_correctly() ) : ?>
     110                                        <?php if ( bp_is_active( 'forums' ) ) : ?>
    111111
    112112                                                <h4><?php _e( 'Group Forums', 'buddypress' ); ?></h4>
    113113
    114                                                 <p><?php _e( 'Should this group have a forum?', 'buddypress' ); ?></p>
     114                                                <?php if ( bp_forums_is_installed_correctly() ) : ?>
    115115
    116                                                 <div class="checkbox">
    117                                                         <label><input type="checkbox" name="group-show-forum" id="group-show-forum" value="1"<?php checked( bp_get_new_group_enable_forum(), true, true ); ?> /> <?php _e( 'Enable discussion forum', 'buddypress' ); ?></label>
    118                                                 </div>
     116                                                        <p><?php _e( 'Should this group have a forum?', 'buddypress' ); ?></p>
     117
     118                                                        <div class="checkbox">
     119                                                                <label><input type="checkbox" name="group-show-forum" id="group-show-forum" value="1"<?php checked( bp_get_new_group_enable_forum(), true, true ); ?> /> <?php _e( 'Enable discussion forum', 'buddypress' ); ?></label>
     120                                                        </div>
     121                                                <?php elseif ( is_super_admin() ) : ?>
     122
     123                                                        <p><?php printf( __( '<strong>Attention Site Admin:</strong> Group forums require the <a href="%s">correct setup and configuration</a> 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' ) ); ?></p>
     124
     125                                                <?php endif; ?>
    119126
    120127                                        <?php endif; ?>
    121128
    get_header( 'buddypress' ); ?> 
    298305                        <?php do_action( 'bp_after_create_group' ); ?>
    299306
    300307                </form>
    301                
     308
    302309                <?php do_action( 'bp_after_create_group_content_template' ); ?>
    303310
    304311                </div><!-- .padder -->