Browse Source

Merge pull request #703 from Arantor/release-2.1

! Turning Log Pruning into Log Settings, with some aesthetic changes tha...
Arantor 10 years ago
parent
commit
2c8f28efdc

+ 5 - 5
Sources/Admin.php

@@ -433,7 +433,7 @@ function AdminMain()
 						'banlog' => array($txt['ban_log'], 'manage_bans'),
 						'spiderlog' => array($txt['spider_logs'], 'admin_forum', 'enabled' => in_array('sp', $context['admin_features'])),
 						'tasklog' => array($txt['scheduled_log'], 'admin_forum'),
-						'pruning' => array($txt['pruning_title'], 'admin_forum'),
+						'settings' => array($txt['log_settings'], 'admin_forum'),
 					),
 				),
 				'repairboards' => array(
@@ -722,7 +722,7 @@ function AdminSearchInternal()
 		array('ModifyRegistrationSettings', 'area=regcenter;sa=settings'),
 		array('ManageSearchEngineSettings', 'area=sengines;sa=settings'),
 		array('ModifySubscriptionSettings', 'area=paidsubscribe;sa=settings'),
-		array('ModifyPruningSettings', 'area=logs;sa=pruning'),
+		array('ModifyLogSettings', 'area=logs;sa=settings'),
 	);
 
 	call_integration_hook('integrate_admin_search', array(&$language_files, &$include_files, &$settings_search));
@@ -900,7 +900,7 @@ function AdminLogs()
 		'banlog' => array('ManageBans.php', 'BanLog'),
 		'spiderlog' => array('ManageSearchEngines.php', 'SpiderLogs'),
 		'tasklog' => array('ManageScheduledTasks.php', 'TaskLog'),
-		'pruning' => array('ManageSettings.php', 'ModifyPruningSettings'),
+		'settings' => array('ManageSettings.php', 'ModifyLogSettings'),
 	);
 
 	call_integration_hook('integrate_manage_logs', array(&$log_functions));
@@ -935,8 +935,8 @@ function AdminLogs()
 			'tasklog' => array(
 				'description' => $txt['scheduled_log_desc'],
 			),
-			'pruning' => array(
-				'description' => $txt['pruning_log_desc'],
+			'settings' => array(
+				'description' => $txt['log_settings_desc'],
 			),
 		),
 	);

+ 27 - 16
Sources/ManageSettings.php

@@ -237,13 +237,6 @@ function ModifyCoreFeatures($return_config = false)
 				'karmaMode' => 2,
 			),
 		),
-		// ml = moderation log.
-		'ml' => array(
-			'url' => 'action=admin;area=logs;sa=modlog',
-			'settings' => array(
-				'modlog_enabled' => 1,
-			),
-		),
 		// pm = post moderation.
 		'pm' => array(
 			'url' => 'action=admin;area=permissions;sa=postmod',
@@ -564,9 +557,6 @@ function ModifyGeneralSecuritySettings($return_config = false)
 		'',
 			array('int', 'failed_login_threshold'),
 			array('int', 'loginHistoryDays'),
-		'',
-			array('check', 'enableErrorLogging'),
-			array('check', 'enableErrorQueryLogging'),
 		'',
 			array('check', 'securityDisable'),
 			array('check', 'securityDisable_moderate'),
@@ -2142,17 +2132,21 @@ function EditCustomProfiles()
  * Allow to edit the settings on the pruning screen.
  * @param $return_config
  */
-function ModifyPruningSettings($return_config = false)
+function ModifyLogSettings($return_config = false)
 {
 	global $txt, $scripturl, $sourcedir, $context, $settings, $sc, $modSettings;
 
 	// Make sure we understand what's going on.
 	loadLanguage('ManageSettings');
 
-	$context['page_title'] = $txt['pruning_title'];
+	$context['page_title'] = $txt['log_settings'];
 
 	$config_vars = array(
+			array('check', 'enableErrorLogging'),
+			array('check', 'enableErrorQueryLogging'),
 			// Even do the pruning?
+			array('title', 'pruning_title'),
+			array('desc', 'pruning_desc'),
 			// The array indexes are there so we can remove/change them before saving.
 			'pruningOptions' => array('check', 'pruningOptions'),
 		'',
@@ -2167,11 +2161,28 @@ function ModifyPruningSettings($return_config = false)
 			// Mod Developers: Do NOT use the pruningOptions master variable for this as SMF Core may overwrite your setting in the future!
 	);
 
-	call_integration_hook('integrate_prune_settings', array(&$config_vars));
+	// We want to be toggling some of these for a nice user experience. If you want to add yours to the list of those magically hidden when the 'pruning' option is off, add to this.
+	$prune_toggle = array('pruneErrorLog', 'pruneModLog', 'pruneBanLog', 'pruneReportLog', 'pruneScheduledTaskLog', 'pruneSpiderHitLog');
+
+	call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle));
+
+	$prune_toggle_dt = array();
+	foreach ($prune_toggle as $item)
+		$prune_toggle_dt[] = 'setting_' . $item;
 
 	if ($return_config)
 		return $config_vars;
 
+	addInlineJavascript('
+	function togglePruned()
+	{
+		var newval = $("#pruningOptions").prop("checked");
+		$("#' . implode(', #', $prune_toggle) . '").closest("dd").toggle(newval);
+		$("#' . implode(', #', $prune_toggle_dt) . '").closest("dt").toggle(newval);
+	};
+	togglePruned();
+	$("#pruningOptions").click(function() { togglePruned(); });', true);
+
 	// We'll need this in a bit.
 	require_once($sourcedir . '/ManageServer.php');
 
@@ -2200,11 +2211,11 @@ function ModifyPruningSettings($return_config = false)
 			$_POST['pruningOptions'] = '';
 
 		saveDBSettings($savevar);
-		redirectexit('action=admin;area=logs;sa=pruning');
+		redirectexit('action=admin;area=logs;sa=settings');
 	}
 
