Katie Horn has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/91893


Change subject: Removing unsupported countries from the RapidHTML country 
dropdown.
......................................................................

Removing unsupported countries from the RapidHTML country dropdown.

Change-Id: I245dd1d90713105f5dc474c9b8b956a1d7431d66
---
M gateway_forms/RapidHtml.php
M special/GatewayFormChooser.php
2 files changed, 36 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface 
refs/changes/93/91893/1

diff --git a/gateway_forms/RapidHtml.php b/gateway_forms/RapidHtml.php
index 6cb0369..24384f2 100644
--- a/gateway_forms/RapidHtml.php
+++ b/gateway_forms/RapidHtml.php
@@ -551,9 +551,22 @@
         * @return string An option list containing all supported countries
         */
        function getCountryDropdown() {
-               # get the list of supported countries
+               global $wgDonationInterfaceForbiddenCountries;
+
+               //returns an array of iso_code => country name
                $countries = GatewayForm::getCountries();
 
+               //unset blacklisted countries first
+               foreach ( $wgDonationInterfaceForbiddenCountries as 
$country_code ) {
+                       unset( $countries[$country_code] );
+               }
+               //only use countries from that array that are represented in 
the form definition
+               foreach ( $countries as $code => $name ) {
+                       if ( !GatewayFormChooser::isSupportedCountry( $code, 
$this->gateway->getData_Unstaged_Escaped( 'ffname' ) ) ) {
+                               unset( $countries[$code] );
+                       }
+               }
+
                $output = "";
 
                # iterate through the countris, ignoring the value since we
diff --git a/special/GatewayFormChooser.php b/special/GatewayFormChooser.php
index 0e79f9e..6f024d6 100644
--- a/special/GatewayFormChooser.php
+++ b/special/GatewayFormChooser.php
@@ -255,6 +255,28 @@
        }
 
        /**
+        * 
+        * @param string $form_key
+        * @return boolean
+        */
+       static function isSupportedCountry( $country_iso, $form_key ) {
+               static $countries = array ( );
+               if ( !array_key_exists( $form_key, $countries ) ) {
+                       $def = self::getFormDefinition( $form_key );
+                       if ( array_key_exists( 'countries', $def ) ) {
+                               $countries[$form_key] = $def['countries'];
+                       } else {
+                               $countries[$form_key] = 'ALL';
+                       }
+               }
+
+               if ( DataValidator::value_appears_in( $country_iso, 
$countries[$form_key] ) ) {
+                       return true;
+               }
+               return false;
+       }
+
+       /**
         * Return an array of all the currently enabled gateways. 
         * I had hoped there would be more to this...
         * @global type $wgDonationInterfaceEnabledGateways

-- 
To view, visit https://gerrit.wikimedia.org/r/91893
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I245dd1d90713105f5dc474c9b8b956a1d7431d66
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Katie Horn <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to