http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73586
Revision: 73586
Author: awjrichards
Date: 2010-09-23 02:48:58 +0000 (Thu, 23 Sep 2010)
Log Message:
-----------
Updated 'email' field overwriting (due to poorly named fields...);
contribution_tracking now properly updates on forms w/ comment fields; changed
'email' field on donation_interface form to 'email-opt' for clarity and to
prevent overwriting by an actual email address field
Modified Paths:
--------------
trunk/extensions/DonationInterface/donate_interface/donate_interface.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-23 00:11:00 UTC (rev 73585)
+++ trunk/extensions/DonationInterface/donate_interface/donate_interface.php
2010-09-23 02:48:58 UTC (rev 73586)
@@ -192,7 +192,7 @@
Xml::checkLabel( wfMsg( 'donate_interface-anon-message' ),
'comment-option', 'input_comment-option', TRUE ) .
Xml::closeElement( 'div' ) .
Xml::openElement( 'div', array( 'id' => 'mw-donation-checkbox' )) .
- Xml::check( 'email', TRUE ) .
+ Xml::check( 'email-opt', TRUE ) .
Xml::tags( 'span', array( 'class' => 'mw-email-agreement' ), wfMsg(
'donate_interface-email-agreement' )) .
Xml::closeElement( 'div' );
Modified:
trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter.php
===================================================================
---
trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter.php
2010-09-23 00:11:00 UTC (rev 73585)
+++
trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter.php
2010-09-23 02:48:58 UTC (rev 73586)
@@ -69,8 +69,8 @@
// email agreement
$form .= '<tr>';
- $form .= '<td>' . Xml::check( 'opt', TRUE ) . '</td>';
- $form .= '<td>' . Xml::label( wfMsg(
'donate_interface-email-agreement' ), 'opt' ) . '</td>';
+ $form .= '<td>' . Xml::check( 'email-opt', TRUE ) . '</td>';
+ $form .= '<td>' . Xml::label( wfMsg(
'donate_interface-email-agreement' ), 'email-opt' ) . '</td>';
$form .= '</tr>';
$form .= Xml::closeElement( 'table' );
Modified:
trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
===================================================================
---
trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
2010-09-23 00:11:00 UTC (rev 73585)
+++
trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
2010-09-23 02:48:58 UTC (rev 73586)
@@ -355,6 +355,9 @@
private function fnPayflowProcessTransaction( $data, $payflow_data ) {
global $wgOut, $wgDonationTestingMode,
$wgPayflowGatewayUseHTTPProxy, $wgPayflowGatewayHTTPProxy;
+ // update contribution tracking
+ $this->updateContributionTracking( $data );
+
// create payflow query string, include string lengths
$queryArray = array(
'TRXTYPE' => $payflow_data['trxtype'],
@@ -892,7 +895,7 @@
'language' => $wgRequest->getText( 'language' ),
'comment' => $wgRequest->getText( 'comment' ),
'anonymous' => $wgRequest->getText(
'comment-option' ),
- 'optout' => $wgRequest->getText( 'email' ),
+ 'optout' => $wgRequest->getText( 'email-opt' ),
'test_string' => $wgRequest->getText( 'process'
), //for showing payflow string during testing
'token' => $token,
'contribution_tracking_id' =>
$wgRequest->getText( 'contribution_tracking_id' ),
@@ -961,4 +964,52 @@
return implode( ".", $source_parts );
}
+
+ public function updateContributionTracking( $data ) {
+ /**
+ * if we're not coming from the regular cc form, fix
optout/anonymous
+ *
+ * @fixme This is a bad hack being pushed out for a
time-sensitive update
+ * and this will only work as expected for a particular
configuartion/usecase
+ * Overall this is fine, but the $data['optout'] and
$data['anonymous']
+ * handling is... bad.
+ */
+ $fix_optouts = false;
+ $source_parts = explode(".", $data[ 'utm_source' ] );
+ foreach ( $source_parts as $value ) {
+ if ( preg_match( "/cc[0-9]/", $value )) {
+ $fix_optouts = true;
+ }
+ }
+ if ( !$fix_optouts ) {
+ return;
+ }
+
+ $data['optout'] = ($data['optout'] == "1") ? '0' : '1';
+ $data['anonymous'] = ($data['anonymous'] == "1") ? '0' : '1';
+
+ $db = payflowGatewayConnection();
+
+ if (!$db) { return true ; }
+
+ $tracked_contribution = array(
+ 'note' => $data['comment'],
+ 'referrer' => $data['referrer'],
+ 'anonymous' => $data['anonymous'],
+ 'utm_source' => $data['utm_source'],
+ 'utm_medium' => $data['utm_medium'],
+ 'utm_campaign' => $data['utm_campaign'],
+ 'optout' => $data['optout'],
+ 'language' => $data['language'],
+ );
+
+ // Make all empty strings NULL
+ foreach ($tracked_contribution as $key => $value) {
+ if ($value === '') {
+ $tracked_contribution[$key] = null;
+ }
+ }
+
+ $db->update( 'contribution_tracking', $tracked_contribution,
array( 'id' => $data[ 'contribution_tracking_id' ] ));
+ }
} // end class
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs