Index: trunk/extensions/DonationInterface/gateway_common/GatewayForm.php |
— | — | @@ -121,6 +121,13 @@ |
122 | 122 | /** |
123 | 123 | * Validates the address |
124 | 124 | * |
| 125 | + * Required: |
| 126 | + * - street |
| 127 | + * - city |
| 128 | + * - state |
| 129 | + * - zip |
| 130 | + * - country |
| 131 | + * |
125 | 132 | * @param array $data Reference to the data of the form |
126 | 133 | * @param array $error Reference to the error messages of the form |
127 | 134 | * |
— | — | @@ -142,18 +149,23 @@ |
143 | 150 | $this->setValidateFormResult( false ); |
144 | 151 | } |
145 | 152 | |
146 | | - $validateState = ( $data['country'] == 'US' ) ? true : false ; |
| 153 | + if ( empty( $data['state'] ) || $data['state'] == 'YY' ) { |
147 | 154 | |
148 | | - if ( empty( $data['state'] ) && $validateState ) { |
149 | | - |
150 | 155 | $error['state'] = wfMsg( 'donate_interface-error-msg', wfMsg( 'donate_interface-error-msg-state' ) ); |
151 | 156 | |
152 | 157 | $this->setValidateFormResult( false ); |
153 | 158 | } |
154 | 159 | |
155 | | - $validateZip = ( $validateState && isset( $data['state'] ) && $data['state'] != 'XX' ) ? true : false ; |
| 160 | + if ( empty( $data['country'] ) || !array_key_exists( $data['country'], $this->getCountries() )) { |
| 161 | + |
| 162 | + $error['country'] = wfMsg( 'donate_interface-error-msg', wfMsg( 'donate_interface-error-msg-country' ) ); |
| 163 | + |
| 164 | + $this->setValidateFormResult( false ); |
| 165 | + } |
| 166 | + |
| 167 | + $ignoreCountries = array(); |
156 | 168 | |
157 | | - if ( empty( $data['zip'] ) && $validateZip ) { |
| 169 | + if ( empty( $data['zip'] ) && !in_array( $data['country'], $ignoreCountries ) ) { |
158 | 170 | |
159 | 171 | $error['zip'] = wfMsg( 'donate_interface-error-msg', wfMsg( 'donate_interface-error-msg-zip' ) ); |
160 | 172 | |