--- affiliates.module.orig	2008-11-24 15:16:53.000000000 -0800
+++ affiliates.module	2008-12-29 10:32:56.000000000 -0800
@@ -2,7 +2,7 @@
 // $Id
 
 // Portions Copyright 2006 http://2bits.com
-define ('AFFILIATE_BUTTONS_DIRECTORY_RELATIVE_FILES', '/images/affiliates');
+define ('AFFILIATE_BUTTONS_DIRECTORY_RELATIVE_FILES', '/affiliates');
 
 define('AFFILIATE_HOMEPAGE_PROFILE',      'affiliate_homepage_profile');
 define('AFFILIATE_BLOCK_TEXT',            'affiliate_block_text');
@@ -260,7 +260,7 @@
    $form['affiliates_settings']['revenue'] = array(
     '#type' => 'fieldset',
     '#title' => t('Revenue'),
-    '#collapsible' => TRE,
+    '#collapsible' => TRUE,
     '#collapsed' => TRUE,
   );	
 
@@ -370,6 +370,7 @@
     '#default_value' => $affiliate->points,
     '#size'          => 3,
     '#maxlength'     => 3,
+    '#required' => TRUE,
   );
 
   $form['affiliate']['type'] = array(
@@ -393,7 +394,7 @@
   	'#type' => 'file',
   	'#title' => t('Upload a button'),
   	'#size' => 40,
-  	'#description' => t('Please upload a button.')
+  	'#description' => t('Please upload a button.<br><br><b>OR</b> specify the button URL:')
   );
 
   $form['affiliate']['anchor'] = array(
@@ -411,6 +412,7 @@
     '#default_value' => $affiliate->redirect,
     '#size'          => 40,
     '#maxlength'     => 80,
+    '#description' => t('If no redirect is specified, the home page will be used.')
   );
 
   $form['affiliate']['order_by'] = array(
@@ -419,6 +421,7 @@
     '#default_value' => $affiliate->order_by,
     '#size'          => 10,
     '#maxlength'     => 5,
+    '#required' => TRUE,
   );
 
   $form['affiliate']['status'] = array(
@@ -463,9 +466,9 @@
   if (!is_numeric($form_values['order_by'])) {
     form_set_error('', t('You must enter a numeric order value'));
   }
-  if (!$form_values['redirect']) {
-    form_set_error('', t('You must enter a redirect url'));
-  }
+//  if (!$form_values['redirect']) {
+//    form_set_error('', t('You must enter a redirect url'));
+//  }
   if (!$form_values['status']) {
     form_set_error('', t('You must select a valid status'));
   }
@@ -1006,15 +1009,21 @@
       VALUES
       (%d, '%s', '%s', '%s', %d, %d)",
       $uid, $cookie_value, $_SERVER['REMOTE_ADDR'], filter_xss($_SERVER['HTTP_REFERER']), $ad_id, time());
-  }
-
-  $redirect = db_result(db_query("SELECT redirect FROM {affiliates_ads} WHERE ad_id = %d", $ad_id));
-
+      
   // Record it in the userpoints
   if (module_exists('userpoints')) {
     $points = (int)db_result(db_query("SELECT points FROM {affiliates_ads} WHERE ad_id = %d", $ad_id));
-    userpoints_userpointsapi('points', $points, $uid, "affiliates");
-  }
+    $params = array(
+    	'points'      => $points,
+        'uid'         => $uid,
+        'operation'   => 'affilate click',
+        'tid'         => variable_get('AFFILIATES_USERPOINTS_TID', 0),
+        'reference'   => 'affiliates'
+    );
+    userpoints_userpointsapi($params);
+  }}
+
+  $redirect = db_result(db_query("SELECT redirect FROM {affiliates_ads} WHERE ad_id = %d", $ad_id));
 
   if ($redirect) {
     header("Location: " . $redirect);
@@ -1033,16 +1042,27 @@
         '#type' => 'fieldset',
         '#collapsible' => TRUE,
         '#collapsed' => TRUE,
-        '#title' => t('%Points for nodevote', userpoints_translation()),
+        '#title' => t('!Points for Affiliates', userpoints_translation()),
       );
-    
-      $form[$group][AFFILIATES_USERPOINTS] = array(
-        '#type' => 'textfield',
-        '#title' => t('%Points for affiliate click', userpoints_translation()),
-        '#default_value' => variable_get(AFFILIATES_USERPOINTS, 1),
-        '#size' => 5,
-        '#maxlength' => 5,
+      
+//This form item is commented out as the value does not modify anything currently. It could be used later on as a modifier.
+//      $form[$group][AFFILIATES_USERPOINTS] = array(
+//        '#type' => 'textfield',
+//        '#title' => t('!Points for Affiliates clicks', userpoints_translation()),
+//        '#default_value' => variable_get(AFFILIATES_USERPOINTS, 1),
+//        '#size' => 5,
+//        '#maxlength' => 5,
+//      );
+      
+      $form[$group]['AFFILIATES_USERPOINTS_TID'] = array(
+        '#type'          => 'select',
+        '#title'         => t('Category'),
+        '#default_value' => variable_get(AFFILIATES_USERPOINTS_TID, 0),
+        '#options'       => userpoints_get_categories(),
+        '#description'   => t('Points for Affilates button click-throughs will be assigned to this category. You can modify what categories are available by modifying the <a href="!url"><b>Userpoints taxonomy</b></a>. Points values are set in the <a href="/affiliates/admin"><b>Affiliates Admin</b></a> section on a per button basis.', 
+          array('!url' => url('admin/content/taxonomy/'. variable_get(USERPOINTS_CATEGORY_DEFAULT_VID, '')))),
       );
+      
       return $form;
   }
 }
@@ -1069,7 +1089,7 @@
           else {
             $output .= '<br/>' . t('No clicks yet.');
           }
-          $output .= "<br/><a href=\"/affiliates/top_users\">more &raquo;</a>";
+          $output .= "<br/><a href=\"affiliates/top_users\">more &raquo;</a>";
 
           if ($user->uid) {
             $output .= "<br/><br/>You have " . _get_user_points($user->uid) . " points.";
