Browse Source

! This should fix the way admin_features gets upgraded, should fix #859

Signed-off-by: Peter Spicer <[email protected]>
Peter Spicer 10 years ago
parent
commit
ab4c294ad6

+ 7 - 0
other/upgrade_2-0_mysql.sql

@@ -1910,8 +1910,15 @@ ADD INDEX id_poll (id_poll, id_member, id_choice);
 if (!isset($modSettings['admin_features']))
 {
 	// Work out what they used to have enabled.
+	$enabled_features = array('rg');
+	if (!empty($modSettings['cal_enabled']))
+		$enabled_features[] = 'cd';
 	if (!empty($modSettings['karmaMode']))
 		$enabled_features[] = 'k';
+	if (!empty($modSettings['modlog_enabled']))
+		$enabled_features[] = 'ml';
+	if (!empty($modSettings['paid_enabled']))
+		$enabled_features[] = 'ps';
 
 	$enabled_features = implode(',', $enabled_features);
 

+ 52 - 1
other/upgrade_2-1_mysql.sql

@@ -660,9 +660,60 @@ WHERE variable = 'avatar_action_too_large'
 	AND (value = 'option_html_resize' OR value = 'option_js_resize');
 ---#
 
+---# Cleaning up the old Core Features page.
+---{
+	// First get the original value
+	$request = $smcFunc['db_query']('', '
+		SELECT value
+		FROM {db_prefix}settings
+		WHERE variable = {literal:admin_features}');
+	if ($smcFunc['db_num_rows']($request) > 0 && $row = $smcFunc['db_fetch_assoc']($request))
+	{
+		// Some of these *should* already be set but you never know.
+		$new_settings = array();
+		$admin_features = explode(',', $row['value']);
+
+		// Now, let's just recap something.
+		// cd = calendar, should also have set cal_enabled already
+		// cp = custom profile fields, which already has several fields that cover tracking
+		// k = karma, should also have set karmaMode already
+		// ps = paid subs, should also have set paid_enabled already
+		// rg = reports generation, which is now permanently on
+		// sp = spider tracking, should also have set spider_mode already
+		// w = warning system, which will be covered with warning_settings
+
+		// The rest we have to deal with manually.
+		// Moderation log - modlog_enabled itself should be set but we have others now
+		if (in_array('ml', $admin_features))
+		{
+			$new_settings[] = array('adminlog_enabled', '1');
+			$new_settings[] = array('userlog_enabled', '1');
+		}
+
+		// Post moderation
+		if (in_array('pm', $admin_features))
+		{
+			$new_settings[] = array('postmod_active', '1');
+		}
+
+		// And now actually apply it.
+		if (!empty($new_settings))
+		{
+			$smcFunc['db_insert']('replace',
+				'{db_prefix}settings',
+				array('variable' => 'string', 'value' => 'string'),
+				$new_settings,
+				array('variable')
+			);
+		}
+	}
+	$smcFunc['db_free_result']($request);
+---}
+---#
+
 ---# Cleaning up old settings.
 DELETE FROM {$db_prefix}settings
-WHERE variable IN ('enableStickyTopics', 'guest_hideContacts', 'notify_new_registration', 'attachmentEncryptFilenames', 'hotTopicPosts', 'hotTopicVeryPosts', 'fixLongWords');
+WHERE variable IN ('enableStickyTopics', 'guest_hideContacts', 'notify_new_registration', 'attachmentEncryptFilenames', 'hotTopicPosts', 'hotTopicVeryPosts', 'fixLongWords', 'admin_features');
 ---#
 
 ---# Cleaning up old theme settings.

+ 52 - 1
other/upgrade_2-1_postgresql.sql

@@ -739,9 +739,60 @@ WHERE variable = 'avatar_action_too_large'
 	AND (value = 'option_html_resize' OR value = 'option_js_resize');
 ---#
 
+---# Cleaning up the old Core Features page.
+---{
+	// First get the original value
+	$request = $smcFunc['db_query']('', '
+		SELECT value
+		FROM {db_prefix}settings
+		WHERE variable = {literal:admin_features}');
+	if ($smcFunc['db_num_rows']($request) > 0 && $row = $smcFunc['db_fetch_assoc']($request))
+	{
+		// Some of these *should* already be set but you never know.
+		$new_settings = array();
+		$admin_features = explode(',', $row['value']);
+
+		// Now, let's just recap something.
+		// cd = calendar, should also have set cal_enabled already
+		// cp = custom profile fields, which already has several fields that cover tracking
+		// k = karma, should also have set karmaMode already
+		// ps = paid subs, should also have set paid_enabled already
+		// rg = reports generation, which is now permanently on
+		// sp = spider tracking, should also have set spider_mode already
+		// w = warning system, which will be covered with warning_settings
+
+		// The rest we have to deal with manually.
+		// Moderation log - modlog_enabled itself should be set but we have others now
+		if (in_array('ml', $admin_features))
+		{
+			$new_settings[] = array('adminlog_enabled', '1');
+			$new_settings[] = array('userlog_enabled', '1');
+		}
+
+		// Post moderation
+		if (in_array('pm', $admin_features))
+		{
+			$new_settings[] = array('postmod_active', '1');
+		}
+
+		// And now actually apply it.
+		if (!empty($new_settings))
+		{
+			$smcFunc['db_insert']('replace',
+				'{db_prefix}settings',
+				array('variable' => 'string', 'value' => 'string'),
+				$new_settings,
+				array('variable')
+			);
+		}
+	}
+	$smcFunc['db_free_result']($request);
+---}
+---#
+
 ---# Cleaning up old settings.
 DELETE FROM {$db_prefix}settings
-WHERE variable IN ('enableStickyTopics', 'guest_hideContacts', 'notify_new_registration', 'attachmentEncryptFilenames', 'hotTopicPosts', 'hotTopicVeryPosts', 'fixLongWords');
+WHERE variable IN ('enableStickyTopics', 'guest_hideContacts', 'notify_new_registration', 'attachmentEncryptFilenames', 'hotTopicPosts', 'hotTopicVeryPosts', 'fixLongWords', 'admin_features');
 ---#
 
 ---# Cleaning up old theme settings.

+ 52 - 1
other/upgrade_2-1_sqlite.sql

@@ -730,9 +730,60 @@ WHERE variable = 'avatar_action_too_large'
 	AND (value = 'option_html_resize' OR value = 'option_js_resize');
 ---#
 
+---# Cleaning up the old Core Features page.
+---{
+	// First get the original value
+	$request = $smcFunc['db_query']('', '
+		SELECT value
+		FROM {db_prefix}settings
+		WHERE variable = {literal:admin_features}');
+	if ($smcFunc['db_num_rows']($request) > 0 && $row = $smcFunc['db_fetch_assoc']($request))
+	{
+		// Some of these *should* already be set but you never know.
+		$new_settings = array();
+		$admin_features = explode(',', $row['value']);
+
+		// Now, let's just recap something.
+		// cd = calendar, should also have set cal_enabled already
+		// cp = custom profile fields, which already has several fields that cover tracking
+		// k = karma, should also have set karmaMode already
+		// ps = paid subs, should also have set paid_enabled already
+		// rg = reports generation, which is now permanently on
+		// sp = spider tracking, should also have set spider_mode already
+		// w = warning system, which will be covered with warning_settings
+
+		// The rest we have to deal with manually.
+		// Moderation log - modlog_enabled itself should be set but we have others now
+		if (in_array('ml', $admin_features))
+		{
+			$new_settings[] = array('adminlog_enabled', '1');
+			$new_settings[] = array('userlog_enabled', '1');
+		}
+
+		// Post moderation
+		if (in_array('pm', $admin_features))
+		{
+			$new_settings[] = array('postmod_active', '1');
+		}
+
+		// And now actually apply it.
+		if (!empty($new_settings))
+		{
+			$smcFunc['db_insert']('replace',
+				'{db_prefix}settings',
+				array('variable' => 'string', 'value' => 'string'),
+				$new_settings,
+				array('variable')
+			);
+		}
+	}
+	$smcFunc['db_free_result']($request);
+---}
+---#
+
 ---# Cleaning up old settings.
 DELETE FROM {$db_prefix}settings
-WHERE variable IN ('enableStickyTopics', 'guest_hideContacts', 'notify_new_registration', 'attachmentEncryptFilenames', 'hotTopicPosts', 'hotTopicVeryPosts', 'fixLongWords');
+WHERE variable IN ('enableStickyTopics', 'guest_hideContacts', 'notify_new_registration', 'attachmentEncryptFilenames', 'hotTopicPosts', 'hotTopicVeryPosts', 'fixLongWords', 'admin_features');
 ---#
 
 ---# Cleaning up old theme settings.