Index: civicrm/trunk/sites/all/modules/queue2civicrm/queue2civicrm_common.inc |
— | — | @@ -271,6 +271,12 @@ |
272 | 272 | 'contribution_recur_id' => $recur_id |
273 | 273 | ); |
274 | 274 | |
| 275 | + watchdog( 'queue2civicrm', 'Contribution array for civicrm_contribution_add(): ' . print_r($contribution, TRUE)); |
| 276 | + |
| 277 | + $contribution_result = civicrm_contribution_add( $contribution ); |
| 278 | + |
| 279 | + watchdog( 'queue2civicrm', 'Contribution result from civicrm_contribution_add(): ' . print_r($contribution_result, TRUE)); |
| 280 | + |
275 | 281 | /** |
276 | 282 | * Apply custom field defaults. |
277 | 283 | * |
— | — | @@ -281,23 +287,22 @@ |
282 | 288 | * |
283 | 289 | * At the moment, all custom fields get default values for online contribution EXCEPT for 'Donor Comment'. |
284 | 290 | */ |
285 | | - $query = "SELECT id, custom_group_id, label, default_value FROM civicrm_custom_field WHERE custom_group_id IN (SELECT id FROM civicrm_custom_group WHERE extends='Contribution' && is_active='1');"; |
| 291 | + $dbs = _queue2civicrm_get_dbs(); |
| 292 | + $dbs->use_civicrm(); |
| 293 | + $query = "SELECT id, custom_group_id, label, default_value, table_name FROM civicrm_custom_field WHERE custom_group_id IN (SELECT id FROM civicrm_custom_group WHERE extends='Contribution' && is_active='1');"; |
286 | 294 | $dao = CRM_Core_DAO::executeQuery( $query ); // Execute's query using CiviCRM data object stuff |
287 | 295 | while ( $dao->fetch() ) { |
288 | 296 | if ( $dao->label == 'Donor Comment' ) { |
289 | 297 | $comment = ( $msg[ 'comment' ] ) ? $msg[ 'comment'] : ''; |
290 | | - $contribution[ 'custom_' . $dao->id ] = $comment; |
| 298 | + $query = "INSERT INTO {" . $dao->table_name . "} (entity_id, donor_comment) VALUES ( %d, '%s' )"; |
| 299 | + db_query( $query, $contribution[ 'id' ], $comment ); |
291 | 300 | } elseif ( $dao->default_value ) { // if we dont make sure $dao->default_value has some value, Civi breaks when we try to insert |
292 | | - $contribution[ 'custom_' . $dao->id ] = $dao->default_value; |
| 301 | + $query = "INSERT INTO {" . $dao->table_name . "} (entity_id) VALUES (%d)"; |
| 302 | + db_query( $query, $contribution[ 'id' ] ); |
293 | 303 | } |
294 | 304 | } |
295 | | - |
296 | | - watchdog( 'queue2civicrm', 'Contribution array for civicrm_contribution_add(): ' . print_r($contribution, TRUE)); |
| 305 | + $dbs->use_default(); |
297 | 306 | |
298 | | - $contribution_result = civicrm_contribution_add( $contribution ); |
299 | | - |
300 | | - watchdog( 'queue2civicrm', 'Contribution result from civicrm_contribution_add(): ' . print_r($contribution_result, TRUE)); |
301 | | - |
302 | 307 | return $contribution_result; |
303 | 308 | } |
304 | 309 | |