Index: trunk/extensions/DonationInterface/donate_interface/donate_interface.php |
— | — | @@ -41,8 +41,8 @@ |
42 | 42 | |
43 | 43 | $parser->setHook( 'donate', 'efDonateRender' ); |
44 | 44 | |
45 | | - //process form |
46 | | - wfRunHooks( 'DonationInterface_DisplayForm' ); |
| 45 | + //process form |
| 46 | + wfRunHooks( 'DonationInterface_DisplayForm' ); |
47 | 47 | |
48 | 48 | return true; |
49 | 49 | } |
— | — | @@ -113,9 +113,9 @@ |
114 | 114 | |
115 | 115 | $gatewayMenu = ''; |
116 | 116 | |
117 | | - foreach($values as $current) { |
| 117 | + foreach($values as $current) { |
118 | 118 | $gatewayMenu .= Xml::option($current['display_name'], $current['form_value']); |
119 | | - } |
| 119 | + } |
120 | 120 | |
121 | 121 | //get available currencies |
122 | 122 | |
— | — | @@ -322,12 +322,17 @@ |
323 | 323 | 'email' => '', |
324 | 324 | ); |
325 | 325 | |
326 | | - // if form has been submitted, assign data and redirect user to chosen payment gateway |
327 | | - if ($_POST['process'] == "_yes_") { |
| 326 | + // Checking that it was posted is not enough, donate_interface-amount-error |
| 327 | + // would be shown on previews, anon purges... (bug 22640) |
| 328 | + if ( ( !$wgRequest->wasPosted() ) || ( $wgRequest->getVal('process') != "_yes_" ) ) { |
| 329 | + return true; |
| 330 | + } |
| 331 | + // if form has been submitted, assign data and redirect user to chosen payment gateway |
| 332 | + |
328 | 333 | //find out which amount option was chosen for amount, redefined buttons or text box |
329 | | - if ( isset($_POST['amount']) && preg_match('/^\d+(\.(\d+)?)?$/', $wgRequest->getText('amount')) ) { |
| 334 | + if ( preg_match( '/^\d+(\.(\d+)?)?$/', $wgRequest->getText('amount') ) ) { |
330 | 335 | $amount = number_format( $wgRequest->getText('amount'), 2 ); |
331 | | - } elseif ( preg_match('/^\d+(\.(\d+)?)?$/', $wgRequest->getText('amountGiven') )) { |
| 336 | + } elseif ( preg_match( '/^\d+(\.(\d+)?)?$/', $wgRequest->getText('amountGiven') ) ) { |
332 | 337 | $amount = number_format( $wgRequest->getText('amountGiven'), 2, '.', '' ); |
333 | 338 | } else { |
334 | 339 | $wgOut->addHTML( wfMsg( 'donate_interface-amount-error' ) ); |
— | — | @@ -353,15 +358,11 @@ |
354 | 359 | $url = ''; |
355 | 360 | |
356 | 361 | if ( wfRunHooks('DonationInterface_Page', array(&$url)) ) { |
357 | | - |
358 | | - // send user to correct page for payment |
359 | | - fnDonateRedirectToProcessorPage( $userInput, $url ); |
360 | | - |
| 362 | + // send user to correct page for payment |
| 363 | + fnDonateRedirectToProcessorPage( $userInput, $url ); |
361 | 364 | } else { |
362 | 365 | $wgOut->addHTML( wfMsg( 'donate_interface-processing-error' ) ); |
363 | | - } |
364 | | - |
365 | | - }// end if form has been submitted |
| 366 | + } |
366 | 367 | |
367 | 368 | return true; |
368 | 369 | } |