r73586 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73585‎ | r73586 | r73587 >
Date:02:48, 23 September 2010
Author:awjrichards
Status:deferred
Tags:
Comment:
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 (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
@@ -355,6 +355,9 @@
356356 private function fnPayflowProcessTransaction( $data, $payflow_data ) {
357357 global $wgOut, $wgDonationTestingMode, $wgPayflowGatewayUseHTTPProxy, $wgPayflowGatewayHTTPProxy;
358358
 359+ // update contribution tracking
 360+ $this->updateContributionTracking( $data );
 361+
359362 // create payflow query string, include string lengths
360363 $queryArray = array(
361364 'TRXTYPE' => $payflow_data['trxtype'],
@@ -892,7 +895,7 @@
893896 'language' => $wgRequest->getText( 'language' ),
894897 'comment' => $wgRequest->getText( 'comment' ),
895898 'anonymous' => $wgRequest->getText( 'comment-option' ),
896 - 'optout' => $wgRequest->getText( 'email' ),
 899+ 'optout' => $wgRequest->getText( 'email-opt' ),
897900 'test_string' => $wgRequest->getText( 'process' ), //for showing payflow string during testing
898901 'token' => $token,
899902 'contribution_tracking_id' => $wgRequest->getText( 'contribution_tracking_id' ),
@@ -961,4 +964,52 @@
962965
963966 return implode( ".", $source_parts );
964967 }
 968+
 969+ public function updateContributionTracking( $data ) {
 970+ /**
 971+ * if we're not coming from the regular cc form, fix optout/anonymous
 972+ *
 973+ * @fixme This is a bad hack being pushed out for a time-sensitive update
 974+ * and this will only work as expected for a particular configuartion/usecase
 975+ * Overall this is fine, but the $data['optout'] and $data['anonymous']
 976+ * handling is... bad.
 977+ */
 978+ $fix_optouts = false;
 979+ $source_parts = explode(".", $data[ 'utm_source' ] );
 980+ foreach ( $source_parts as $value ) {
 981+ if ( preg_match( "/cc[0-9]/", $value )) {
 982+ $fix_optouts = true;
 983+ }
 984+ }
 985+ if ( !$fix_optouts ) {
 986+ return;
 987+ }
 988+
 989+ $data['optout'] = ($data['optout'] == "1") ? '0' : '1';
 990+ $data['anonymous'] = ($data['anonymous'] == "1") ? '0' : '1';
 991+
 992+ $db = payflowGatewayConnection();
 993+
 994+ if (!$db) { return true ; }
 995+
 996+ $tracked_contribution = array(
 997+ 'note' => $data['comment'],
 998+ 'referrer' => $data['referrer'],
 999+ 'anonymous' => $data['anonymous'],
 1000+ 'utm_source' => $data['utm_source'],
 1001+ 'utm_medium' => $data['utm_medium'],
 1002+ 'utm_campaign' => $data['utm_campaign'],
 1003+ 'optout' => $data['optout'],
 1004+ 'language' => $data['language'],
 1005+ );
 1006+
 1007+ // Make all empty strings NULL
 1008+ foreach ($tracked_contribution as $key => $value) {
 1009+ if ($value === '') {
 1010+ $tracked_contribution[$key] = null;
 1011+ }
 1012+ }
 1013+
 1014+ $db->update( 'contribution_tracking', $tracked_contribution, array( 'id' => $data[ 'contribution_tracking_id' ] ));
 1015+ }
9651016 } // end class
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter.php
@@ -69,8 +69,8 @@
7070
7171 // email agreement
7272 $form .= '<tr>';
73 - $form .= '<td>' . Xml::check( 'opt', TRUE ) . '</td>';
74 - $form .= '<td>' . Xml::label( wfMsg( 'donate_interface-email-agreement' ), 'opt' ) . '</td>';
 73+ $form .= '<td>' . Xml::check( 'email-opt', TRUE ) . '</td>';
 74+ $form .= '<td>' . Xml::label( wfMsg( 'donate_interface-email-agreement' ), 'email-opt' ) . '</td>';
7575 $form .= '</tr>';
7676
7777 $form .= Xml::closeElement( 'table' );
Index: trunk/extensions/DonationInterface/donate_interface/donate_interface.php
@@ -192,7 +192,7 @@
193193 Xml::checkLabel( wfMsg( 'donate_interface-anon-message' ), 'comment-option', 'input_comment-option', TRUE ) .
194194 Xml::closeElement( 'div' ) .
195195 Xml::openElement( 'div', array( 'id' => 'mw-donation-checkbox' )) .
196 - Xml::check( 'email', TRUE ) .
 196+ Xml::check( 'email-opt', TRUE ) .
197197 Xml::tags( 'span', array( 'class' => 'mw-email-agreement' ), wfMsg( 'donate_interface-email-agreement' )) .
198198 Xml::closeElement( 'div' );
199199

Status & tagging log