Index: trunk/extensions/ContributionTracking/countryCodes.inc |
— | — | @@ -1,254 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * List of ISO numeric country codes to display as select menu to user |
6 | | - * needed to translate country to name-value pair 3-digit variable |
7 | | - */ |
8 | | -function countryCodes() { |
9 | | - $countryCode = array( |
10 | | - '840' => 'United States', |
11 | | - '124' => 'Canada', |
12 | | - '826' => 'United Kingdom', |
13 | | - '004' => 'Afghanistan', |
14 | | - '008' => 'Albania', |
15 | | - '012' => 'Algeria', |
16 | | - '016' => 'American Samoa', |
17 | | - '020' => 'Andorra', |
18 | | - '024' => 'Angola', |
19 | | - '660' => 'Anguilla', |
20 | | - '010' => 'Antarctica', |
21 | | - '028' => 'Antigua and Barbuda', |
22 | | - '032' => 'Argentina', |
23 | | - '051' => 'Armenia', |
24 | | - '533' => 'Aruba', |
25 | | - '036' => 'Australia', |
26 | | - '040' => 'Austria', |
27 | | - '031' => 'Azerbaijan', |
28 | | - '044' => 'Bahamas', |
29 | | - '048' => 'Bahrain', |
30 | | - '050' => 'Bangladesh', |
31 | | - '052' => 'Barbados', |
32 | | - '112' => 'Belarus', |
33 | | - '056' => 'Belgium', |
34 | | - '084' => 'Belize', |
35 | | - '204' => 'Benin', |
36 | | - '060' => 'Bermuda', |
37 | | - '064' => 'Bhutan', |
38 | | - '068' => 'Bolivia, Plurinational State of', |
39 | | - '070' => 'Bosnia and Herzegovina', |
40 | | - '072' => 'Botswana', |
41 | | - '074' => 'Bouvet Island', |
42 | | - '076' => 'Brazil', |
43 | | - '086' => 'British Indian Ocean Territory', |
44 | | - '096' => 'Brunei Darussalam', |
45 | | - '100' => 'Bulgaria', |
46 | | - '854' => 'Burkina Faso', |
47 | | - '108' => 'Burundi', |
48 | | - '116' => 'Cambodia', |
49 | | - '120' => 'Cameroon', |
50 | | - '124' => 'Canada', |
51 | | - '132' => 'Cape Verde', |
52 | | - '136' => 'Cayman Islands', |
53 | | - '140' => 'Central African Republic', |
54 | | - '148' => 'Chad', |
55 | | - '152' => 'Chile', |
56 | | - '156' => 'China', |
57 | | - '162' => 'Christmas Island', |
58 | | - '166' => 'Cocos (Keeling) Islands', |
59 | | - '017' => 'Colombia', |
60 | | - '174' => 'Comoros', |
61 | | - '178' => 'Congo', |
62 | | - '180' => 'Congo, the Democratic Republic of the', |
63 | | - '184' => 'Cook Islands', |
64 | | - '188' => 'Costa Rica', |
65 | | - '384' => "Cote D'Ivoire", |
66 | | - '191' => 'Croatia', |
67 | | - '192' => 'Cuba', |
68 | | - '196' => 'Cyprus', |
69 | | - '203' => 'Czech Republic', |
70 | | - '208' => 'Denmark', |
71 | | - '262' => 'Djibouti', |
72 | | - '212' => 'Dominica', |
73 | | - '214' => 'Dominican Republic', |
74 | | - '626' => 'East Timor', |
75 | | - '218' => 'Ecuador', |
76 | | - '818' => 'Egypt', |
77 | | - '222' => 'El Salvador', |
78 | | - '226' => 'Equatorial Guinea', |
79 | | - '232' => 'Eritrea', |
80 | | - '233' => 'Estonia', |
81 | | - '231' => 'Ethiopia', |
82 | | - '238' => 'Falkland Islands (Malvinas)', |
83 | | - '234' => 'Faroe Islands', |
84 | | - '242' => 'Fiji', |
85 | | - '246' => 'Finland', |
86 | | - '250' => 'France', |
87 | | - '254' => 'French Guiana', |
88 | | - '258' => 'French Polynesia', |
89 | | - '260' => 'French Southern Territories', |
90 | | - '266' => 'Gabon', |
91 | | - '270' => 'Gambia', |
92 | | - '268' => 'Georgia', |
93 | | - '276' => 'Germany', |
94 | | - '288' => 'Ghana', |
95 | | - '292' => 'Gibraltar', |
96 | | - '300' => 'Greece', |
97 | | - '304' => 'Greenland', |
98 | | - '308' => 'Grenada', |
99 | | - '312' => 'Guadeloupe', |
100 | | - '316' => 'Guam', |
101 | | - '320' => 'Guatemala', |
102 | | - '324' => 'Guinea', |
103 | | - '624' => 'Guinea-Bissau', |
104 | | - '328' => 'Guyana', |
105 | | - '332' => 'Haiti', |
106 | | - '334' => 'Heard Island and McDonald Islands', |
107 | | - '340' => 'Honduras', |
108 | | - '344' => 'Hong Kong', |
109 | | - '348' => 'Hungary', |
110 | | - '352' => 'Iceland', |
111 | | - '356' => 'India', |
112 | | - '360' => 'Indonesia', |
113 | | - '364' => 'Iran, Islamic Republic of', |
114 | | - '368' => 'Iraq', |
115 | | - '372' => 'Ireland', |
116 | | - '376' => 'Israel', |
117 | | - '380' => 'Italy', |
118 | | - '388' => 'Jamaica', |
119 | | - '392' => 'Japan', |
120 | | - '400' => 'Jordan', |
121 | | - '398' => 'Kazakhstan', |
122 | | - '404' => 'Kenya', |
123 | | - '296' => 'Kiribati', |
124 | | - '408' => "Korea, Democratic People's Republic of", |
125 | | - '410' => 'Korea, Republic of', |
126 | | - '414' => 'Kuwait', |
127 | | - '417' => 'Kyrgyzstan', |
128 | | - '418' => 'Laos', |
129 | | - '428' => 'Latvia', |
130 | | - '422' => 'Lebanon', |
131 | | - '426' => 'Lesotho', |
132 | | - '430' => 'Liberia', |
133 | | - '434' => 'Libyan Arab Jamahiriya', |
134 | | - '438' => 'Liechtenstein', |
135 | | - '440' => 'Lithuania', |
136 | | - '442' => 'Luxembourg', |
137 | | - '446' => 'Macao', |
138 | | - '807' => 'Macedonia', |
139 | | - '450' => 'Madagascar', |
140 | | - '454' => 'Malawi', |
141 | | - '458' => 'Malaysia', |
142 | | - '462' => 'Maldives', |
143 | | - '466' => 'Mali', |
144 | | - '470' => 'Malta', |
145 | | - '584' => 'Marshall Islands', |
146 | | - '474' => 'Martinique', |
147 | | - '478' => 'Mauritania', |
148 | | - '480' => 'Mauritius', |
149 | | - '175' => 'Mayotte', |
150 | | - '484' => 'Mexico', |
151 | | - '583' => 'Micronesia, Federated States of', |
152 | | - '498' => 'Moldova, Republic of', |
153 | | - '492' => 'Monaco', |
154 | | - '496' => 'Mongolia', |
155 | | - '499' => 'Montenegro', |
156 | | - '500' => 'Montserrat', |
157 | | - '504' => 'Morocco', |
158 | | - '508' => 'Mozambique', |
159 | | - '104' => 'Myanmar', |
160 | | - '516' => 'Namibia', |
161 | | - '520' => 'Nauru', |
162 | | - '524' => 'Nepal', |
163 | | - '528' => 'Netherlands', |
164 | | - '530' => 'Netherlands Antilles', |
165 | | - '540' => 'New Caledonia', |
166 | | - '554' => 'New Zealand', |
167 | | - '558' => 'Nicaragua', |
168 | | - '562' => 'Niger', |
169 | | - '566' => 'Nigeria', |
170 | | - '570' => 'Niue', |
171 | | - '574' => 'Norfolk Island', |
172 | | - '580' => 'Northern Mariana Islands', |
173 | | - '578' => 'Norway', |
174 | | - '512' => 'Oman', |
175 | | - '586' => 'Pakistan', |
176 | | - '585' => 'Palau', |
177 | | - '591' => 'Panama', |
178 | | - '598' => 'Papua New Guinea', |
179 | | - '600' => 'Paraguay', |
180 | | - '604' => 'Peru', |
181 | | - '608' => 'Philippines', |
182 | | - '612' => 'Pitcairn', |
183 | | - '616' => 'Poland', |
184 | | - '620' => 'Portugal', |
185 | | - '630' => 'Puerto Rico', |
186 | | - '634' => 'Qatar', |
187 | | - '642' => 'Romania', |
188 | | - '643' => 'Russian Federation', |
189 | | - '646' => 'Rwanda', |
190 | | - '659' => 'Saint Kitts and Nevis', |
191 | | - '662' => 'Saint Lucia', |
192 | | - '670' => 'Saint Vincent and the Grenadines', |
193 | | - '882' => 'Samoa', |
194 | | - '674' => 'San Marino', |
195 | | - '678' => 'Sao Tome and Principe', |
196 | | - '682' => 'Saudi Arabia', |
197 | | - '686' => 'Senegal', |
198 | | - '688' => 'Serbia', |
199 | | - '690' => 'Seychelles', |
200 | | - '694' => 'Sierra Leone', |
201 | | - '702' => 'Singapore', |
202 | | - '703' => 'Slovakia', |
203 | | - '705' => 'Slovenia', |
204 | | - '090' => 'Solomon Islands', |
205 | | - '706' => 'Somalia', |
206 | | - '710' => 'South Africa', |
207 | | - //'239' => 'South Georgia and the South Sandwich Islands', |
208 | | - '724' => 'Spain', |
209 | | - '144' => 'Sri Lanka', |
210 | | - '654' => 'Saint Helena', |
211 | | - '666' => 'Saint Pierre and Miquelon', |
212 | | - '736' => 'Sudan', |
213 | | - '740' => 'Suriname', |
214 | | - '744' => 'Svalbard and Jan Mayen', |
215 | | - '748' => 'Swaziland', |
216 | | - '752' => 'Sweden', |
217 | | - '756' => 'Switzerland', |
218 | | - '760' => 'Syrian Arab Republic', |
219 | | - '762' => 'Tajikistan', |
220 | | - '834' => 'Tanzania, United Republic of', |
221 | | - '158' => 'Taiwan', |
222 | | - '764' => 'Thailand', |
223 | | - '768' => 'Togo', |
224 | | - '772' => 'Tokelau', |
225 | | - '776' => 'Tonga', |
226 | | - '780' => 'Trinidad and Tobago', |
227 | | - '788' => 'Tunisia', |
228 | | - '792' => 'Turkey', |
229 | | - '795' => 'Turkmenistan', |
230 | | - '796' => 'Turks and Caicos Islands', |
231 | | - '798' => 'Tuvalu', |
232 | | - '800' => 'Uganda', |
233 | | - '804' => 'Ukraine', |
234 | | - '784' => 'United Arab Emirates', |
235 | | - '826' => 'United Kingdom', |
236 | | - '840' => 'United States', |
237 | | - '581' => 'United States Minor Outlying Islands', |
238 | | - '858' => 'Uruguay', |
239 | | - '860' => 'Uzbekistan', |
240 | | - '548' => 'Vanuatu', |
241 | | - '336' => 'Vatican City State', |
242 | | - '862' => 'Venezuela, Bolivarian Republic of', |
243 | | - '704' => 'Viet Nam', |
244 | | - '092' => 'Virgin Islands, British', |
245 | | - '850' => 'Virgin Islands, U.S.', |
246 | | - '876' => 'Wallis and Futuna', |
247 | | - '732' => 'Western Sahara', |
248 | | - '882' => 'Western Samoa', |
249 | | - '887' => 'Yemen', |
250 | | - '894' => 'Zambia', |
251 | | - '716' => 'Zimbabwe' |
252 | | - ); |
253 | | - |
254 | | - return $countryCode; |
255 | | -} |
Index: trunk/extensions/ContributionTracking/ContributionTracking_body.php |
— | — | @@ -28,23 +28,22 @@ |
29 | 29 | |
30 | 30 | |
31 | 31 | function execute( $language ) { |
32 | | - require_once( 'countryCodes.inc' ); |
33 | 32 | global $wgRequest, $wgOut, $wgContributionTrackingPayPalIPN, $wgContributionTrackingReturnToURLDefault, |
34 | 33 | $wgContributionTrackingPayPalRecurringIPN, $wgContributionTrackingPayPalBusiness; |
35 | | - |
| 34 | + |
36 | 35 | if ( !preg_match( '/^[a-z-]+$/', $language ) ) { |
37 | 36 | $language = 'en'; |
38 | 37 | } |
39 | 38 | $this->lang = Language::factory( $language ); |
40 | | - |
| 39 | + |
41 | 40 | $this->setHeaders(); |
42 | | - |
| 41 | + |
43 | 42 | $gateway = $wgRequest->getText( 'gateway' ); |
44 | 43 | if( !in_array( $gateway, array( 'paypal', 'moneybookers' ) ) ) { |
45 | 44 | $wgOut->showErrorPage( 'contrib-tracking-error', 'contrib-tracking-error-text' ); |
46 | 45 | return; |
47 | 46 | } |
48 | | - |
| 47 | + |
49 | 48 | $db = contributionTrackingConnection(); |
50 | 49 | |
51 | 50 | $ts = $db->timestamp(); |
— | — | @@ -54,14 +53,6 @@ |
55 | 54 | $owa_ref = $this->get_owa_ref_id($owa_ref); |
56 | 55 | } |
57 | 56 | |
58 | | - // Translate the shipping country from a code to a country name |
59 | | - $country = ''; |
60 | | - $code = $wgRequest->getText('country2'); |
61 | | - if ( $code ) { |
62 | | - $countries = countryCodes(); |
63 | | - $country = $countries[$code]; |
64 | | - } |
65 | | - |
66 | 57 | $tracked_contribution = array( |
67 | 58 | 'note' => $wgRequest->getText('comment', null), |
68 | 59 | 'referrer' => $wgRequest->getText('referrer', null), |
— | — | @@ -71,25 +62,24 @@ |
72 | 63 | 'utm_campaign' => $wgRequest->getText('utm_campaign', null), |
73 | 64 | 'optout' => ($wgRequest->getCheck('email-opt', 0) ? 0 : 1), |
74 | 65 | 'language' => $wgRequest->getText('language', null), |
75 | | - 'country' => $country, |
76 | 66 | 'owa_session' => $wgRequest->getText('owa_session', null), |
77 | 67 | 'owa_ref' => $owa_ref, |
78 | 68 | 'ts' => $ts, |
79 | 69 | ); |
80 | | - |
| 70 | + |
81 | 71 | // Make all empty strings NULL |
82 | 72 | foreach ($tracked_contribution as $key => $value) { |
83 | 73 | if ($value === '') { |
84 | 74 | $tracked_contribution[$key] = null; |
85 | 75 | } |
86 | 76 | } |
87 | | - |
| 77 | + |
88 | 78 | // Store the contribution data |
89 | 79 | if ( !$wgRequest->getVal( 'contribution_tracking_id', 0 )) { |
90 | 80 | $db->insert( 'contribution_tracking', $tracked_contribution ); |
91 | 81 | } |
92 | 82 | $contribution_tracking_id = $wgRequest->getVal( 'contribution_tracking_id', $db->insertId()); |
93 | | - |
| 83 | + |
94 | 84 | $returnText = $wgRequest->getText( 'returnto', "Donate-thanks/$language" ); |
95 | 85 | $returnTitle = Title::newFromText( $returnText ); |
96 | 86 | if( $returnTitle ) { |
— | — | @@ -97,13 +87,13 @@ |
98 | 88 | } else { |
99 | 89 | $returnto = $wgContributionTrackingReturnToURLDefault . "/$language"; |
100 | 90 | } |
101 | | - |
| 91 | + |
102 | 92 | // Set the action and tracking ID fields |
103 | 93 | $repost = array(); |
104 | 94 | $action = 'http://wikimediafoundation.org/'; |
105 | 95 | $amount_field_name = 'amount'; // the amount fieldname may be different depending on the service |
106 | 96 | if ( $gateway == 'paypal' ) { |
107 | | - |
| 97 | + |
108 | 98 | $action = 'https://www.paypal.com/cgi-bin/webscr'; |
109 | 99 | |
110 | 100 | // Premiums |
— | — | @@ -114,25 +104,25 @@ |
115 | 105 | $repost['os1'] = $wgRequest->getText( 'premium_language' ); |
116 | 106 | $repost['no_shipping'] = 2; |
117 | 107 | } |
118 | | - |
| 108 | + |
119 | 109 | // PayPal |
120 | 110 | $repost['business'] = $wgContributionTrackingPayPalBusiness; |
121 | 111 | $repost['item_number'] = 'DONATE'; |
122 | 112 | $repost['no_note'] = '0'; |
123 | 113 | $repost['return'] = $returnto; |
124 | 114 | $repost['currency_code'] = $wgRequest->getText( 'currency_code', 'USD' ); |
125 | | - |
| 115 | + |
126 | 116 | // additional fields to pass to PayPal from single-step credit card form |
127 | 117 | $repost[ 'first_name' ] = $wgRequest->getText( 'fname', null ); |
128 | 118 | $repost[ 'last_name' ] = $wgRequest->getText( 'lname', null ); |
129 | 119 | $repost[ 'email' ] = $wgRequest->getText( 'email', null ); |
130 | | - |
| 120 | + |
131 | 121 | // if this is a recurring donation, we have add'l fields to send to paypal |
132 | 122 | if ( $wgRequest->getText( 'recurring_paypal' ) == 'true' ) { |
133 | 123 | $repost[ 't3' ] = "M"; // The unit of measurement for for p3 (M = month) |
134 | 124 | $repost[ 'p3' ] = '1'; // Billing cycle duration |
135 | 125 | $repost[ 'srt' ] = '12'; // # of billing cycles |
136 | | - $repost[ 'src' ] = '1'; // Make this 'recurring' |
| 126 | + $repost[ 'src' ] = '1'; // Make this 'recurring' |
137 | 127 | $repost[ 'sra' ] = '1'; // Turn on re-attempt on failure |
138 | 128 | $repost[ 'cmd' ] = '_xclick-subscriptions'; |
139 | 129 | $amount_field_name = 'a3'; |
— | — | @@ -144,7 +134,7 @@ |
145 | 135 | $repost['item_name'] = $this->msg( 'contrib-tracking-item-name-onetime' ); |
146 | 136 | } |
147 | 137 | } |
148 | | - elseif ( $gateway == 'moneybookers' ) { |
| 138 | + else if ( $gateway == 'moneybookers' ) { |
149 | 139 | $action = 'https://www.moneybookers.com/app/payment.pl'; |
150 | 140 | |
151 | 141 | // Tracking |
— | — | @@ -160,28 +150,28 @@ |
161 | 151 | } else { |
162 | 152 | throw new MWException( "This shouldn't happen, we validated the gateway earlier." ); |
163 | 153 | } |
164 | | - |
| 154 | + |
165 | 155 | // Normalized amount |
166 | 156 | $repost[ $amount_field_name ] = $wgRequest->getVal( 'amount' ); |
167 | 157 | if ( $wgRequest->getVal( 'amountGiven' ) ) { |
168 | 158 | $repost[ $amount_field_name ] = $wgRequest->getVal( 'amountGiven' ); |
169 | 159 | } |
170 | | - |
| 160 | + |
171 | 161 | // Tracking |
172 | 162 | $repost['custom'] = $contribution_tracking_id; |
173 | | - |
| 163 | + |
174 | 164 | $wgOut->addWikiText( "{{2009/Donate-banner/$language}}" ); |
175 | 165 | $wgOut->addHTML( $this->msgWiki( 'contrib-tracking-submitting' ) ); |
176 | | - |
| 166 | + |
177 | 167 | // Output the repost form |
178 | 168 | $output = '<form method="post" name="contributiontracking" action="' . $action . '">'; |
179 | 169 | |
180 | 170 | foreach ( $repost as $key => $value ) { |
181 | 171 | $output .= '<input type="hidden" name="' . htmlspecialchars($key) . '" value="' . htmlspecialchars($value) . '" />'; |
182 | 172 | } |
183 | | - |
| 173 | + |
184 | 174 | $output .= $this->msgWiki( 'contrib-tracking-redirect' ); |
185 | | - |
| 175 | + |
186 | 176 | // Offer a button to post the form if the user has no Javascript support |
187 | 177 | $output .= '<noscript>'; |
188 | 178 | $output .= $this->msgWiki( 'contrib-tracking-continue' ); |