r75675 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75674‎ | r75675 | r75676 >
Date:21:16, 29 October 2010
Author:reedy
Status:deferred
Tags:
Comment:
Better tab some of the code, fix some unclear code up
Modified paths:
  • /trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php (modified) (history)
  • /trunk/extensions/DonationInterface/donate_interface/donate_interface.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/extras/minfraud/ccfd/HTTPBase.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
@@ -216,7 +216,8 @@
217217
218218 // save contrib tracking id early to track abondonment
219219 if ( $data[ 'numAttempt' ] == '0' && ( !$wgRequest->getText( 'utm_source_id', false ) || $wgRequest->getText( '_nocache_' ) == 'true' ) ) {
220 - if ( !$tracked = $this->fnPayflowSaveContributionTracking( $data ) ) {
 220+ $tracked = $this->fnPayflowSaveContributionTracking( $data );
 221+ if ( !$tracked ) {
221222 $when = time();
222223 wfDebugLog( 'payflowpro_gateway', 'Unable to save data to the contribution_tracking table ' . $when );
223224 }
Index: trunk/extensions/DonationInterface/payflowpro_gateway/extras/minfraud/ccfd/HTTPBase.php
@@ -20,21 +20,21 @@
2121 */
2222
2323 class HTTPBase {
24 - var $server;
25 - var $numservers;
26 - var $url;
27 - var $queries;
28 - var $allowed_fields;
29 - var $num_allowed_fields;
30 - var $outputstr;
31 - var $isSecure;
32 - var $timeout;
33 - var $debug;
34 - var $check_field;
35 - var $wsIpaddrRefreshTimeout;
36 - var $wsIpaddrCacheFile;
37 - var $useDNS;
38 - var $ipstr;
 24+ var $server;
 25+ var $numservers;
 26+ var $url;
 27+ var $queries;
 28+ var $allowed_fields;
 29+ var $num_allowed_fields;
 30+ var $outputstr;
 31+ var $isSecure;
 32+ var $timeout;
 33+ var $debug;
 34+ var $check_field;
 35+ var $wsIpaddrRefreshTimeout;
 36+ var $wsIpaddrCacheFile;
 37+ var $useDNS;
 38+ var $ipstr;
3939 function __construct() {
4040 $this->isSecure = 0;
4141 $this->debug = 0;
@@ -51,7 +51,7 @@
5252
5353 // this function sets the checked field
5454 function set_check_field( $f ) {
55 - $check_field = $f;
 55+ $this->check_field = $f;
5656 }
5757
5858 // this function sets the allowed fields
@@ -344,7 +344,7 @@
345345 $url3 = parse_url( $url );
346346 $host = $url3["host"];
347347 $path = $url3["path"];
348 - $query = $url3["query"];
 348+ $query = $url3["query"];
349349
350350 // open the connection
351351 $fp = fsockopen ( $host, 80, $errno, $errstr, $this->timeout );
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php
@@ -125,21 +125,21 @@
126126 $wgAutoloadClasses[ 'ApiPayflowProGateway' ] = $dir . 'api_payflowpro_gateway.php';
127127
128128 function payflowGatewayConnection() {
129 - global $wgPayflowGatewayDBserver, $wgPayflowGatewayDBname;
130 - global $wgPayflowGatewayDBuser, $wgPayflowGatewayDBpassword;
 129+ global $wgPayflowGatewayDBserver, $wgPayflowGatewayDBname;
 130+ global $wgPayflowGatewayDBuser, $wgPayflowGatewayDBpassword;
131131
132 - static $db;
 132+ static $db;
133133
134 - if ( !$db ) {
135 - $db = new DatabaseMysql(
136 - $wgPayflowGatewayDBserver,
137 - $wgPayflowGatewayDBuser,
138 - $wgPayflowGatewayDBpassword,
139 - $wgPayflowGatewayDBname );
140 - $db->query( "SET names utf8" );
141 - }
 134+ if ( !$db ) {
 135+ $db = new DatabaseMysql(
 136+ $wgPayflowGatewayDBserver,
 137+ $wgPayflowGatewayDBuser,
 138+ $wgPayflowGatewayDBpassword,
 139+ $wgPayflowGatewayDBname );
 140+ $db->query( "SET names utf8" );
 141+ }
142142
143 - return $db;
 143+ return $db;
144144 }
145145
146146 /**
@@ -147,22 +147,21 @@
148148 * also supplies currencies supported by this gateway
149149 */
150150 function pfpGatewayValue( &$values ) {
 151+ $values['payflow'] = array(
 152+ 'gateway' => 'payflow',
 153+ 'display_name' => 'Credit Card',
 154+ 'form_value' => 'payflow',
 155+ 'currencies' => array(
 156+ 'GBP' => 'GBP: British Pound',
 157+ 'EUR' => 'EUR: Euro',
 158+ 'USD' => 'USD: U.S. Dollar',
 159+ 'AUD' => 'AUD: Australian Dollar',
 160+ 'CAD' => 'CAD: Canadian Dollar',
 161+ 'JPY' => 'JPY: Japanese Yen',
 162+ ),
 163+ );
151164
152 - $values['payflow'] = array(
153 - 'gateway' => 'payflow',
154 - 'display_name' => 'Credit Card',
155 - 'form_value' => 'payflow',
156 - 'currencies' => array(
157 - 'GBP' => 'GBP: British Pound',
158 - 'EUR' => 'EUR: Euro',
159 - 'USD' => 'USD: U.S. Dollar',
160 - 'AUD' => 'AUD: Australian Dollar',
161 - 'CAD' => 'CAD: Canadian Dollar',
162 - 'JPY' => 'JPY: Japanese Yen',
163 - ),
164 - );
165 -
166 - return true;
 165+ return true;
167166 }
168167
169168 /**
@@ -173,15 +172,8 @@
174173 * the result might look like this: http://www.yourdomain.com/index.php?title=Special:PayflowPro&amount=75.00&currency_code=USD&payment_method=payflow
175174 */
176175 function pfpGatewayPage( &$url ) {
177 - global $wgScript;
 176+ global $wgScript;
178177
179 - $url['payflow'] = $wgScript . "?title=Special:PayflowProGateway";
180 - return true;
 178+ $url['payflow'] = $wgScript . "?title=Special:PayflowProGateway";
 179+ return true;
181180 }
182 -
183 -// Add JQuery
184 -$wgHooks['BeforePageDisplay'][] = 'pfpAddJQuery';
185 -function pfpAddJQuery( $out, $sk ) {
186 - $out->includeJQuery();
187 - return true;
188 -}
Index: trunk/extensions/DonationInterface/donate_interface/donate_interface.php
@@ -60,7 +60,7 @@
6161
6262 if ( !$formProcessed ) {
6363 // process form
64 - wfRunHooks( 'DonationInterface_DisplayForm' );
 64+ wfRunHooks( 'DonationInterface_DisplayForm' );
6565 $formProcessed = true;
6666 }
6767
@@ -89,13 +89,13 @@
9090 $url = $wgRequest->getRequestURL();
9191
9292 if ( $url ) {
93 - $getLang = explode( '/', $url );
94 - $language = substr( $getLang[3], 0, 2 );
 93+ $getLang = explode( '/', $url );
 94+ $language = substr( $getLang[3], 0, 2 );
9595 }
9696
9797 // error check and set "en" as default
9898 if ( !preg_match( '/^[a-z-]+$/', $language ) ) {
99 - $language = 'en';
 99+ $language = 'en';
100100 }
101101
102102 // get payment method gateway value and name from each gateway and create menu of options
@@ -105,7 +105,7 @@
106106 $gatewayMenu = '';
107107
108108 foreach ( $values as $current ) {
109 - $gatewayMenu .= Xml::option( $current['display_name'], $current['form_value'] );
 109+ $gatewayMenu .= Xml::option( $current['display_name'], $current['form_value'] );
110110 }
111111
112112 // get available currencies
@@ -113,9 +113,9 @@
114114 $currencies = array( 'USD' => "USD: U.S. Dollar" );
115115 // FIXME: It uses the currencies of the last gateway to be loaded. It should probably use the union of currencies, (currencies allowed by any gateway).
116116 foreach ( $values as $key ) {
117 - if ( isset( $key['currencies'] ) ) {
118 - $currencies = $key['currencies'];
119 - }
 117+ if ( isset( $key['currencies'] ) ) {
 118+ $currencies = $key['currencies'];
 119+ }
120120 }
121121
122122 $currencyMenu = '';
@@ -156,15 +156,15 @@
157157
158158 $currency_options = '';
159159 foreach ( $currencies as $code => $name ) {
160 - $selected = '';
161 - if ( $code == $default_currency ) {
162 - $selected = ' selected="selected"';
163 - }
164 - $currency_options .= '<option value="' . $code . '"' . $selected . '>' . wfMsg( 'donate_interface-' . $code ) . '</option>';
 160+ $selected = '';
 161+ if ( $code == $default_currency ) {
 162+ $selected = ' selected="selected"';
 163+ }
 164+ $currency_options .= '<option value="' . $code . '"' . $selected . '>' . wfMsg( 'donate_interface-' . $code ) . '</option>';
165165 }
166166
167167 $currencyFields = Xml::openElement( 'select', array( 'name' => 'currency_code', 'id' => "input_currency_code" ) ) .
168 - $currency_options .
 168+ $currency_options .
169169 Xml::closeElement( 'select' );
170170
171171 $output .= Xml::fieldset( wfMsg( 'donate_interface-currency' ), $currencyFields, array( 'class' => "mw-donation-currency" ) );
Index: trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php
@@ -29,25 +29,24 @@
3030 * Create <donate /> tag to include landing page donation form
3131 */
3232 function efStompSetup( &$parser ) {
33 - global $wgParser, ;
 33+ global $wgParser;
3434
35 - // redundant and causes Fatal Error
36 - // $parser->disableCache();
 35+ // redundant and causes Fatal Error
 36+ // $parser->disableCache();
3737
38 - $wgParser->setHook( 'stomp', 'efStompTest' );
 38+ $wgParser->setHook( 'stomp', 'efStompTest' );
3939
40 - return true;
 40+ return true;
4141 }
4242
4343 function efStompTest( $input, $args, &$parser ) {
 44+ $parser->disableCache();
4445
45 - $parser->disableCache();
 46+ $output = "STOMP Test page";
4647
47 - $output = "STOMP Test page";
 48+ wfRunHooks( 'gwStomp', array( &$transaction ) );
4849
49 - wfRunHooks( 'gwStomp', array( &$transaction ) );
50 -
51 - return $output;
 50+ return $output;
5251 }
5352
5453 /**
@@ -61,62 +60,62 @@
6261 * Hook to send transaction information to ActiveMQ server
6362 */
6463 function sendSTOMP( $transaction ) {
65 - global $wgStompServer, $wgStompQueueName;
 64+ global $wgStompServer, $wgStompQueueName;
6665
67 - $queueName = isset ( $wgStompQueueName ) ? $wgStompQueueName : 'test';
 66+ $queueName = isset ( $wgStompQueueName ) ? $wgStompQueueName : 'test';
6867
69 - // include a library
70 - require_once( "Stomp.php" );
 68+ // include a library
 69+ require_once( "Stomp.php" );
7170
72 - $message = json_encode( createQueueMessage( $transaction ) );
 71+ $message = json_encode( createQueueMessage( $transaction ) );
7372
74 - // make a connection
75 - $con = new Stomp( $wgStompServer );
 73+ // make a connection
 74+ $con = new Stomp( $wgStompServer );
7675
77 - // connect
78 - $con->connect();
 76+ // connect
 77+ $con->connect();
7978
80 - // send a message to the queue
81 - $result = $con->send( "/queue/$queueName", $message, array( 'persistent' => 'true' ) );
 79+ // send a message to the queue
 80+ $result = $con->send( "/queue/$queueName", $message, array( 'persistent' => 'true' ) );
8281
83 - if ( !$result ) {
84 - wfDebugLog( 'activemq_stomp', 'Send to Q failed for this message: ' . $message );
85 -}
 82+ if ( !$result ) {
 83+ wfDebugLog( 'activemq_stomp', 'Send to Q failed for this message: ' . $message );
 84+ }
8685
87 - $con->disconnect();
 86+ $con->disconnect();
8887
89 - return true;
 88+ return true;
9089 }
9190
9291 /*
9392 * Hook to send transaction information to ActiveMQ server
9493 */
9594 function sendPendingSTOMP( $transaction ) {
96 - global $wgStompServer, $wgPendingStompQueueName;
 95+ global $wgStompServer, $wgPendingStompQueueName;
9796
98 - $queueName = isset ( $wgPendingStompQueueName ) ? $wgPendingStompQueueName : 'pending';
 97+ $queueName = isset ( $wgPendingStompQueueName ) ? $wgPendingStompQueueName : 'pending';
9998
100 - // include a library
101 - require_once( "Stomp.php" );
 99+ // include a library
 100+ require_once( "Stomp.php" );
102101
103 - $message = json_encode( createQueueMessage( $transaction ) );
 102+ $message = json_encode( createQueueMessage( $transaction ) );
104103
105 - // make a connection
106 - $con = new Stomp( $wgStompServer );
 104+ // make a connection
 105+ $con = new Stomp( $wgStompServer );
107106
108 - // connect
109 - $con->connect();
 107+ // connect
 108+ $con->connect();
110109
111 - // send a message to the queue
112 - $result = $con->send( "/queue/$queueName", $message, array( 'persistent' => 'true' ) );
 110+ // send a message to the queue
 111+ $result = $con->send( "/queue/$queueName", $message, array( 'persistent' => 'true' ) );
113112
114 - if ( !$result ) {
115 - wfDebugLog( 'activemq_stomp', 'Send to Pending Q failed for this message: ' . $message );
116 -}
 113+ if ( !$result ) {
 114+ wfDebugLog( 'activemq_stomp', 'Send to Pending Q failed for this message: ' . $message );
 115+ }
117116
118 - $con->disconnect();
 117+ $con->disconnect();
119118
120 - return true;
 119+ return true;
121120 }
122121
123122 /**
@@ -133,41 +132,40 @@
134133 * Response from Payflow is assigned to 'response'
135134 */
136135 function createQueueMessage( $transaction ) {
137 - // specifically designed to match the CiviCRM API that will handle it
138 - // edit this array to include/ignore transaction data sent to the server
139 - $message = array(
140 - 'contribution_tracking_id' => $transaction['contribution_tracking_id'],
141 - 'optout' => $transaction['optout'],
142 - 'anonymous' => $transaction['anonymous'],
143 - 'comment' => $transaction['comment'],
144 - 'utm_source' => $transaction['utm_source'],
145 - 'utm_medium' => $transaction['utm_medium'],
146 - 'utm_campaign' => $transaction['utm_campaign'],
147 - 'language' => $transaction['language'],
148 - 'referrer' => $transaction['referrer'],
149 - 'email' => $transaction['email'],
150 - 'first_name' => $transaction['fname'],
151 - 'middle_name' => $transaction['mname'],
152 - 'last_name' => $transaction['lname'],
153 - 'street_address' => $transaction['street'],
154 - 'supplemental_address_1' => '',
155 - 'city' => $transaction['city'],
156 - 'state_province' => $transaction['state'],
157 - 'country' => $transaction['country_name'],
158 - 'countryID' => $transaction['country_code'],
159 - 'postal_code' => $transaction['zip'],
160 - 'gateway' => $transaction[ 'gateway' ],
161 - 'gateway_txn_id' => $transaction['PNREF'],
162 - 'response' => $transaction['RESPMSG'],
163 - 'currency' => $transaction['currency'],
164 - 'original_currency' => $transaction['currency'],
165 - 'original_gross' => $transaction['amount'],
166 - 'fee' => '0',
167 - 'gross' => $transaction['amount'],
168 - 'net' => $transaction['amount'],
169 - 'date' => $transaction['date'],
 136+ // specifically designed to match the CiviCRM API that will handle it
 137+ // edit this array to include/ignore transaction data sent to the server
 138+ $message = array(
 139+ 'contribution_tracking_id' => $transaction['contribution_tracking_id'],
 140+ 'optout' => $transaction['optout'],
 141+ 'anonymous' => $transaction['anonymous'],
 142+ 'comment' => $transaction['comment'],
 143+ 'utm_source' => $transaction['utm_source'],
 144+ 'utm_medium' => $transaction['utm_medium'],
 145+ 'utm_campaign' => $transaction['utm_campaign'],
 146+ 'language' => $transaction['language'],
 147+ 'referrer' => $transaction['referrer'],
 148+ 'email' => $transaction['email'],
 149+ 'first_name' => $transaction['fname'],
 150+ 'middle_name' => $transaction['mname'],
 151+ 'last_name' => $transaction['lname'],
 152+ 'street_address' => $transaction['street'],
 153+ 'supplemental_address_1' => '',
 154+ 'city' => $transaction['city'],
 155+ 'state_province' => $transaction['state'],
 156+ 'country' => $transaction['country_name'],
 157+ 'countryID' => $transaction['country_code'],
 158+ 'postal_code' => $transaction['zip'],
 159+ 'gateway' => $transaction[ 'gateway' ],
 160+ 'gateway_txn_id' => $transaction['PNREF'],
 161+ 'response' => $transaction['RESPMSG'],
 162+ 'currency' => $transaction['currency'],
 163+ 'original_currency' => $transaction['currency'],
 164+ 'original_gross' => $transaction['amount'],
 165+ 'fee' => '0',
 166+ 'gross' => $transaction['amount'],
 167+ 'net' => $transaction['amount'],
 168+ 'date' => $transaction['date'],
 169+ );
170170
171 - );
172 -
173 - return $message;
 171+ return $message;
174172 }

Status & tagging log