r99227 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99226‎ | r99227 | r99228 >
Date:18:38, 7 October 2011
Author:khorn
Status:ok
Tags:fundraising 
Comment:
Got most of the way through the process of more or less centralizing the various DonationInterface installation files.
Basically, all the globals, auto-loaded classes, hooks, and everything else will be eaten by the main donationinterface.php file. Functions were left where they were to be conditionally included or not, based on LocalSettings.
All that remains is the two current gateway adapters, and any bug squashing that will certainly ensue.

Also removed a couple completely unused functions and marked several files as possible cruft.
Modified paths:
  • /branches/fundraising/extensions/DonationInterface/activemq_stomp/activemq_stomp.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/donate_interface/donate_interface.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/donationinterface.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/extras/conversion_log/conversion_log.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/extras/custom_filters/custom_filters.body.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/extras/custom_filters/custom_filters.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/extras/custom_filters/filters/minfraud/minfraud.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/extras/extras.body.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/extras/extras.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/extras/minfraud/minfraud.body.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/extras/minfraud/minfraud.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/extras/recaptcha/recaptcha.body.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/extras/recaptcha/recaptcha.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/gateway_common/DonationData.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.body.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/payflowpro_gateway/api_payflowpro_gateway.php (modified) (history)
  • /branches/fundraising/extensions/DonationInterface/paypal_gateway/paypal_gateway.php (modified) (history)

Diff [purge]

Index: branches/fundraising/extensions/DonationInterface/donationinterface.php
@@ -1,5 +1,14 @@
22 <?php
33
 4+/**
 5+ * Donation Interface
 6+ *
 7+ * To install the DontaionInterface extension, put the following line in LocalSettings.php:
 8+ * require_once( "\$IP/extensions/DonationInterface/donationinterface.php" );
 9+ *
 10+ */
 11+
 12+
