--- userpoints_invite.module.orig	2008-11-06 18:59:38.000000000 -0800
+++ userpoints_invite.module	2008-12-24 16:52:31.000000000 -0800
@@ -59,6 +59,15 @@
         '#default_value' => variable_get(USERPOINTS_INVITE_REGISTER_REMOVE_ON_DELETE, 0),
       );
 
+      $form[$group]['userpoints_invite_tid'] = array(
+        '#type'          => 'select',
+        '#title'         => t('Category'),
+        '#default_value' => variable_get(userpoints_invite_tid, 0),
+        '#options'       => userpoints_get_categories(),
+        '#description' => t('Invites will be assigned to this category. You can modify what categories are available by modifying the <a href="!url">Userpoints taxonomy</a>.', 
+          array('!url' => url('admin/content/taxonomy/'. variable_get(USERPOINTS_CATEGORY_DEFAULT_VID, '')))),
+      );
+      
       return $form;
   }
 }
@@ -73,6 +82,7 @@
         'operation' => 'invite '.$op,
         'entity_id' => $args['inviter']->uid,
         'entity_type' => 'user',
+        'tid'         => variable_get('userpoints_invite_tid', 0),
         'reference' => 'userpoints_invite'
       );
       userpoints_userpointsapi($params);      
@@ -85,6 +95,7 @@
         'operation' => 'invite '.$op,
         'entity_id' => $args['inviter']->uid,
         'entity_type' => 'user',
+        'tid'         => variable_get('userpoints_invite_tid', 0),
         'reference' => 'userpoints_invite'
       );
       userpoints_userpointsapi($params);
@@ -98,6 +109,7 @@
         'operation' => 'invite '.$op.' invited '.$args['invitee']->uid,
         'entity_id' => $args['inviter']->uid,
         'entity_type' => 'user',
+        'tid'         => variable_get('userpoints_invite_tid', 0),
         'reference' => 'userpoints_invite'
       );
       userpoints_userpointsapi($params);
@@ -108,6 +120,7 @@
         'operation' => 'invite '.$op. ' invited by '.$args['inviter']->uid,
         'entity_id' => $args['invitee']->uid,
         'entity_type' => 'user',
+        'tid'         => variable_get('userpoints_invite_tid', 0),
         'reference' => 'userpoints_invite'
       );
       userpoints_userpointsapi($params);
@@ -118,9 +131,9 @@
 function userpoints_invite_user($op, &$edit, &$account, $category = NULL) {
   switch($op) {
     case 'delete':
-      if (variable_get(USERPOINTS_INVITE_REGISTER_REMOVE_ON_DELETE, 0) == 1) {
+      if (variable_get(USERPOINTS_INVITE_REGISTER_REMOVE_ON_DELETE, true)) {
         $result = db_query("SELECT uid FROM {userpoints_txn} WHERE operation = '%s' ORDER BY time_stamp DESC LIMIT 1", 'invite register invited '.$account->uid);
-        if (db_num_rows($result) > 0) {
+        if (db_result($result) > 0) {
           $uid = db_result($result);
           $points = -(variable_get(USERPOINTS_INVITE_INVITE, 0) + variable_get(USERPOINTS_INVITE_REGISTER_INVITER, 0));
           $params = array(
@@ -129,6 +142,7 @@
             'operation' => 'invited user '.$account->uid.' deleted',
             'entity_id' => $uid,
             'entity_type' => 'user',
+            'tid'         => variable_get('userpoints_invite_tid', 0),
             'reference' => 'userpoints_invite'
           );
           userpoints_userpointsapi($params);