-	$context['post_url'] = $scripturl . '?action=admin;area=logs;save;sa=pruning';
-	$context['settings_title'] = $txt['pruning_title'];
+	$context['post_url'] = $scripturl . '?action=admin;area=logs;save;sa=settings';
+	$context['settings_title'] = $txt['log_settings'];
 	$context['sub_template'] = 'show_settings';
 
 	// Get the actual values

+ 2 - 2
Themes/default/Admin.template.php

@@ -752,8 +752,8 @@ function template_show_settings()
 			if ($config_var['type'] == 'title')
 			{
 				echo '
-					<div class="cat_bar">
-						<h3 class="', !empty($config_var['class']) ? $config_var['class'] : 'catbg', '"', !empty($config_var['force_div_id']) ? ' id="' . $config_var['force_div_id'] . '"' : '', '>
+					<div class="title_bar">
+						<h3 class="', !empty($config_var['class']) ? $config_var['class'] : 'titlebg', '"', !empty($config_var['force_div_id']) ? ' id="' . $config_var['force_div_id'] . '"' : '', '>
 							', ($config_var['help'] ? '<a href="' . $scripturl . '?action=helpadmin;help=' . $config_var['help'] . '" onclick="return reqOverlayDiv(this.href);" class="help"><img src="' . $settings['images_url'] . '/helptopics_hd.png" class="icon" alt="' . $txt['help'] . '" /></a>' : ''), '
 							', $config_var['label'], '
 						</h3>

+ 2 - 2
Themes/default/Errors.template.php

@@ -49,8 +49,8 @@ function template_error_log()
 		<form class="generic_list_wrapper" action="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';start=', $context['start'], $context['has_filter'] ? $context['filter']['href'] : '', '" method="post" accept-charset="', $context['character_set'], '">';
 
 	echo '
-			<div class="title_bar clear_right">
-				<h3 class="titlebg">
+			<div class="cat_bar clear_right">
+				<h3 class="catbg">
 					<a href="', $scripturl, '?action=helpadmin;help=error_log" onclick="return reqOverlayDiv(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.png" class="icon" alt="', $txt['help'], '" /></a> ', $txt['errlog'], '
 				</h3>
 			</div>

+ 2 - 4
Themes/default/css/admin.css

@@ -162,7 +162,7 @@ div.quick_tasks {
 #mailqueue_stats .windowbg .content {
 	padding: 12px 9px 0 9px;
 }
-#admin_form_wrapper div.cat_bar:first-child, #admin_newsletters div.cat_bar:first-child,
+#admin_newsletters div.cat_bar:first-child,
 #generate_reports_type div.cat_bar:first-child, #groupForm div.cat_bar:first-child,
 #admin_form_wrapper div.title_bar, #mailqueue_stats div.cat_bar:first-child,
 #new_group div.cat_bar:first-child, #view_group div.cat_bar, #view_group div.cat_bar:first-child {
@@ -171,7 +171,7 @@ div.quick_tasks {
 	border-bottom: 1px solid #fff;
 	box-shadow: none;
 }
-#admin_form_wrapper div.cat_bar:first-child h3.catbg, #admin_newsletters div.cat_bar:first-child h3.catbg,
+#admin_newsletters div.cat_bar:first-child h3.catbg,
 #generate_reports_type div.cat_bar:first-child h3.catbg, #groupForm div.cat_bar:first-child h3.catbg, #mailqueue_stats div.cat_bar:first-child  h3.catbg,
 #new_group div.cat_bar:first-child  h3.catbg, #view_group div.cat_bar  h3.catbg, #view_group div.cat_bar:first-child  h3.catbg {
 	color: #444;
@@ -181,8 +181,6 @@ div.quick_tasks {
 	border-bottom: 1px solid #bbb;
 }
 #admin_form_wrapper div.title_bar {
-
-	border: 1px solid #ccc;
 	border-radius: 2px 2px 0 0;
 	margin: 0;
 	background: linear-gradient(bottom, #FFFFFF 1%, #F1F3F5 96%);

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

@@ -239,7 +239,7 @@ $txt['admin_log_desc'] = 'Lists administrative tasks that have been performed by
 $txt['moderation_log'] = 'Moderation Log';
 $txt['moderation_log_desc'] = 'Lists moderation activities that have been performed by moderators on your forum.';
 $txt['spider_log_desc'] = 'Review the entries related to search engine spider activity on your forum.';
-$txt['pruning_log_desc'] = 'Use these tools to prune older entries in the various logs.';
+$txt['log_settings_desc'] = 'Use these options to configure how logging works on your forum.';
 
 $txt['mailqueue_title'] = 'Mail';
 
@@ -654,6 +654,8 @@ $txt['moderation_settings_short'] = 'Moderation';
 $txt['signature_settings_short'] = 'Signatures';
 $txt['custom_profile_shorttitle'] = 'Profile Fields';
 $txt['pruning_title'] = 'Log Pruning';
+$txt['pruning_desc'] = 'The following options are useful for keeping your logs from growing too big, because most of the time older entries are not really of that much use.';
+$txt['log_settings'] = 'Log Settings';
 
 $txt['core_settings_activation_message'] = 'The feature {core_feature} has been activated, click on the title to configure it';
 $txt['core_settings_deactivation_message'] = 'The feature {core_feature} has been deactivated';