? .DS_Store
? my.patch
Index: community_tags.ajax.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/community_tags/community_tags.ajax.inc,v
retrieving revision 1.2
diff -u -p -r1.2 community_tags.ajax.inc
--- community_tags.ajax.inc	4 Dec 2009 22:24:56 -0000	1.2
+++ community_tags.ajax.inc	10 May 2010 14:58:55 -0000
@@ -15,18 +15,17 @@
 /**
  * Callback for the JS tagger.
  */
-function community_tags_from_js($node) {
+function community_tags_from_js($node, $vid) {
   global $user;
 
   $tags = (isset($_POST['tags']) && is_array($_POST['tags'])) ? $_POST['tags'] : array();
 
   // Merge in new tag and save.
   $tags = array_unique(array_merge($tags, drupal_explode_tags($_POST['add'])));
-  $vid = array_shift(community_tags_vids_for_node($node));
   community_tags_taxonomy_node_save($node, array('tags' => array($vid => $tags)), FALSE, $user->uid);
 
   // Fetch updated list.
-  $tags = community_tags_flatten(community_tags_get_user_node_tags($user->uid, $node->nid));
+  $tags = community_tags_flatten(community_tags_get_user_node_tags($user->uid, $node->nid, $vid));
 
   // Output JSON.
   print drupal_json(array('status' => TRUE, 'tags' => $tags, 'sequence' => $_POST['sequence']));
@@ -34,4 +33,4 @@ function community_tags_from_js($node) {
 
 /**
  * @}
- */
\ No newline at end of file
+ */
Index: community_tags.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/community_tags/community_tags.js,v
retrieving revision 1.5
diff -u -p -r1.5 community_tags.js
--- community_tags.js	4 Dec 2009 22:24:56 -0000	1.5
+++ community_tags.js	10 May 2010 14:58:56 -0000
@@ -34,7 +34,8 @@ Drupal.behaviors.communityTags = functio
 
       // Fetch settings.
       var nid = $('input[name=nid]', this.form).val();
-      var o = Drupal.settings.communityTags['n_' + nid];
+      var vid = $('input[name=vid]', this.form).val();
+      var o = Drupal.settings.communityTags['n_' + nid]['v_' + vid];
 
       var sequence = 0;
 
@@ -101,4 +102,4 @@ Drupal.behaviors.communityTags = functio
 
       updateList();
   });
-}
\ No newline at end of file
+}
Index: community_tags.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/community_tags/community_tags.module,v
retrieving revision 1.38
diff -u -p -r1.38 community_tags.module
--- community_tags.module	4 Dec 2009 22:24:56 -0000	1.38
+++ community_tags.module	10 May 2010 14:58:57 -0000
@@ -194,6 +194,8 @@ function community_tags_nodeapi(&$node, 
       }
       break;
 
+    // TODO is delete needed here?
+
     case 'view':
       global $user;
       // Show quick tag form for this node if we're on a node page view and the
