http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73264

Revision: 73264
Author:   awjrichards
Date:     2010-09-18 00:40:06 +0000 (Sat, 18 Sep 2010)

Log Message:
-----------
Cleaned up uninitialized variables to prevent php notices in payflowpro_gateway 
code; fixed layout problems in twocolumnletter form; updated handling of msg 
for error 125 to properly render HTML; some minor style fixes;

Modified Paths:
--------------
    trunk/extensions/DonationInterface/donate_interface/donate_interface.php
    
trunk/extensions/DonationInterface/payflowpro_gateway/extras/custom_filters/filters/minfraud/minfraud.body.php
    
trunk/extensions/DonationInterface/payflowpro_gateway/extras/custom_filters/filters/minfraud/minfraud.php
    
trunk/extensions/DonationInterface/payflowpro_gateway/extras/minfraud/minfraud.body.php
    
trunk/extensions/DonationInterface/payflowpro_gateway/extras/recaptcha/recaptcha.body.php
    trunk/extensions/DonationInterface/payflowpro_gateway/forms/Form.php
    trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumn.php
    
trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter.php
    
trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php

Modified: 
trunk/extensions/DonationInterface/donate_interface/donate_interface.php
===================================================================
--- trunk/extensions/DonationInterface/donate_interface/donate_interface.php    
2010-09-17 23:58:58 UTC (rev 73263)
+++ trunk/extensions/DonationInterface/donate_interface/donate_interface.php    
2010-09-18 00:40:06 UTC (rev 73264)
@@ -94,11 +94,11 @@
   $utm_source = $wgRequest->getText( 'utm_source' );
   $utm_medium = $wgRequest->getText( 'utm_medium' );
   $utm_campaign = $wgRequest->getText( 'utm_campaign' );
-  $referrer = $_SERVER['HTTP_REFERER'];
+  $referrer = $wgRequest->getHeader('referer');
         
   //get language from URL
