r102125 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102124‎ | r102125 | r102126 >
Date:22:32, 5 November 2011
Author:jpostlethwaite
Status:ok
Tags:fundraising 
Comment:
Requiring state, country and zip on all forms. See r101556.
Modified paths:
  • /trunk/extensions/DonationInterface/gateway_common/GatewayForm.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/gateway_common/GatewayForm.php
@@ -121,6 +121,13 @@
122122 /**
123123 * Validates the address
124124 *
 125+ * Required:
 126+ * - street
 127+ * - city
 128+ * - state
 129+ * - zip
 130+ * - country
 131+ *
125132 * @param array $data Reference to the data of the form
126133 * @param array $error Reference to the error messages of the form
127134 *
@@ -142,18 +149,23 @@
143150 $this->setValidateFormResult( false );
144151 }
145152
146 - $validateState = ( $data['country'] == 'US' ) ? true : false ;
 153+ if ( empty( $data['state'] ) || $data['state'] == 'YY' ) {
147154
148 - if ( empty( $data['state'] ) && $validateState ) {
149 -
150155 $error['state'] = wfMsg( 'donate_interface-error-msg', wfMsg( 'donate_interface-error-msg-state' ) );
151156
152157 $this->setValidateFormResult( false );
153158 }
154159
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();
156168
157 - if ( empty( $data['zip'] ) && $validateZip ) {
 169+ if ( empty( $data['zip'] ) && !in_array( $data['country'], $ignoreCountries ) ) {
158170
159171 $error['zip'] = wfMsg( 'donate_interface-error-msg', wfMsg( 'donate_interface-error-msg-zip' ) );
160172

Follow-up revisions

RevisionCommit summaryAuthorDate
r102236MFT r90286, r100671, r100837, r100950, r101060, r101063, r101064, r101073, r1......khorn03:06, 7 November 2011
r102237MFT r90286, r100671, r100837, r100950, r101060, r101063, r101064, r101073, r1......khorn03:07, 7 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r101556Updated validation to accomodate forms without a state input element.jpostlethwaite23:59, 1 November 2011

Status & tagging log