Changeset 4556
- Timestamp:
- 06/24/2011 05:12:13 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/admin/bp-core-update.php
r4487 r4556 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 // Ensure that we have access to some utility functions 20 include( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' ); 21 22 // Get current DB version 23 $this->database_version = !empty( $bp->database_version ) ? (int) $bp->database_version : 0; 24 25 if ( !empty( $bp->is_network_activate ) ) { 26 $this->is_network_activate = $bp->is_network_activate; 27 28 } elseif ( !$this->current_step() ) { 29 setcookie( 'bp-wizard-step', 0, time() + 60 * 60 * 24, COOKIEPATH ); 30 $_COOKIE['bp-wizard-step'] = 0; 27 31 } 28 32 29 33 $this->new_version = constant( 'BP_DB_VERSION' ); 30 $this->setup_type = ( empty( $this->database_version ) && !(int)get_site_option( 'bp-core-db-version' ) ) ? 'install' : 'update';34 $this->setup_type = !empty( $bp->maintenance_mode ) ? $bp->maintenance_mode : ''; 31 35 $this->current_step = $this->current_step(); 36 37 // Remove the admin menu while we update/install 38 remove_action( bp_core_admin_hook(), 'bp_core_add_admin_menu', 9 ); 32 39 33 40 // Call the save method that will save data and modify $current_step … … 72 79 $steps[] = __( 'Multisite Update', 'buddypress' ); 73 80 74 if ( $this->database_version < $this->new_version )81 if ( $this->database_version < (int) $this->new_version ) 75 82 $steps[] = __( 'Database Update', 'buddypress' ); 76 83 77 if ( $this->database_version < 1 225|| !bp_core_get_page_meta() )84 if ( $this->database_version < 1801 || !bp_core_get_page_meta() ) 78 85 $steps[] = __( 'Pages', 'buddypress' ); 79 86 … … 265 272 266 273 // Call up old bp-pages to see if a page has been previously linked to Blogs 267 $page_blog_id 268 $existing_pages_data 269 $existing_pages 274 $page_blog_id = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG; 275 $existing_pages_data = get_blog_option( $page_blog_id, 'bp-pages' ); 276 $existing_pages = $existing_pages_data[$page_blog_id]; 270 277 271 278 if ( !empty( $existing_pages['blogs'] ) ) … … 719 726 720 727 function step_db_update_save() { 728 global $bp; 729 721 730 if ( isset( $_POST['submit'] ) ) { 722 731 check_admin_referer( 'bpwizard_db_update' ); … … 725 734 bp_core_install(); 726 735 727 if ( $this->database_version < 1 225)736 if ( $this->database_version < 1801 ) 728 737 $this->update_1_3(); 738 739 // Update the active components option early if we're updating 740 if ( 'update' == $this->setup_type ) 741 update_site_option( 'bp-active-components', $bp->active_components ); 729 742 730 743 return true; … … 740 753 check_admin_referer( 'bpwizard_ms_update' ); 741 754 742 if ( !$active_components = get_ option( 'bp-active-components' ) )755 if ( !$active_components = get_site_option( 'bp-active-components' ) ) 743 756 $active_components = array(); 744 757 745 758 // Transfer important settings from blog options to site options 746 759 $options = array( 747 'bp-db-version' 748 'bp-active-components' 749 'avatar-default' 760 'bp-db-version' => $this->database_version, 761 'bp-active-components' => $active_components, 762 'avatar-default' => get_option( 'avatar-default' ) 750 763 ); 751 764 bp_core_activate_site_options( $options ); … … 759 772 760 773 // Move bp-pages data from the blog options table to site options 761 $page_blog_id 762 $existing_pages_data 763 $existing_pages 764 765 $bp_pages 766 $bp_pages 774 $page_blog_id = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG; 775 $existing_pages_data = get_blog_option( $page_blog_id, 'bp-pages' ); 776 $existing_pages = $existing_pages_data[$page_blog_id]; 777 778 $bp_pages = $this->setup_pages( (array)$_POST['bp_pages'] ); 779 $bp_pages = array_merge( (array)$existing_pages, (array)$bp_pages ); 767 780 768 781 $existing_pages_data[$page_blog_id] = $bp_pages; … … 822 835 wp_delete_post( $page_id, true ); 823 836 824 $blog_pages 825 $page_blog_id 826 $bp_pages 837 $blog_pages = $this->setup_pages( (array)$_POST['bp_pages'] ); 838 $page_blog_id = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? get_current_blog_id() : BP_ROOT_BLOG; 839 $bp_pages = array( $page_blog_id => $blog_pages ); 827 840 828 841 update_site_option( 'bp-pages', $bp_pages ); … … 995 1008 996 1009 // Update the DB version in the database 997 update_site_option( 'bp-db-version', constant( 'BP_DB_VERSION' ));1010 update_site_option( 'bp-db-version', $this->new_version ); 998 1011 delete_site_option( 'bp-core-db-version' ); 999 1012 … … 1181 1194 */ 1182 1195 function bp_core_update_add_admin_menu() { 1183 global $bp , $bp_wizard;1196 global $bp_wizard; 1184 1197 1185 1198 // Only load this version of the menu if this is an upgrade or a new installation 1186 if ( empty( $bp ->maintenence_mode ) )1199 if ( empty( $bp_wizard->setup_type ) ) 1187 1200 return false; 1188 1201 … … 1190 1203 return false; 1191 1204 1192 if ( ' ' == get_site_option( 'bp-db-version' ) && !(int)get_site_option( 'bp-core-db-version' ) && !$bp_wizard->is_network_activate )1205 if ( 'install' == $bp_wizard->setup_type ) 1193 1206 $status = __( 'Setup', 'buddypress' ); 1194 1207 else … … 1278 1291 */ 1279 1292 function bp_core_update_nag() { 1280 global $bp, $pagenow; 1293 global $bp_wizard, $pagenow; 1294 1295 if ( empty( $bp_wizard->setup_type ) ) 1296 return; 1281 1297 1282 1298 if ( !is_super_admin() ) … … 1288 1304 $url = bp_core_update_do_network_admin() ? network_admin_url( 'admin.php?page=bp-wizard' ) : admin_url( 'admin.php?page=bp-wizard' ); 1289 1305 1290 switch( $bp ->maintenence_mode ) {1306 switch( $bp_wizard->setup_type ) { 1291 1307 case 'update': 1292 1308 $msg = sprintf( __( 'BuddyPress has been updated! Please run the <a href="%s">update wizard</a>.', 'buddypress' ), $url ); -
trunk/bp-core/bp-core-functions.php
r4506 r4556 308 308 309 309 // Don't show these messages during setup or upgrade 310 if ( isset( $bp->mainten ence_mode ) )310 if ( isset( $bp->maintenance_mode ) ) 311 311 return; 312 312 -
trunk/bp-core/bp-core-loader.php
r4488 r4556 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 59 // Blogs component only available for multisite 60 if ( is_multisite() ) 61 $bp->optional_components[] = 'blogs'; 62 63 $bp->optional_components = apply_filters( 'bp_optional_components', $bp->optional_components ); 58 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', 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 … … 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 … … 75 81 76 82 // Setup the active components 77 $active_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 -
trunk/bp-loader.php
r4444 r4556 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 … … 68 68 // This is a new installation. 69 69 if ( empty( $bp->database_version ) ) { 70 $bp->mainten ence_mode = 'install';70 $bp->maintenance_mode = 'install'; 71 71 require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-update.php' ); 72 72 … … 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 ) ) {80 $bp->mainten ence_mode = 'update';79 if ( (int)$bp->database_version < (int)constant( 'BP_DB_VERSION' ) || isset( $bp->is_network_activate ) ) { 80 $bp->maintenance_mode = 'update'; 81 81 require_once( WP_PLUGIN_DIR . '/buddypress/bp-core/admin/bp-core-update.php' ); 82 82 }
Note: See TracChangeset
for help on using the changeset viewer.