r76045 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76044‎ | r76045 | r76046 >
Date:21:36, 4 November 2010
Author:nimishg
Status:deferred
Tags:
Comment:
merged OWA branch code
Modified paths:
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/Form.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/owa_get_info.js (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js
@@ -1,14 +1,14 @@
22 //<![CDATA[
3 -function addEvent(obj, evType, fn){
4 - if (obj.addEventListener){
5 - obj.addEventListener(evType, fn, false);
6 - return true;
7 - } else if (obj.attachEvent){
8 - var r = obj.attachEvent("on"+evType, fn);
9 - return r;
10 - } else {
11 - return false;
12 - }
 3+function addEvent(obj, evType, fn){
 4+ if (obj.addEventListener){
 5+ obj.addEventListener(evType, fn, false);
 6+ return true;
 7+ } else if (obj.attachEvent){
 8+ var r = obj.attachEvent("on"+evType, fn);
 9+ return r;
 10+ } else {
 11+ return false;
 12+ }
1313 }
1414
1515 function getIfSessionSet() {
@@ -21,24 +21,7 @@
2222 field.style.color = 'black';
2323 }
2424 }
25 -function clearField2( field, defaultValue ) {
26 - if (field.value != defaultValue) {
27 - field.value = '';
28 - field.style.color = 'black';
29 - }
30 -}
3125
32 -function switchToPayPal() {
33 - document.getElementById('payflow-table-cc').style.display = 'none';
34 - document.getElementById('payflowpro_gateway-form-submit').style.display = 'none';
35 - document.getElementById('payflowpro_gateway-form-submit-paypal').style.display = 'block';
36 -}
37 -function switchToCreditCard() {
38 - document.getElementById('payflow-table-cc').style.display = 'table';
39 - document.getElementById('payflowpro_gateway-form-submit').style.display = 'block';
40 - document.getElementById('payflowpro_gateway-form-submit-paypal').style.display = 'none';
41 -}
42 -
4326 function validate_form( form ) {
4427 var msg = [ 'EmailAdd', 'Fname', 'Lname', 'Street', 'City', 'State', 'Zip', 'CardNum', 'Cvv' ];
4528
@@ -54,7 +37,7 @@
5538 output += payflowproGatewayErrorMsgJs + ' ' + currField + '.\r\n';
5639 }
5740 }
58 -
 41+
5942 //set state to "outside us"
6043 if ( document.payment.country.value != '840' ) {
6144 document.payment.state.value = 'XX';
@@ -72,8 +55,8 @@
7356 if( output ) {
7457 alert( output );
7558 return false;
76 - }
77 -
 59+ }
 60+
7861 return true;
7962 }
8063
@@ -100,7 +83,7 @@
10184
10285 function PopupCVV() {
10386 cvv = window.open("", 'cvvhelp','scrollbars=yes,resizable=yes,width=600,height=400,left=200,top=100');
104 - cvv.document.write( payflowproGatewayCVVExplain );
 87+ cvv.document.write( payflowproGatewayCVVExplain );
10588 cvv.focus();
10689 }
10790
@@ -111,5 +94,5 @@
11295 }
11396 }
11497
115 -window.onfocus = CloseCVV;
 98+window.onfocus = CloseCVV;
11699 //]]>
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
@@ -384,7 +384,7 @@
385385 global $wgOut, $wgDonationTestingMode, $wgPayflowGatewayUseHTTPProxy, $wgPayflowGatewayHTTPProxy;
386386
387387 // update contribution tracking
388 - $this->updateContributionTracking( $data );
 388+ $this->updateContributionTracking( $data, defined( 'OWA' ) );
389389
390390 // create payflow query string, include string lengths
391391 $queryArray = array(
@@ -919,6 +919,36 @@
920920 wfSetupSession();
921921 }
922922
 923+
 924+/**
 925+ * Fetches ID for reference URL for OWA tracking
 926+ *
 927+ * In the event that the URL is not already in the database, insert it
 928+ * and return it's id. Otehrewise, just return its id.
 929+ * @param string $ref The reference URL
 930+ * @return int The id for the reference URL - 0 if not found
 931+ */
 932+ function get_owa_ref_id( $ref ) {
 933+ // Replication lag means sometimes a new event will not exist in the table yet
 934+ $dbw = contributionTrackingConnection();
 935+ $id_num = $dbw->selectField(
 936+ 'contribution_tracking_owa_ref',
 937+ 'id',
 938+ array( 'url' => $ref ),
 939+ __METHOD__
 940+ );
 941+ // Once we're on mysql 5, we can use replace() instead of this selectField --> insert or update hooey
 942+ if ( $id_num === false ) {
 943+ $dbw->insert(
 944+ 'contribution_tracking_owa_ref',
 945+ array( 'url' => (string) $ref ),
 946+ __METHOD__
 947+ );
 948+ $id_num = $dbw->insertId();
 949+ }
 950+ return $id_num === false ? 0 : $id_num;
 951+ }
 952+
