]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
ids.cgi: Add code to handle enable/disable autoupdate for a provider.
authorStefan Schantl <stefan.schantl@ipfire.org>
Tue, 23 Mar 2021 16:40:44 +0000 (17:40 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Sun, 19 Dec 2021 12:22:59 +0000 (13:22 +0100)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
html/cgi-bin/ids.cgi

index 5ceb7e4001aee4eca939173ce7ac7007e865a040..400a53322cc4b63828aa2a29b042d71f842823cf 100644 (file)
@@ -666,6 +666,40 @@ if ($cgiparams{'RULESET'} eq $Lang::tr{'save'}) {
                &reload();
        }
 
+# Toggle Enable/Disable autoupdate for a provider
+} elsif ($cgiparams{'AUTOUPDATE'} eq $Lang::tr{'toggle enable disable'}) {
+       my %used_providers = ();
+
+       # Only go further, if an ID has been passed.
+       if ($cgiparams{'ID'}) {
+               # Assign the given ID.
+               my $id = $cgiparams{'ID'};
+
+               # Undef the given ID.
+               undef($cgiparams{'ID'});
+
+               # Read-in providers settings file.
+               &General::readhasharray($IDS::providers_settings_file, \%used_providers);
+
+               # Grab the configured status of the corresponding entry.
+               my $status_autoupdate = $used_providers{$id}[2];
+
+               # Switch the status.
+               if ($status_autoupdate eq "disabled") {
+                       $status_autoupdate = "enabled";
+               } else {
+                       $status_autoupdate = "disabled";
+               }
+
+               # Modify the status of the existing entry.
+               $used_providers{$id} = ["$used_providers{$id}[0]", "$used_providers{$id}[1]", "$status_autoupdate", "$used_providers{$id}[3]"];
+
+               # Write the changed hash to the providers settings file.
+               &General::writehasharray($IDS::providers_settings_file, \%used_providers);
+       }
+
+# Add/Edit a provider to the list of used providers.
+#
 } elsif (($cgiparams{'PROVIDERS'} eq "$Lang::tr{'add'}") || ($cgiparams{'PROVIDERS'} eq "$Lang::tr{'update'}")) {
        my %used_providers = ();