Message info
 
To:buddypress-trac@lists.automattic.com From:buddypress-trac@lists.automattic.com Subject:[buddypress-trac] [BuddyPress][6067] trunk: Correct BuddyPress core settings values when upgrading from 1.5 to 1.6. Date:Fri, 8 Jun 2012 21:52:38 +0000 (UTC)
 

Revision
6067
Author
djpaul
Date
2012-06-08 21:52:38 +0000 (Fri, 08 Jun 2012)

Log Message

Correct BuddyPress core settings values when upgrading from 1.5 to 1.6. Fixes #4008

Modified Paths

Diff

Modified: trunk/bp-core/admin/bp-core-settings.php (6066 => 6067)


--- trunk/bp-core/admin/bp-core-settings.php	2012-06-08 21:44:34 UTC (rev 6066)
+++ trunk/bp-core/admin/bp-core-settings.php	2012-06-08 21:52:38 UTC (rev 6067)
@@ -208,11 +208,11 @@
 
 		// Some legacy options are not registered with the Settings API
 		$legacy_options = array(
+			'bp-disable-account-deletion',
+			'bp-disable-avatar-uploads',
 			'bp-disable-profile-sync',
+			'bp_restrict_group_creation',
 			'hide-loggedout-adminbar',
-			'bp-disable-avatar-uploads',
-			'bp-disable-account-deletion',
-			'bp_restrict_group_creation'
 		);
 
 		foreach( $legacy_options as $legacy_option ) {

Modified: trunk/bp-core/admin/bp-core-update.php (6066 => 6067)


--- trunk/bp-core/admin/bp-core-update.php	2012-06-08 21:44:34 UTC (rev 6066)
+++ trunk/bp-core/admin/bp-core-update.php	2012-06-08 21:52:38 UTC (rev 6067)
@@ -1037,6 +1037,30 @@
 		delete_blog_option( bp_get_root_blog_id(), 'bp-core-db-version'  );
 		delete_site_option( bp_get_root_blog_id(), '_bp-core-db-version' );
 		delete_site_option( bp_get_root_blog_id(), '_bp_db_version'      );
+
+		// Some legacy options need to be flipped from 1 to 0s
+		$legacy_options = array(
+			'bp-disable-account-deletion',
+			'bp-disable-avatar-uploads',
+			'bp-disable-profile-sync',
+			'bp_restrict_group_creation',
+			'hide-loggedout-adminbar',
+		);
+
+		/**
+		 * Note: Each of these options is represented by its opposite in the UI
+		 * Ie, the Profile Syncing option reads "Enable Sync", so when it's checked,
+		 * the corresponding option should be unset.
+		 */
+		foreach( $legacy_options as $legacy_option ) {
+			$value = bp_get_option( $legacy_option );
+			if ( empty( $value ) )
+				$value = 1;
+			else
+				$value = 0;
+
+			bp_update_option( $legacy_option, $value );
+		}
 	}
 
 	/**

Modified: trunk/bp-core/bp-core-admin.php (6066 => 6067)


--- trunk/bp-core/bp-core-admin.php	2012-06-08 21:44:34 UTC (rev 6066)
+++ trunk/bp-core/bp-core-admin.php	2012-06-08 21:52:38 UTC (rev 6067)
@@ -282,13 +282,13 @@
 		// Add the main section
 		add_settings_section( 'bp_main',            __( 'Main Settings',    'buddypress' ), 'bp_admin_setting_callback_main_section',     'buddypress'            );
 
-		// Throttle setting
-		add_settings_field( '_bp_admin_bar',        __( 'Toolbar',        'buddypress' ), 'bp_admin_setting_callback_admin_bar',        'buddypress', 'bp_main' );
-	 	register_setting  ( 'buddypress',           '_bp_admin_bar',        'intval'                                                                              );
+		// Hide toolbar for logged out users setting
+		add_settings_field( 'hide-loggedout-adminbar',        __( 'Toolbar',        'buddypress' ), 'bp_admin_setting_callback_admin_bar',        'buddypress', 'bp_main' );
+	 	register_setting  ( 'buddypress',           'hide-loggedout-adminbar',        'intval'                                                                              );
 
 		// Allow favorites setting
-		add_settings_field( '_bp_account_deletion', __( 'Account Deletion', 'buddypress' ), 'bp_admin_setting_callback_account_deletion', 'buddypress', 'bp_main' );
-	 	register_setting  ( 'buddypress',           '_bp_account_deletion', 'intval'                                                                              );
+		add_settings_field( 'bp-disable-account-deletion', __( 'Account Deletion', 'buddypress' ), 'bp_admin_setting_callback_account_deletion', 'buddypress', 'bp_main' );
+	 	register_setting  ( 'buddypress',           'bp-disable-account-deletion', 'intval'                                                                              );
 
 		/** XProfile Section **************************************************/
 
