Ticket #3153: 3153.005.diff
| File 3153.005.diff, 13.2 KB (added by , 15 years ago) |
|---|
-
bp-core/bp-core-loader.php
53 53 54 54 /** Components ********************************************************/ 55 55 56 // Set the included and optional components 57 $bp->optional_components = apply_filters( 'bp_optional_components', array( 'activity', 'blogs', 'forums', 'friends', 'groups', 'messages', 'settings', 'xprofile', ));56 // Set the included and optional components. 57 $bp->optional_components = array( 'activity', 'forums', 'friends', 'groups', 'messages', 'settings', 'xprofile', ); 58 58 59 // Blogs component only available for multisite 60 if ( is_multisite() ) 61 $bp->optional_components = array( 'blogs' ); 62 63 $bp->optional_components = apply_filters( 'bp_optional_components', $bp->optional_components ); 64 59 65 // Set the required components 60 $bp->required_components = apply_filters( 'bp_required_components', array( 'members',) );66 $bp->required_components = apply_filters( 'bp_required_components', array( 'members' ) ); 61 67 62 68 // Get a list of activated components 63 69 if ( $active_components = get_site_option( 'bp-active-components' ) ) { 64 $bp->active_components = apply_filters( 'bp_active_components', $active_components );70 $bp->active_components = apply_filters( 'bp_active_components', $active_components ); 65 71 $bp->deactivated_components = apply_filters( 'bp_deactivated_components', array_values( array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_keys( $bp->active_components ) ) ) ); 66 72 67 73 // Pre 1.3 Backwards compatibility 68 74 } elseif ( $deactivated_components = get_site_option( 'bp-deactivated-components' ) ) { 69 75 // Trim off namespace and filename 70 foreach ( $deactivated_components as $component => $value )76 foreach ( (array) $deactivated_components as $component => $value ) 71 77 $trimmed[] = str_replace( '.php', '', str_replace( 'bp-', '', $component ) ); 72 78 73 79 // Set globals 74 80 $bp->deactivated_components = apply_filters( 'bp_deactivated_components', $trimmed ); 75 81 76 82 // Setup the active components 77 $active_components = array_flip( array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_values( $bp->deactivated_components ) ) );83 $active_components = array_flip( array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_values( $bp->deactivated_components ) ) ); 78 84 79 85 // Loop through active components and set the values 80 foreach( $active_components as $component => $value ) 81 $bp->active_components[$component] = 1; 86 $bp->active_components = array_map( '__return_true', $active_components ); 82 87 83 88 // Set the active component global 84 $bp->active_components = apply_filters( 'bp_active_components', $bp->active_components ); 89 $bp->active_components = apply_filters( 'bp_active_components', $bp->active_components ); 90 91 // Default to all components active 92 } else { 93 // Set globals 94 $bp->deactivated_components = array(); 95 96 // Setup the active components 97 $active_components = array_flip( array_values( array_merge( $bp->optional_components, $bp->required_components ) ) ); 98 99 // Loop through active components and set the values 100 $bp->active_components = array_map( '__return_true', $active_components ); 101 102 // Set the active component global 103 $bp->active_components = apply_filters( 'bp_active_components', $bp->active_components ); 85 104 } 86 105 87 106 // Loop through optional components … … 215 234 // Initialize the BuddyPress Core 216 235 $bp->core = new BP_Core(); 217 236 218 ?> 237 ?> 238 No newline at end of file -
bp-core/admin/bp-core-update.php
14 14 } 15 15 16 16 function __construct() { 17 // Look for current DB version 18 if ( !$this->database_version = get_site_option( 'bp-db-version' ) ) { 19 if ( $this->database_version = get_option( 'bp-db-version' ) ) { 20 $this->is_network_activate = true; 21 } else { 22 if ( !$this->current_step() ) { 23 setcookie( 'bp-wizard-step', 0, time() + 60 * 60 * 24, COOKIEPATH ); 24 $_COOKIE['bp-wizard-step'] = 0; 25 } 26 } 17 global $bp; 18 19 // Get current DB version 20 $this->database_version = !empty( $bp->database_version ) ? (int) $bp->database_version : 0; 21 22 if ( !empty( $bp->is_network_activate ) ) { 23 $this->is_network_activate = $bp->is_network_activate; 24 25 } elseif ( !$this->current_step() ) { 26 setcookie( 'bp-wizard-step', 0, time() + 60 * 60 * 24, COOKIEPATH ); 27 $_COOKIE['bp-wizard-step'] = 0; 27 28 } 28 29 29 30 $this->new_version = constant( 'BP_DB_VERSION' ); … … 71 72 if ( $this->is_network_activate ) 72 73 $steps[] = __( 'Multisite Update', 'buddypress' ); 73 74 74 if ( $this->database_version < $this->new_version )75 if ( $this->database_version < (int) $this->new_version ) 75 76 $steps[] = __( 'Database Update', 'buddypress' ); 76 77 77 if ( $this->database_version < 1 225|| !bp_core_get_page_meta() )78 if ( $this->database_version < 1801 || !bp_core_get_page_meta() ) 78 79 $steps[] = __( 'Pages', 'buddypress' ); 79 80 80 81 $steps[] = __( 'Finish', 'buddypress' ); … … 264 265 $blogs_slug = 'blogs'; 265 266 266 267 // Call up old bp-pages to see if a page has been previously linked to Blogs 267 $page_blog_id = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG;268 $existing_pages_data = get_blog_option( $page_blog_id, 'bp-pages' );269 $existing_pages = $existing_pages_data[$page_blog_id];268 $page_blog_id = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG; 269 $existing_pages_data = get_blog_option( $page_blog_id, 'bp-pages' ); 270 $existing_pages = $existing_pages_data[$page_blog_id]; 270 271 271 272 if ( !empty( $existing_pages['blogs'] ) ) 272 273 $existing_blog_page = '&selected=' . $existing_pages['blogs']; … … 364 365 $existing_pages = bp_core_update_get_page_meta(); 365 366 366 367 // Get active components 367 $active_components = apply_filters( 'bp_active_components', get_site_option( 'bp-active-components' ) ); 368 if ( !empty( $bp->active_components ) ) 369 $active_components = $bp->active_components; 370 else 371 $active_components = apply_filters( 'bp_active_components', get_site_option( 'bp-active-components' ) ); 368 372 369 373 // Check for defined slugs 370 374 $members_slug = !empty( $bp->members->slug ) ? $bp->members->slug : __( 'members', 'buddypress' ); … … 724 728 // Run the schema install to update tables 725 729 bp_core_install(); 726 730 727 if ( $this->database_version < 1 225)731 if ( $this->database_version < 1801 ) 728 732 $this->update_1_3(); 729 733 730 734 return true; … … 739 743 if ( isset( $_POST['submit'] ) ) { 740 744 check_admin_referer( 'bpwizard_ms_update' ); 741 745 742 if ( !$active_components = get_ option( 'bp-active-components' ) )746 if ( !$active_components = get_site_option( 'bp-active-components' ) ) 743 747 $active_components = array(); 744 748 745 749 // Transfer important settings from blog options to site options 746 750 $options = array( 747 'bp-db-version' => $this->database_version,748 'bp-active-components' => $active_components,749 'avatar-default' => get_option( 'avatar-default' )751 'bp-db-version' => $this->database_version, 752 'bp-active-components' => $active_components, 753 'avatar-default' => get_option( 'avatar-default' ) 750 754 ); 751 755 bp_core_activate_site_options( $options ); 752 756 … … 758 762 switch_to_blog( BP_ROOT_BLOG ); 759 763 760 764 // Move bp-pages data from the blog options table to site options 761 $page_blog_id = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG;762 $existing_pages_data = get_blog_option( $page_blog_id, 'bp-pages' );763 $existing_pages = $existing_pages_data[$page_blog_id];765 $page_blog_id = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG; 766 $existing_pages_data = get_blog_option( $page_blog_id, 'bp-pages' ); 767 $existing_pages = $existing_pages_data[$page_blog_id]; 764 768 765 $bp_pages = $this->setup_pages( (array)$_POST['bp_pages'] );766 $bp_pages = array_merge( (array)$existing_pages, (array)$bp_pages );769 $bp_pages = $this->setup_pages( (array)$_POST['bp_pages'] ); 770 $bp_pages = array_merge( (array)$existing_pages, (array)$bp_pages ); 767 771 768 772 $existing_pages_data[$page_blog_id] = $bp_pages; 769 773 … … 821 825 foreach ( (array)$existing_pages as $page_id ) 822 826 wp_delete_post( $page_id, true ); 823 827 824 $blog_pages = $this->setup_pages( (array)$_POST['bp_pages'] );825 $page_blog_id = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG;826 $bp_pages = array( $page_blog_id => $blog_pages );828 $blog_pages = $this->setup_pages( (array)$_POST['bp_pages'] ); 829 $page_blog_id = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG; 830 $bp_pages = array( $page_blog_id => $blog_pages ); 827 831 828 832 update_site_option( 'bp-pages', $bp_pages ); 829 833 … … 994 998 check_admin_referer( 'bpwizard_finish' ); 995 999 996 1000 // Update the DB version in the database 997 update_site_option( 'bp-db-version', constant( 'BP_DB_VERSION' ));1001 update_site_option( 'bp-db-version', $this->new_version ); 998 1002 delete_site_option( 'bp-core-db-version' ); 999 1003 1000 1004 // Delete the setup cookie … … 1180 1184 * @uses add_submenu_page() WP function to add a submenu item 1181 1185 */ 1182 1186 function bp_core_update_add_admin_menu() { 1183 global $bp , $bp_wizard;1187 global $bp_wizard; 1184 1188 1185 1189 // Only load this version of the menu if this is an upgrade or a new installation 1186 if ( empty( $bp ->maintenence_mode ) )1190 if ( empty( $bp_wizard->setup_type ) ) 1187 1191 return false; 1188 1192 1189 1193 if ( !current_user_can( 'activate_plugins' ) ) 1190 1194 return false; 1191 1195 1192 if ( ' ' == get_site_option( 'bp-db-version' ) && !(int)get_site_option( 'bp-core-db-version' ) && !$bp_wizard->is_network_activate )1196 if ( 'install' == $bp_wizard->setup_type ) 1193 1197 $status = __( 'Setup', 'buddypress' ); 1194 1198 else 1195 1199 $status = __( 'Update', 'buddypress' ); … … 1256 1260 1257 1261 function bp_core_update_do_network_admin() { 1258 1262 $do_network_admin = false; 1259 1263 1260 1264 if ( is_multisite() && ( !defined( 'BP_ENABLE_MULTIBLOG' ) || !BP_ENABLE_MULTIBLOG ) ) 1261 1265 $do_network_admin = true; 1262 1266 1263 1267 return apply_filters( 'bp_core_do_network_admin', $do_network_admin ); 1264 1268 } 1265 1269 1266 1270 function bp_core_update_admin_hook() { 1267 1271 $hook = bp_core_update_do_network_admin() ? 'network_admin_menu' : 'admin_menu'; 1268 1272 1269 1273 return apply_filters( 'bp_core_admin_hook', $hook ); 1270 1274 } 1271 1275 … … 1277 1281 * @global $pagenow The current admin page 1278 1282 */ 1279 1283 function bp_core_update_nag() { 1280 global $bp , $pagenow;1284 global $bp_wizard, $pagenow; 1281 1285 1286 if ( empty( $bp_wizard->setup_type ) ) 1287 return; 1288 1282 1289 if ( !is_super_admin() ) 1283 1290 return; 1284 1291 … … 1287 1294 1288 1295 $url = bp_core_update_do_network_admin() ? network_admin_url( 'admin.php?page=bp-wizard' ) : admin_url( 'admin.php?page=bp-wizard' ); 1289 1296 1290 switch( $bp ->maintenence_mode ) {1297 switch( $bp_wizard->setup_type ) { 1291 1298 case 'update': 1292 1299 $msg = sprintf( __( 'BuddyPress has been updated! Please run the <a href="%s">update wizard</a>.', 'buddypress' ), $url ); 1293 1300 break; -
bp-loader.php
59 59 // Test to see whether this is a new installation or an upgraded version of BuddyPress 60 60 if ( !$bp->database_version = get_site_option( 'bp-db-version' ) ) { 61 61 if ( $bp->database_version = get_option( 'bp-db-version' ) ) { 62 $bp->is_ ms_activate = 1;62 $bp->is_network_activate = 1; 63 63 } else { 64 64 $bp->database_version = get_site_option( 'bp-core-db-version' ); // BP 1.2 option 65 65 } … … 76 76 require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/bp-core-loader.php' ); 77 77 78 78 // Check if an update is required 79 if ( (int)$bp->database_version < (int)constant( 'BP_DB_VERSION' ) || isset( $bp->is_ ms_activate ) ) {79 if ( (int)$bp->database_version < (int)constant( 'BP_DB_VERSION' ) || isset( $bp->is_network_activate ) ) { 80 80 $bp->maintenence_mode = 'update'; 81 81 require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-update.php' ); 82 82 } … … 86 86 87 87 if ( !function_exists( 'bp_loader_activate' ) ) : 88 88 /** 89 * Defines BP's activation routine. 90 * 91 * Most of BP's crucial setup is handled by the setup wizard. This function takes care of some 92 * issues with incompatible legacy themes, and provides a hook for other functions to know that 93 * BP has been activated. 94 * 95 * @package BuddyPress Core 96 */ 89 * Defines BP's activation routine. 90 * 91 * Most of BP's crucial setup is handled by the setup wizard. This function takes care of some 92 * issues with incompatible legacy themes, and provides a hook for other functions to know that 93 * BP has been activated. 94 * 95 * @package BuddyPress Core 96 */ 97 97 function bp_loader_activate() { 98 98 // Force refresh theme roots. 99 99 delete_site_transient( 'theme_roots' );