Ticket #4258: 4258.02.patch
| File 4258.02.patch, 24.8 KB (added by , 13 years ago) |
|---|
-
bp-core/admin/bp-core-functions.php
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
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
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' ); 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" ); 19 15 20 // Fudge the highlighted subnav item when on a BuddyPress admin page16 // Fudge the highlighted subnav item when on the BuddyPress Forums admin page 21 17 add_action( "admin_head-$hook", 'bp_core_modify_admin_menu_highlight' ); 22 18 } 23 19 add_action( bp_core_admin_hook(), 'bp_forums_add_admin_menu' ); 24 20 25 21 function bp_forums_bbpress_admin() { 26 ?> 22 global $bp; 27 23 28 <div class="wrap">24 $action = bp_get_admin_url( 'admin.php?page=bb-forums-setup&reinstall=1' ); ?> 29 25 26 <div class="wrap"> 30 27 <?php screen_icon( 'buddypress' ); ?> 31 28 32 29 <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Forums', 'buddypress' ) ); ?></h2> 33 30 34 < h3><?php _e( 'Forum Repair', 'buddypress' ); ?></h3>31 <?php if ( isset( $_POST['submit'] ) ) : ?> 35 32 36 <?php if ( bp_forums_is_repair() ) : ?> 33 <div id="message" class="updated fade"> 34 <p><?php _e( 'Settings Saved.', 'buddypress' ) ?></p> 35 </div> 37 36 38 <p><?php printf( __( 'The following configuration was successfully saved to: %s', 'buddypress' ), bp_get_option( 'bb-config-location' ) );?></p>37 <?php endif; ?> 39 38 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 43 40 44 <?php elseif ( bp_forums_is_migrate() ) : ?>41 if ( isset( $_REQUEST['reinstall'] ) || !bp_forums_is_installed_correctly() ) : 45 42 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> 51 51 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> 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> 53 54 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> 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> 82 </div> 83 </div> 55 84 56 85 <?php endif; ?> 57 86 … … function bp_forums_bbpress_admin() { 59 88 <?php 60 89 } 61 90 62 /** _is_ **********************************************************************/ 91 function 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; 63 121 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(); 71 125 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' ); ?> 75 133 76 return false; 77 } 134 <textarea style="display:block; margin-top: 30px; width: 80%;" rows="50"><?php echo htmlspecialchars( $result ); ?></textarea> 78 135 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 { ?> 86 140 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> 90 145 91 return false; 92 } 146 <?php 147 } 148 break; 93 149 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/' ) ) { ?> 101 152 102 // Bail if bbPress 1.x was never installed103 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> 105 156 106 return false; 107 } 157 <?php } else { 108 158 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 116 160 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 ?> 120 165 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> 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> 200 </div> 201 </div> 202 203 <?php } 204 break; 205 } 122 206 } 123 207 124 /** Config ********************************************************************/ 208 function 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 } 125 222 126 function bp_forums_bbpress_install( $location = '' ) { 127 global $wpdb, $bp; 223 bp_update_option( 'bb-config-location', $_REQUEST['bbconfigloc'] ); 128 224 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 231 function bp_forums_bbpress_install() { 232 global $wpdb, $bbdb, $bp; 233 234 check_admin_referer( 'bp_forums_new_install_init' ); 131 235 132 236 // Create the bb-config.php file 133 237 $initial_write = bp_forums_bbpress_write( 134 238 BP_PLUGIN_DIR . '/bp-forums/bbpress/bb-config-sample.php', 135 $location,239 ABSPATH . 'bb-config.php', 136 240 array( 137 241 "define( 'BBDB_NAME'," => array( "'bbpress'", "'" . DB_NAME . "'" ), 138 242 "define( 'BBDB_USER'," => array( "'username'", "'" . DB_USER . "'" ), … … function bp_forums_bbpress_install( $location = '' ) { 150 254 ); 151 255 152 256 // 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 156 260 $file = &$initial_write; 157 }158 261 159 262 $file = trim( $file ); 160 if ( '?>' == substr( $file, -2, 2 ) ) {263 if ( '?>' == substr( $file, -2, 2 ) ) 161 264 $file = substr( $file, 0, -2 ); 162 }163 265 164 266 $file .= "\n" . '$bb->custom_user_table = \'' . $wpdb->users . '\';'; 165 267 $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/\';'; 167 269 $file .= "\n" . '$bb->name = \'' . get_blog_option( bp_get_root_blog_id(), 'blogname' ) . ' ' . __( 'Forums', 'buddypress' ) . '\';'; 168 270 169 if ( is_multisite() ) {271 if ( is_multisite() ) 170 272 $file .= "\n" . '$bb->wordpress_mu_primary_blog_id = ' . bp_get_root_blog_id() . ';'; 171 }172 273 173 if ( defined( 'AUTH_SALT' ) ) {274 if ( defined( 'AUTH_SALT' ) ) 174 275 $file .= "\n\n" . 'define(\'BB_AUTH_SALT\', \'' . addslashes( AUTH_SALT ) . '\');'; 175 }176 276 177 if ( defined( 'LOGGED_IN_SALT' ) ) {277 if ( defined( 'LOGGED_IN_SALT' ) ) 178 278 $file .= "\n" . 'define(\'BB_LOGGED_IN_SALT\', \'' . addslashes( LOGGED_IN_SALT ) . '\');'; 179 }180 279 181 if ( defined( 'SECURE_AUTH_SALT' ) ) {280 if ( defined( 'SECURE_AUTH_SALT' ) ) 182 281 $file .= "\n" . 'define(\'BB_SECURE_AUTH_SALT\', \'' . addslashes( SECURE_AUTH_SALT ) . '\');'; 183 }184 282 185 283 $file .= "\n\n" . 'define(\'WP_AUTH_COOKIE_VERSION\', 2);'; 186 284 $file .= "\n\n" . '?>'; 187 285 188 286 if ( $initial_write == 1 ) { 189 $file_handle = fopen( $location, 'w' );287 $file_handle = fopen( ABSPATH . 'bb-config.php', 'w' ); 190 288 fwrite( $file_handle, $file ); 191 289 fclose( $file_handle ); 192 290 } else { 193 291 $initial_write = $file; 194 292 } 195 293 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; 199 296 } 200 297 201 298 function bp_forums_bbpress_write( $file_source, $file_target, $alterations ) { 202 299 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 ) ) 204 301 return -1; 205 }206 302 207 if ( empty( $file_target ) ) {303 if ( !$file_target ) 208 304 $file_target = $file_source; 209 }210 305 211 if ( empty( $alterations ) || !is_array( $alterations ) ) {306 if ( !$alterations || !is_array( $alterations ) ) 212 307 return -2; 213 }214 308 215 309 // Get the existing lines in the file 216 310 $lines = file( $file_source ); … … function bp_forums_bbpress_write( $file_source, $file_target, $alterations ) { 219 313 $modified_lines = array(); 220 314 221 315 // Loop through the lines and modify them 222 foreach ( (array) $lines as $line ) {316 foreach ( (array)$lines as $line ) { 223 317 if ( isset( $alterations[substr( $line, 0, 20 )] ) ) { 224 318 $alteration = $alterations[substr( $line, 0, 20 )]; 225 319 $modified_lines[] = str_replace( $alteration[0], $alteration[1], $line ); … … function bp_forums_bbpress_write( $file_source, $file_target, $alterations ) { 245 339 } 246 340 } 247 341 248 if ( empty( $writable ) ) {342 if ( empty( $writable ) ) 249 343 return trim( join( null, $modified_lines ) ); 250 }251 344 252 345 // Open the file for writing - rewrites the whole file 253 346 $file_handle = fopen( $file_target, 'w' ); 254 347 255 348 // 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, '?>' ) ) { 258 351 $modified_line = '?>'; 259 352 } 353 260 354 fwrite( $file_handle, $modified_line ); 261 355 if ( $modified_line == '?>' ) { 262 356 break; -
bp-forums/bp-forums-functions.php
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
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
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 -->