瀏覽代碼

! Remove the warning item from Core Features, push it to its own section with its own enable option and fix everywhere else up. Also split up the former Security and Moderation page into separate Anti-Spam and Warnings pages.

Signed-off-by: Peter Spicer <[email protected]>
Peter Spicer 10 年之前
父節點
當前提交
3a3e244f0d

+ 13 - 10
Sources/Admin.php

@@ -122,15 +122,11 @@ function AdminMain()
 						'profile' => array($txt['custom_profile_shorttitle']),
 					),
 				),
-				'securitysettings' => array(
-					'label' => $txt['admin_security_moderation'],
+				'antispam' => array(
+					'label' => $txt['antispam_title'],
 					'file' => 'ManageSettings.php',
-					'function' => 'ModifySecuritySettings',
+					'function' => 'ModifyAntispamSettings',
 					'icon' => 'security.png',
-					'subsections' => array(
-						'spam' => array($txt['antispam_title']),
-						'moderation' => array($txt['moderation_settings_short'], 'enabled' => in_array('w', $context['admin_features'])),
-					),
 				),
 				'languages' => array(
 					'label' => $txt['language_configuration'],
@@ -336,6 +332,13 @@ function AdminMain()
 						'settings' => array($txt['settings'], 'admin_forum'),
 					),
 				),
+				'warnings' => array(
+					'label' => $txt['warnings'],
+					'file' => 'ManageSettings.php',
+					'function' => 'ModifyWarningSettings',
+					'icon' => 'warning.png',
+					'inactive' => $modSettings['warning_settings'][0] == 0,
+				),
 				'ban' => array(
 					'label' => $txt['ban_title'],
 					'file' => 'ManageBans.php',
@@ -696,8 +699,8 @@ function AdminSearchInternal()
 		array('ModifyLayoutSettings', 'area=featuresettings;sa=layout'),
 		array('ModifyKarmaSettings', 'area=featuresettings;sa=karma'),
 		array('ModifySignatureSettings', 'area=featuresettings;sa=sig'),
-		array('ModifySpamSettings', 'area=securitysettings;sa=spam'),
-		array('ModifyModerationSettings', 'area=securitysettings;sa=moderation'),
+		array('ModifyAntispamSettings', 'area=antispam'),
+		array('ModifyWarningSettings', 'area=warnings'),
 		array('ModifyGeneralModSettings', 'area=modsettings;sa=general'),
 		// Mod authors if you want to be "real freaking good" then add any setting pages for your mod BELOW this line!
 		array('ManageAttachmentSettings', 'area=manageattachments;sa=attachments'),
@@ -743,7 +746,7 @@ function AdminSearchInternal()
 		),
 		'settings' => array(
 			array('COPPA', 'area=regcenter;sa=settings'),
-			array('CAPTCHA', 'area=securitysettings;sa=spam'),
+			array('CAPTCHA', 'area=antispam'),
 		),
 	);
 

+ 1 - 1
Sources/Display.php

@@ -1096,7 +1096,7 @@ function Display()
 	$context['can_remove_poll'] &= $modSettings['pollMode'] == '1' && $topicinfo['id_poll'] > 0;
 	$context['can_reply'] &= empty($topicinfo['locked']) || allowedTo('moderate_board');
 	$context['can_reply_unapproved'] &= $modSettings['postmod_active'] && (empty($topicinfo['locked']) || allowedTo('moderate_board'));
-	$context['can_issue_warning'] &= in_array('w', $context['admin_features']) && $modSettings['warning_settings'][0] == 1;
+	$context['can_issue_warning'] &= $modSettings['warning_settings'][0] == 1;
 	// Handle approval flags...
 	$context['can_reply_approved'] = $context['can_reply'];
 	$context['can_reply'] |= $context['can_reply_unapproved'];

+ 1 - 1
Sources/ManagePermissions.php

@@ -1551,7 +1551,7 @@ function loadAllPermissions($loadType = 'classic')
 		$hiddenPermissions[] = 'calendar_post';
 		$hiddenPermissions[] = 'calendar_edit';
 	}
