--- userpoints.module.ORIG	2007-05-10 12:21:19.000000000 +0800
+++ userpoints.module	2007-05-10 12:37:44.000000000 +0800
@@ -226,7 +226,7 @@ function userpoints_get_current_points($
  *
  * @return FALSE when no action is take, TRUE when points are credited or debited
  */
-function userpoints_userpointsapi($op, $points = 0, $uid = 0, $event = NULL, $description = NULL) {
+function userpoints_userpointsapi($op, $points = 0, $uid = 0, $event = NULL, $description = NULL, $reference=NULL) {
   // anonymous users do not get points, and there have to be points to process
   if ($uid == 0 || $points == 0) {
     return FALSE;
@@ -261,7 +261,7 @@ function userpoints_userpointsapi($op, $
   }
 
   if ($op != 'txn approve') {
-    $moderation = userpoints_transaction($points, $uid, $event, $description);
+    $moderation = userpoints_transaction($points, $uid, $event, $description, $reference);
     if ($moderation) {
       // Points are moderated, so we do nothing for now.  
       drupal_set_message(t('User %uname %op %pointsvalue !points, pending administrator approval.',
@@ -314,15 +314,16 @@ function userpoints_userpointsapi($op, $
   return TRUE;
 }
 
-function userpoints_transaction($points = 0, $uid = 0, $event = NULL, $description = NULL) {
+function userpoints_transaction($points = 0, $uid = 0, $event = NULL, $description = NULL, $reference=NULL) {
   $moderation = variable_get(USERPOINTS_POINTS_MODERATION, FALSE);
   db_query("INSERT INTO {userpoints_txn}
-    VALUES (0, %d, 0, %d, %d, '%s', '%s', %d)",
+    VALUES (0, %d, 0, %d, %d, '%s', '%s', '%s', %d)",
     $uid,
     $points,
     time(),
     $event,
     $description,
+    $reference,
     $moderation);
   return $moderation;
 }