923953 /**
924954 * Populate the $data array for the credit card form
925955 *
@@ -928,6 +958,12 @@
929959 public function fnGetFormData( $amount, $numAttempt, $token, $order_id ) {
930960 global $wgPayflowGatewayTest, $wgRequest;
931961
 962+ // fetch ID for the url reference for OWA tracking
 963+ $owa_ref = $wgRequest->getText( 'owa_ref', null );
 964+ if( $owa_ref != null && !is_numeric( $owa_ref )){
 965+ $owa_ref = $this->get_owa_ref_id( $owa_ref );
 966+ }
 967+
932968 // if we're in testing mode and an action hasn't yet be specified, prepopulate the form
933969 if ( !$wgRequest->getText( 'action', false ) && !$numAttempt && $wgPayflowGatewayTest ) {
934970 // define arrays of cc's and cc #s for random selection
@@ -978,6 +1014,8 @@
9791015 'data_hash' => $wgRequest->getText( 'data_hash' ),
9801016 'action' => $wgRequest->getText( 'action' ),
9811017 'gateway' => 'payflowpro',
 1018+ 'owa_session' => $wgRequest->getText( 'owa_session', null ),
 1019+ 'owa_ref' => $owa_ref,
9821020 );
9831021 } else {
9841022 $data = array(
@@ -1015,6 +1053,8 @@
10161054 'data_hash' => $wgRequest->getText( 'data_hash' ),
10171055 'action' => $wgRequest->getText( 'action' ),
10181056 'gateway' => 'payflowpro', // this may need to become dynamic in the future
 1057+ 'owa_session' => $wgRequest->getText( 'owa_session', null ),
 1058+ 'owa_ref' => $owa_ref,
10191059 );
10201060 }
10211061 return $data;
@@ -1133,6 +1173,8 @@
11341174 'utm_source' => $data['utm_source'],
11351175 'utm_medium' => $data['utm_medium'],
11361176 'utm_campaign' => $data['utm_campaign'],
 1177+ 'owa_session' => $data['owa_session'],
 1178+ 'owa_ref' => $data['owa_ref'],
11371179 'optout' => $optout[ 'optout' ],
11381180 'language' => $data['language'],
11391181 );
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/Form.php
@@ -65,6 +65,15 @@
6666 $this->setStylePath();
6767 }
6868 $wgOut->addExtensionStyle( $this->getStylePath() );
 69+ /**
 70+ * if OWA is enabled, load the JS.
 71+ *
 72+ * We do this here (rather than in individual forms) because if OWA is
 73+ * enabled, we ALWAYS want to make sure it gets included.
 74+ */
 75+ if(defined('OWA')){
 76+ $this->loadOwaJs();
 77+ }
6978 }
7079
7180 /**
@@ -351,6 +360,8 @@
352361 'contribution_tracking_id' => $this->form_data[ 'contribution_tracking_id' ],
353362 'data_hash' => $this->form_data[ 'data_hash' ],
354363 'action' => $this->form_data[ 'action' ],
 364+ 'owa_session' => $this->form_data[ 'owa_session' ],
 365+ 'owa_ref' => $this->form_data[ 'owa_ref' ],
355366 );
356367 }
357368
@@ -651,6 +662,20 @@
652663 '/extensions/DonationInterface/payflowpro_gateway/pfp_api_controller.js?284"></script>' );
653664 }
654665
 666+ protected function loadOwaJs() {
 667+ global $wgOut, $wgScriptPath;
 668+ $wgOut->addHeadItem('owa_tracker_verts', '<script type="text/javascript" src="http://owa.tesla.usability.wikimedia.org/owa/modules/base/js/owa.tracker-combined-min.js"></script>');
 669+
 670+ $wgOut->addHeadItem( 'owa_get_info', '<script type="text/javascript" src="' .
 671+ $wgScriptPath .
 672+ '/extensions/DonationInterface/payflowpro_gateway/owa_get_info.js?284"></script>' );
 673+ $wgOut->addHeadItem( 'owa_tracker', '<script type="text/javascript" src="' .
 674+ $wgScriptPath .
 675+ '/extensions/DonationInterface/payflowpro_gateway/owa.tracker-combined-min.js?284"></script>' );
 676+
 677+ }
 678+
 679+
655680 /**
656681 * Generate HTML for <noscript> tags
657682 *
Index: trunk/extensions/DonationInterface/payflowpro_gateway/owa_get_info.js
@@ -1,18 +1,7 @@
22 var get_owa_information = function() {
3 -if(OWA.util.readCookie){
4 - var owa_s_val = OWA.util.readCookie("owa_s");
5 - var owa_s_ident = "sid%3D%3E";
6 - var owaS_start_index = owa_s_val.indexOf(owa_s_ident);
7 - //NOTE: This only works as long as sid is the last param in the OWA cookie
8 - if(owaS_start_index >= 0){
9 - var owaSessionID = owa_s_val.substr(owaS_start_index + owa_s_ident.length);
10 - if(document.getElementById("owa_session_id") &&
11 - document.getElementById("owa_pageref") ){ ){
12 - document.getElementById("owa_session_id").value = owaSessionID;
13 - document.getElementById("owa_pageref").value = encode(window.location);
14 - }
15 - }
 3+if(OWA.util.getState){
 4+ jQuery("input[name=owa_session]").val( OWA.util.getState('s', 'sid') );
 5+ jQuery("input[name=owa_ref]").val( escape(window.location) );
166 }
177 };
18 -
198 if(jQuery){jQuery(document).ready(get_owa_information);}

Status & tagging log