Index: trunk/extensions/DonationInterface/gateway_common/GatewayForm.php |
— | — | @@ -78,8 +78,6 @@ |
79 | 79 | /** |
80 | 80 | * Checks posted form data for errors and returns array of messages |
81 | 81 | * |
82 | | - * This is update to GatewayForm::fnValidateForm(). |
83 | | - * |
84 | 82 | * @param array $data Reference to the data of the form |
85 | 83 | * @param array $error Reference to the error messages of the form |
86 | 84 | * @param array $options |
— | — | @@ -91,39 +89,37 @@ |
92 | 90 | * - name - Validates: fname, lname |
93 | 91 | * |
94 | 92 | * @return 0|1 Returns 0 on success and 1 on failure |
95 | | - * |
96 | | - * @see GatewayForm::fnValidateForm() |
97 | 93 | */ |
98 | | - public function validateForm( &$data, &$error, $options = false ) { |
| 94 | + public function validateForm( &$data, &$error, $options = array() ) { |
99 | 95 | |
100 | | - $validateAll = false; |
101 | | - if ($options === false){ |
102 | | - $validateAll = true; |
103 | | - } |
104 | | - |
105 | | - if ( is_array( $options ) ){ |
106 | | - extract( $options ); |
107 | | - } |
| 96 | + extract( $options ); |
108 | 97 | |
| 98 | + // Set which items will be validated |
| 99 | + $address = isset( $address ) ? ( boolean ) $address : true; |
| 100 | + $amount = isset( $amount ) ? ( boolean ) $amount : true; |
| 101 | + $creditCard = isset( $creditCard ) ? ( boolean ) $creditCard : false; |
| 102 | + $email = isset( $email ) ? ( boolean ) $email : true; |
| 103 | + $name = isset( $name ) ? ( boolean ) $name : true; |
| 104 | + |
109 | 105 | // These are set in the order they will most likely appear on the form. |
110 | | - |
111 | | - if ( $validateAll || isset( $name ) ) { |
| 106 | + |
| 107 | + if ( $name ) { |
112 | 108 | $this->validateName( $data, $error ); |
113 | 109 | } |
114 | 110 | |
115 | | - if ( $validateAll || isset( $address ) ) { |
| 111 | + if ( $address ) { |
116 | 112 | $this->validateAddress( $data, $error ); |
117 | 113 | } |
118 | 114 | |
119 | | - if ( $validateAll || isset( $amount ) ) { |
| 115 | + if ( $amount ) { |
120 | 116 | $this->validateAmount( $data, $error ); |
121 | 117 | } |
122 | 118 | |
123 | | - if ( $validateAll || isset( $email ) ) { |
| 119 | + if ( $email ) { |
124 | 120 | $this->validateEmail( $data, $error ); |
125 | 121 | } |
126 | 122 | |
127 | | - if ( $validateAll || isset( $creditCard ) ) { |
| 123 | + if ( $creditCard ) { |
128 | 124 | $this->validateCreditCard( $data, $error ); |
129 | 125 | } |
130 | 126 | |