-	if (!in_array('w', $context['admin_features']))
+	if ($modSettings['warning_settings'][0] == 0)
 		$hiddenPermissions[] = 'issue_warning';
 	if (!in_array('k', $context['admin_features']))
 		$hiddenPermissions[] = 'karma_edit';

+ 84 - 90
Sources/ManageSettings.php

@@ -94,46 +94,6 @@ function ModifyFeatureSettings()
 	$subActions[$_REQUEST['sa']]();
 }
 
-/**
- * This function passes control through to the relevant security tab.
- */
-function ModifySecuritySettings()
-{
-	global $context, $txt, $scripturl, $modSettings, $settings;
-
-	$context['page_title'] = $txt['admin_security_moderation'];
-
-	$subActions = array(
-		'spam' => 'ModifySpamSettings',
-		'moderation' => 'ModifyModerationSettings',
-	);
-
-	call_integration_hook('integrate_modify_security', array(&$subActions));
-
-	// If Warning System is disabled don't show the setting page
-	if (!in_array('w', $context['admin_features']))
-		unset($subActions['moderation']);
-
-	loadGeneralSettingParameters($subActions, 'spam');
-
-	// Load up all the tabs...
-	$context[$context['admin_menu_name']]['tab_data'] = array(
-		'title' => $txt['admin_security_moderation'],
-		'help' => 'securitysettings',
-		'description' => $txt['security_settings_desc'],
-		'tabs' => array(
-			'spam' => array(
-				'description' => $txt['antispam_Settings_desc'] ,
-			),
-			'moderation' => array(
-			),
-		),
-	);
-
-	// Call the right function for this sub-action.
-	$subActions[$_REQUEST['sa']]();
-}
-
 /**
  * This my friend, is for all the mod authors out there.
  */
@@ -192,36 +152,6 @@ function ModifyCoreFeatures($return_config = false)
 				'karmaMode' => 2,
 			),
 		),
-		// w = warning.
-		'w' => array(
-			'url' => 'action=admin;area=securitysettings;sa=moderation',
-			'setting_callback' => create_function('$value', '
-				global $modSettings;
-				list ($modSettings[\'warning_enable\'], $modSettings[\'user_limit\'], $modSettings[\'warning_decrement\']) = explode(\',\', $modSettings[\'warning_settings\']);
-				$warning_settings = ($value ? 1 : 0) . \',\' . $modSettings[\'user_limit\'] . \',\' . $modSettings[\'warning_decrement\'];
-				if (!$value)
-				{
-					$returnSettings = array(
-						\'warning_watch\' => 0,
-						\'warning_moderate\' => 0,
-						\'warning_mute\' => 0,
-					);
-				}
-				elseif (empty($modSettings[\'warning_enable\']) && $value)
-				{
-					$returnSettings = array(
-						\'warning_watch\' => 10,
-						\'warning_moderate\' => 35,
-						\'warning_mute\' => 60,
-					);
-				}
-				else
-					$returnSettings = array();
-
-				$returnSettings[\'warning_settings\'] = $warning_settings;
-				return $returnSettings;
-			'),
-		),
 	);
 
 	// Anyone who would like to add a core feature?
@@ -540,21 +470,36 @@ function ModifyKarmaSettings($return_config = false)
  *
  * @param bool $return_config = false
  */
-function ModifyModerationSettings($return_config = false)
+function ModifyWarningSettings($return_config = false)
 {
-	global $txt, $scripturl, $context, $settings, $sc, $modSettings;
+	global $txt, $scripturl, $context, $settings, $sc, $modSettings, $sourcedir;
+
+	// You need to be an admin to edit settings!
+	isAllowedTo('admin_forum');
+
+	loadLanguage('Help');
+	loadLanguage('ManageSettings');
+
+	// We need the existing ones for this
+	list ($currently_enabled, $modSettings['user_limit'], $modSettings['warning_decrement']) = explode(',', $modSettings['warning_settings']);
 
 	$config_vars = array(
 			// Warning system?
-			array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'], 'help' => 'warning_enable'),
-			'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note']),
-			array('int', 'warning_mute', 'subtext' => $txt['setting_warning_mute_note']),
-			'rem1' => array('int', 'user_limit', 'subtext' => $txt['setting_user_limit_note']),
-			'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note']),
-			array('select', 'warning_show', 'subtext' => $txt['setting_warning_show_note'], array($txt['setting_warning_show_mods'], $txt['setting_warning_show_user'], $txt['setting_warning_show_all'])),
+			'enable' => array('check', 'warning_enable'),
 	);
 
-	call_integration_hook('integrate_moderation_settings', array(&$config_vars));
+	if (!empty($modSettings['warning_settings']) && $currently_enabled)
+		$config_vars += array(
+			'',
+				array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'], 'help' => 'warning_enable'),
+				'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note']),
+				array('int', 'warning_mute', 'subtext' => $txt['setting_warning_mute_note']),
+				'rem1' => array('int', 'user_limit', 'subtext' => $txt['setting_user_limit_note']),
+				'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note']),
+				array('select', 'warning_show', 'subtext' => $txt['setting_warning_show_note'], array($txt['setting_warning_show_mods'], $txt['setting_warning_show_user'], $txt['setting_warning_show_all'])),
+		);
+
+	call_integration_hook('integrate_warning_settings', array(&$config_vars));
 
 	if ($return_config)
 		return $config_vars;