@@ -232,9 +234,9 @@ function community_tags_form_alter(&$for
 /**
  * Retrieve list of tags for a given node that belong to a user.
  */
-function community_tags_get_user_node_tags($uid, $nid) {
+function community_tags_get_user_node_tags($uid, $nid, $vid) {
   $tags = array();
-  $result = db_query("SELECT t.tid, t.name, c.uid, c.nid FROM {term_data} t INNER JOIN {community_tags} c ON c.tid = t.tid WHERE c.nid = %d AND c.uid = %d ORDER BY t.name", $nid, $uid);
+  $result = db_query("SELECT t.tid, t.name, c.uid, c.nid FROM {term_data} t INNER JOIN {community_tags} c ON c.tid = t.tid WHERE c.nid = %d AND c.uid = %d AND t.vid = %d ORDER BY t.name", $nid, $uid, $vid);
   while ($term = db_fetch_object($result)) {
     $tags[$term->tid] = $term;
   }
@@ -257,7 +259,7 @@ function community_tags_taxonomy_node_sa
   // If not, we at least want the existing counts to update them.
 
   $old_tags_by_uid = array();
-  $result = db_query('SELECT * FROM {community_tags} ttn WHERE nid = %d', $nid);
+  $result = db_query('SELECT ttn.*, td.vid FROM {community_tags} ttn JOIN {term_data} td ON td.tid = ttn.tid WHERE nid = %d', $nid);
   while ($old_tag_node = db_fetch_object($result)) {
     $old_tags_by_uid[$old_tag_node->uid][$old_tag_node->tid] = $old_tag_node;
   }
@@ -266,14 +268,20 @@ function community_tags_taxonomy_node_sa
   $inserted_tids = array();
 
   $tids = array();
+  $vids = array(); // Future support for multiple vocabularies to be used in the same form
+
+  // Process the entries from the quick tag form
+
   // Free tagging vocabularies do not send their tids in the form,
   // so we'll detect them here and process them independently.
   if (isset($terms['tags'])) {
     $typed_input = $terms['tags'];
     unset($terms['tags']);
     
-      foreach ($typed_input as $vid=>$vid_value) {
-        if (isset($community_tagged[$vid])) {
+    foreach ($typed_input as $vid=>$vid_value) {
+      if (isset($community_tagged[$vid])) {
+        // http://groups.google.com/group/tickets-cakephp/browse_thread/thread/7f5f9ab54795a4d3
+        $vids[$vid] = true;
 
         $typed_terms = is_array($vid_value)?$vid_value:drupal_explode_tags($vid_value);
         foreach ($typed_terms as $typed_term) {
@@ -284,6 +292,7 @@ function community_tags_taxonomy_node_sa
           foreach ($possibilities as $possibility) {
             if ($possibility->vid == $vid) {
               $typed_term_tid = $possibility->tid;
+              break; // Stop at the first one
             }
           }
     
@@ -325,7 +334,8 @@ function community_tags_taxonomy_node_sa
       if ($is_owner && isset($inserted_tids[$old_tag->tid]) && $old_tag->uid != $uid) {
         $tag_nodes[] = $old_tag;
       }
-      elseif (!$is_owner && $old_tag->uid != $uid) {
+      // Otherwise, re-insert if it's another user's or another vid
+      elseif (!$is_owner && ($old_tag->uid != $uid || !isset($vids[$old_tag->vid]))) {
         $tag_nodes[] = $old_tag;
       }
     }
@@ -341,6 +351,7 @@ function community_tags_taxonomy_node_sa
     $existing_term_nodes[$term_node->tid] = TRUE;
   }
 
+  // TODO this is rather expensive. Is this for real?
   // Re-insert tag-node-user associations and term-node if not existing.
   db_lock_table('{community_tags}');
   db_query('DELETE FROM {community_tags} WHERE nid = %d', $nid);
@@ -406,6 +417,7 @@ function _community_tags_get_tag_result(
   $sql = '';
 
   switch ($type) {
+    // TODO not updated for multiple vid
     case 'node':
       $arg1 = (int)$arg1;
       $arg2 = NULL;
@@ -453,30 +465,32 @@ function community_tags_node_view($node,
 
   //!/  $cloud = community_tags_display('node', NULL, $node->nid);
 
-  $vid = array_shift(community_tags_vids_for_node($node));
-  $tags = community_tags_get_user_node_tags($user->uid, $node->nid);
-  $names = array();
-  $output = '';
-  
+  $vids = community_tags_vids_for_node($node);
   module_load_include('inc', 'community_tags', 'community_tags.pages');
+  $output = '';
+  foreach ($vids as $vid) {
+    $tags = community_tags_get_user_node_tags($user->uid, $node->nid, $vid);
+    $names = array();
+
+    if (!count($tags)) {
+      // User has not yet added tags to this node yet. Show form.
+      $output .= drupal_get_form('community_tags_form', array('node' => $node,/* //!/ 'cloud' => $cloud,*/ 'nid' => $node->nid, 'vid' => $vid, 'tags' => NULL, 'inline' => $inline));
+    } 
+    elseif (user_access('edit own tags')) {
+      // User has already tagged this node, but can edit their tags. Show form
+      // with the user's tags pre-populated.
+      $names = community_tags_flatten($tags);
+      $tags = taxonomy_implode_tags($tags);
+      $output .= drupal_get_form('community_tags_form', array('node' => $node,/* //!/'cloud' => $cloud,*/ 'nid' => $node->nid, 'vid' => $vid, 'tags' => $tags, 'inline' => $inline));
+    }
+    else {
+      // Sorry, no more adding tags for you!
+      $output .= '<p>'. t('You have already tagged this post. Your tags: ') .'</p>';
+    }
 
-  if (!count($tags)) {
-    // User has not yet added tags to this node yet. Show form.
-    $output .= drupal_get_form('community_tags_form', array('node' => $node,/* //!/ 'cloud' => $cloud,*/ 'nid' => $node->nid, 'vid' => $vid, 'tags' => NULL, 'inline' => $inline));
-  } 
-  elseif (user_access('edit own tags')) {
-    // User has already tagged this node, but can edit their tags. Show form
-    // with the user's tags pre-populated.
-    $names = community_tags_flatten($tags);
-    $tags = taxonomy_implode_tags($tags);
-    $output .= drupal_get_form('community_tags_form', array('node' => $node,/* //!/'cloud' => $cloud,*/ 'nid' => $node->nid, 'vid' => $vid, 'tags' => $tags, 'inline' => $inline));
+    // TODO might want to optimise this call
+    drupal_add_js(array('communityTags' => array('n_'. $node->nid => array('v_'. $vid => array('tags' => $names, 'url' => url('community-tags/js/'. $node->nid .'/'. $vid), 'add' => t('Add'))))), 'setting');
   }
-  else {
-    // Sorry, no more adding tags for you!
-    $output .= '<p>'. t('You have already tagged this post. Your tags: ') .'</p>';
-  }
-
-  drupal_add_js(array('communityTags' => array('n_'. $node->nid => array('tags' => $names, 'url' => url('community-tags/js/'. $node->nid), 'add' => t('Add')))), 'setting');
 
   return $output;
 }
Index: community_tags.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/community_tags/community_tags.pages.inc,v
retrieving revision 1.2
diff -u -p -r1.2 community_tags.pages.inc
--- community_tags.pages.inc	4 Dec 2009 22:24:56 -0000	1.2
+++ community_tags.pages.inc	10 May 2010 14:58:57 -0000
@@ -15,6 +15,7 @@
  * Quick tag form.
  */
 function community_tags_form($form_state, $edit, $title = NULL) {
+  $vocabulary = taxonomy_vocabulary_load($edit['vid']);
   
 /* //!/ $form['cloud'] = array(
     '#type' => 'markup',
@@ -25,18 +26,18 @@ function community_tags_form($form_state
   
   $access = user_access('tag content');
 
-  $form['tags'] = array(
+  $form['tags-'. $edit['vid']] = array(
     '#type' => 'textfield',
-    '#title' => t('My tags'),
+    '#title' => t('My !name', array('!name' => $vocabulary->name)),
     '#maxlength' => 100,
     '#default_value' => $edit['tags'],
     '#required' => FALSE,
     '#autocomplete_path' => 'taxonomy/autocomplete/'. $edit['vid'],
-    '#attributes' => array('class' => 'form-tags'),
+    '#attributes' => array('class' => 'form-tags form-tags-'. $edit['vid']),
     '#access' => $access,
   );
   if ($edit['inline']) {
-    $form['tags']['#size'] = 20;
+    $form['tags-'. $edit['vid']]['#size'] = 20;
   }
   
   if (!$access) {
@@ -65,7 +66,7 @@ function community_tags_form($form_state
   );
 
   $form['vid'] = array(
-    '#type' => 'value',
+    '#type' => 'hidden',
     '#value' => $edit['vid'],
   );
 
@@ -128,7 +129,7 @@ function community_tags_settings() {
 
   // Build list of available free-tagging vocabularies
   $options = array();
-  $vocabs = db_query('SELECT v.vid, v.name FROM {vocabulary} v WHERE v.tags = 1 ORDER BY v.weight, v.name');
+  $vocabs = db_query('SELECT v.vid, v.name FROM {vocabulary} v ORDER BY v.weight, v.name');
   while ($vocabulary = db_fetch_object($vocabs)) {
     $options[$vocabulary->vid] = $vocabulary->name;
   }
@@ -139,7 +140,7 @@ function community_tags_settings() {
       '#title' => t('Community vocabularies'),
       '#default_value' => variable_get('community_tags_vocabularies', array()),
       '#options' => $options,
-      '#description' => t('Which vocabularies should community tagging use? Note: only one community tagged vocabulary per node type is supported.'),
+      '#description' => t('Which vocabularies should community tagging use?'),
     );
   }
 
