From dd40f71523311a0e42dec9f321c68f53aa2d99ad Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Mon, 25 Sep 2023 21:38:37 +0200 Subject: [PATCH] System: Configuration: History - move "backupcount" setting to "System: Configuration: Backups" for https://github.com/opnsense/core/issues/6828 Local backup configuration would be best stored in the backup configuration for consistency. Eventually we should refactor the backup configuration as well, but while refactoring the history page and adding a host selection (when used in conjunction with OPNcentral), this setting is a bit out of place. --- src/www/diag_backup.php | 41 ++++++++++++++++++++++++++++++++- src/www/diag_confbak.php | 49 ++++------------------------------------ 2 files changed, 44 insertions(+), 46 deletions(-) diff --git a/src/www/diag_backup.php b/src/www/diag_backup.php index 39f94590d..e28d58f59 100644 --- a/src/www/diag_backup.php +++ b/src/www/diag_backup.php @@ -110,7 +110,7 @@ $do_reboot = false; if ($_SERVER['REQUEST_METHOD'] === 'GET') { $pconfig = array(); - + $pconfig['backupcount'] = isset($config['system']['backupcount']) ? $config['system']['backupcount'] : null; foreach ($backupFactory->listProviders() as $providerId => $provider) { foreach ($provider['handle']->getConfigurationFields() as $field) { $fieldId = $providerId . "_" .$field['name']; @@ -324,6 +324,19 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { } system_cron_configure(); } + } elseif (!empty($pconfig['save'])) { + if ($pconfig['backupcount'] != null && (!is_numeric($pconfig['backupcount']) || $pconfig['backupcount'] <= 0)) { + $input_errors[] = gettext('Backup count must be greater than zero.'); + } + if (count($input_errors) == 0) { + if ($pconfig['backupcount'] != null) { + $config['system']['backupcount'] = $pconfig['backupcount']; + } elseif (isset($config['system']['backupcount'])) { + unset($config['system']['backupcount']); + } + write_config('Changed backup revision count'); + $savemsg = get_std_save_message(); + } } } @@ -374,6 +387,32 @@ $( document ).ready(function() { 0) print_input_errors($input_errors); ?>
+
+
+ +
+
+ + + + + + + + + + + + + +
+ +getBackups(true)) > 0): ?> + + +
+
+
diff --git a/src/www/diag_confbak.php b/src/www/diag_confbak.php index 49b20d5e5..a67f8d0ff 100644 --- a/src/www/diag_confbak.php +++ b/src/www/diag_confbak.php @@ -93,21 +93,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $input_errors = array(); $pconfig = $_POST; - if (!empty($pconfig['save'])) { - if ($pconfig['backupcount'] != null && (!is_numeric($pconfig['backupcount']) || $pconfig['backupcount'] <= 0)) { - $input_errors[] = gettext('Backup count must be greater than zero.'); - } - if (count($input_errors) == 0) { - if ($pconfig['backupcount'] != null) { - $config['system']['backupcount'] = $pconfig['backupcount']; - } elseif (isset($config['system']['backupcount'])) { - unset($config['system']['backupcount']); - } - write_config('Changed backup revision count'); - $savemsg = get_std_save_message(); - } - } - $cnf = OPNsense\Core\Config::getInstance(); $confvers = $cnf->getBackups(true); array_shift($confvers); @@ -206,41 +191,15 @@ include("fbegin.inc"); ?>
+ + + +
0) print_input_errors($input_errors); ?>
-
- - -
-
- - - - - - - - - - - - - -
- -
- - - - 0): ?> - - -
-
-