@@ -563,18 +508,38 @@ function ModifyModerationSettings($return_config = false)
 	if (!$modSettings['postmod_active'])
 		unset($config_vars['moderate']);
 
+	// Will need the utility functions from here.
+	require_once($sourcedir . '/ManageServer.php');
+
 	// Saving?
 	if (isset($_GET['save']))
 	{
 		checkSession();
 
 		// Make sure these don't have an effect.
-		if (substr($modSettings['warning_settings'], 0, 1) != 1)
+		if (!$currently_enabled && empty($_POST['warning_enable']))
 		{
 			$_POST['warning_watch'] = 0;
 			$_POST['warning_moderate'] = 0;
 			$_POST['warning_mute'] = 0;
 		}
+		// If it was disabled and we're enabling it now, set some sane defaults.
+		elseif (!$currently_enabled && !empty($_POST['warning_enable']))
+		{
+			// Need to add these, these weren't there before...
+			$vars = array(
+				'warning_watch' => 10,
+				'warning_mute' => 60,
+			);
+			if ($modSettings['postmod_active'])
+				$vars['warning_moderate'] = 35;
+
+			foreach ($vars as $var => $value)
+			{
+				$config_vars[] = array('int', $var);
+				$_POST[$var] = $value;
+			}
+		}
 		else
 		{
 			$_POST['warning_watch'] = min($_POST['warning_watch'], 100);
@@ -582,23 +547,35 @@ function ModifyModerationSettings($return_config = false)
 			$_POST['warning_mute'] = min($_POST['warning_mute'], 100);
 		}
 
+		// We might not have these already depending on how we got here.
+		$_POST['user_limit'] = isset($_POST['user_limit']) ? (int) $_POST['user_limit'] : $modSettings['user_limit'];
+		$_POST['warning_decrement'] = isset($_POST['warning_decrement']) ? (int) $_POST['warning_decrement'] : $modSettings['warning_decrement'];
+
 		// Fix the warning setting array!
-		$_POST['warning_settings'] = '1,' . min(100, (int) $_POST['user_limit']) . ',' . min(100, (int) $_POST['warning_decrement']);
+		$_POST['warning_settings'] = (!empty($_POST['warning_enable']) ? 1 : 0) . ',' . min(100, $_POST['user_limit']) . ',' . min(100, $_POST['warning_decrement']);
 		$save_vars = $config_vars;
 		$save_vars[] = array('text', 'warning_settings');
-		unset($save_vars['rem1'], $save_vars['rem2']);
+		unset($save_vars['enable'], $save_vars['rem1'], $save_vars['rem2']);
 
-		call_integration_hook('integrate_save_karma_settings', array(&$save_vars));
+		call_integration_hook('integrate_save_warning_settings', array(&$save_vars));
 
 		saveDBSettings($save_vars);
-		redirectexit('action=admin;area=securitysettings;sa=moderation');
+		redirectexit('action=admin;area=warnings');
 	}
 
 	// We actually store lots of these together - for efficiency.
 	list ($modSettings['warning_enable'], $modSettings['user_limit'], $modSettings['warning_decrement']) = explode(',', $modSettings['warning_settings']);
 
