Ticket #4258: 4258.01.patch
File 4258.01.patch, 24.5 KB (added by , 12 years ago) |
---|
-
bp-core/admin/bp-core-functions.php
diff --git bp-core/admin/bp-core-functions.php bp-core/admin/bp-core-functions.php index 81944c6..f67b88e 100644
function bp_core_admin_tabs( $active_tab = '' ) { 365 365 ) 366 366 ); 367 367 368 // If forums component is active and bbPress 1.x is in useadd additional tab369 if ( bp_is_active( 'forums' ) && bp_forums_is_repair()) {368 // If forums component is active, add additional tab 369 if ( bp_is_active( 'forums' ) ) { 370 370 $tabs['3'] = array( 371 371 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bb-forums-setup' ), 'admin.php' ) ), 372 372 'name' => __( 'Forums', 'buddypress' ) -
bp-core/admin/bp-core-update.php
diff --git bp-core/admin/bp-core-update.php bp-core/admin/bp-core-update.php index fdb06e3..4d29ede 100644
class BP_Core_Setup_Wizard { 542 542 $current_theme = wp_get_theme(); 543 543 $screenshot = ''; 544 544 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']; 547 547 } ?> 548 548 549 549 <script type="text/javascript"> -
bp-forums/bp-forums-admin.php
diff --git bp-forums/bp-forums-admin.php bp-forums/bp-forums-admin.php index 40e6d49..c5299d7 100644
1 1 <?php 2 3 2 // Exit if accessed directly 4 3 if ( !defined( 'ABSPATH' ) ) exit; 5 4 6 /** UI ************************************************************************/7 8 5 function bp_forums_add_admin_menu() { 6 global $bp; 9 7 10 if ( ! bp_current_user_can( 'bp_moderate') )11 return ;8 if ( !is_super_admin() ) 9 return false; 12 10 13 if ( ! bp_forums_is_repair() ) 14 return; 11 $page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php'; 15 12 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' ); 19 20 // Fudge the highlighted subnav item when on a BuddyPress admin page 21 add_action( "admin_head-$hook", 'bp_core_modify_admin_menu_highlight' ); 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" ); 22 15 } 23 16 add_action( bp_core_admin_hook(), 'bp_forums_add_admin_menu' ); 24 17 25 18 function bp_forums_bbpress_admin() { 26 ?> 19 global $bp; 27 20 28 <div class="wrap">21 $action = bp_get_admin_url( 'admin.php?page=bb-forums-setup&reinstall=1' ); ?> 29 22 23 <div class="wrap"> 30 24 <?php screen_icon( 'buddypress' ); ?> 31 25 32 26 <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Forums', 'buddypress' ) ); ?></h2> 33 27 34 < h3><?php _e( 'Forum Repair', 'buddypress' ); ?></h3>28 <?php if ( isset( $_POST['submit'] ) ) : ?> 35 29 36 <?php if ( bp_forums_is_repair() ) : ?> 30 <div id="message" class="updated fade"> 31 <p><?php _e( 'Settings Saved.', 'buddypress' ) ?></p> 32 </div> 37 33 38 <p><?php printf( __( 'The following configuration was successfully saved to: %s', 'buddypress' ), bp_get_option( 'bb-config-location' ) );?></p>34 <?php endif; ?> 39 35 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> 36 <?php 43 37 44 <?php elseif ( bp_forums_is_migrate() ) : ?>38 if ( isset( $_REQUEST['reinstall'] ) || !bp_forums_is_installed_correctly() ) : 45 39 46 <?php47 add_thickbox();48 wp_enqueue_script( 'plugin-install');49 wp_admin_css( 'plugin-install' ); 50 40 // Delete the bb-config.php location option 41 bp_delete_option( 'bb-config-location' ); 42 bp_forums_bbpress_install_wizard(); 43 44 else : ?> 51 45 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> 46 <div style="width: 45%; float: left; margin-top: 20px;"> 47 <h3><?php _e( '(Installed)', 'buddypress' ); ?> <?php _e( 'Forums for Groups', 'buddypress' ) ?></h3> 53 48 54 <?php else : ?> 49 <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> 50 <p class="description"><?php _e( 'You may use an existing bbPress installation if you have one.', 'buddypress' ); ?></p> 51 52 <h4 style="margin-bottom: 10px;"><?php _e( 'Features', 'buddypress' ); ?></h4> 53 <ul class="description" style="list-style: square; margin-left: 30px;"> 54 <li><?php _e( 'Group Integration', 'buddypress' ); ?></p></li> 55 <li><?php _e( 'Member Profile Integration', 'buddypress' ); ?></p></li> 56 <li><?php _e( 'Activity Stream Integration', 'buddypress' ); ?></p></li> 57 <li><?php _e( '@ Mention Integration', 'buddypress' ); ?></p></li> 58 </ul> 59 60 <div> 61 <a class="button button-primary" href="<?php echo $action ?>"><?php _e( 'Uninstall Group Forums', 'buddypress' ) ?></a> 62 </div> 63 </div> 64 65 <div style="width: 45%; float: left; margin: 20px 0 20px 20px; padding: 0 20px 20px 20px; border: 1px solid #ddd; background-color: #fff;"> 66 <h3><?php _e( 'New! Site Wide Forums', 'buddypress' ) ?></h3> 67 <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> 68 <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> 69 70 <h4 style="margin-bottom: 10px;"><?php _e( 'Features', 'buddypress' ); ?></h4> 71 <ul class="description" style="list-style: square; margin-left: 30px;"> 72 <li><?php _e( 'Central Discussion Area', 'buddypress' ); ?></p></li> 73 <li><?php _e( 'Forum Plugins Available', 'buddypress' ); ?></p></li> 74 <li><?php _e( 'Activity Stream Integration', 'buddypress' ); ?></p></li> 75 <li><?php _e( '@ Mention Integration', 'buddypress' ); ?></p></li> 76 </ul> 77 <div> 78 <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> 79 </div> 80 </div> 55 81 56 82 <?php endif; ?> 57 83 … … function bp_forums_bbpress_admin() { 59 85 <?php 60 86 } 61 87 62 /** _is_ **********************************************************************/ 88 function bp_forums_bbpress_install_wizard() { 89 $post_url = network_admin_url( 'admin.php?page=bb-forums-setup' ); 90 91 $step = isset( $_REQUEST['step'] ) ? $_REQUEST['step'] : ''; 92 93 switch( $step ) { 94 case 'existing': 95 if ( isset( $_REQUEST['doinstall'] ) && ( 1 == (int) $_REQUEST['doinstall'] ) ) { 96 if ( !bp_forums_configure_existing_install() ) { 97 _e( 'The bb-config.php file was not found at that location, please try again.', 'buddypress' ); 98 } else { 99 ?> 100 <h3><?php _e( 'Forums were set up correctly using your existing bbPress install!', 'buddypress' ) ?></h3> 101 <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 102 } 103 } else { ?> 104 105 <form action="" method="post"> 106 <h3><?php _e( 'Existing bbPress Installation', 'buddypress' ) ?></h3> 107 <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> 108 <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> 109 <p><input type="submit" class="button-primary" value="<?php _e( 'Complete Installation', 'buddypress' ) ?>" /></p> 110 <input type="hidden" name="step" value="existing" /> 111 <input type="hidden" name="doinstall" value="1" /> 112 <?php wp_nonce_field( 'bp_forums_existing_install_init' ) ?> 113 </form> 114 115 <?php 116 } 117 break; 63 118 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() { 119 case 'new': 120 if ( isset( $_REQUEST['doinstall'] ) && 1 == (int)$_REQUEST['doinstall'] ) { 121 $result = bp_forums_bbpress_install(); 71 122 72 // Bail if bbPress 1.x was never installed 73 if ( isset( $_REQUEST['repair'] ) && bp_forums_is_installed_correctly() ) 74 return true; 123 switch ( $result ) { 124 case 1: 125 _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' ); 126 break; 127 default: 128 // Just write the contents to screen 129 _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' ); ?> 75 130 76 return false; 77 } 131 <textarea style="display:block; margin-top: 30px; width: 80%;" rows="50"><?php echo htmlspecialchars( $result ); ?></textarea> 78 132 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() { 133 <?php 134 break; 135 } 136 } else { ?> 86 137 87 // Bail if bbPress 1.x was never installed 88 if ( isset( $_REQUEST['migrate'] ) && bp_forums_is_installed_correctly() ) 89 return true; 138 <h3><?php _e( 'New bbPress Installation', 'buddypress' ) ?></h3> 139 <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 140 process. When you're ready, hit the link below.", 'buddypress' ) ?></p> 141 <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> 90 142 91 return false; 92 } 143 <?php 144 } 145 break; 93 146 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() { 147 default: 148 if ( !file_exists( BP_PLUGIN_DIR . '/bp-forums/bbpress/' ) ) { ?> 101 149 102 // Bail if bbPress 1.x was never installed103 if ( isset( $_REQUEST['install'] ) && ! bp_forums_is_installed_correctly() )104 return true;150 <div id="message" class="error"> 151 <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> 152 </div> 105 153 106 return false; 107 } 154 <?php } else { 108 155 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() { 156 // Include the plugin install 116 157 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; 158 add_thickbox(); 159 wp_enqueue_script( 'plugin-install' ); 160 wp_admin_css( 'plugin-install' ); 161 ?> 120 162 121 return false; 163 <div style="width: 45%; float: left; margin-top: 20px;"> 164 <h3><?php _e( 'Forums for Groups', 'buddypress' ) ?></h3> 165 166 <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> 167 <p class="description"><?php _e( 'You may use an existing bbPress installation if you have one.', 'buddypress' ); ?></p> 168 169 <h4 style="margin-bottom: 10px;"><?php _e( 'Features', 'buddypress' ); ?></h4> 170 <ul class="description" style="list-style: square; margin-left: 30px;"> 171 <li><?php _e( 'Group Integration', 'buddypress' ); ?></p></li> 172 <li><?php _e( 'Member Profile Integration', 'buddypress' ); ?></p></li> 173 <li><?php _e( 'Activity Stream Integration', 'buddypress' ); ?></p></li> 174 <li><?php _e( '@ Mention Integration', 'buddypress' ); ?></p></li> 175 </ul> 176 177 <div> 178 <a class="button button-primary" href="<?php echo $post_url . '&step=new' ?>"><?php _e( 'Install Group Forums', 'buddypress' ) ?></a> 179 <a class="button" href="<?php echo $post_url . '&step=existing' ?>"><?php _e( 'Use Existing Installation', 'buddypress' ) ?></a> 180 </div> 181 </div> 182 183 <div style="width: 45%; float: left; margin: 20px 0 20px 20px; padding: 0 20px 20px 20px; border: 1px solid #ddd; background-color: #fff;"> 184 <h3><?php _e( 'New! Site Wide Forums', 'buddypress' ) ?></h3> 185 <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> 186 <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> 187 188 <h4 style="margin-bottom: 10px;"><?php _e( 'Features', 'buddypress' ); ?></h4> 189 <ul class="description" style="list-style: square; margin-left: 30px;"> 190 <li><?php _e( 'Central Discussion Area', 'buddypress' ); ?></p></li> 191 <li><?php _e( 'Forum Plugins Available', 'buddypress' ); ?></p></li> 192 <li><?php _e( 'Activity Stream Integration', 'buddypress' ); ?></p></li> 193 <li><?php _e( '@ Mention Integration', 'buddypress' ); ?></p></li> 194 </ul> 195 <div> 196 <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> 197 </div> 198 </div> 199 200 <?php } 201 break; 202 } 122 203 } 123 204 124 /** Config ********************************************************************/ 205 function bp_forums_configure_existing_install() { 206 global $wpdb, $bbdb; 207 208 check_admin_referer( 'bp_forums_existing_install_init' ); 209 210 // Sanitize $_REQUEST['bbconfigloc'] 211 $_REQUEST['bbconfigloc'] = apply_filters( 'bp_forums_bbconfig_location', $_REQUEST['bbconfigloc'] ); 212 213 if ( false === strpos( $_REQUEST['bbconfigloc'], 'bb-config.php' ) ) { 214 if ( '/' != substr( $_REQUEST['bbconfigloc'], -1, 1 ) ) 215 $_REQUEST['bbconfigloc'] .= '/'; 216 217 $_REQUEST['bbconfigloc'] .= 'bb-config.php'; 218 } 125 219 126 function bp_forums_bbpress_install( $location = '' ) { 127 global $wpdb, $bp; 220 bp_update_option( 'bb-config-location', $_REQUEST['bbconfigloc'] ); 128 221 129 if ( empty( $location ) ) 130 $location = ABSPATH . 'bb-config.php'; 222 if ( !file_exists( $_REQUEST['bbconfigloc'] ) ) 223 return false; 224 225 return true; 226 } 227 228 function bp_forums_bbpress_install() { 229 global $wpdb, $bbdb, $bp; 230 231 check_admin_referer( 'bp_forums_new_install_init' ); 131 232 132 233 // Create the bb-config.php file 133 234 $initial_write = bp_forums_bbpress_write( 134 235 BP_PLUGIN_DIR . '/bp-forums/bbpress/bb-config-sample.php', 135 $location,236 ABSPATH . 'bb-config.php', 136 237 array( 137 238 "define( 'BBDB_NAME'," => array( "'bbpress'", "'" . DB_NAME . "'" ), 138 239 "define( 'BBDB_USER'," => array( "'username'", "'" . DB_USER . "'" ), … … function bp_forums_bbpress_install( $location = '' ) { 150 251 ); 151 252 152 253 // Add the custom user and usermeta entries to the config file 153 if ( $initial_write == 1 ) {154 $file = file_get_contents( $location);155 } else {254 if ( $initial_write == 1 ) 255 $file = file_get_contents( ABSPATH . 'bb-config.php' ); 256 else 156 257 $file = &$initial_write; 157 }158 258 159 259 $file = trim( $file ); 160 if ( '?>' == substr( $file, -2, 2 ) ) {260 if ( '?>' == substr( $file, -2, 2 ) ) 161 261 $file = substr( $file, 0, -2 ); 162 }163 262 164 263 $file .= "\n" . '$bb->custom_user_table = \'' . $wpdb->users . '\';'; 165 264 $file .= "\n" . '$bb->custom_user_meta_table = \'' . $wpdb->usermeta . '\';'; 166 $file .= "\n\n" . '$bb->uri = \'' . BP_PLUGIN_URL . ' bp-forums/bbpress/\';';265 $file .= "\n\n" . '$bb->uri = \'' . BP_PLUGIN_URL . '/bp-forums/bbpress/\';'; 167 266 $file .= "\n" . '$bb->name = \'' . get_blog_option( bp_get_root_blog_id(), 'blogname' ) . ' ' . __( 'Forums', 'buddypress' ) . '\';'; 168 267 169 if ( is_multisite() ) {268 if ( is_multisite() ) 170 269 $file .= "\n" . '$bb->wordpress_mu_primary_blog_id = ' . bp_get_root_blog_id() . ';'; 171 }172 270 173 if ( defined( 'AUTH_SALT' ) ) {271 if ( defined( 'AUTH_SALT' ) ) 174 272 $file .= "\n\n" . 'define(\'BB_AUTH_SALT\', \'' . addslashes( AUTH_SALT ) . '\');'; 175 }176 273 177 if ( defined( 'LOGGED_IN_SALT' ) ) {274 if ( defined( 'LOGGED_IN_SALT' ) ) 178 275 $file .= "\n" . 'define(\'BB_LOGGED_IN_SALT\', \'' . addslashes( LOGGED_IN_SALT ) . '\');'; 179 }180 276 181 if ( defined( 'SECURE_AUTH_SALT' ) ) {277 if ( defined( 'SECURE_AUTH_SALT' ) ) 182 278 $file .= "\n" . 'define(\'BB_SECURE_AUTH_SALT\', \'' . addslashes( SECURE_AUTH_SALT ) . '\');'; 183 }184 279 185 280 $file .= "\n\n" . 'define(\'WP_AUTH_COOKIE_VERSION\', 2);'; 186 281 $file .= "\n\n" . '?>'; 187 282 188 283 if ( $initial_write == 1 ) { 189 $file_handle = fopen( $location, 'w' );284 $file_handle = fopen( ABSPATH . 'bb-config.php', 'w' ); 190 285 fwrite( $file_handle, $file ); 191 286 fclose( $file_handle ); 192 287 } else { 193 288 $initial_write = $file; 194 289 } 195 290 196 bp_update_option( 'bb-config-location', $location ); 197 198 return $file; 291 bp_update_option( 'bb-config-location', ABSPATH . 'bb-config.php' ); 292 return $initial_write; 199 293 } 200 294 201 295 function bp_forums_bbpress_write( $file_source, $file_target, $alterations ) { 202 296 203 if ( empty( $file_source ) || !file_exists( $file_source ) || !is_file( $file_source ) ) {297 if ( !$file_source || !file_exists( $file_source ) || !is_file( $file_source ) ) 204 298 return -1; 205 }206 299 207 if ( empty( $file_target ) ) {300 if ( !$file_target ) 208 301 $file_target = $file_source; 209 }210 302 211 if ( empty( $alterations ) || !is_array( $alterations ) ) {303 if ( !$alterations || !is_array( $alterations ) ) 212 304 return -2; 213 }214 305 215 306 // Get the existing lines in the file 216 307 $lines = file( $file_source ); … … function bp_forums_bbpress_write( $file_source, $file_target, $alterations ) { 219 310 $modified_lines = array(); 220 311 221 312 // Loop through the lines and modify them 222 foreach ( (array) 313 foreach ( (array)$lines as $line ) { 223 314 if ( isset( $alterations[substr( $line, 0, 20 )] ) ) { 224 315 $alteration = $alterations[substr( $line, 0, 20 )]; 225 316 $modified_lines[] = str_replace( $alteration[0], $alteration[1], $line ); … … function bp_forums_bbpress_write( $file_source, $file_target, $alterations ) { 245 336 } 246 337 } 247 338 248 if ( empty( $writable ) ) {339 if ( empty( $writable ) ) 249 340 return trim( join( null, $modified_lines ) ); 250 }251 341 252 342 // Open the file for writing - rewrites the whole file 253 343 $file_handle = fopen( $file_target, 'w' ); 254 344 255 345 // Write lines one by one to avoid OS specific newline hassles 256 foreach ( (array) 257 if ( false !== strpos( $modified_line, '?>' ) ) {346 foreach ( (array)$modified_lines as $modified_line ) { 347 if ( strlen( $modified_line ) - 2 === strrpos( $modified_line, '?>' ) ) { 258 348 $modified_line = '?>'; 259 349 } 350 260 351 fwrite( $file_handle, $modified_line ); 261 352 if ( $modified_line == '?>' ) { 262 353 break; -
bp-forums/bp-forums-functions.php
diff --git bp-forums/bp-forums-functions.php bp-forums/bp-forums-functions.php index 41e33be..5a34dd7 100644
function bp_forums_is_bbpress_active() { 34 34 * @return boolean True if option exists, false if not 35 35 */ 36 36 function 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 ) ) 38 40 return true; 39 41 40 42 return false; … … function bp_forums_update_topic( $args = '' ) { 240 242 $r = wp_parse_args( $args, $defaults ); 241 243 extract( $r, EXTR_SKIP ); 242 244 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() ) ) 245 247 return false; 246 248 247 249 // bb_insert_topic() will append tags, but not remove them. So we remove all existing tags. … … function bp_forums_total_topic_count() { 351 353 */ 352 354 function bp_forums_reply_exists( $text = '', $topic_id = 0, $user_id = 0 ) { 353 355 $reply_exists = false; 354 356 355 357 if ( $text && $topic_id && $user_id ) { 356 358 do_action( 'bbpress_init' ); 357 359 358 360 $args = array( 359 361 'post_author_id' => $user_id, 360 362 'topic_id' => $topic_id 361 363 ); 362 364 363 365 // BB_Query's post_text parameter does a MATCH, while we need exact matches 364 366 add_filter( 'get_posts_where', create_function( '$q', 'return $q . " AND p.post_text = \'' . $text . '\'";' ) ); 365 367 366 368 $query = new BB_Query( 'post', $args ); 367 369 368 370 $reply_exists = !empty( $query->results ); 369 371 } 370 372 371 373 return apply_filters( 'bp_forums_reply_exists', $reply_exists, $text, $topic_id, $user_id ); 372 374 } 373 375 -
bp-forums/bp-forums-loader.php
diff --git bp-forums/bp-forums-loader.php bp-forums/bp-forums-loader.php index aad85ba..24b9cfe 100644
class BP_Forums_Component extends BP_Component { 47 47 if ( !defined( 'BP_FORUMS_SLUG' ) ) 48 48 define( 'BP_FORUMS_SLUG', $this->id ); 49 49 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 50 54 // All globals for messaging component. 51 55 // Note that global_tables is included in this array. 52 56 $globals = array( -
bp-themes/bp-default/groups/create.php
diff --git bp-themes/bp-default/groups/create.php bp-themes/bp-default/groups/create.php index c177feb..0f8853e 100644
get_header( 'buddypress' ); ?> 11 11 12 12 <div id="content"> 13 13 <div class="padder"> 14 14 15 15 <?php do_action( 'bp_before_create_group_content_template' ); ?> 16 16 17 17 <form action="<?php bp_group_creation_form_action(); ?>" method="post" id="create-group-form" class="standard-form" enctype="multipart/form-data"> … … get_header( 'buddypress' ); ?> 107 107 </label> 108 108 </div> 109 109 110 <?php if ( bp_is_active( 'forums' ) && bp_forums_is_installed_correctly()) : ?>110 <?php if ( bp_is_active( 'forums' ) ) : ?> 111 111 112 112 <h4><?php _e( 'Group Forums', 'buddypress' ); ?></h4> 113 113 114 < p><?php _e( 'Should this group have a forum?', 'buddypress' ); ?></p>114 <?php if ( bp_forums_is_installed_correctly() ) : ?> 115 115 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; ?> 119 126 120 127 <?php endif; ?> 121 128 … … get_header( 'buddypress' ); ?> 298 305 <?php do_action( 'bp_after_create_group' ); ?> 299 306 300 307 </form> 301 308 302 309 <?php do_action( 'bp_after_create_group_content_template' ); ?> 303 310 304 311 </div><!-- .padder -->