Browse Source

Copy over the 'Allow users to disable word censor' setting when upgrading

Signed-off-by: Michael Eshom <[email protected]>
Michael Eshom 11 years ago
parent
commit
e896373c84
3 changed files with 117 additions and 0 deletions
  1. 29 0
      other/upgrade_2-1_mysql.sql
  2. 29 0
      other/upgrade_2-1_postgresql.sql
  3. 59 0
      other/upgrade_2-1_sqlite.sql

+ 29 - 0
other/upgrade_2-1_mysql.sql

@@ -28,6 +28,35 @@ if (!isset($modSettings['package_make_full_backups']) && isset($modSettings['pac
 ---}
 ---#
 
+---# Copying the current "allow users to disable word censor" setting...
+---{
+if (!isset($modSettings['allow_no_censor']))
+{
+	$request = upgrade_query("
+		SELECT value
+		FROM {$db_prefix}settings
+		WHERE variable='allow_no_censor'
+		AND id_theme = 1 OR id_theme = '$modSettings[theme_default]'
+	");
+	
+	// Is it set for either "default" or the one they've set as default?
+	while ($row = mysql_fetch_assoc($request))
+	{
+		if ($row['value'] == 1)
+		{
+			upgrade_query("
+				INSERT INTO {$db_prefix}settings
+				VALUES ('allow_no_censor', 1)
+			");
+			
+			// Don't do this twice...
+			break;
+		}
+	}
+}
+---}
+---#
+
 /******************************************************************************/
 --- Updating legacy attachments...
 /******************************************************************************/

+ 29 - 0
other/upgrade_2-1_postgresql.sql

@@ -30,6 +30,35 @@ if (!isset($modSettings['package_make_full_backups']) && isset($modSettings['pac
 ---}
 ---#
 
+---# Copying the current "allow users to disable word censor" setting...
+---{
+if (!isset($modSettings['allow_no_censor']))
+{
+	$request = upgrade_query("
+		SELECT value
+		FROM {$db_prefix}settings
+		WHERE variable='allow_no_censor'
+		AND id_theme = 1 OR id_theme = '$modSettings[theme_default]'
+	");
+	
+	// Is it set for either "default" or the one they've set as default?
+	while ($row = mysql_fetch_assoc($request))
+	{
+		if ($row['value'] == 1)
+		{
+			upgrade_query("
+				INSERT INTO {$db_prefix}settings
+				VALUES ('allow_no_censor', 1)
+			");
+			
+			// Don't do this twice...
+			break;
+		}
+	}
+}
+---}
+---#
+
 /******************************************************************************/
 --- Updating legacy attachments...
 /******************************************************************************/

+ 59 - 0
other/upgrade_2-1_sqlite.sql

@@ -28,6 +28,35 @@ if (!isset($modSettings['package_make_full_backups']) && isset($modSettings['pac
 ---}
 ---#
 
+---# Copying the current "allow users to disable word censor" setting...
+---{
+if (!isset($modSettings['allow_no_censor']))
+{
+	$request = upgrade_query("
+		SELECT value
+		FROM {$db_prefix}settings
+		WHERE variable='allow_no_censor'
+		AND id_theme = 1 OR id_theme = '$modSettings[theme_default]'
+	");
+	
+	// Is it set for either "default" or the one they've set as default?
+	while ($row = mysql_fetch_assoc($request))
+	{
+		if ($row['value'] == 1)
+		{
+			upgrade_query("
+				INSERT INTO {$db_prefix}settings
+				VALUES ('allow_no_censor', 1)
+			");
+			
+			// Don't do this twice...
+			break;
+		}
+	}
+}
+---}
+---#
+
 /******************************************************************************/
 --- Updating legacy attachments...
 /******************************************************************************/
@@ -325,6 +354,36 @@ if (file_exists($GLOBALS['boarddir'] . '/Themes/core'))
 	}
 }
 
+/******************************************************************************/
+--- Moving "allow users to disable word censor" setting...
+/******************************************************************************/
+---#
+---{
+	$request = upgrade_query("
+		SELECT value
+		FROM {$db_prefix}settings
+		WHERE variable='allow_no_censor'
+		AND id_theme = 1 OR id_theme = '$modSettings[theme_default]'
+	");
+	
+	// Is it set for either "default" or the one they've set as default?
+	while ($row = mysql_fetch_assoc($request))
+	{
+		if ($row['value'] == 1)
+		{
+			upgrade_query("
+				INSERT INTO {$db_prefix}settings
+				VALUES ('allow_no_censor', 1)
+			");
+			
+			// Don't do this multiple twice...
+			break;
+		}
+	}
+}
+---}
+---#
+
 /******************************************************************************/
 --- Adding support for drafts
 /******************************************************************************/