-	$context['post_url'] = $scripturl . '?action=admin;area=securitysettings;save;sa=moderation';
-	$context['settings_title'] = $txt['moderation_settings'];
+	$context['sub_template'] = 'show_settings';
+	$context['post_url'] = $scripturl . '?action=admin;area=warnings;save';
+	$context['settings_title'] = $txt['warnings'];
+	$context['page_title'] = $txt['warnings'];
+
+	$context[$context['admin_menu_name']]['tab_data'] = array(
+		'title' => $txt['warnings'],
+		'help' => '',
+		'description' => $txt['warnings_desc'],
+	);
 
 	prepareDBSettingContext($config_vars);
 }
@@ -607,9 +584,12 @@ function ModifyModerationSettings($return_config = false)
  * Let's try keep the spam to a minimum ah Thantos?
  * @param bool $return_config = false
  */
-function ModifySpamSettings($return_config = false)
+function ModifyAntispamSettings($return_config = false)
 {
-	global $txt, $scripturl, $context, $settings, $sc, $modSettings, $smcFunc, $language;
+	global $txt, $scripturl, $context, $settings, $sc, $modSettings, $smcFunc, $language, $sourcedir;
+
+	loadLanguage('Help');
+	loadLanguage('ManageSettings');
 
 	// Generate a sample registration image.
 	$context['use_graphic_library'] = in_array('gd', get_loaded_extensions());
@@ -642,6 +622,9 @@ function ModifySpamSettings($return_config = false)
 	if ($return_config)
 		return $config_vars;
 
+	// You need to be an admin to edit settings!
+	isAllowedTo('admin_forum');
+
 	// Firstly, figure out what languages we're dealing with, and do a little processing for the form's benefit.
 	getLanguages();
 	$context['qa_languages'] = array();
@@ -695,6 +678,9 @@ function ModifySpamSettings($return_config = false)
 	}
 	$("#qa_dt_' . $language . ' a").click();', true);
 
+	// Will need the utility functions from here.
+	require_once($sourcedir . '/ManageServer.php');
+
 	// Saving?
 	if (isset($_GET['save']))
 	{
@@ -841,7 +827,7 @@ function ModifySpamSettings($return_config = false)
 
 		cache_put_data('verificationQuestions', null, 300);
 
-		redirectexit('action=admin;area=securitysettings;sa=spam');
+		redirectexit('action=admin;area=antispam');
 	}
 
 	$character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y'));
@@ -877,8 +863,16 @@ function ModifySpamSettings($return_config = false)
 		$context['settings_post_javascript'] .= '
 		document.getElementById(\'guests_require_captcha\').disabled = true;';
 
-	$context['post_url'] = $scripturl . '?action=admin;area=securitysettings;save;sa=spam';
+	// And everything else.
+	$context['post_url'] = $scripturl . '?action=admin;area=antispam;save';
 	$context['settings_title'] = $txt['antispam_Settings'];
+	$context['page_title'] = $txt['antispam_title'];
+	$context['sub_template'] = 'show_settings';
+
+	$context[$context['admin_menu_name']]['tab_data'] = array(
+		'title' => $txt['antispam_title'],
+		'description' => $txt['antispam_Settings_desc'],
+	);
 
 	prepareDBSettingContext($config_vars);
 }

+ 2 - 2
Sources/ModerationCenter.php

