Bläddra i källkod

Merge pull request #623 from Oldiesmann/release-2.1

Move 'Allow users to disable word censor' to a global setting
Michael Eshom 10 år sedan
förälder
incheckning
7078f0fcb3

+ 1 - 1
Sources/Load.php

@@ -2425,7 +2425,7 @@ function censorText(&$text, $force = false)
 	global $modSettings, $options, $settings, $txt;
 	static $censor_vulgar = null, $censor_proper;
 
-	if ((!empty($options['show_no_censored']) && $settings['allow_no_censored'] && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '')
+	if ((!empty($options['show_no_censored']) && $modSettings['allow_no_censored'] && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '')
 		return $text;
 
 	// If they haven't yet been loaded, load them.

+ 0 - 3
Sources/ManagePermissions.php

@@ -1408,7 +1408,6 @@ function loadAllPermissions($loadType = 'classic')
 		'membergroup' => array(
 			'simple' => array(
 				'view_basic_info',
-				'disable_censor',
 				'use_pm_system',
 				'post_calendar',
 				'edit_profile',
@@ -1463,7 +1462,6 @@ function loadAllPermissions($loadType = 'classic')
 			'who_view' => array(false, 'general', 'view_basic_info'),
 			'search_posts' => array(false, 'general', 'view_basic_info'),
 			'karma_edit' => array(false, 'general', 'moderate_general'),
-			'disable_censor' => array(false, 'general', 'disable_censor'),
 			'pm_read' => array(false, 'pm', 'use_pm_system'),
 			'pm_send' => array(false, 'pm', 'use_pm_system'),
 			'pm_draft' => array(false, 'pm', 'use_pm_system'),
@@ -2260,7 +2258,6 @@ function loadIllegalGuestPermissions()
 		'post_autosave_draft',
 		'pm_draft',
 		'pm_autosave_draft',
-		'disable_censor',
 		'report_any',
 		'make_sticky',
 		'merge_any',

+ 4 - 0
Sources/ManagePosts.php

@@ -124,6 +124,7 @@ function SetCensor()
 		$updates = array(
 			'censor_vulgar' => implode("\n", $censored_vulgar),
 			'censor_proper' => implode("\n", $censored_proper),
+			'allow_no_censor' => empty($_POST['allow_no_censor']) ? '0' : '1',
 			'censorWholeWord' => empty($_POST['censorWholeWord']) ? '0' : '1',
 			'censorIgnoreCase' => empty($_POST['censorIgnoreCase']) ? '0' : '1',
 		);
@@ -159,6 +160,9 @@ function SetCensor()
 	}
 
 	call_integration_hook('integrate_censors');
+	
+	// Since the "Allow users to disable the word censor" stuff was moved from a theme setting to a global one, we need this...
+	loadLanguage('Themes');
 
 	$context['sub_template'] = 'edit_censored';
 	$context['page_title'] = $txt['admin_censored_words'];

+ 1 - 1
Sources/Profile-Modify.php

@@ -581,7 +581,7 @@ function loadProfileFields($force_reload = false)
 
 				$context[\'allow_no_censored\'] = false;
 				if ($user_info[\'is_admin\'] || $context[\'user\'][\'is_owner\'])
-					$context[\'allow_no_censored\'] = allowedTo(\'disable_censor\');
+					$context[\'allow_no_censored\'] = $modSettings[\'allow_no_censored\'];
 
 				return true;
 			'),

+ 6 - 0
Themes/default/Admin.template.php

@@ -583,6 +583,12 @@ function template_edit_censored()
 					// ]]></script>
 					<hr width="100%" size="1" class="hrcolor clear" />
 					<dl class="settings">
+						<dt>
+							<strong><label for="allow_no_ccensored">', $txt['allow_no_censored'], ':</label></strong>
+						</dt>
+						<dd>
+							<input type="checkbox" name="allow_no_censored" value="1" id="allow_no_censored"', empty($modSettings['allow_no_censored']) ? '' : ' checked="checked"', ' class="input_check" />
+						</dd>
 						<dt>
 							<strong><label for="censorWholeWord_check">', $txt['censor_whole_words'], ':</label></strong>
 						</dt>

+ 1 - 1
Themes/default/Profile.template.php

@@ -1542,7 +1542,7 @@ function template_profile_theme_settings()
 								<input type="checkbox" name="default_options[show_no_signatures]" id="show_no_signatures" value="1"', !empty($context['member']['options']['show_no_signatures']) ? ' checked="checked"' : '', ' class="input_check" />
 							</dd>';
 
-	if ($settings['allow_no_censored'])
+	if ($modSettings['allow_no_censored'])
 		echo '
 							<dt>
 								<label for="show_no_censored">' . $txt['show_no_censored'] . '</label>

+ 0 - 4
Themes/default/Settings.template.php

@@ -201,10 +201,6 @@ function template_settings()
 			'id' => 'show_mark_read',
 			'label' => $txt['enable_mark_as_read'],
 		),
-		array(
-			'id' => 'allow_no_censored',
-			'label' => $txt['allow_no_censored'],
-		),
 		array(
 			'id' => 'enable_news',
 			'label' => $txt['enable_random_news'],

+ 0 - 2
Themes/default/languages/ManagePermissions.english.php

@@ -86,8 +86,6 @@ $txt['permissionname_search_posts'] = 'Search for posts and topics';
 $txt['permissionhelp_search_posts'] = 'The Search permission allows the user to search all boards he or she is allowed to access. When the search permission is enabled, a \'Search\' button will be added to the forum button bar.';
 $txt['permissionname_karma_edit'] = 'Change other people\'s karma';
 $txt['permissionhelp_karma_edit'] = 'Karma is a feature that shows the popularity of a member. In order to use this feature, you need to have it enabled in \'Features and Options\'. This permission will allow a membergroup to cast a vote. This permission has no effect on guests.';
-$txt['permissionname_disable_censor'] = 'Disable word censor';
-$txt['permissionhelp_disable_censor'] = 'Allows members the option to disable the word censor.';
 
 $txt['permissiongroup_pm'] = 'Personal Messaging';
 $txt['permissionname_pm_read'] = 'Read personal messages';

+ 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...
 /******************************************************************************/
@@ -341,6 +370,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
 /******************************************************************************/