https://www.mediawiki.org/wiki/Special:Code/MediaWiki/102125

Revision: 102125
Author:   jpostlethwaite
Date:     2011-11-05 22:32:43 +0000 (Sat, 05 Nov 2011)
Log Message:
-----------
Requiring state, country and zip on all forms. See r101556.

Modified Paths:
--------------
    trunk/extensions/DonationInterface/gateway_common/GatewayForm.php

Modified: trunk/extensions/DonationInterface/gateway_common/GatewayForm.php
===================================================================
--- trunk/extensions/DonationInterface/gateway_common/GatewayForm.php   
2011-11-05 22:13:56 UTC (rev 102124)
+++ trunk/extensions/DonationInterface/gateway_common/GatewayForm.php   
2011-11-05 22:32:43 UTC (rev 102125)
@@ -121,6 +121,13 @@
        /**
         * Validates the address
         *
+        * Required:
+        * - street
+        * - city
+        * - state
+        * - zip
+        * - country
+        *
         * @param array $data   Reference to the data of the form
         * @param array $error  Reference to the error messages of the form
         *
@@ -142,18 +149,23 @@
                        $this->setValidateFormResult( false );
                }
 
-               $validateState = ( $data['country'] == 'US' ) ? true : false ;
+               if ( empty( $data['state'] ) || $data['state'] == 'YY' ) {
 
-               if ( empty( $data['state'] ) && $validateState  ) {
-
                        $error['state'] = wfMsg( 'donate_interface-error-msg', 
wfMsg( 'donate_interface-error-msg-state' ) );
 
                        $this->setValidateFormResult( false );
                }
 
-               $validateZip = ( $validateState && isset( $data['state'] ) && 
$data['state'] != 'XX' ) ? true : false ;
+               if ( empty( $data['country'] ) || !array_key_exists( 
$data['country'], $this->getCountries() )) {
+
+                       $error['country'] = wfMsg( 
'donate_interface-error-msg', wfMsg( 'donate_interface-error-msg-country' ) );
+
+                       $this->setValidateFormResult( false );
+               }
+
+               $ignoreCountries = array();
                
-               if ( empty( $data['zip'] ) && $validateZip ) {
+               if ( empty( $data['zip'] ) && !in_array( $data['country'], 
$ignoreCountries ) ) {
 
                        $error['zip'] = wfMsg( 'donate_interface-error-msg', 
wfMsg( 'donate_interface-error-msg-zip' ) );
 


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

Reply via email to