From mboxrd@z Thu Jan  1 00:00:00 1970
From: Stefan Schantl <stefan.schantl@ipfire.org>
To: development@lists.ipfire.org
Subject: [PATCH 4/5] locations-functions.pl: Allow get_locations() function to
 skip special locations.
Date: Sat, 07 Nov 2020 19:47:23 +0100
Message-ID: <20201107184724.3590-4-stefan.schantl@ipfire.org>
In-Reply-To: <20201107184724.3590-1-stefan.schantl@ipfire.org>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============6643482225221706449=="
List-Id: <development.lists.ipfire.org>

--===============6643482225221706449==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

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(a)ipfire.org>
---
 config/cfgroot/location-functions.pl | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/config/cfgroot/location-functions.pl b/config/cfgroot/location-f=
unctions.pl
index e8db4ba9b..fdf2c6efe 100644
--- a/config/cfgroot/location-functions.pl
+++ b/config/cfgroot/location-functions.pl
@@ -177,16 +177,24 @@ sub get_full_country_name($) {
=20
 # Function to get all available locations.
 sub get_locations() {
+	my ($mode) =3D @_;
+
+	# Set default mode to add_special_locations.
+	$mode =3D $mode ? $mode : "add_special_locations";
+
 	# Get locations which are stored in the location database.
-	my @database_locations =3D &Location::database_countries($db_handle);
+	my @locations =3D &Location::database_countries($db_handle);
=20
-	# Merge special locations array and the database locations array.
-	my @locations =3D (@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 =3D (@special_locations, @locations);
+	}
=20
 	# Sort locations array in alphabetical order.
 	my @sorted_locations =3D sort(@locations);
=20
-	# Return the array..
+	# Return the array.
 	return @sorted_locations;
 }
=20
--=20
2.20.1


--===============6643482225221706449==--