]> git.ipfire.org Git - people/stevee/ipfire-2.x.git/commitdiff
ids.cgi: Introduce and use get_provider_name() function.
authorStefan Schantl <stefan.schantl@ipfire.org>
Sat, 20 Mar 2021 17:07:57 +0000 (18:07 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Sun, 19 Dec 2021 12:21:51 +0000 (13:21 +0100)
This function is used to grab the name of a provider by the given
handle.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
html/cgi-bin/ids.cgi

index 478b2ff1542c243c6027929cb487bef6c83e4ec2..6ff29bd2c764b427821b70f84e88e9593e2d6fc3 100644 (file)
@@ -900,20 +900,10 @@ END
 
                        # Loop throgh the list of providers.
                        foreach my $provider (@ruleset_providers) {
-                               my $option_string;
-
-                               # Get the translation required string for the current provider.
-                               my $tr_string = $IDS::Ruleset::Providers{$provider}{'tr_string'};
-
-                               # Check if a translation string is available in the language files.
-                               if ($Lang::tr{$tr_string}) {
-                                       # Use the translated string from the language file.
-                                       $option_string = $Lang::tr{$tr_string};
-                               } else {
-                                       # Fallback and use the provider summary from the providers file.
-                                       $option_string = $IDS::Ruleset::Providers{$provider}{'summary'};
-                               }
+                               # Call get_provider_name function to obtain the provider name.
+                               my $option_string = &get_provider_name($provider);
 
+                               # Print option.
                                print "<option value='$provider' $selected{'RULES'}{$provider}>$option_string</option>\n";
                        }
 print <<END;
@@ -1399,6 +1389,29 @@ sub read_enabled_disabled_sids_file($) {
        return %temphash;
 }
 
+#
+## Function to get the provider name from the language file or providers file for a given handle.
+#
+sub get_provider_name($) {
+       my ($handle) = @_;
+       my $provider_name;
+
+       # Get the required translation string for the given provider handle.
+       my $tr_string = $IDS::Ruleset::Providers{$handle}{'tr_string'};
+
+       # Check if the translation string is available in the language files.
+       if ($Lang::tr{$tr_string}) {
+               # Use the translated string from the language file.
+               $provider_name = $Lang::tr{$tr_string};
+       } else {
+               # Fallback and use the provider summary from the providers file.
+               $provider_name = $IDS::Ruleset::Providers{$handle}{'summary'};
+       }
+
+       # Return the obtained provider name.
+       return $provider_name;
+}
+
 #
 ## Private function to convert a given rulefile to a category name.
 ## ( No file extension anymore and if the name contained a dot, it