mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-05-05 03:18:00 +02:00
locations-functions.pl: Allow get_locations() function to skip special locations.
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>
This commit is contained in:
committed by
Michael Tremer
parent
5bf91fe1b1
commit
427190d578
@@ -177,16 +177,24 @@ sub get_full_country_name($) {
|
||||
|
||||
# Function to get all available locations.
|
||||
sub get_locations() {
|
||||
# Get locations which are stored in the location database.
|
||||
my @database_locations = &Location::database_countries($db_handle);
|
||||
my ($mode) = @_;
|
||||
|
||||
# Merge special locations array and the database locations array.
|
||||
my @locations = (@special_locations, @database_locations);
|
||||
# Set default mode to add_special_locations.
|
||||
$mode = $mode ? $mode : "add_special_locations";
|
||||
|
||||
# Get locations which are stored in the location database.
|
||||
my @locations = &Location::database_countries($db_handle);
|
||||
|
||||
# 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user