Index: user_terms.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/user_terms/Attic/user_terms.admin.inc,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 user_terms.admin.inc
--- user_terms.admin.inc	16 Jan 2010 15:01:06 -0000	1.1.2.1
+++ user_terms.admin.inc	2 Apr 2010 04:40:56 -0000
@@ -13,22 +13,54 @@
  *   The form elements.
  */
 function user_terms_settings() {
+  drupal_add_js(drupal_get_path('module', 'user_terms').'/user_terms.js', 'module');
   $form = array();
   $vocabs = taxonomy_get_vocabularies();
-
-  foreach ($vocabs as $vid => $voc) {
-    $options[$vid] = $voc->name;
+  $vocabs_enabled = variable_get('user_terms_vocabs', '');
+  $vocabs_path = variable_get('user_terms_vocabs_path', '');
+  $vocabs_register = variable_get('user_terms_vocabs_register', '');
+  
+  // new
+  $profile_exists = module_exists('profile');
+  
+  if ($profile_exists) {
+    $categories = profile_categories();
+    $category_options = array(
+      'default' => t('Default'),
+      'account' => t('Account (main page)'),
+    );
+    foreach ($categories as $cat) {
+      $category_options[$cat['name']] = check_plain($cat['name']);
+    }
   }
 
-  $form['user_terms_vocabs'] = array(
-    '#type'          => 'select',
-    '#title'         => t('User vocabularies'),
-    '#options'       => $options,
-    '#description'   => t('Choose the vocabularies that will be used to tag users. To select multiple values, hold down the Control key while clicking. If you are using an Apple, hold down the Apple or Command key.'),
-    '#default_value' => variable_get('user_terms_vocabs', ''),
-    '#multiple'      => TRUE,
-  );
-
+  $vids_js = drupal_to_js(array_keys($vocabs));
+  drupal_add_js('var user_terms_vocabs = '.$vids_js, 'inline');
+  
+  foreach ($vocabs as $vid => $voc) {
+    $form['vocabularies'][$vid]['name'] = array('#value' => check_plain($voc->name));
+    $form['vocabularies'][$vid]['enabled'] = array(
+      '#type' => 'checkbox', 
+      '#default_value' => isset($vocabs_enabled[$vid]), 
+    );
+    // Only add this option if the profile module is enabled.
+    if ($profile_exists) {
+      $form['vocabularies'][$vid]['category'] = array(
+        '#type' => 'select', 
+        '#options' => $category_options,
+        '#default_value' => isset($vocabs_path[$vid]) ? $vocabs_path[$vid] : $field->category,
+      );
+    }
+    $form['vocabularies'][$vid]['registration'] = array(
+      '#type' => 'checkbox',
+      '#default_value' => isset($vocabs_register[$vid]),
+    );
+  } 
+  $form['vocabularies']['#tree'] = TRUE;
+  $form['vocabularies']['#theme'] = 'user_terms_settings';
+  // this doesn't work, wtf?
+  //$form['vocabularies']['#submit'] = array('user_terms_settings_vocabularies_submit');
+  
   // Only add this option if the profile module is enabled.
   if (module_exists('profile')) {
     $data    = profile_categories();
@@ -44,7 +76,7 @@ function user_terms_settings() {
       '#type'           => 'select',
       '#title'          => t('Profile page'),
       '#options'        => $options,
-      '#description'    => t('The profile category on which vocabularies should appear when the user is editing their profile.'),
+      '#description'    => t('The default profile category on which vocabularies should appear when the user is editing their profile.'),
       '#default_value'  => variable_get('user_terms_profile_path', 'account'),
     );
   }
@@ -69,6 +101,79 @@ function user_terms_settings() {
       '#description'    => t('The text to use as a heading when all terms are grouped.'),
       '#size'           => 32,
     );
+    
+  // Add our own submit handler to process the table. 
+  $form['#submit'] = array('user_terms_settings_submit');
 
   return system_settings_form($form);
 }
+
+/**
+ * Theme the admin settings form.
+ *
+ * @ingroup themeable
+ * @see user_terms_settings()
+ */
+function theme_user_terms_settings($form) {
+  $profile_exists = module_exists('profile');
+    
+  $rows = array();
+  foreach (element_children($form) as $key) {
+    $field = &$form[$key];
+    
+    $row = array();
+    $row[] = drupal_render($field['name']);
+    $row[] = drupal_render($field['enabled']);
+    if ($profile_exists) {
+      $row[] = drupal_render($field['category']);
+    }
+    $row[] = drupal_render($field['registration']);
+    
+    $rows[] = $row;
+  }
+  
+  if (empty($rows)) {
+    $rows[] = array(array('data' => t('No vocabularies available.'), 'colspan' => 3));
+  }
+
+  $header[] = t('Vocabulary'); 
+  $header[] = t('Enabled'); 
+  if ($profile_exists) {
+    $header[] = t('Category');
+  }
+  $header[] = t('Use on registration'); 
+
+  $output = theme('table', $header, $rows, array('id' => 'user-terms-fields'));
+  $output .= drupal_render($form);
+
+  return $output;
+}
+
+/**
+ * Submit handler for the admin settings form.
+ *
+ * Handles the table of vocabularies.
+ * Other settings that are simple elements are saved by system_settings_form()'s
+ * system_settings_form_submit handler.
+ */
+function user_terms_settings_submit($form, &$form_state) {
+  //dsm($form_state);
+
+  // Save the enabled vocabularies.
+  $vocabs_enabled = array();
+  $vocabs_path = array();
+  $vocabs_register = array();
+  foreach ($form_state['values']['vocabularies'] as $vid => $vocab_values) {
+    if ($vocab_values['enabled']) {
+      $vocabs_enabled[$vid] = $vid;
+      $vocabs_path[$vid] = $vocab_values['category'];
+      if ($vocab_values['registration'])
+        $vocabs_register[$vid] = $vid;
+    }
+  }
+  variable_set('user_terms_vocabs', $vocabs_enabled);
+  variable_set('user_terms_vocabs_path', $vocabs_path);
+  variable_set('user_terms_vocabs_register', $vocabs_register);
+  // Remove the form values so system_settings_form_submit() doesn't save them.
+  unset($form_state['values']['vocabularies']);
+}
\ No newline at end of file
Index: user_terms.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/user_terms/user_terms.install,v
retrieving revision 1.1.2.2
diff -u -p -r1.1.2.2 user_terms.install
--- user_terms.install	21 Jul 2009 03:33:42 -0000	1.1.2.2
+++ user_terms.install	2 Apr 2010 04:40:56 -0000
@@ -63,6 +63,8 @@ function user_terms_uninstall() {
   variable_del('user_terms_profile_path');
   variable_del('user_terms_group_terms');
   variable_del('user_terms_group_title');
+  variable_del('user_terms_vocabs_register');
+  variable_del('user_terms_vocabs_path');
 }
 
 
@@ -77,3 +79,13 @@ function user_terms_update_6001() {
 
   return array();
 }
+
+function user_terms_update_6002() {
+  $vocabs = variable_get('user_terms_vocabs', '');
+  variable_set('user_terms_vocabs_register', $vocabs);
+
+  $vocabs_path = array();
+  foreach ($vocabs as $vid) $vocabs_path[$vid] = 'default';
+  variable_set('user_terms_vocabs_path', $vocabs_path);
+  return array();
+}
Index: user_terms.js
===================================================================
RCS file: user_terms.js
diff -N user_terms.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ user_terms.js	2 Apr 2010 04:40:56 -0000
@@ -0,0 +1,14 @@
+// $Id$
+$(function() {
+  for (var i in user_terms_vocabs) {
+    function onClick() {
+      re = /^edit-vocabularies-(.*)-enabled$/;
+      register = $('#edit-vocabularies-' + this.id.match(re)[1] + '-registration');
+      
+      if ($('#' + this.id + ':checked').val()) register.attr('disabled', '');
+      else register.attr('disabled', 'disabled');
+    }
+    $('#edit-vocabularies-' + user_terms_vocabs[i] + '-enabled').click(onClick);
+    $('#edit-vocabularies-' + user_terms_vocabs[i] + '-enabled').each(onClick);
+  }
+});
\ No newline at end of file
Index: user_terms.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/user_terms/user_terms.module,v
retrieving revision 1.1.2.25
diff -u -p -r1.1.2.25 user_terms.module
--- user_terms.module	19 Mar 2010 22:23:33 -0000	1.1.2.25
+++ user_terms.module	2 Apr 2010 04:40:56 -0000
@@ -47,15 +47,6 @@ function user_terms_menu() {
  * Implementation of hook_user().
  */
 function user_terms_user($op, &$edit, &$account, $category = NULL) {
-  // Should user terms be displayed in the interface?
-  $display = TRUE;
-  if (module_exists('profile')) {
-    $profile_page = variable_get('user_terms_profile_path', 'account');
-    if ($category && ($category != $profile_page)) {
-      $display = FALSE;
-    }
-  }
-
   switch ($op) {
     // The user account is being loaded.
     case 'load':
@@ -64,7 +55,7 @@ function user_terms_user($op, &$edit, &$
     // The user account registration form is about to be displayed. 
     // The module should present the form elements it wishes to inject into the form.
     case 'register':
-      return $display ? user_terms_form_profile($edit, $account, $category, TRUE) : '';
+      return user_terms_form_profile($edit, $account, $category, TRUE);
 
     // The user account is being added. 
     // The module should save its custom additions to the user object into the 
@@ -82,14 +73,14 @@ function user_terms_user($op, &$edit, &$
     // The user account edit form is about to be displayed.
     // The module should present the form elements it wishes to inject into the form.
     case 'form':
-      return $display ? user_terms_form_profile($edit, $account, $category) : '';
+      return user_terms_form_profile($edit, $account, $category);
 
     // The user account is being changed. 
     // The module should save its custom additions to the user object into the 
     // database and set the saved fields to NULL in $edit.
     // TODO: This method doesn't seem to work because it's stored on a page generated by profile.module
     case 'update':
-      return $display ? user_terms_save_profile($edit, $account, $category) : '';
+      return user_terms_save_profile($edit, $account, $category);
 
     // The user account is being deleted. 
     // The module should remove its custom additions to the user object from the database. 
@@ -227,6 +218,17 @@ function user_terms_form_profile($edit, 
   if (!variable_get('user_terms_override_selector', FALSE)) {
     $form  = array();
     $vids = variable_get('user_terms_vocabs', '');
+    if ($register)
+      $vids = variable_get('user_terms_vocabs_register', '');
+
+    if ($category) {
+      $vids_path = variable_get('user_terms_vocabs_path', '');
+      $def_path = variable_get('user_terms_profile_path', '') == $category;
+      foreach ($vids as $vid) {
+        if (($vids_path[$vid] == 'default') && $def_path) continue;
+        if ($vids_path[$vid] != $category) unset($vids[$vid]);
+      }
+    }
 
     // Skip everything if no user term vocabulary is selected.
     if (!empty($vids)) {
@@ -322,6 +324,18 @@ function user_terms_save_profile(&$edit,
   }
 }
 
+/**
+ * Implementation of hook_theme().
+ */
+function user_terms_theme($existing, $type, $theme, $path) {
+  return array(
+    'user_terms_settings' => array(
+      'arguments' => array('form' => NULL),
+      'file' => 'user_terms.admin.inc',
+    )
+  );
+}
+
 
 /**
  * Implementation of hook_views_api().
