From patchwork Sat Nov 7 18:47:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 3650 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4CT5q25XdDz3wlM for ; Sat, 7 Nov 2020 18:47:42 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4CT5pz0Jj1z1qJ; Sat, 7 Nov 2020 18:47:39 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4CT5py6ll6z2ydZ; Sat, 7 Nov 2020 18:47:38 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4CT5px1G09z2xGb for ; Sat, 7 Nov 2020 18:47:37 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4CT5pw6KMKz1Qr; Sat, 7 Nov 2020 18:47:36 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1604774857; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lno+baKTSDpcQsPZWuvspwhQIgoFbKH2S0Wlvbx89Dc=; b=qGYxIb3X034xkOSUPE1f3CqWPTnE5E1ktzgnIM4e2swskttG5kilvKlIKr28G2dkFDtGwX 7WTn6H1tymE5SOCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1604774857; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lno+baKTSDpcQsPZWuvspwhQIgoFbKH2S0Wlvbx89Dc=; b=fwcLaYYME0ZO7rJSumTKtFI9XzXa4ak7991y4yy0tNksUN7AVzUbjyvLFHd3TeA2XHoR/3 KU8uWzRBPinXT/CLgL8b6j+02i7/qYvG5NIN1qkp/0APPbN6xMFvzLYuMMO1/18JrckpKZ 1pXgr0VhNtKeogjr7BC9ObxTlmYmPZpun+wAxZB7OaF59Mr6WakfiHP3/2jcAq7F4QyVaQ sG1WSrmbQ8S7wGNocDJyayTQVod9iKlTxZUljQ8GovXZXKPUD5DfAjwMp6P5v0Lt3Iom2u 7/6cYazNFA5o6Hr3O+551gZenqFTx8xiidKgS81f7GRLuFxRKpoXwjCwpn+fOw== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH 4/5] locations-functions.pl: Allow get_locations() function to skip special locations. Date: Sat, 7 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> References: <20201107184724.3590-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" 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 --- 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-functions.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($) { # 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; }