Changeset 6108
- Timestamp:
- 06/18/2012 01:06:13 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/admin/bp-core-functions.php
r6094 r6108 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' ) ), -
trunk/bp-core/admin/bp-core-update.php
r6105 r6108 541 541 $screenshot = ''; 542 542 543 if ( !empty( $installed_themes[$current_theme ]['Screenshot'] ) ) {544 $screenshot = trailingslashit( get_stylesheet_directory_uri() ) . $installed_themes[$current_theme ]['Screenshot'];543 if ( !empty( $installed_themes[$current_theme->stylesheet]['Screenshot'] ) ) { 544 $screenshot = trailingslashit( get_stylesheet_directory_uri() ) . $installed_themes[$current_theme->stylesheet]['Screenshot']; 545 545 } ?> 546 546 -
trunk/bp-forums/bp-forums-admin.php
r5885 r6108 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() { 9 10 if ( ! bp_current_user_can( 'bp_moderate' ) ) 11 return; 12 13 if ( ! bp_forums_is_repair() ) 14 return; 15 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 6 global $bp; 7 8 if ( !is_super_admin() ) 9 return false; 10 11 $page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php'; 12 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" ); 15 16 // 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 } … … 24 20 25 21 function bp_forums_bbpress_admin() { 26 ?> 22 global $bp; 23 24 $action = bp_get_admin_url( 'admin.php?page=bb-forums-setup&reinstall=1' ); ?> 27 25 28 26 <div class="wrap"> 29 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> 35 36 <?php if ( bp_forums_is_repair() ) : ?> 37 38 <p><?php printf( __( 'The following configuration was successfully saved to: %s', 'buddypress' ), bp_get_option( 'bb-config-location' ) );?></p> 39 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> 31 <?php if ( isset( $_POST['submit'] ) ) : ?> 32 33 <div id="message" class="updated fade"> 34 <p><?php _e( 'Settings Saved.', 'buddypress' ) ?></p> 42 35 </div> 43 36 44 <?php elseif ( bp_forums_is_migrate() ) : ?> 45 46 <?php 37 <?php endif; ?> 38 39 <?php 40 41 if ( isset( $_REQUEST['reinstall'] ) || !bp_forums_is_installed_correctly() ) : 42 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 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> 54 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> 84 85 <?php endif; ?> 86 87 </div> 88 <?php 89 } 90 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; 121 122 case 'new': 123 if ( isset( $_REQUEST['doinstall'] ) && 1 == (int)$_REQUEST['doinstall'] ) { 124 $result = bp_forums_bbpress_install(); 125 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' ); ?> 133 134 <textarea style="display:block; margin-top: 30px; width: 80%;" rows="50"><?php echo htmlspecialchars( $result ); ?></textarea> 135 136 <?php 137 break; 138 } 139 } else { ?> 140 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> 145 146 <?php 147 } 148 break; 149 150 default: 151 if ( !file_exists( BP_PLUGIN_DIR . '/bp-forums/bbpress/' ) ) { ?> 152 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> 156 157 <?php } else { 158 159 // Include the plugin install 160 47 161 add_thickbox(); 48 162 wp_enqueue_script( 'plugin-install' ); … … 50 164 ?> 51 165 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> 53 54 <?php else : ?> 55 56 <?php endif; ?> 57 58 </div> 59 <?php 60 } 61 62 /** _is_ **********************************************************************/ 63 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() { 71 72 // Bail if bbPress 1.x was never installed 73 if ( isset( $_REQUEST['repair'] ) && bp_forums_is_installed_correctly() ) 74 return true; 75 76 return false; 77 } 78 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() { 86 87 // Bail if bbPress 1.x was never installed 88 if ( isset( $_REQUEST['migrate'] ) && bp_forums_is_installed_correctly() ) 89 return true; 90 91 return false; 92 } 93 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() { 101 102 // Bail if bbPress 1.x was never installed 103 if ( isset( $_REQUEST['install'] ) && ! bp_forums_is_installed_correctly() ) 104 return true; 105 106 return false; 107 } 108 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() { 116 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; 120 121 return false; 122 } 123 124 /** Config ********************************************************************/ 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 } 206 } 207 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 } 222 223 bp_update_option( 'bb-config-location', $_REQUEST['bbconfigloc'] ); 224 225 if ( !file_exists( $_REQUEST['bbconfigloc'] ) ) { 226 return false; 227 } 228 229 return true; 230 } 125 231 126 232 function bp_forums_bbpress_install( $location = '' ) { 127 global $wpdb, $bp; 128 129 if ( empty( $location ) ) 233 global $wpdb, $bbdb, $bp; 234 235 check_admin_referer( 'bp_forums_new_install_init' ); 236 237 if ( empty( $location ) ) { 130 238 $location = ABSPATH . 'bb-config.php'; 239 } 131 240 132 241 // Create the bb-config.php file … … 164 273 $file .= "\n" . '$bb->custom_user_table = \'' . $wpdb->users . '\';'; 165 274 $file .= "\n" . '$bb->custom_user_meta_table = \'' . $wpdb->usermeta . '\';'; 166 $file .= "\n\n" . '$bb->uri = \'' . BP_PLUGIN_URL . ' bp-forums/bbpress/\';';275 $file .= "\n\n" . '$bb->uri = \'' . BP_PLUGIN_URL . '/bp-forums/bbpress/\';'; 167 276 $file .= "\n" . '$bb->name = \'' . get_blog_option( bp_get_root_blog_id(), 'blogname' ) . ' ' . __( 'Forums', 'buddypress' ) . '\';'; 168 277 … … 195 304 196 305 bp_update_option( 'bb-config-location', $location ); 197 198 return $file; 306 return $initial_write; 199 307 } 200 308 … … 255 363 // Write lines one by one to avoid OS specific newline hassles 256 364 foreach ( (array) $modified_lines as $modified_line ) { 257 if ( false !== strpos( $modified_line, '?>' ) ) {365 if ( strlen( $modified_line ) - 2 === strrpos( $modified_line, '?>' ) ) { 258 366 $modified_line = '?>'; 259 367 } 368 260 369 fwrite( $file_handle, $modified_line ); 261 370 if ( $modified_line == '?>' ) { -
trunk/bp-forums/bp-forums-functions.php
r6093 r6108 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 -
trunk/bp-forums/bp-forums-loader.php
r6093 r6108 47 47 if ( !defined( 'BP_FORUMS_SLUG' ) ) 48 48 define( 'BP_FORUMS_SLUG', $this->id ); 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']; 49 53 50 54 // All globals for messaging component. -
trunk/bp-themes/bp-default/groups/create.php
r5888 r6108 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> 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> 114 <?php if ( bp_forums_is_installed_correctly() ) : ?> 115 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; ?>
Note: See TracChangeset
for help on using the changeset viewer.