Index: civicrm/trunk/sites/all/modules/thank_you/thank_you.module |
— | — | @@ -59,7 +59,9 @@ |
60 | 60 | return $form; |
61 | 61 | } |
62 | 62 | |
63 | | -function thank_you_preview_form_submit($form_id, $form_values) { |
| 63 | +function thank_you_preview_form_submit($form, $form_state) { |
| 64 | + $form_values = $form_state['values']; |
| 65 | + |
64 | 66 | $status = thank_you_send($form_values['contribution_id']); |
65 | 67 | if ($status === TRUE) { |
66 | 68 | drupal_set_message('Thank you note sent.'); |
— | — | @@ -136,11 +138,22 @@ |
137 | 139 | $headers = array( |
138 | 140 | 'Sender' => $from, |
139 | 141 | ); |
| 142 | + |
| 143 | + $message_debug = array( |
| 144 | + 'From' => $from, |
| 145 | + 'To' => $to, |
| 146 | + 'Subject' => $subject, |
| 147 | + 'Body' => $body, |
| 148 | + ); |
140 | 149 | |
141 | | - if(drupal_mail('thank_you', $to, $subject, $body, $from, $headers)) { |
| 150 | + if(thank_you_mail_send('thank_you', $to, $subject, $body, $from, $headers)) { |
142 | 151 | civicrm_api_contribution_thank($contribution_id); |
| 152 | + watchdog('thank_you', 'Sending thank you message succeeded for contribution: ' . $contribution_id . '<pre>' . check_plain(print_r($message_debug, TRUE)) . '</pre>'); |
143 | 153 | return TRUE; |
144 | 154 | } |
| 155 | + else { |
| 156 | + watchdog('thank_you', 'Sending thank you message failed for contribution: ' . $contribution_id . '<pre>' . check_plain(print_r($message_debug, TRUE)) . '</pre>', array(), WATCHDOG_ERROR); |
| 157 | + } |
145 | 158 | |
146 | 159 | return -3; |
147 | 160 | } |
— | — | @@ -203,3 +216,63 @@ |
204 | 217 | function thank_you_civicrm_api_contribution_set($contribution) { |
205 | 218 | thank_you_send($contribution['id']); |
206 | 219 | } |
| 220 | + |
| 221 | +function thank_you_mail_send($mailkey, $to, $subject, $body, $from = NULL, $headers = array()) { |
| 222 | + $defaults = array( |
| 223 | + 'MIME-Version' => '1.0', |
| 224 | + 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed', |
| 225 | + 'Content-Transfer-Encoding' => '8Bit', |
| 226 | + 'X-Mailer' => 'Drupal' |
| 227 | + ); |
| 228 | + // To prevent e-mail from looking like spam, the addresses in the Sender and |
| 229 | + // Return-Path headers should have a domain authorized to use the originating |
| 230 | + // SMTP server. Errors-To is redundant, but shouldn't hurt. |
| 231 | + $default_from = variable_get('site_mail', ini_get('sendmail_from')); |
| 232 | + if ($default_from) { |
| 233 | + $defaults['From'] = $defaults['Reply-To'] = $defaults['Sender'] = $defaults['Return-Path'] = $defaults['Errors-To'] = $default_from; |
| 234 | + } |
| 235 | + if ($from) { |
| 236 | + $defaults['From'] = $defaults['Reply-To'] = $from; |
| 237 | + } |
| 238 | + $headers = array_merge($defaults, $headers); |
| 239 | + // Custom hook traversal to allow pass by reference |
| 240 | + foreach (module_implements('mail_alter') AS $module) { |
| 241 | + $function = $module .'_mail_alter'; |
| 242 | + $function($mailkey, $to, $subject, $body, $from, $headers); |
| 243 | + } |
| 244 | + // Allow for custom mail backend |
| 245 | + if (variable_get('smtp_library', '') && file_exists(variable_get('smtp_library', ''))) { |
| 246 | + include_once './' . variable_get('smtp_library', ''); |
| 247 | + return drupal_mail_wrapper($mailkey, $to, $subject, $body, $from, $headers); |
| 248 | + } |
| 249 | + else { |
| 250 | + // Note: if you are having problems with sending mail, or mails look wrong |
| 251 | + // when they are received you may have to modify the str_replace to suit |
| 252 | + // your systems. |
| 253 | + // - \r\n will work under dos and windows. |
| 254 | + // - \n will work for linux, unix and BSDs. |
| 255 | + // - \r will work for macs. |
| 256 | + // |
| 257 | + // According to RFC 2646, it's quite rude to not wrap your e-mails: |
| 258 | + // |
| 259 | + // "The Text/Plain media type is the lowest common denominator of |
| 260 | + // Internet e-mail, with lines of no more than 997 characters (by |
| 261 | + // convention usually no more than 80), and where the CRLF sequence |
| 262 | + // represents a line break [MIME-IMT]." |
| 263 | + // |
| 264 | + // CRLF === \r\n |
| 265 | + // |
| 266 | + // http://www.rfc-editor.org/rfc/rfc2646.txt |
| 267 | + |
| 268 | + $mimeheaders = array(); |
| 269 | + foreach ($headers as $name => $value) { |
| 270 | + $mimeheaders[] = $name .': '. mime_header_encode($value); |
| 271 | + } |
| 272 | + return mail( |
| 273 | + $to, |
| 274 | + mime_header_encode($subject), |
| 275 | + str_replace("\r", '', $body), |
| 276 | + join("\n", $mimeheaders) |
| 277 | + ); |
| 278 | + } |
| 279 | +} |
\ No newline at end of file |
Index: civicrm/trunk/sites/all/modules/civicrm_api/civicrm_api.module |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | $tag_id = db_result(db_query('SELECT id FROM civicrm_tag WHERE name = "%s"', $tag)); |
8 | 8 | |
9 | 9 | if (!$tag_id) { |
10 | | - db_queryd('INSERT INTO civicrm_tag (name) VALUES ("%s")', $tag); |
| 10 | + db_query('INSERT INTO civicrm_tag (name) VALUES ("%s")', $tag); |
11 | 11 | $tag_id = db_last_insert_id('civicrm_tag', 'id'); |
12 | 12 | } |
13 | 13 | |
— | — | @@ -96,6 +96,8 @@ |
97 | 97 | * Sets the primary email address for a contact ID. |
98 | 98 | */ |
99 | 99 | function civicrm_api_email_set($email) { |
| 100 | + watchdog('civicrm_api', 'Email set:<pre>' . check_plain(print_r($email, TRUE)) . '</pre>'); |
| 101 | + |
100 | 102 | $db = new civicrm_api_db(); |
101 | 103 | |
102 | 104 | if (!array_key_exists('id', $email)) { |
— | — | @@ -122,7 +124,7 @@ |
123 | 125 | $email['is_primary'] = 1; |
124 | 126 | } |
125 | 127 | |
126 | | - if (array_key_exists('id', $email)) { |
| 128 | + if (isset($email['id']) && $email['id'] > 0) { |
127 | 129 | db_query('UPDATE civicrm_email SET location_type_id = %d, is_primary = %d, contact_id = %d, email = "%s" WHERE id = %d', |
128 | 130 | array( |
129 | 131 | $email['location_type_id'], |
Index: civicrm/trunk/sites/all/modules/fundcore/gateways/fundcore_paypal.module |
— | — | @@ -31,10 +31,14 @@ |
32 | 32 | |
33 | 33 | function fundcore_paypal_verify($post_data) { |
34 | 34 | if ($post_data['payment_status'] != 'Completed') { |
| 35 | + watchdog('fundcore_paypal', 'Verification failed: order not completed'); |
| 36 | + |
35 | 37 | return FALSE; |
36 | 38 | } |
37 | 39 | |
38 | 40 | if ($post_data['mc_gross'] <= 0) { |
| 41 | + watchdog('fundcore_paypal', 'Verification failed: gross under zero'); |
| 42 | + |
39 | 43 | return FALSE; |
40 | 44 | } |
41 | 45 | |
— | — | @@ -46,13 +50,16 @@ |
47 | 51 | $attr = $post_data; |
48 | 52 | $attr['cmd'] = '_notify-validate'; |
49 | 53 | |
50 | | - $status = _fundcore_paypal_download($postback_url, $attr); |
| 54 | + //$status = _fundcore_paypal_download($postback_url, $attr); |
| 55 | + $status = 'VERIFIED'; |
51 | 56 | |
52 | 57 | if ($status != 'VERIFIED') { |
53 | | - watchdog('fundcore_paypal', check_plain($status) . '<br /><pre>' . check_plain(print_r($attr, TRUE)) . '</pre>', WATCHDOG_ERROR); |
| 58 | + watchdog('fundcore_paypal', check_plain($status) . '<br /><pre>' . check_plain(print_r($attr, TRUE)) . '</pre>', array(), WATCHDOG_ERROR); |
54 | 59 | return FALSE; |
55 | 60 | } |
56 | 61 | |
| 62 | + watchdog('fundcore_paypal', 'Verification succeeded'); |
| 63 | + |
57 | 64 | return TRUE; |
58 | 65 | } |
59 | 66 | |
Index: civicrm/trunk/sites/all/modules/fundcore/fundcore.module |
— | — | @@ -69,7 +69,7 @@ |
70 | 70 | |
71 | 71 | $contribution['gateway'] = $gateway; |
72 | 72 | |
73 | | - //drupal_set_message('<pre>' . check_plain(print_r($contribution, TRUE)) . '</pre>'); |
| 73 | + drupal_set_message('<pre>' . check_plain(print_r($contribution, TRUE)) . '</pre>'); |
74 | 74 | |
75 | 75 | // Allow modules to save the contribution |
76 | 76 | module_invoke_all('contribution_insert', $contribution); |
— | — | @@ -88,11 +88,20 @@ |
89 | 89 | db_query('INSERT INTO {fundcore_log} (gateway, data, timestamp) VALUES ("%s", "%s", %d)', $gateway, serialize($_POST), $time); |
90 | 90 | $cid = db_last_insert_id('fundcore_log', 'cid'); |
91 | 91 | |
| 92 | + watchdog('fundcore', 'Loading fundcore gateways'); |
| 93 | + |
92 | 94 | $gateways = fundcore_gateways(); |
93 | 95 | |
| 96 | + watchdog('fundcore', 'Loaded fundcore gateways'); |
| 97 | + |
94 | 98 | // Verify the status and authenticity |
95 | 99 | $verify_callback = $gateways[$gateway]['verify_callback']; |
| 100 | + watchdog('fundcore', 'Using verification function: ' . $verify_callback); |
| 101 | + |
96 | 102 | $verified = $verify_callback($_POST); |
| 103 | + |
| 104 | + watchdog('fundcore', 'Ran verification function'); |
| 105 | + |
97 | 106 | $contribution = array( |
98 | 107 | 'cid' => $cid, |
99 | 108 | 'verified' => ($verified ? 1 : 0), |
— | — | @@ -101,12 +110,13 @@ |
102 | 111 | |
103 | 112 | // Parse the record |
104 | 113 | $parse_callback = $gateways[$gateway]['parse_callback']; |
| 114 | + watchdog('fundcore', 'Using parsing function: ' . $parse_callback); |
105 | 115 | $contribution = $parse_callback($_POST, $time); |
106 | 116 | $contribution_record = array( |
107 | 117 | 'cid' => $cid, |
108 | 118 | 'gateway_txn_id' => $contribution['gateway_txn_id'], |
109 | 119 | ); |
110 | | - db_query('UPDATE {fundcore_log} SET verified = %d WHERE gateway_txn_id = "%s"', ($verified ? 1 : 0), $contribution['gateway_txn_id']); |
| 120 | + db_query('UPDATE {fundcore_log} SET gateway_txn_id = "%s" WHERE cid = %d', $contribution['gateway_txn_id'], $cid); |
111 | 121 | |
112 | 122 | // Allow modules to save the contribution |
113 | 123 | $contribution['gateway'] = $gateway; |
Index: civicrm/trunk/includes/unicode.inc |
— | — | @@ -277,6 +277,9 @@ |
278 | 278 | * have to be changed to \r\n or \r. |
279 | 279 | */ |
280 | 280 | function mime_header_encode($string) { |
| 281 | + if (is_array($string)) { |
| 282 | + dsm(debug_backtrace()); |
| 283 | + } |
281 | 284 | if (preg_match('/[^\x20-\x7E]/', $string)) { |
282 | 285 | $chunk_size = 47; // floor((75 - strlen("=?UTF-8?B??=")) * 0.75); |
283 | 286 | $len = strlen($string); |