-  $url = $_SERVER['REQUEST_URI'];
-        
+  $url = $wgRequest->getRequestURL(); 
+  
   if ($url) {
     $getLang = explode('/', $url);
     $language = substr($getLang[3], 0, 2);

Modified: 
trunk/extensions/DonationInterface/payflowpro_gateway/extras/custom_filters/filters/minfraud/minfraud.body.php
===================================================================
--- 
trunk/extensions/DonationInterface/payflowpro_gateway/extras/custom_filters/filters/minfraud/minfraud.body.php
      2010-09-17 23:58:58 UTC (rev 73263)
+++ 
trunk/extensions/DonationInterface/payflowpro_gateway/extras/custom_filters/filters/minfraud/minfraud.body.php
      2010-09-18 00:40:06 UTC (rev 73264)
@@ -10,16 +10,16 @@
 class PayflowProGateway_Extras_CustomFilters_MinFraud extends 
PayflowProGateway_Extras_MinFraud {
        static $instance;
 
-       public function validate( &$custom_filter_object ) {
+       public function filter( &$custom_filter_object ) {
                $pfp_gateway_object =& $custom_filter_object->gateway_object;
                $data =& $custom_filter_object->gateway_data;
 
                // see if we can bypass minfraud
-               if ( $this->can_bypass_minfraud( $pfp_gateway_object, $data )) 
return TRUE;
+               if ( $this->can_bypass_minfraud( $pfp_gateway_object, $data )) 
return TRUE;
 
-               $minfraud_query = $this->build_query( $data );
-               $this->query_minfraud( $minfraud_query );
-               $pfp_gateway_object->action = 'Filter';
+        $minfraud_query = $this->build_query( $data );
+        $this->query_minfraud( $minfraud_query );
+               $pfp_gateway_object->action = 'Filter';
 
                $custom_filter_object->risk_score += 
$this->minfraud_response['riskScore'];
                
@@ -30,8 +30,8 @@
 
        }
 
-       static function onValidate( &$custom_filter_object ) {
-               return self::singleton()->validate( $custom_filter_object );
+       static function onFilter( &$custom_filter_object ) {
+               return self::singleton()->filter( $custom_filter_object );
        }
 
        static function singleton() {

Modified: 
trunk/extensions/DonationInterface/payflowpro_gateway/extras/custom_filters/filters/minfraud/minfraud.php
===================================================================
--- 
trunk/extensions/DonationInterface/payflowpro_gateway/extras/custom_filters/filters/minfraud/minfraud.php
   2010-09-17 23:58:58 UTC (rev 73263)
+++ 
trunk/extensions/DonationInterface/payflowpro_gateway/extras/custom_filters/filters/minfraud/minfraud.php
   2010-09-18 00:40:06 UTC (rev 73264)
@@ -42,5 +42,5 @@
 
 function efCustomFiltersMinFraudSetup() {
        global $wgMinFraudStandalone, $wgHooks;
-       if ( !$wgMinFraudStandalone ) $wgHooks[ 'PayflowGatewayCustomFilter' 
][] = array( "PayflowProGateway_Extras_CustomFilters_MinFraud::onValidate" );
+       if ( !$wgMinFraudStandalone ) $wgHooks[ 'PayflowGatewayCustomFilter' 
][] = array( "PayflowProGateway_Extras_CustomFilters_MinFraud::onFilter" );
 }

Modified: 
trunk/extensions/DonationInterface/payflowpro_gateway/extras/minfraud/minfraud.body.php
===================================================================
--- 
trunk/extensions/DonationInterface/payflowpro_gateway/extras/minfraud/minfraud.body.php
     2010-09-17 23:58:58 UTC (rev 73263)
+++ 
trunk/extensions/DonationInterface/payflowpro_gateway/extras/minfraud/minfraud.body.php
     2010-09-18 00:40:06 UTC (rev 73264)
@@ -27,6 +27,12 @@
        );
 
        /**
+        * Container for minFraud object
+        * @var public object
+        */
+       public $ccfd;
+
+       /**
         * For holding an instance of self
         */
        static $instance;

Modified: 
trunk/extensions/DonationInterface/payflowpro_gateway/extras/recaptcha/recaptcha.body.php
===================================================================
--- 
trunk/extensions/DonationInterface/payflowpro_gateway/extras/recaptcha/recaptcha.body.php
   2010-09-17 23:58:58 UTC (rev 73263)
+++ 
trunk/extensions/DonationInterface/payflowpro_gateway/extras/recaptcha/recaptcha.body.php
   2010-09-18 00:40:06 UTC (rev 73264)
@@ -10,6 +10,12 @@
         */
        static $instance;
 
+       /**
+        * Container for the captcha error
+        * @var string
+        */
+       public $recap_err;
+
        public function __construct() {
                parent::__construct();
 
@@ -20,7 +26,7 @@
        /**
         * Handle the challenge logic
         */
-       public function challenge( &$pfp_gateway_object, &$data, $error=array() 
) {
+       public function challenge( &$pfp_gateway_object, &$data ) {
                // if captcha posted, validate
                if ( isset( $_POST[ 'recaptcha_response_field' ] )) { 
                        //check the captcha response
@@ -31,37 +37,34 @@
                                $pfp_gateway_object->action = "process";
                                return TRUE;
                        } else {
-                               $error[ 'recap_err' ] = $captcha_resp->error;
+                               $this->recap_err = $captcha_resp->error;
                                $this->log( $data[ 'contribution_tracking_id' 
], 'Captcha failed' );
                        }
                }
                // display captcha
-               $this->display_captcha( $pfp_gateway_object, $data, $error );
+               $this->display_captcha( $pfp_gateway_object, $data  );
                return TRUE;
        }
 
        /**
         * Display the submission form with the captcha injected into it
         */
-       public function display_captcha( &$pfp_gateway_object, &$data, 
$error=array() ) {
+       public function display_captcha( &$pfp_gateway_object, &$data ) {
                $this->log( $data[ 'contribution_tracking_id' ], 'Captcha 
triggered' );
                
-               // set the recaptcha error, if we have one.
-               $recap_err = ( $error[ 'recap_err' ] ) ? $error[ 'recap_err' ] 
: NULL;
-
                global $wgOut;
                $form_class = $pfp_gateway_object->getFormClass();
-               $form_obj = new $form_class( $data, $error );
-               $form = $form_obj->generateFormBody( $data, $error );
+               $form_obj = new $form_class( $data, $pfp_gateway_object->errors 
);
+               $form = $form_obj->generateFormBody( $data, 
$pfp_gateway_object->errors );
                $form .= Xml::openElement( 'div', array( 'id' => 
'mw-donate-captcha' ));
 
                // get the captcha
                global $wgPayflowRecaptchaPublicKey, $wgProto;
                $use_ssl = ( $wgProto == 'https' ) ? TRUE : FALSE;
-               $form .= recaptcha_get_html( $wgPayflowRecaptchaPublicKey, 
$recap_err, $use_ssl );
+               $form .= recaptcha_get_html( $wgPayflowRecaptchaPublicKey, 
$this->recap_err, $use_ssl );
                $form .= '<span class="creditcard-error-msg">' . wfMsg( 
'payflowpro_gateway-error-msg-captcha-please') . '</span>';
                $form .= Xml::closeElement( 'div' );
-               $form .= $form_obj->generateFormSubmit( $data, $error );
+               $form .= $form_obj->generateFormSubmit( $data, 
$pfp_gateway_object->errors );
                $wgOut->addHTML( $form );
        }
 

Modified: trunk/extensions/DonationInterface/payflowpro_gateway/forms/Form.php
===================================================================
--- trunk/extensions/DonationInterface/payflowpro_gateway/forms/Form.php        
2010-09-17 23:58:58 UTC (rev 73263)
+++ trunk/extensions/DonationInterface/payflowpro_gateway/forms/Form.php        
2010-09-18 00:40:06 UTC (rev 73264)
@@ -113,6 +113,7 @@
                global $wgLang;
 
                // derive the previously set expiry month, if set
+               $month = NULL;
                if ( $this->form_data[ 'expiration' ] ) {
                        $month = substr( $this->form_data[ 'expiration' ], 0, 2 
);
                }
@@ -141,6 +142,7 @@
 
        public function generateExpiryYearDropdown() {
                // derive the previously set expiry year, if set
+               $year = NULL;
                if ( $this->form_data[ 'expiration' ] ) {
                        $year = substr( $this->form_data[ 'expiration' ], 2, 2 
);
                }

Modified: 
trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumn.php
===================================================================
--- trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumn.php   
2010-09-17 23:58:58 UTC (rev 73263)
+++ trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumn.php   
2010-09-18 00:40:06 UTC (rev 73264)
@@ -8,8 +8,7 @@
        
        public function generateFormBody() {
                global $wgPayflowGatewayHeader, $wgPayflwGatewayTest, $wgOut;
-
-               $form .= $this->generateBannerHeader();
+               $form = $this->generateBannerHeader();
                
                $form .= $this->generatePersonalContainerTop();
                $form .= $this->generatePersonalFields();
@@ -35,6 +34,13 @@
                $form .= Xml::closeElement( 'div' );
                $form .= Xml::closeElement( 'div' );
                $form .= Xml::closeElement( 'div' );
+               // add hidden fields                    
+               $hidden_fields = $this->getHiddenFields();
+               foreach ( $hidden_fields as $field => $value ) {
+                       $form .= Xml::hidden( $field, $value );
+               }
+                       
+               $form .= Xml::closeElement( 'form' );
                $form .= Xml::openElement( 'div', array( 'class' => 
'payflow-cc-form-section', 'id' => 'payflowpro_gateway-donate-addl-info' ));
                $form .= Xml::tags( 'p', array( 'class' => '' ), 
                                wfMsg( 
'payflowpro_gateway-credit-storage-processing' ) ) .
@@ -42,15 +48,9 @@
                                wfMsg( 'payflowpro_gateway-question-comment' ) 
);
                $form .= Xml::closeElement( 'div' );
 
-               // add hidden fields                    
-               $hidden_fields = $this->getHiddenFields();
-               foreach ( $hidden_fields as $field => $value ) {
-                       $form .= Xml::hidden( $field, $value );
-               }
-                       
-               $form .= Xml::closeElement( 'form' ) .
-                       Xml::closeElement( 'div' ) .
-                       Xml::closeElement( 'div' );
+               $form .= Xml::closeElement( 'div' );
+               $form .= Xml::closeElement( 'div' );
+               $form .= Xml::closeElement( 'div' );
                return $form;
        }
 
@@ -83,8 +83,9 @@
                }
 
                // open form and table
-               $form .= Xml::openElement( 'div', array( 'id' => 
'mw-creditcard-form' ) ) . 
-                       Xml::element( 'p', array( 'class' => 
'creditcard-error-msg' ), $this->form_errors['retryMsg'] );
+               $form .= Xml::openElement( 'div', array( 'id' => 
'mw-creditcard-form' ) );
+               // Xml::element seems to convert html to htmlentities
+               $form .= "<p class='creditcard-error-msg'>" . 
$this->form_errors['retryMsg'] . "</p>";
                $form .= Xml::openElement( 'form', array( 'name' => 'payment', 
'method' => 'post', 'action' => '', 'onsubmit' => 'return validate_form(this)', 
'autocomplete' => 'off' ) );
                $form .= Xml::openElement( 'div', array( 'class' => 
'payflow-cc-form-section', 'id' => 'payflowpro_gateway-personal-info' ));       
            ;
                $form .= Xml::tags( 'h3', array( 'class' => 
'payflow-cc-form-header','id' => 'payflow-cc-form-header-personal' ), wfMsg( 
'payflowpro_gateway-cc-form-header-personal' ));
@@ -95,7 +96,7 @@
 
        protected function generatePersonalFields() {
                // first name                   
-               $form .= '<tr>';
+               $form = '<tr>';
                $form .= '<td>' . Xml::label( wfMsg( 
'payflowpro_gateway-donor-fname' ), 'fname' ) . '</td>';
                $form .= '<td>' . Xml::input( 'fname', '30', 
$this->form_data['fname'], array( 'maxlength' => '15', 'class' => 'required', 
'id' => 'fname' ) ) .
                        '<span class="creditcard-error-msg">' . '  ' . 
$this->form_errors['fname'] . '</span></td>';
@@ -161,10 +162,7 @@
 
        protected function generatePaymentContainerTop() {
                // credit card info
-               global $wgPayflowGatewayTest;
-               $card_num = ( $wgPayflowGatewayTest ) ? $this->form_data[ 
'card_num' ] : '';
-               $cvv = ( $wgPayflowGatewayTest ) ? $this->form_data[ 'cvv' ] : 
'';
-               $form .= Xml::openElement( 'div', array( 'class' => 
'payflow-cc-form-section', 'id' => 'payflowpro_gateway-payment-info' ));
+               $form = Xml::openElement( 'div', array( 'class' => 
'payflow-cc-form-section', 'id' => 'payflowpro_gateway-payment-info' ));
                $form .= Xml::tags( 'h3', array( 'class' => 
'payflow-cc-form-header', 'id' => 'payflow-cc-form-header-payment' ), wfMsg( 
'payflowpro_gateway-cc-form-header-payment' ));
                $form .= Xml::openElement( 'table', array( 'id' => 
'payflow-table-cc' ) );
 
@@ -172,9 +170,12 @@
        }
 
        protected function generatePaymentFields() {
-               global $wgScriptPath;   
-               // amount
-               $form .= '<tr>';
+               global $wgScriptPath, $wgPayflowGatewayTest;
+               $card_num = ( $wgPayflowGatewayTest ) ? $this->form_data[ 
'card_num' ] : '';
+               $cvv = ( $wgPayflowGatewayTest ) ? $this->form_data[ 'cvv' ] : 
'';
+
+       // amount
+               $form = '<tr>';
                $form .= '<td>' . Xml::label(wfMsg( 
'payflowpro_gateway-amount-legend' ), 'amount', array( 'maxlength' => '10' ) ) 
. '</td>'; 
                $form .= '<td>' . Xml::input( 'amount', '7', 
$this->form_data['amount'], array( 'id' => 'amount' ) ) .
                        '<span class="creditcard-error-msg">' . '  ' . 
$this->form_errors['invalidamount'] . '</span>';

Modified: 
trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter.php
===================================================================
--- 
trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter.php 
    2010-09-17 23:58:58 UTC (rev 73263)
+++ 
trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter.php 
    2010-09-18 00:40:06 UTC (rev 73264)
@@ -21,7 +21,6 @@
                 $form .= parent::generatePersonalFields();
                 $form .= Xml::closeElement( 'table' );
                 $form .= Xml::closeElement( 'div' );
-                $form .= Xml::closeElement( 'div' );
                 $form .= parent::generatePaymentContainerTop();
                 $form .= parent::generatePaymentFields();
                 $form .= Xml::closeElement( 'table' );
@@ -30,7 +29,7 @@
 
         public function generateFormSubmit() {
                 global $wgRequest, $wgOut;
-                $form .= parent::generateFormSubmit();  
+                $form = parent::generateFormSubmit();  
 
                 $form .= Xml::openElement( 'div', array( 'id' => 
'payflowpro_gateway-cc_form_letter', 'class' => 
'payflowpro_gateway-cc_form_column'));
 
@@ -40,8 +39,8 @@
                 $form .= ( strlen( $text_template )) ? $wgOut->parse( 
'{{'.$text_template.'}}' ) : '';
                 $form .= Xml::closeElement( 'div' );
                 
-                $form .=Xml::closeElement( 'div' );
+                               $form .=Xml::closeElement( 'div' );
+                $form .= Xml::closeElement( 'div' );
                 return $form;
         }
 }
-

Modified: 
trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
===================================================================
--- 
trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
   2010-09-17 23:58:58 UTC (rev 73263)
+++ 
trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
   2010-09-18 00:40:06 UTC (rev 73264)
@@ -31,11 +31,19 @@
        public $form_class;
        
        /**
+        * An array of form errors
+        * @var array
+        */
+       public $errors = array();
+
+       /**
         * Constructor - set up the new special page
         */
        public function __construct() {
                parent::__construct( 'PayflowProGateway' );
                wfLoadExtensionMessages( 'PayflowProGateway' );
+
+               $this->errors = $this->getPossibleErrors();
        }
 
        /**
@@ -81,18 +89,16 @@
                global $wgPayflowGatewaySalt;
                $token = $this->fnPayflowEditToken( $wgPayflowGatewaySalt ); 
//$wgUser->editToken( 'mrxc877668DwQQ' );
 
-               $error[] = '';
 
                // find out if amount was a radio button or textbox, set amount
                if( isset( $_REQUEST['amount'] ) && preg_match( 
'/^\d+(\.(\d+)?)?$/', $wgRequest->getText( 'amount' ) ) ) {
                        $amount = $wgRequest->getText( 'amount' );
                } elseif( isset( $_REQUEST['amountGiven'] ) && preg_match( 
'/^\d+(\.(\d+)?)?$/', $wgRequest->getText( 'amountGiven' ) ) ) { 
-                               $amount = number_format( $wgRequest->getText( 
'amountGiven' ), 2, '.', '' );
+                       $amount = number_format( $wgRequest->getText( 
'amountGiven' ), 2, '.', '' );
                } elseif( isset( $_REQUEST['amount'] ) ) { 
-                               $amount = '0.00';
+                       $amount = '0.00';
                } else {
-                               /*$wgOut->addHTML( wfMsg( 
'payflowpro_gateway-accessible' ) );
-                               return;*/
+                       $amount = '0.00';
                }
                
                // track the number of attempts the user has made
@@ -116,9 +122,9 @@
                                ++$data['numAttempt'];
                                
                                // Check form for errors and redisplay with 
messages
-                               $form_errors = $this->fnPayflowValidateForm( 
$data, $error );
+                               $form_errors = $this->fnPayflowValidateForm( 
$data, $this->errors );
                                if( $form_errors ) {
-                                       $this->fnPayflowDisplayForm( $data, 
$error );
+                                       $this->fnPayflowDisplayForm( $data, 
$this->errors );
                                } else { // The submitted form data is valid, 
so process it
                                        // allow any external validators to 
have their way with the data        
                                        wfRunHooks( 'PayflowGatewayValidate', 
array( &$this, &$data ));
@@ -157,12 +163,12 @@
                                }
                        } else {
                                //Display form for the first time
-                               $this->fnPayflowDisplayForm($data, $error);
+                               $this->fnPayflowDisplayForm( $data, 
$this->errors );
                        }
                } else { 
                        // there's a token mismatch
-                       $error['general']['token-mismatch'] = wfMsg( 
'payflowpro_gateway-token-mismatch' );
-                       $this->fnPayflowDisplayForm( $data, $error );
+                       $this->errors['general']['token-mismatch'] = wfMsg( 
'payflowpro_gateway-token-mismatch' );
+                       $this->fnPayflowDisplayForm( $data, $this->errors );
                }
        }
 
@@ -236,8 +242,6 @@
        private function fnPayflowValidateForm( $data, &$error ) {
                global $wgOut;
                
-               $error = '';
-
                // begin with no errors
                $error_result = '0';
 
@@ -480,8 +484,8 @@
                        // give user a second chance to enter incorrect data
                } elseif( ( $errorCode == '3' ) && ( $data['numAttempt'] < '5' 
) ) {
                        // pass responseMsg as an array key as required by 
displayForm
-                               $tryAgainResponse['retryMsg'] = $responseMsg;
-                               $this->fnPayflowDisplayForm( $data, 
$tryAgainResponse );
+                               $this->errors['retryMsg'] = $responseMsg;
+                               $this->fnPayflowDisplayForm( $data, 
$this->errors );
                        // if declined or if user has already made two 
attempts, decline
                } elseif( ( $errorCode == '2' ) || ( $data['numAttempt'] >= '3' 
) ) {
                                $this->fnPayflowDisplayDeclinedResults( 
$responseMsg );
@@ -549,6 +553,8 @@
                                $responseMsg = wfMsg( 
'payflowpro_gateway-response-default' );
                                $errorCode = '4';
                }
+                               $responseMsg = wfMsg( 
'payflowpro_gateway-response-125-2' );
+                               $errorCode = '3';
 
                return $errorCode;
        } 
@@ -797,26 +803,11 @@
                global $wgPayflowGatewayTest, $wgRequest;
                if ( $wgRequest->getText( 'email' ) && !$numAttempt && 
$wgPayflowGatewayTest ) { // if we're in testing mode, prepopulate the form
                        // define arrays of cc's and cc #s for random selection
-                       $cards = array( 'visa', 'mastercard', 'american', 
'discover');
+                       $cards = array( 'american' );
                        $card_nums = array(
-                               'visa' => array(
-                                       4111111111111111,
-                                       4012888888881881,
-                                       4222222222222
-                               ),
-                               'mastercard' => array(
-                                       5105105105105100,
-                                       5555555555554444,
-                               ),
                                'american' => array(
-                                       378734493671000,
-                                       371449635398431,
                                        378282246310005
                                ),
-                               'discover' => array(
-                                       6011111111111117,
-                                       6011000990139424
-                               ),
                        );
 
                        // randomly select a credit cards
@@ -895,4 +886,23 @@
                }
                return $data;
        }
+
+       public function getPossibleErrors() {
+               return array(
+                       'general' => '',
+                       'retryMsg' => '',
+                       'invalidamount' => '',
+                       'card_num' => '',
+                       'card' => '',
+                       'cvv' => '',
+                       'fname' => '',
+                       'lname' => '',
+                       'city' => '',
+                       'country' => '',
+                       'street' => '',
+                       'state' => '',
+                       'zip' => '',
+                       'emailAdd' => '',
+               );
+       }
 } // end class



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

Reply via email to