@@ -298,12 +298,12 @@
 			add_settings_section( 'bp_xprofile',      __( 'Profile Settings', 'buddypress' ), 'bp_admin_setting_callback_xprofile_section', 'buddypress'                );
 
 			// Allow topic and reply revisions
-			add_settings_field( '_bp_avatar_uploads', __( 'Avatar Uploads',   'buddypress' ), 'bp_admin_setting_callback_avatar_uploads',   'buddypress', 'bp_xprofile' );
-			register_setting  ( 'buddypress',         '_bp_avatar_uploads',   'intval'                                                                                  );
+			add_settings_field( 'bp-disable-avatar-uploads', __( 'Avatar Uploads',   'buddypress' ), 'bp_admin_setting_callback_avatar_uploads',   'buddypress', 'bp_xprofile' );
+			register_setting  ( 'buddypress',         'bp-disable-avatar-uploads',   'intval'                                                                                  );
 
 			// Profile sync setting
-			add_settings_field( '_bp_profile_sync',   __( 'Profile Syncing',  'buddypress' ), 'bp_admin_setting_callback_profile_sync',     'buddypress', 'bp_xprofile' );
-			register_setting  ( 'buddypress',         '_bp_profile_sync',     'intval'                                                                                  );
+			add_settings_field( 'bp-disable-profile-sync',   __( 'Profile Syncing',  'buddypress' ), 'bp_admin_setting_callback_profile_sync',     'buddypress', 'bp_xprofile' );
+			register_setting  ( 'buddypress',         'bp-disable-profile-sync',     'intval'                                                                                  );
 		}
 
 		/** Groups Section ****************************************************/
@@ -314,8 +314,8 @@
 			add_settings_section( 'bp_groups',        __( 'Groups Settings',  'buddypress' ), 'bp_admin_setting_callback_groups_section',   'buddypress'              );
 
 			// Allow subscriptions setting
-			add_settings_field( '_bp_group_creation', __( 'Group Creation',   'buddypress' ), 'bp_admin_setting_callback_group_creation',   'buddypress', 'bp_groups' );
-			register_setting  ( 'buddypress',         '_bp_group_creation',   'intval'                                                                                );
+			add_settings_field( 'bp_restrict_group_creation', __( 'Group Creation',   'buddypress' ), 'bp_admin_setting_callback_group_creation',   'buddypress', 'bp_groups' );
+			register_setting  ( 'buddypress',         'bp_restrict_group_creation',   'intval'                                                                                );
 		}
 
 		/** Forums ************************************************************/

Modified: trunk/bp-loader.php (6066 => 6067)


--- trunk/bp-loader.php	2012-06-08 21:44:34 UTC (rev 6066)
+++ trunk/bp-loader.php	2012-06-08 21:52:38 UTC (rev 6067)
@@ -57,7 +57,7 @@
 	/**
 	 * @var int Database version of current BuddyPress files
 	 */
-	public $db_version = 5251;
+	public $db_version = 6066;
 	
 	/**
 	 * @var int Database version raw from database connection