@@ -83,7 +83,7 @@ function ModerationMain($dont_call = false)
 				),
 				'warnings' => array(
 					'label' => $txt['mc_warnings'],
-					'enabled' => in_array('w', $context['admin_features']) && $modSettings['warning_settings'][0] == 1 && $context['can_moderate_boards'],
+					'enabled' => $modSettings['warning_settings'][0] == 1 && $context['can_moderate_boards'],
 					'function' => 'ViewWarnings',
 					'subsections' => array(
 						'log' => array($txt['mc_warning_log']),
@@ -132,7 +132,7 @@ function ModerationMain($dont_call = false)
 			'areas' => array(
 				'userwatch' => array(
 					'label' => $txt['mc_watched_users_title'],
-					'enabled' => in_array('w', $context['admin_features']) && $modSettings['warning_settings'][0] == 1 && $context['can_moderate_boards'],
+					'enabled' => $modSettings['warning_settings'][0] == 1 && $context['can_moderate_boards'],
 					'function' => 'ViewWatchedUsers',
 					'subsections' => array(
 						'member' => array($txt['mc_watched_users_member']),

+ 1 - 1
Sources/PersonalMessage.php

@@ -172,7 +172,7 @@ function MessageMain()
 
 	// This is convenient.  Do you know how annoying it is to do this every time?!
 	$context['current_label_redirect'] = 'action=pm;f=' . $context['folder'] . (isset($_GET['start']) ? ';start=' . $_GET['start'] : '') . (isset($_REQUEST['l']) ? ';l=' . $_REQUEST['l'] : '');
-	$context['can_issue_warning'] = in_array('w', $context['admin_features']) && allowedTo('issue_warning') && $modSettings['warning_settings'][0] == 1;
+	$context['can_issue_warning'] = allowedTo('issue_warning') && $modSettings['warning_settings'][0] == 1;
 
 	// Are PM drafts enabled?
 	$context['drafts_pm_save'] = !empty($modSettings['drafts_pm_enabled']) && allowedTo('pm_draft');

+ 2 - 2
Sources/Profile-View.php

@@ -32,10 +32,10 @@ function summary($memID)
 		'can_send_pm' => allowedTo('pm_send'),
 		'can_send_email' => allowedTo('send_email_to_members'),
 		'can_have_buddy' => allowedTo('profile_identity_own') && !empty($modSettings['enable_buddylist']),
-		'can_issue_warning' => in_array('w', $context['admin_features']) && allowedTo('issue_warning') && $modSettings['warning_settings'][0] == 1,
+		'can_issue_warning' => allowedTo('issue_warning') && $modSettings['warning_settings'][0] == 1,
 	);
 	$context['member'] = &$memberContext[$memID];
-	$context['can_view_warning'] = in_array('w', $context['admin_features']) && (allowedTo('issue_warning') && !$context['user']['is_owner']) || (!empty($modSettings['warning_show']) && ($modSettings['warning_show'] > 1 || $context['user']['is_owner']));
+	$context['can_view_warning'] = (allowedTo('issue_warning') && !$context['user']['is_owner']) || (!empty($modSettings['warning_show']) && ($modSettings['warning_show'] > 1 || $context['user']['is_owner']));
 
 	// Set a canonical URL for this page.
 	$context['canonical_url'] = $scripturl . '?action=profile;u=' . $memID;

+ 2 - 2
Sources/Profile.php

@@ -153,7 +153,7 @@ function ModifyProfile($post_errors = array())
 				),
 				'viewwarning' => array(
 					'label' => $txt['profile_view_warnings'],
-					'enabled' => in_array('w', $context['admin_features']) && $modSettings['warning_settings'][0] == 1 && $cur_profile['warning'] && (!empty($modSettings['warning_show']) && ($context['user']['is_owner'] || $modSettings['warning_show'] == 2)),
+					'enabled' => $modSettings['warning_settings'][0] == 1 && $cur_profile['warning'] && (!empty($modSettings['warning_show']) && ($context['user']['is_owner'] || $modSettings['warning_show'] == 2)),
 					'file' => 'Profile-View.php',
 					'function' => 'viewWarning',
 					'permission' => array(
@@ -295,7 +295,7 @@ function ModifyProfile($post_errors = array())
 				),
 				'issuewarning' => array(
 					'label' => $txt['profile_issue_warning'],
-					'enabled' => in_array('w', $context['admin_features']) && $modSettings['warning_settings'][0] == 1,
+					'enabled' => $modSettings['warning_settings'][0] == 1,
 					'file' => 'Profile-Actions.php',
 					'function' => 'issueWarning',
 					'token' => 'profile-iw%u',

二進制
Themes/default/images/admin/feature_w.png


+ 3 - 1
Themes/default/languages/Admin.english.php

@@ -20,7 +20,6 @@ $txt['admin_censored_desc'] = 'Due to the public nature of forums there may be s
 $txt['admin_reserved_names'] = 'Reserved Names';
 $txt['admin_template_edit'] = 'Edit your forum template';
 $txt['admin_modifications'] = 'Modification Settings';
-$txt['admin_security_moderation'] = 'Security and Moderation';
 $txt['admin_server_settings'] = 'Server Settings';
 $txt['admin_reserved_set'] = 'Set reserved names';
 $txt['admin_reserved_line'] = 'One reserved word per line.';
@@ -147,6 +146,9 @@ $txt['email_as_pms'] = 'Send this to these groups using personal messages.';
 $txt['email_continue'] = 'Continue';
 $txt['email_done'] = 'done.';
 
+$txt['warnings'] = 'Warnings';
+$txt['warnings_desc'] = 'This system allows administrators and moderators to issue warnings to users, and can automatically remove user rights as their warning level increases. To take full advantage of this system, &quot;Post Moderation&quot; should be enabled.';
+
 $txt['ban_title'] = 'Ban List';
 $txt['ban_ip'] = 'IP banning: (e.g. 192.168.12.213 or 128.0.*.*) - one entry per line';
 $txt['ban_email'] = 'Email banning: (e.g. [email protected]) - one entry per line';

+ 0 - 3
Themes/default/languages/Help.english.php

@@ -102,9 +102,6 @@ $helptxt['ban_members'] = '<strong>Ban Members</strong><br />
 $helptxt['featuresettings'] = '<strong>Features and Options</strong><br />
 	There are several features in this section that can be changed to your preference.';
 
-$helptxt['securitysettings'] = '<strong>Security and Moderation</strong><br />
-	This section contains settings relating to the security and moderation of your forum.';
-
 $helptxt['modsettings'] = '<strong>Modification Settings</strong><br />
 	This section should contain any settings added by modifications installed on your forum.';
 

+ 0 - 3
Themes/default/languages/ManageSettings.english.php

@@ -4,7 +4,6 @@
 global $scripturl;
 
 $txt['modSettings_desc'] = 'This page allows you to change the settings of features and basic options in your forum.  Please see the <a href="' . $scripturl . '?action=admin;area=theme;sa=list;th=%1$s;%3$s=%2$s">theme settings</a> for more options.  Click the help icons for more information about a setting.';
-$txt['security_settings_desc'] = 'This page allows you to set options specifically related to the security and moderation of your forum, including anti-spam options.';
 $txt['modification_settings_desc'] = 'This page contains settings added by any modifications to your forum';
 
 $txt['modification_no_misc_settings'] = 'There are no modifications installed that have added any settings to this area yet.';
@@ -299,8 +298,6 @@ $txt['core_settings_welcome_msg'] = 'Welcome to Your New Forum';
 $txt['core_settings_welcome_msg_desc'] = 'To get you started we suggest you select which of SMF\'s core features you want to enable. We\'d recommend only enabling with those features you need!';
 $txt['core_settings_item_k'] = 'Karma';
 $txt['core_settings_item_k_desc'] = 'Karma is a feature that shows the popularity of a member. Members, if allowed, can \'applaud\' or \'smite\' other members, which is how their popularity is calculated.';
-$txt['core_settings_item_w'] = 'Warning System';
-$txt['core_settings_item_w_desc'] = 'This system allows administrators and moderators to issue warnings to users, and can automatically remove user rights as their warning level increases. To take full advantage of this system, &quot;Post Moderation&quot; should be enabled.';
 $txt['core_settings_switch_on'] = 'Click to Enable';
 $txt['core_settings_switch_off'] = 'Click to Disable';
 $txt['core_settings_enabled'] = 'Enabled';