413 # Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly.
514 if ( !defined( 'MEDIAWIKI' ) ) {
615 echo <<<EOT
@@ -20,28 +29,47 @@
2130
2231 $donationinterface_dir = dirname( __FILE__ ) . '/';
2332
24 -//TODO: It may be a good idea to make all these stop behaving like they're independent extensions.
25 -//Better yet, we should decide if they're a required part of this or not,
26 -//and split 'em entirely off, or roll 'em all the way in to this file.
27 -require_once( $donationinterface_dir . 'donate_interface/donate_interface.php' );
28 -require_once( $donationinterface_dir . 'activemq_stomp/activemq_stomp.php' );
 33+/**
 34+ * Figure out what we've got enabled.
 35+ */
2936
30 -require_once( $donationinterface_dir . 'extras/extras.php' );
31 -require_once( $donationinterface_dir . 'extras/custom_filters/custom_filters.php' );
32 -require_once( $donationinterface_dir . 'extras/conversion_log/conversion_log.php' );
33 -require_once( $donationinterface_dir . 'extras/minfraud/minfraud.php' );
34 -require_once( $donationinterface_dir . 'extras/recaptcha/recaptcha.php' );
 37+$optionalParts = array( //define as fail closed. This variable will be unset before we leave this file.
 38+ 'Extras' => false, //this one gets set in the next loop, so don't bother.
 39+ 'Stomp' => false,
 40+ 'CustomFilters' => false, //this is definitely an Extra
 41+ 'ConversionLog' => false, //this is definitely an Extra
 42+ 'Minfraud' => false, //this is definitely an Extra
 43+ 'Minfraud_as_filter' => false, //extra
 44+ 'Recaptcha' => false, //extra
 45+ 'Paypal' => false, //this is the paypal redirect. TODO: Determine if we're even using this anymore.
 46+ 'PayflowPro' => false,
 47+ 'GlobalCollect' => false,
 48+
 49+);
3550
 51+foreach ($optionalParts as $subextension => $enabled){
 52+ $globalname = 'wgDonationInterfaceEnable' . $subextension;
 53+ global $$globalname;
 54+ if ( isset( $$globalname ) && $$globalname === true ) {
 55+ $optionalParts[$subextension] = true;
 56+ if ( $subextension === 'CustomFilters' ||
 57+ $subextension === 'ConversionLog' ||
 58+ $subextension === 'Minfraud' ||
 59+ $subextension === 'Recaptcha' ) {
 60+
 61+ $optionalParts['Extras'] = true;
 62+ }
 63+ }
 64+}
3665
 66+
3767 /**
38 - * Global form dir and whitelist
 68+ * CLASSES
3969 */
40 -$wgDonationInterfaceHtmlFormDir = dirname( __FILE__ ) . "/gateway_forms/html";
41 -//ffname is the $key from now on.
42 -$wgDonationInterfaceAllowedHtmlForms = array(
43 - 'demo' => $wgDonationInterfaceHtmlFormDir . "/demo.html",
44 - 'globalcollect_test' => $wgDonationInterfaceHtmlFormDir . "/globalcollect_test.html",
45 -);
 70+$wgAutoloadClasses['DonationData'] = $donationinterface_dir . 'gateway_common/DonationData.php';
 71+$wgAutoloadClasses['GatewayAdapter'] = $donationinterface_dir . 'gateway_common/gateway.adapter.php';
 72+$wgAutoloadClasses['GatewayForm'] = $donationinterface_dir . 'gateway_common/GatewayForm.php';
 73+$wgAutoloadClasses['DonationApi'] = $donationinterface_dir . 'gateway_common/donation.api.php';
4674
4775 //load all possible form classes
4876 $wgAutoloadClasses['Gateway_Form'] = $donationinterface_dir . 'gateway_forms/Form.php';
@@ -66,50 +94,248 @@
6795 $wgAutoloadClasses['Gateway_Form_SingleColumn'] = $donationinterface_dir . 'gateway_forms/SingleColumn.php';
6896
6997
70 -$wgAutoloadClasses['DonationData'] = $donationinterface_dir . 'gateway_common/DonationData.php';
71 -$wgAutoloadClasses['GatewayAdapter'] = $donationinterface_dir . 'gateway_common/gateway.adapter.php';
72 -$wgAutoloadClasses['GatewayForm'] = $donationinterface_dir . 'gateway_common/GatewayForm.php';
73 -$wgAutoloadClasses['DonationApi'] = $donationinterface_dir . 'gateway_common/donation.api.php';
7498
75 -//THE GATEWAYS WILL RESET THIS when they are instantiated. You can override it, but it won't stick around that way.
76 -$wgDonationInterfaceTest = false;
 99+//Stomp classes
 100+if ($optionalParts['Stomp'] === true){
 101+ $wgAutoloadClasses['activemq_stomp'] = $donationinterface_dir . 'activemq_stomp/activemq_stomp.php'; # Tell MediaWiki to load the extension body.
 102+}
77103
 104+//Extras classes - required for ANY optional class that is considered an "extra".
 105+if ($optionalParts['Extras'] === true){
 106+ $wgAutoloadClasses['Gateway_Extras'] = $donationinterface_dir . "extras/extras.body.php";
 107+}
78108
 109+//Custom Filters classes
 110+if ($optionalParts['CustomFilters'] === true){
 111+ $wgAutoloadClasses['Gateway_Extras_CustomFilters'] = $donationinterface_dir . "extras/custom_filters/custom_filters.body.php";
 112+}
 113+
 114+//Conversion Log classes
 115+if ($optionalParts['ConversionLog'] === true){
 116+ $wgAutoloadClasses['Gateway_Extras_ConversionLog'] = $donationinterface_dir . "extras/conversion_log/conversion_log.body.php";
 117+}
 118+
 119+//Minfraud classes
 120+if ( $optionalParts['Minfraud'] === true || $optionalParts['Minfraud_as_filter'] === true ){
 121+ $wgAutoloadClasses['Gateway_Extras_MinFraud'] = $donationinterface_dir . "extras/minfraud/minfraud.body.php";
 122+}
 123+
 124+//Minfraud as Filter classes
 125+if ( $optionalParts['Minfraud_as_filter'] === true ){
 126+ $wgAutoloadClasses['Gateway_Extras_CustomFilters_MinFraud'] = $donationinterface_dir . "extras/custom_filters/filters/minfraud/minfraud.body.php";
 127+}
 128+
 129+//Recaptcha classes
 130+if ( $optionalParts['Recaptcha'] === true ){
 131+ $wgAutoloadClasses['Gateway_Extras_ReCaptcha'] = $donationinterface_dir . "extras/recaptcha/recaptcha.body.php";
 132+}
 133+
 134+
79135 /**
 136+ * GLOBALS
 137+ */
 138+
 139+/**
 140+ * Global form dir and RapidHTML whitelist
 141+ */
 142+$wgDonationInterfaceHtmlFormDir = dirname( __FILE__ ) . "/gateway_forms/html";
 143+//ffname is the $key from now on.
 144+$wgDonationInterfaceAllowedHtmlForms = array(
 145+ 'demo' => $wgDonationInterfaceHtmlFormDir . "/demo.html",
 146+ 'globalcollect_test' => $wgDonationInterfaceHtmlFormDir . "/globalcollect_test.html",
 147+);
 148+
 149+$wgDonationInterfaceTest = false;
 150+
 151+/**
80152 * Default Thank You and Fail pages for all of donationinterface - language will be calc'd and appended at runtime.
81153 */
82154 //$wgDonationInterfaceThankYouPage = 'https://wikimediafoundation.org/wiki/Thank_You';
83155 $wgDonationInterfaceThankYouPage = 'Donate-thanks';
84156 $wgDonationInterfaceFailPage = 'Donate-error';
85157
86 -//This is going to be a little funky.
87 -//Override this in LocalSettings.php BEFORE you include this file, if you want
88 -//to disable gateways.
89 -//TODO: Unfunktify, if you have a better idea here for auto-loading the classes after LocalSettings.php runs all the way.
90 -if ( !isset( $wgDonationInterfaceEnabledGateways ) ) {
91 - $wgDonationInterfaceEnabledGateways = array(
92 - 'paypal',
93 - 'payflowpro',
94 - 'globalcollect'
 158+/**
 159+ * The URL to redirect a transaction to PayPal
 160+ */
 161+$wgDonationInterfacePaypalURL = '';
 162+$wgDonationInterfaceRetrySeconds = 5;
 163+
 164+
 165+//Paypal gateway globals
 166+if ( $optionalParts['Paypal'] === true ){
 167+ // default variables that should be set in LocalSettings.php
 168+ $wgPaypalEmail = '';
 169+ $wgPaypalUrl = 'http://wikimediafoundation.org/wiki/Special:ContributionTracking?';
 170+}
 171+
 172+//Stomp globals
 173+if ($optionalParts['Stomp'] === true){
 174+ $wgStompServer = "";
 175+ //$wgStompQueueName = ""; //only set this with an actual value. Default is unset.
 176+ //$wgPendingStompQueueName = ""; //only set this with an actual value. Default is unset.
 177+}
 178+
 179+//Extras globals - required for ANY optional class that is considered an "extra".
 180+if ($optionalParts['Extras'] === true){
 181+ $wgDonationInterfaceExtrasLog = '';
 182+}
 183+
 184+//Custom Filters globals
 185+if ( $optionalParts['CustomFilters'] === true ){
 186+ //Define the action to take for a given $risk_score
 187+ $wgDonationInterfaceCustomFiltersActionRanges = array(
 188+ 'process' => array( 0, 100 ),
 189+ 'review' => array( -1, -1 ),
 190+ 'challenge' => array( -1, -1 ),
 191+ 'reject' => array( -1, -1 ),
95192 );
 193+
 194+ /**
 195+ * A value for tracking the 'riskiness' of a transaction
 196+ *
 197+ * The action to take based on a transaction's riskScore is determined by
 198+ * $action_ranges. This is built assuming a range of possible risk scores
 199+ * as 0-100, although you can probably bend this as needed.
 200+ */
 201+ $wgDonationInterfaceCustomFiltersRiskScore = 0;
96202 }
97203
98 -foreach ( $wgDonationInterfaceEnabledGateways as $gateway ) {
99 - //include 'em
100 - require_once( $donationinterface_dir . $gateway . '_gateway/' . $gateway . '_gateway.php' );
 204+//Minfraud globals
 205+if ( $optionalParts['Minfraud'] === true || $optionalParts['Minfraud_as_filter'] === true ){
 206+ /**
 207+ * Your minFraud license key.
 208+ */
 209+ $wgMinFraudLicenseKey = '';
 210+
 211+ /**
 212+ * Set the risk score ranges that will cause a particular 'action'
 213+ *
 214+ * The keys to the array are the 'actions' to be taken (eg 'process').
 215+ * The value for one of these keys is an array representing the lower
 216+ * and upper bounds for that action. For instance,
 217+ * $wgMinFraudActionRagnes = array(
 218+ * 'process' => array( 0, 100)
 219+ * ...
 220+ * );
 221+ * means that any transaction with a risk score greather than or equal
 222+ * to 0 and less than or equal to 100 will be given the 'process' action.
 223+ *
 224+ * These are evauluated on a >= or <= basis. Please refer to minFraud
 225+ * documentation for a thorough explanation of the 'riskScore'.
 226+ */
 227+ $wgMinFraudActionRanges = array(
 228+ 'process' => array( 0, 100 ),
 229+ 'review' => array( -1, -1 ),
 230+ 'challenge' => array( -1, -1 ),
 231+ 'reject' => array( -1, -1 )
 232+ );
 233+
 234+ // Timeout in seconds for communicating with MaxMind
 235+ $wgMinFraudTimeout = 2;
 236+
 237+ /**
 238+ * Define whether or not to run minFraud in stand alone mode
 239+ *
 240+ * If this is set to run in standalone, these scripts will be
 241+ * accessed directly via the "GatewayValidate" hook.
 242+ * You may not want to run this in standalone mode if you prefer
 243+ * to use this in conjunction with Custom Filters. This has the
 244+ * advantage of sharing minFraud info with other filters.
 245+ */
 246+ $wgMinFraudStandalone = TRUE;
 247+
101248 }
102249
 250+//Minfraud as Filter globals
 251+if ( $optionalParts['Minfraud_as_filter'] === true ){
 252+ $wgMinFraudStandalone = FALSE;
 253+}
 254+
 255+//Recaptcha globals
 256+if ( $optionalParts['Recaptcha'] === true ){
 257+ /**
 258+ * Public and Private reCaptcha keys
 259+ *
 260+ * These can be obtained at:
 261+ * http://www.google.com/recaptcha/whyrecaptcha
 262+ */
 263+ $wgDonationInterfaceRecaptchaPublicKey = '';
 264+ $wgDonationInterfaceRecaptchaPrivateKey = '';
 265+
 266+ // Timeout (in seconds) for communicating with reCatpcha
 267+ $wgDonationInterfaceRecaptchaTimeout = 2;
 268+
 269+ /**
 270+ * HTTP Proxy settings
 271+ *
 272+ * Default to settings in DonationInterface
 273+ */
 274+ //TODO: I think we can get rid of these entirely, due to the way we are now checking for globals in the extras.
 275+ //$wgDonationInterfaceRecaptchaUseHTTPProxy = $wgDonationInterfaceUseHTTPProxy;
 276+ //$wgDonationInterfaceRecaptchaHTTPProxy = $wgDonationInterfaceHTTPProxy;
 277+
 278+ /**
 279+ * Use SSL to communicate with reCaptcha
 280+ */
 281+ $wgDonationInterfaceRecaptchaUseSSL = 1;
 282+
 283+ /**
 284+ * The # of times to retry communicating with reCaptcha if communication fails
 285+ * @var int
 286+ */
 287+ $wgDonationInterfaceRecaptchaComsRetryLimit = 3;
 288+}
 289+
 290+
103291 /**
104 - * Hooks required to interface with the donation extension (include <donate> on page)
105 - *
106 - * gwValue supplies the value of the form option, the name that appears on the form
107 - * and the currencies supported by the gateway in the $values array
 292+ * HOOKS
108293 */
109 -//$wgHooks['DonationInterface_Value'][] = 'pfpGatewayValue';
110 -//$wgHooks['DonationInterface_Page'][] = 'pfpGatewayPage';
111 -# Unit tests
 294+
 295+//Unit tests
112296 $wgHooks['UnitTestsList'][] = 'efDonationInterfaceUnitTests';
113297
 298+
 299+//Paypal gateway globals
 300+if ( $optionalParts['Paypal'] === true ){
 301+ //TODO: Determine if this is all cruft. I'm guessing "Probably".
 302+ /**
 303+ * Hooks required to interface with the donation extension (include <donate> on page)
 304+ *
 305+ * gwValue supplies the value of the form option, the name that appears on the form
 306+ * and the currencies supported by the gateway in the $values array
 307+ */
 308+ $wgHooks['DonationInterface_Value'][] = 'paypalGatewayValue';
 309+ $wgHooks['DonationInterface_Page'][] = 'paypalGatewayPage';
 310+}
 311+
 312+//Stomp hooks
 313+if ($optionalParts['Stomp'] === true){
 314+ $wgHooks['ParserFirstCallInit'][] = 'efStompSetup';
 315+ $wgHooks['gwStomp'][] = 'sendSTOMP';
 316+ $wgHooks['gwPendingStomp'][] = 'sendPendingSTOMP';
 317+}
 318+
 319+//Custom Filters hooks
 320+if ($optionalParts['CustomFilters'] === true){
 321+ $wgHooks["GatewayValidate"][] = array( 'Gateway_Extras_CustomFilters::onValidate' );
 322+}
 323+
 324+//Conversion Log hooks
 325+if ($optionalParts['ConversionLog'] === true){
 326+ // Sets the 'conversion log' as logger for post-processing
 327+ $wgHooks["GatewayPostProcess"][] = array( "Gateway_Extras_ConversionLog::onPostProcess" );
 328+}
 329+
 330+//Recaptcha hooks
 331+if ($optionalParts['Recaptcha'] === true){
 332+ // Set reCpatcha as plugin for 'challenge' action
 333+ $wgHooks["GatewayChallenge"][] = array( "Gateway_Extras_ReCaptcha::onChallenge" );
 334+}
 335+
 336+/**
 337+ * ADDITIONAL MAGICAL GLOBALS
 338+ */
 339+
114340 // enable the API
115341 $wgAPIModules['donate'] = 'DonationApi';
116342
@@ -127,14 +353,74 @@
128354 'position' => 'top'
129355 ) + $wgResourceTemplate;
130356
 357+$wgExtensionMessagesFiles['DonateInterface'] = $donationinterface_dir . 'donate_interface/donate_interface.i18n.php';
131358
 359+//Paypal magical globals
 360+if ( $optionalParts['Paypal'] === true ){
 361+ $wgExtensionMessagesFiles['PaypalGateway'] = $donationinterface_dir . 'paypal_gateway/paypal_gateway.i18n.php';
 362+}
 363+
 364+//Minfraud magical globals
 365+if ( $optionalParts['Minfraud'] === true ){ //We do not want this in filter mode.
 366+ $wgExtensionFunctions[] = 'efMinFraudSetup';
 367+}
 368+
 369+//Minfraud as Filter globals
 370+if ( $optionalParts['Minfraud_as_filter'] === true ){
 371+ $wgExtensionFunctions[] = 'efCustomFiltersMinFraudSetup';
 372+}
 373+
 374+
132375 /**
133 - * The URL to redirect a transaction to PayPal
 376+ * FUNCTIONS
134377 */
135 -$wgDonationInterfacePaypalURL = '';
136 -$wgDonationInterfaceRetrySeconds = 5;
137378
 379+//---Stomp functions---
 380+if ($optionalParts['Stomp'] === true){
 381+ require_once( $donationinterface_dir . 'activemq_stomp/activemq_stomp.php' );
 382+}
 383+
 384+//---Minfraud functions---
 385+if ($optionalParts['Minfraud'] === true){
 386+ require_once( $donationinterface_dir . 'extras/minfraud/minfraud.php' );
 387+}
 388+
 389+//---Minfraud as filter functions---
 390+if ($optionalParts['Minfraud_as_filter'] === true){
 391+ require_once( $donationinterface_dir . 'extras/custom_filters/filters/minfraud/minfraud.php' );
 392+}
 393+
 394+//---Paypal functions---
 395+if ($optionalParts['Paypal'] === true){
 396+ require_once( $donationinterface_dir . 'paypal_gateway/paypal_gateway.php' );
 397+}
 398+
 399+
 400+
 401+
 402+
 403+
 404+
 405+//This is going to be a little funky.
 406+//Override this in LocalSettings.php BEFORE you include this file, if you want
 407+//to disable gateways.
 408+//TODO: Unfunktify, if you have a better idea here for auto-loading the classes after LocalSettings.php runs all the way.
 409+if ( !isset( $wgDonationInterfaceEnabledGateways ) ) {
 410+ $wgDonationInterfaceEnabledGateways = array(
 411+ 'payflowpro',
 412+ 'globalcollect'
 413+ );
 414+}
 415+
 416+foreach ( $wgDonationInterfaceEnabledGateways as $gateway ) {
 417+ //include 'em
 418+ require_once( $donationinterface_dir . $gateway . '_gateway/' . $gateway . '_gateway.php' );
 419+}
 420+
 421+
138422 function efDonationInterfaceUnitTests( &$files ) {
139 - $files[] = dirname( __FILE__ ) . '/tests/AllTests.php';
 423+ $files[] = $donationinterface_dir . 'tests/AllTests.php';
140424 return true;
141425 }
 426+
 427+unset( $optionalParts );
Index: branches/fundraising/extensions/DonationInterface/payflowpro_gateway/api_payflowpro_gateway.php
@@ -2,6 +2,7 @@
33 /**
44 * PayflowPro Gateway API extension
55 * Call with api.php?action=pfp
 6+ * TODO: Determine if this is being used by anything anymore, and if so, what.
67 */
78
89 class ApiPayflowProGateway extends ApiBase {
@@ -124,6 +125,8 @@
125126 global $wgPayflowProGatewaySalt;
126127
127128 // fetch the order_id
 129+ //TODO: This include should be *very* deprecated. All the functionality there has been
 130+ //recently eaten by gateway.adapter.php and DontationData.php.
128131 require_once( 'includes/payflowUser.inc' );
129132 $payflow_data = payflowUser();
130133 $order_id = $payflow_data[ 'order_id' ];
Index: branches/fundraising/extensions/DonationInterface/extras/custom_filters/custom_filters.body.php
@@ -26,8 +26,8 @@
2727 public function __construct( &$gateway_adapter ) {
2828 parent::__construct( $gateway_adapter ); //gateway_adapter is set in there.
2929 // load user action ranges and risk score
30 - $this->action_ranges = $this->getGlobal( 'CustomFiltersActionRanges' );
31 - $this->risk_score = $this->getGlobal( 'CustomFiltersRiskScore' );
 30+ $this->action_ranges = $this->gateway_adapter->getGlobal( 'CustomFiltersActionRanges' );
 31+ $this->risk_score = $this->gateway_adapter->getGlobal( 'CustomFiltersRiskScore' );
3232 }
3333
3434 /**
Index: branches/fundraising/extensions/DonationInterface/extras/custom_filters/custom_filters.php
@@ -10,7 +10,12 @@
1111 * The actual filters themselves are regular MW extensions and can optional be organized in filters/
1212 * They should be invoked by using the 'GatewayCustomFilter' hook, which will pass the entire
1313 * CustomFilter object to the filter. The gateway object and its data are included in the CustomFilter
14 - * object.
 14+ * object.
 15+ *
 16+ * To install the DontaionInterface extension, put the following line in LocalSettings.php:
 17+ * require_once( "\$IP/extensions/DonationInterface/donationinterface.php" );
 18+ *
 19+ * TODO: Remove this file. :)
1520 */
1621 if ( !defined( 'MEDIAWIKI' ) ) {
1722 die( "This file is part of the MinFraud for Gateway extension. It is not a valid entry point.\n" );
@@ -22,27 +27,3 @@
2328 'url' => '',
2429 'description' => 'This extension provides a way to define custom filters for incoming transactions for the gateway.'
2530 );
26 -
27 -/**
28 - * Define the action to take for a given $risk_score
29 - */
30 -$wgDonationInterfaceCustomFiltersActionRanges = array(
31 - 'process' => array( 0, 100 ),
32 - 'review' => array( -1, -1 ),
33 - 'challenge' => array( -1, -1 ),
34 - 'reject' => array( -1, -1 ),
35 -);
36 -
37 -/**
38 - * A value for tracking the 'riskiness' of a transaction
39 - *
40 - * The action to take based on a transaction's riskScore is determined by
41 - * $action_ranges. This is built assuming a range of possible risk scores
42 - * as 0-100, although you can probably bend this as needed.
43 - */
44 -$wgDonationInterfaceCustomFiltersRiskScore = 0;
45 -
46 -$dir = dirname( __FILE__ ) . "/";
47 -$wgAutoloadClasses['Gateway_Extras_CustomFilters'] = $dir . "custom_filters.body.php";
48 -
49 -$wgHooks["GatewayValidate"][] = array( 'Gateway_Extras_CustomFilters::onValidate' );
Index: branches/fundraising/extensions/DonationInterface/extras/custom_filters/filters/minfraud/minfraud.php
@@ -32,14 +32,14 @@
3333 * you will want to make sure you know whether minFraud queries are
3434 * happening before or after custom filters, defined by the order of
3535 * your require statements in LocalSettings.
 36+ *
 37+ * To install the DontaionInterface extension, put the following line in LocalSettings.php:
 38+ * require_once( "\$IP/extensions/DonationInterface/donationinterface.php" );
 39+ *
 40+ * TODO: Outline required globals to include this bad boy!
 41+ *
3642 */
37 -$wgMinFraudStandalone = FALSE;
3843
39 -$dir = dirname( __FILE__ ) . "/";
40 -$wgAutoloadClasses['Gateway_Extras_MinFraud'] = $dir . "../../../minfraud/minfraud.body.php";
41 -$wgAutoloadClasses['Gateway_Extras_CustomFilters_MinFraud'] = $dir . "minfraud.body.php";
42 -$wgExtensionFunctions[] = 'efCustomFiltersMinFraudSetup';
43 -
4444 function efCustomFiltersMinFraudSetup() {
4545 global $wgMinFraudStandalone, $wgHooks;
4646 if ( !$wgMinFraudStandalone )
Index: branches/fundraising/extensions/DonationInterface/extras/minfraud/minfraud.body.php
@@ -157,8 +157,6 @@
158158 * @return array containing hash for minfraud query
159159 */
160160 public function build_query( array $data ) {
161 - global $wgDonationInterfaceTest;
162 -
163161 // mapping of data keys -> minfraud array keys
164162 $map = array(
165163 "city" => "city",
@@ -175,7 +173,7 @@
176174 $minfraud_array["license_key"] = $this->minfraud_license_key;
177175
178176 // user's IP address
179 - $minfraud_array["i"] = ( $wgDonationInterfaceTest ) ? '12.12.12.12' : wfGetIP();
 177+ $minfraud_array["i"] = ( $this->gateway_adapter->getGlobal( "Test" ) ) ? '12.12.12.12' : wfGetIP();
180178
181179 // user's user agent
182180 global $wgRequest;
Index: branches/fundraising/extensions/DonationInterface/extras/minfraud/minfraud.php
@@ -5,9 +5,11 @@
66 *
77 * For more details on minFraud, go: http://www.maxmind.com/app/minfraud
88 *
9 - * To install:
10 - * require_once( "$IP/extensions/DonationInterface/extras/minfraud/minfraud.php" );
11 - *
 9+ * To install the DontaionInterface extension, put the following line in LocalSettings.php:
 10+ * require_once( "\$IP/extensions/DonationInterface/donationinterface.php" );
 11+ *
 12+ * TODO: Outline required globals to include this bad boy!
 13+ *
1214 */
1315 if ( !defined( 'MEDIAWIKI' ) ) {
1416 die( "This file is part of the MinFraud for Gateway extension. It is not a valid entry point.\n" );
@@ -20,53 +22,6 @@
2123 'description' => 'This extension uses the MaxMind minFraud service as a validator for the gateway.'
2224 );
2325
24 -/**
25 - * Your minFraud license key.
26 - */
27 -$wgMinFraudLicenseKey = '';
28 -
29 -/**
30 - * Set the risk score ranges that will cause a particular 'action'
31 - *
32 - * The keys to the array are the 'actions' to be taken (eg 'process').
33 - * The value for one of these keys is an array representing the lower
34 - * and upper bounds for that action. For instance,
35 - * $wgMinFraudActionRagnes = array(
36 - * 'process' => array( 0, 100)
37 - * ...
38 - * );
39 - * means that any transaction with a risk score greather than or equal
40 - * to 0 and less than or equal to 100 will be given the 'process' action.
41 - *
42 - * These are evauluated on a >= or <= basis. Please refer to minFraud
43 - * documentation for a thorough explanation of the 'riskScore'.
44 - */
45 -$wgMinFraudActionRanges = array(
46 - 'process' => array( 0, 100 ),
47 - 'review' => array( -1, -1 ),
48 - 'challenge' => array( -1, -1 ),
49 - 'reject' => array( -1, -1 )
50 -);
51 -
52 -// Timeout in seconds for communicating with MaxMind
53 -$wgMinFraudTimeout = 2;
54 -
55 -/**
56 - * Define whether or not to run minFraud in stand alone mode
57 - *
58 - * If this is set to run in standalone, these scripts will be
59 - * accessed directly via the "GatewayValidate" hook.
60 - * You may not want to run this in standalone mode if you prefer
61 - * to use this in conjunction with Custom Filters. This has the
62 - * advantage of sharing minFraud info with other filters.
63 - */
64 -$wgMinFraudStandalone = TRUE;
65 -
66 -$dir = dirname( __FILE__ ) . "/";
67 -$wgAutoloadClasses['Gateway_Extras_MinFraud'] = $dir . "minfraud.body.php";
68 -
69 -$wgExtensionFunctions[] = 'efMinFraudSetup';
70 -
7126 function efMinFraudSetup() {
7227 // if we're in standalone mode, use the GatewayValidate hook
7328 global $wgMinFraudStandalone, $wgHooks;
Index: branches/fundraising/extensions/DonationInterface/extras/conversion_log/conversion_log.php
@@ -5,8 +5,10 @@
66 *
77 * @fixme Class/file names should likely change to reflect change in purpose...
88 *
9 - * To install:
10 - * require_once( "$IP/extensions/DonationInterface/extras/conversion_log/conversion_log.php"
 9+ * To install the DontaionInterface extension, put the following line in LocalSettings.php:
 10+ * require_once( "\$IP/extensions/DonationInterface/donationinterface.php" );
 11+ *
 12+ * TODO: Remove this file. :)
1113 */
1214 if ( !defined( 'MEDIAWIKI' ) ) {
1315 die( "This file is part of the Conversion Log for Gateway extension. It is not a valid entry point.\n" );
@@ -18,9 +20,3 @@
1921 'url' => '',
2022 'description' => "This extension handles logging for Gateway extension 'extras'"
2123 );
22 -
23 -$dir = dirname( __FILE__ ) . "/";
24 -$wgAutoloadClasses['Gateway_Extras_ConversionLog'] = $dir . "conversion_log.body.php";
25 -
26 -// Sets the 'conversion log' as logger for post-processing
27 -$wgHooks["GatewayPostProcess"][] = array( "Gateway_Extras_ConversionLog::onPostProcess" );
Index: branches/fundraising/extensions/DonationInterface/extras/extras.body.php
@@ -15,24 +15,12 @@
1616 public function __construct( &$gateway_adapter ) {
1717 $this->gateway_adapter = &$gateway_adapter;
1818
19 - $extrasLog = $this->getGlobal( 'ExtrasLog' );
 19+ $extrasLog = $this->gateway_adapter->getGlobal( 'ExtrasLog' );
2020 // prepare the log file if the user has specified one
2121 if ( strlen( $extrasLog ) > 0 )
2222 $this->prepare_log_file( $extrasLog );
2323 }
2424
25 - function getGlobal( $varname ) {
26 - //basically, if the global is defined in the adapter, use the overridden value.
27 - //otherwise, grab the default.
28 - $ret = $this->gateway_adapter->getGlobal( $varname );
29 - if ( empty( $ret ) ) {
30 - $globalname = 'wgDonationInterface' . $varname;
31 - global $$globalname;
32 - $ret = $$globalname;
33 - }
34 - return $ret;
35 - }
36 -
3725 /**
3826 * Prepare logging mechanism
3927 *
@@ -91,7 +79,7 @@
9280 * @return string The hash of the data
9381 */
9482 public function generate_hash( $data ) {
95 - $salt = $this->getGlobal( 'Salt' );
 83+ $salt = $this->gateway_adapter->getGlobal( 'Salt' );
9684 return hash( "sha512", $salt . $data );
9785 }
9886
Index: branches/fundraising/extensions/DonationInterface/extras/recaptcha/recaptcha.php
@@ -3,8 +3,10 @@
44 /**
55 * Extra to expose a recaptcha for 'challenged' transactions
66 *
7 - * To install:
8 - * require_once( "$IP/extensions/DonationInterface/extras/recaptcha/recaptcha.php"
 7+ * To install the DontaionInterface extension, put the following line in LocalSettings.php:
 8+ * require_once( "\$IP/extensions/DonationInterface/donationinterface.php" );
 9+ *
 10+ * TODO: Remove this file. :)
911 */
1012 if ( !defined( 'MEDIAWIKI' ) ) {
1113 die( "This file is part of the ReCaptcha for Gateway extension. It is not a valid entry point.\n" );
@@ -16,41 +18,3 @@
1719 'url' => '',
1820 'description' => "This extension exposes a reCpathca for 'challenged' transactions in the Gateway"
1921 );
20 -
21 -/**
22 - * Public and Private reCaptcha keys
23 - *
24 - * These can be obtained at:
25 - * http://www.google.com/recaptcha/whyrecaptcha
26 - */
27 -$wgDonationInterfaceRecaptchaPublicKey = '';
28 -$wgDonationInterfaceRecaptchaPrivateKey = '';
29 -
30 -// Timeout (in seconds) for communicating with reCatpcha
31 -$wgDonationInterfaceRecaptchaTimeout = 2;
32 -
33 -/**
34 - * HTTP Proxy settings
35 - *
36 - * Default to settings in DonationInterface
37 - */
38 -//TODO: I think we can get rid of these entirely, due to the way we are now checking for globals in the extras.
39 -//$wgDonationInterfaceRecaptchaUseHTTPProxy = $wgDonationInterfaceUseHTTPProxy;
40 -//$wgDonationInterfaceRecaptchaHTTPProxy = $wgDonationInterfaceHTTPProxy;
41 -
42 -/**
43 - * Use SSL to communicate with reCaptcha
44 - */
45 -$wgDonationInterfaceRecaptchaUseSSL = 1;
46 -
47 -/**
48 - * The # of times to retry communicating with reCaptcha if communication fails
49 - * @var int
50 - */
51 -$wgDonationInterfaceRecaptchaComsRetryLimit = 3;
52 -
53 -$dir = dirname( __FILE__ ) . "/";
54 -$wgAutoloadClasses['Gateway_Extras_ReCaptcha'] = $dir . "recaptcha.body.php";
55 -
56 -// Set reCpatcha as plugin for 'challenge' action
57 -$wgHooks["GatewayChallenge"][] = array( "Gateway_Extras_ReCaptcha::onChallenge" );
Index: branches/fundraising/extensions/DonationInterface/extras/recaptcha/recaptcha.body.php
@@ -22,11 +22,11 @@
2323 //stash all the vars that reCaptcha is going to need in a global just for it.
2424 //I know this is vaguely unpleasant, but it's the quickest way back to zero.
2525 global $wgReCaptchaConfData;
26 - $wgReCaptchaConfData['UseHTTPProxy'] = $this->getGlobal( 'RecaptchaUseHTTPProxy' );
27 - $wgReCaptchaConfData['HTTPProxy'] = $this->getGlobal( 'RecaptchaHTTPProxy' );
28 - $wgReCaptchaConfData['Timeout'] = $this->getGlobal( 'RecaptchaTimeout' );
29 - $wgReCaptchaConfData['UseSSL'] = $this->getGlobal( 'RecaptchaUseSSL' );
30 - $wgReCaptchaConfData['ComsRetryLimit'] = $this->getGlobal( 'RecaptchaComsRetryLimit' );
 26+ $wgReCaptchaConfData['UseHTTPProxy'] = $this->gateway_adapter->getGlobal( 'RecaptchaUseHTTPProxy' );
 27+ $wgReCaptchaConfData['HTTPProxy'] = $this->gateway_adapter->getGlobal( 'RecaptchaHTTPProxy' );
 28+ $wgReCaptchaConfData['Timeout'] = $this->gateway_adapter->getGlobal( 'RecaptchaTimeout' );
 29+ $wgReCaptchaConfData['UseSSL'] = $this->gateway_adapter->getGlobal( 'RecaptchaUseSSL' );
 30+ $wgReCaptchaConfData['ComsRetryLimit'] = $this->gateway_adapter->getGlobal( 'RecaptchaComsRetryLimit' );
3131 $wgReCaptchaConfData['GatewayClass'] = $this->gateway_adapter->getGatewayAdapterClass(); //for properly routing the logging
3232 // load the reCaptcha API
3333 require_once( dirname( __FILE__ ) . '/recaptcha-php/recaptchalib.php' );
@@ -60,8 +60,8 @@
6161 */
6262 public function display_captcha() {
6363 global $wgOut;
64 - $publicKey = $this->getGlobal( 'RecaptchaPublicKey' );
65 - $useSSL = $this->getGlobal( 'RecaptchaUseSSL' );
 64+ $publicKey = $this->gateway_adapter->getGlobal( 'RecaptchaPublicKey' );
 65+ $useSSL = $this->gateway_adapter->getGlobal( 'RecaptchaUseSSL' );
6666
6767 // log that a captcha's been triggered
6868 $this->log( $this->gateway_adapter->getData( 'contribution_tracking_id' ), 'Captcha triggered' );
@@ -94,7 +94,7 @@
9595 */
9696 public function check_captcha() {
9797 global $wgRequest;
98 - $privateKey = $this->getGlobal( 'RecaptchaPrivateKey' );
 98+ $privateKey = $this->gateway_adapter->getGlobal( 'RecaptchaPrivateKey' );
9999 $resp = recaptcha_check_answer( $privateKey, wfGetIP(), $wgRequest->getText( 'recaptcha_challenge_field' ), $wgRequest->getText( 'recaptcha_response_field' ) );
100100
101101 return $resp;
Index: branches/fundraising/extensions/DonationInterface/extras/extras.php
@@ -3,9 +3,10 @@
44 /**
55 * An abstract class and set up for gateway 'extras'
66 *
7 - * To install:
8 - * require_once( "$IP/extensions/DonationInterface/extras/extras.php"
9 - * Note: This should be specified in LocalSettings.php BEFORE requiring any of the other 'extras'
 7+ * To install the DontaionInterface extension, put the following line in LocalSettings.php:
 8+ * require_once( "\$IP/extensions/DonationInterface/donationinterface.php" );
 9+ *
 10+ * TODO: Remove this file. :)
1011 */
1112 if ( !defined( 'MEDIAWIKI' ) ) {
1213 die( "This file is part of Gateway extension. It is not a valid entry point.\n" );
@@ -18,12 +19,3 @@
1920 'description' => "This extension handles some of the set up required for Gateway extras"
2021 );
2122
22 -/**
23 - * Full path to file to use for logging for Gateway scripts
24 - *
25 - * Declare in LocalSettings.php
26 - */
27 -$wgDonationInterfaceExtrasLog = '';
28 -
29 -$dir = dirname( __FILE__ ) . "/";
30 -$wgAutoloadClasses['Gateway_Extras'] = $dir . "extras.body.php";
\ No newline at end of file
Index: branches/fundraising/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.body.php
@@ -29,6 +29,9 @@
3030 $wgOut->addExtensionStyle(
3131 $wgExtensionAssetsPath . '/DonationInterface/gateway_forms/css/gateway.css?284' .
3232 $CSSVersion );
 33+
 34+ // Hide unneeded interface elements
 35+ $wgOut->addModules( 'donationInterface.skinOverride' );
3336
3437 $gateway_id = $this->adapter->getIdentifier();
3538
Index: branches/fundraising/extensions/DonationInterface/paypal_gateway/paypal_gateway.php
@@ -1,4 +1,12 @@
22 <?php
 3+/**
 4+ *
 5+ * To install the DontaionInterface extension, put the following line in LocalSettings.php:
 6+ * require_once( "\$IP/extensions/DonationInterface/donationinterface.php" );
 7+ *
 8+ * TODO: Remove this file. :)
 9+ */
 10+
311 # Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly.
412 if ( !defined( 'MEDIAWIKI' ) ) {
513 echo <<<EOT
@@ -17,24 +25,7 @@
1826 'version' => '1.0.0',
1927 );
2028
21 -// Set up i18n
22 -$dir = dirname( __FILE__ ) . '/';
23 -$wgExtensionMessagesFiles['PaypalGateway'] = $dir . 'paypal_gateway.i18n.php';
24 -
25 -// default variables that should be set in LocalSettings.php
26 -$wgPaypalEmail = '';
27 -$wgPaypalUrl = 'http://wikimediafoundation.org/wiki/Special:ContributionTracking?';
28 -
2929 /**
30 - * Hooks required to interface with the donation extension (include <donate> on page)
31 - *
32 - * gwValue supplies the value of the form option, the name that appears on the form
33 - * and the currencies supported by the gateway in the $values array
34 - */
35 -$wgHooks['DonationInterface_Value'][] = 'paypalGatewayValue';
36 -$wgHooks['DonationInterface_Page'][] = 'paypalGatewayPage';
37 -
38 -/**
3930 * Hook to register form value and display name of this gateway
4031 * also supplies currencies supported by this gateway
4132 */
Index: branches/fundraising/extensions/DonationInterface/gateway_common/DonationData.php
@@ -714,20 +714,6 @@
715715 }
716716 }
717717
718 - public function decrementNumAttempt() {
719 - //minfraud...
720 - //TODO: Determine if I killed this or not.
721 - if ( $this->isSomething( 'numAttempt' ) ) {
722 - $attempts = $this->getVal( 'numAttempt' );
723 - if ( is_numeric( $attempts ) ) {
724 - $this->setVal( 'numAttempt', $attempts - 1 );
725 - } else {
726 - //I guess...
727 - $this->setVal( 'numAttempt', 0 );
728 - }
729 - }
730 - }
731 -
732718 }
733719
734720 ?>
Index: branches/fundraising/extensions/DonationInterface/donate_interface/donate_interface.php
@@ -5,6 +5,11 @@
66 * @file
77 * @ingroup Extensions
88 * @link http://www.mediawiki.org/wiki/Extension:DonateInterface Documentation
 9+ *
 10+ * To install the DontaionInterface extension, put the following line in LocalSettings.php:
 11+ * require_once( "\$IP/extensions/DonationInterface/donationinterface.php" );
 12+ *
 13+ * TODO: Remove this file. :)
914 */
1015
1116 if ( !defined( 'MEDIAWIKI' ) ) {
Index: branches/fundraising/extensions/DonationInterface/activemq_stomp/activemq_stomp.php
@@ -17,14 +17,6 @@
1818 'version' => '1.0.0',
1919 );
2020
21 -$dir = dirname( __FILE__ ) . '/';
22 -
23 -$wgAutoloadClasses['activemq_stomp'] = $dir . 'activemq_stomp.php'; # Tell MediaWiki to load the extension body.
24 -// default variables that should be set in LocalSettings
25 -$wgStompServer = "";
26 -
27 -$wgHooks['ParserFirstCallInit'][] = 'efStompSetup';
28 -
2921 /*
3022 * Create <donate /> tag to include landing page donation form
3123 */
@@ -49,16 +41,13 @@
5042 }
5143
5244 /**
53 - * Hook to get user provided and order data
54 - *
 45+ * Hook to send complete transaction information to ActiveMQ server
 46+ * @global string $wgStompServer ActiveMQ server name.
 47+ * @global string $wgStompQueueName Name of the destination queue for completed transactions.
 48+ * @param array $transaction Key-value array of staged and ready donation data.
 49+ * @return bool Just returns true all the time. Presumably an indication that
 50+ * nothing exploded big enough to kill the whole thing.
5551 */
56 -$wgHooks['gwStomp'][] = 'sendSTOMP';
57 -$wgHooks['gwPendingStomp'][] = 'sendPendingSTOMP';
58 -
59 -/*
60 - * Hook to send transaction information to ActiveMQ server
61 - */
62 -
6352 function sendSTOMP( $transaction ) {
6453 global $wgStompServer, $wgStompQueueName;
6554
@@ -87,10 +76,16 @@
8877 return true;
8978 }
9079
91 -/*
 80+/**
9281 * Hook to send transaction information to ActiveMQ server
 82+ * TODO: Parameterize sendStomp instead of maintaining this copy.
 83+ * @global string $wgStompServer ActiveMQ server name.
 84+ * @global string $wgPendingStompQueueName Name of the destination queue for
 85+ * pending transactions.
 86+ * @param array $transaction Key-value array of staged and ready donation data.
 87+ * @return bool Just returns true all the time. Presumably an indication that
 88+ * nothing exploded big enough to kill the whole thing.
9389 */
94 -
9590 function sendPendingSTOMP( $transaction ) {
9691 global $wgStompServer, $wgPendingStompQueueName;
9792
@@ -121,6 +116,9 @@
122117
123118 /**
124119 * Assign correct values to the array of data to be sent to the ActiveMQ server
 120+ * TODO: Probably something else. I don't like the way this works and neither do you.
 121+ *
 122+ * Older notes follow:
125123 * TODO: include optout and comments option in the donation page
126124 * NOTES: includes middle name
127125 * Currency in receiving module has currency set to USD, should take passed variable for these

Status & tagging log