? .svn
? userpoints_params_by_ref_and_use_drupal_write_record.patch
? po/.svn
? tests/.svn
? translations/.svn
Index: userpoints.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/userpoints/userpoints.module,v
retrieving revision 1.67.2.26
diff -u -p -r1.67.2.26 userpoints.module
--- userpoints.module	9 Jan 2009 10:02:01 -0000	1.67.2.26
+++ userpoints.module	22 Apr 2009 17:45:57 -0000
@@ -464,7 +464,7 @@ function userpoints_get_max_points($uid 
  *     'status' => FALSE when no action is take, TRUE when points are credited or debited
  *     'reason' => (string) error message to indicate reason for failure
  */
-function userpoints_userpointsapi($params) {
+function userpoints_userpointsapi(&$params) {
 
   //Test for the existence of parameters and set defaults if necessary
   if (!isset($params['txn_id'])) {
@@ -569,7 +569,7 @@ function userpoints_userpointsapi($param
       'reason' => 'transaction failed in _userpoints_transaction, this is an internal module error',
     );
   }
-  
+  dpm($params);
   if ($params['status'] == 1) {
     $mesg = (t('User %uname %op %pointsvalue !points, pending administrator approval.',
       array_merge(userpoints_translation(), array(
@@ -685,24 +685,11 @@ function _userpoints_transaction(&$param
     _userpoints_update_cache($params);
   }
   else {
-    $ret = db_query("INSERT INTO {userpoints_txn}
-      (uid, points, time_stamp, status, operation, description, 
-      reference, expirydate, expired, parent_txn_id, tid, entity_id, entity_type)
-      VALUES (%d, %d, %d, %d, '%s', '%s', '%s', %d, %d, %d, %d, %d, '%s')",
-      $params['uid'],
-      $params['points'],
-      time(),
-      $params['status'],
-      $params['operation'],
-      $params['description'],
-      $params['reference'],
-      $params['expirydate'],
-      $params['expired'], 
-      $params['parent_txn_id'],
-      $params['tid'],
-      $params['entity_id'],
-      $params['entity_type']
-    );
+    //set timestamp if not already set
+    if(!isset($params['time_stamp'])) {
+      $params['time_stamp'] = time();
+    } 
+    $ret = drupal_write_record('userpoints_txn', $params);
     if ($params['status'] != true && $ret != false) {
       _userpoints_update_cache($params);
     }
