]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
locations-functions.pl: Allow get_locations() function to skip special locations.
authorStefan Schantl <stefan.schantl@ipfire.org>
Sat, 7 Nov 2020 18:47:23 +0000 (19:47 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 9 Nov 2020 14:07:14 +0000 (14:07 +0000)
When adding "no_special_locations" to the function call as argument
the special locations liks "A1, A2, A3 etc" will not be added to the
returned array as available locations.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/cfgroot/location-functions.pl

index e8db4ba9b788fe9a57ec10db61a4e7a5f39173d9..fdf2c6efecd52e8efacb291aae9259e003db65de 100644 (file)
@@ -177,16 +177,24 @@ sub get_full_country_name($) {
 
 # Function to get all available locations.
 sub get_locations() {
+       my ($mode) = @_;
+
+       # Set default mode to add_special_locations.
+       $mode = $mode ? $mode : "add_special_locations";
+
        # Get locations which are stored in the location database.
-       my @database_locations = &Location::database_countries($db_handle);
+       my @locations = &Location::database_countries($db_handle);
 
-       # Merge special locations array and the database locations array.
-       my @locations = (@special_locations, @database_locations);
+       # Check if the special locations should be added.
+       if ($mode ne "no_special_locations") {
+               # Merge special locations array and the database locations array.
+               @locations = (@special_locations, @locations);
+       }
 
        # Sort locations array in alphabetical order.
        my @sorted_locations = sort(@locations);
 
-       # Return the array..
+       # Return the array.
        return @sorted_locations;
 }