Index: community_tags.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/community_tags/community_tags.module,v
retrieving revision 1.36
diff -u -r1.36 community_tags.module
--- community_tags.module	1 Aug 2007 22:37:14 -0000	1.36
+++ community_tags.module	17 Jul 2008 04:34:24 -0000
@@ -19,58 +19,60 @@
   }
 }
 
+/**
+ * Implementation of hook_theme().
+ */
+function community_tags_theme() {
+  return array(
+    'community_tags_form' => array(
+      'arguments' => array('form' => NULL),
+    ),
+    'community_tags' => array(
+      'arguments' => array('tags' => NULL),
+    ),    
+  );
+}
 
 /**
  * Implementation of hook_menu().
  */
-function community_tags_menu($may_cache) {
+function community_tags_menu() {
   $items = array();
 
-  if ($may_cache) {
-    $items[] = array(
-      'path' => 'admin/settings/community-tags',
-      'title' => t('Community tags'),
-      'description' => t('Configure community tagging.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => 'community_tags_settings',
-      'access' => user_access('administer site configuration'),
-    );
-    $items[] = array(
-      'path' => 'community-tags/js',
-      'callback' => 'community_tags_from_js',
-      'access' => user_access('access content') && user_access('tag content'),
-      'type' => MENU_CALLBACK,
-    );
-    $items[] = array(
-      'path' => 'community-tags/user',
-      'callback' => 'community_tags_by_user',
-      'access' => user_access('access content') && user_access('tag content'),
-      'type' => MENU_CALLBACK,
-    );
-  }
-  else {
-    // Add tagging tab, if necessary and supported for this node.
-    if (arg(0) == 'node' && is_numeric(arg(1))) {
-      $node = node_load(arg(1));
-      if ($node) {
-        $tab = variable_get('community_tags_display_'. $node->type, COMMUNITY_TAGS_MODE_TAB) == COMMUNITY_TAGS_MODE_TAB;
-        $vids = community_tags_vids_for_node($node);
-        $items[] = array(
-          'path' => 'node/'. arg(1) .'/tag',
-          'title' => t('Tags'),
-          'callback' => 'community_tags_node_view',
-          'callback arguments' => array(arg(1), FALSE),
-          'access' => (user_access('access content') && user_access('tag content') && count($vids)),
-          'type' => $tab ? MENU_LOCAL_TASK : MENU_CALLBACK,
-          'weight' => 2,
-        );
-      }
-    }
-  }
+  $items['admin/settings/community-tags'] = array(
+    'title' => 'Community tags',
+    'description' => t('Configure community tagging.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('community_tags_settings'),
+    'access arguments' => array('administer site configuration'),
+  );
+
+  $items['community-tags/js'] = array(
+    'page callback' => 'community_tags_from_js',
+    'access callback' => '_community_tags_menu_access',
+    'type' => MENU_CALLBACK,
+  );
+  
+  $items['community-tags/user'] = array(
+    'page callback' => 'community_tags_by_user',
+    'access callback' => '_community_tags_menu_access',
+    'type' => MENU_CALLBACK,
+  );
+
+  $items['node/%node/tag'] = array(
+    'title' => 'Tags',
+    'page callback' => 'community_tags_node_view',
+    'page arguments' => array(1, FALSE),
+    'access callback' => '_community_tags_tag_access',
+    'access arguments' => array(1),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 2,
+  );
 
   return $items;
 }
 
+
 /**
  * Resync community_tags table with term_node table, after vocabulary change.
  */
@@ -178,17 +180,18 @@
   $vid = array_shift(community_tags_vids_for_node($node));
   $tags = community_tags_get_user_node_tags($user->uid, $node->nid);
   $names = array();
+  $output = '';
 
   if (!count($tags)) {
     // User has not yet added tags to this node yet. Show form.
-    $output .= drupal_get_form('community_tags_form', array('cloud' => $cloud, 'nid' => $node->nid, 'vid' => $vid, 'tags' => NULL, 'inline' => $inline));
-  }
+    $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('cloud' => $cloud, 'nid' => $node->nid, 'vid' => $vid, 'tags' => $tags, 'inline' => $inline));
+    $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!
@@ -225,7 +228,7 @@
       // be one.  Only when using a "quick add" form can we increase the count.
       if (is_array($node->taxonomy['tags'])) {
         global $user;
-        community_tags_taxonomy_node_save($node->nid, $node->taxonomy, TRUE, $user->uid);
+        community_tags_taxonomy_node_save($node, $node->taxonomy, TRUE, $user->uid);
       }
       break;
 
@@ -252,6 +255,7 @@
   community_tags_rehash();
 
   // 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');
   while ($vocabulary = db_fetch_object($vocabs)) {
     $options[$vocabulary->vid] = $vocabulary->name;
@@ -275,7 +279,7 @@
 /**
  * Implementation of hook_form_alter().
  */
-function community_tags_form_alter($form_id, &$form) {
+function community_tags_form_alter(&$form, &$form_state, $form_id) {
   // Provide option to enable Community Tags per node type.
   if ($form_id == 'node_type_form' && isset($form['identity']['type'])) {
     $modes = array(
@@ -309,7 +313,7 @@
 /**
  * Quick tag form
  */
-function community_tags_form($edit, $title = NULL) {
+function community_tags_form($form_state, $edit, $title = NULL) {
   $form['cloud'] = array(
     '#type' => 'markup',
     '#title' => t('All tags'),
@@ -325,7 +329,6 @@
     '#default_value' => $edit['tags'],
     '#required' => FALSE,
     '#autocomplete_path' => 'taxonomy/autocomplete/'. $edit['vid'],
-    '#description' => t('<span class="no-js">A comma-separated list of terms describing this content. </span>Example: funny, bungee jumping, "Company, Inc.".'),
     '#attributes' => array('class' => 'form-tags'),
     '#access' => $access,
   );
@@ -344,8 +347,14 @@
   $form['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Save'),
+    '#access' => $access,
   );
-
+  
+  $form['node'] = array(
+    '#type' => 'value',
+    '#value' => $edit['node'],
+  );
+  
   $form['nid'] = array(
     '#type' => 'value',
     '#value' => $edit['nid'],
@@ -362,8 +371,8 @@
 /**
  * Validate the quick tag form.
  */
-function community_tags_form_validate($form_id, $form_values) {
-  if ($form_values['tags'] == '') {
+function community_tags_form_validate($form, &$form_state) {
+  if ($form_state['values']['tags'] == '') {
     form_set_error('tags', t('You must enter at least one tag.'));
   }
 }
@@ -371,12 +380,12 @@
 /**
  * Submit callback for quick tag form.
  */
-function community_tags_form_submit($form_id, $form_values) {
+function community_tags_form_submit($form, &$form_state) {
   global $user;
-  
-  community_tags_taxonomy_node_save($form_values['nid'], array('tags' => array($form_values['vid'] => $form_values['tags'])), FALSE, $user->uid);
+  $form_values = $form_state['values']; 
+  community_tags_taxonomy_node_save($form_values['node'], array('tags' => array($form_values['vid'] => $form_values['tags'])), FALSE, $user->uid);
 
-  return array('node/'. $form_values['nid']);
+  $form_state['redirect'] = 'node/'. $form_values['nid']; 
 }
 
 /**
@@ -384,7 +393,7 @@
  * @ingroup themeable
  */
 function theme_community_tags_form($form) {
-  $output .= theme('form_element', array('#title' => t('All tags')), drupal_render($form['cloud']));
+  $output = theme('form_element', array('#title' => t('All tags')), drupal_render($form['cloud']));
 
   $output .= drupal_render($form);
 
@@ -415,12 +424,12 @@
     return;
   }
 
-  $tags = is_array($_POST['tags']) ? $_POST['tags'] : array();
+  $tags = (isset($_POST['tags']) && is_array($_POST['tags'])) ? $_POST['tags'] : array();
 
   // Merge in new tag and save
   $tags = array_unique(array_merge($tags, taxonomy_explode_tags($_POST['add'])));
   $vid = array_shift(community_tags_vids_for_node($node));
-  community_tags_taxonomy_node_save($node->nid, array('tags' => array($vid => $tags)), FALSE, $user->uid);
+  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));
@@ -433,11 +442,12 @@
 /**
  * Save community_tags term associations and counts for a given node.
  */
-function community_tags_taxonomy_node_save($nid, $terms, $is_owner, $uid) {
+function community_tags_taxonomy_node_save($node, $terms, $is_owner, $uid) {
   $community_tagged = variable_get('community_tags_vocabularies', array());
   if (count($community_tagged) == 0) {
     return;
   }
+  $nid = $node->nid;
 
   // If we're adding tags from the node add/edit page, then we want to delete
   // any tags that aren't entered to allow admins to remove node tags.
@@ -492,6 +502,7 @@
         $tag_node->nid = $nid;
         $tag_node->uid = $uid;
         $tag_node->date = time();
+        $tag_node->vid = $node->vid;
 
         // So we don't add this tag again on this run or re-insert the old tag for this user.
         $inserted_tids[$typed_term_tid] = $typed_term_tid;
@@ -541,7 +552,7 @@
   // Avoid locking term_node so we loop again.
   foreach ($add_term_nodes as $tag_node) {
     // Insert term-node relation into term_node table since it doesn't exist already.
-    db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $tag_node->nid, $tag_node->tid);
+    db_query('INSERT INTO {term_node} (nid, tid, vid) VALUES (%d, %d, %d)', $tag_node->nid, $tag_node->tid, $tag_node->vid);
   }
 
   // Match real tags to community tags, if necessary (e.g. after quick tagging).
@@ -670,24 +681,17 @@
 
     return $tags;
   }
+}
 
-  /**
-   * Implode a list of tags of a certain vocabulary into a string.
-   */
-  function taxonomy_implode_tags($tags, $vid = NULL) {
-    $typed_tags = array();
-    foreach ($tags as $tag) {
-      // Extract terms belonging to the vocabulary in question.
-      if (is_null($vid) || $tag->vid == $vid) {
-
-        // Commas and quotes in tag names are special cases, so encode 'em.
-        if (strpos($tag->name, ',') !== FALSE || strpos($tag->name, '"') !== FALSE) {
-          $tag->name = '"'. str_replace('"', '""', $tag->name) .'"';
-        }
+/**
+ * Menu access callbacks
+ */
+function _community_tags_menu_access() {
+  return user_access('access content') && user_access('tag content');
+}
 
-        $typed_tags[] = $tag->name;
-      }
-    }
-    return implode(', ', $typed_tags);
-  }
+function _community_tags_tag_access($node) {
+  $vids = community_tags_vids_for_node($node);
+  return _community_tags_menu_access() && count($vids);
 }
+
Index: community_tags.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/community_tags/community_tags.install,v
retrieving revision 1.8
diff -u -r1.8 community_tags.install
--- community_tags.install	3 May 2007 09:13:28 -0000	1.8
+++ community_tags.install	17 Jul 2008 04:34:21 -0000
@@ -2,78 +2,58 @@
 // $Id: community_tags.install,v 1.8 2007/05/03 09:13:28 unconed Exp $
 
 /**
+ * @file
+ * The install file for the community_tags module.
+ */
+
+/**
  * Implementation of hook_install().
  */
 function community_tags_install() {
-  $status = array();
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      $status[] = db_query("CREATE TABLE {community_tags} (
-        tid int(10) unsigned NOT NULL DEFAULT '0',
-        nid int(10) unsigned NOT NULL DEFAULT '0',
-        uid int(10) unsigned NOT NULL DEFAULT '0',
-        date int(10) unsigned NOT NULL DEFAULT '0',
-        PRIMARY KEY  (tid,nid,uid),
-        KEY tid (tid),
-        KEY nid (nid),
-        KEY uid (uid)
-      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
-      break;
-
-    case 'pgsql':
-      $status[] = db_query("CREATE TABLE {community_tags} (
-        tid integer NOT NULL DEFAULT '0',
-        nid integer NOT NULL DEFAULT '0',
-        uid integer NOT NULL DEFAULT '0',
-        date integer NOT NULL DEFAULT '0',
-        PRIMARY KEY (tid,nid,uid)
-      );");
-      $status[] = db_query("CREATE INDEX {community_tags}_tid_idx ON {community_tags} (tid);");
-      $status[] = db_query("CREATE INDEX {community_tags}_nid_idx ON {community_tags} (nid);");
-      $status[] = db_query("CREATE INDEX {community_tags}_uid_idx ON {community_tags} (uid);");
-      break;
-  }
-
+  // Install schema
+  drupal_install_schema('community_tags');
+  
   // Drop module weight so we act after taxonomy.
   $weight = (int)db_result(db_query("SELECT weight FROM {system} WHERE name = 'taxonomy'"));
   db_query("UPDATE {system} SET weight = %d WHERE name = 'community_tags'", $weight + 1);
-
-  // If there is one FALSE value in the status array, there was an error.
-  if (array_search(FALSE, $status) !== FALSE) {
-    drupal_set_message(t('Table installation for the Community Tags module was unsuccessful. The tables may need to be installed by hand.'), 'error');
-  }
-  else {
-    drupal_set_message(t('Community Tags module installed successfully.'));
-  }
 }
 
 /**
  * Implementation of hook_uninstall().
  */
 function community_tags_uninstall() {
-  db_query('DROP TABLE {community_tags}');
+  drupal_uninstall_schema('community_tags');
+}
+
+/**
+ * Implementation of hook_schema().
+ */
+function community_tags_schema() {
+  $schema['community_tags'] = array(
+    'fields' => array(
+      'tid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'date' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+    ),
+    'indexes' => array(
+      'tid' => array('tid'),
+      'nid' => array('nid'),
+      'uid' => array('uid'),
+    ),
+    'primary key' => array('tid', 'uid', 'nid'),
+  );
+  return $schema;
 }
 
 /**
  * Update: Add tid column key.
  */
 function community_tags_update_1() {
-  $items = array();
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      $items[] = update_sql('ALTER TABLE {community_tags} ADD KEY tid (tid)');
-      break;
-
-    case 'pgsql':
-      $items[] = update_sql("CREATE INDEX {community_tags}_tid_idx ON {community_tags} (tid);");
-      break;
-  }
-
+  $ret = array();
+  db_add_index($ret, 'community_tags', 'tid', array('tid'));
   community_tags_rehash(TRUE);
-
-  return $items;
+  return $ret;
 }
 
 /**
Index: community_tags.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/community_tags/community_tags.info,v
retrieving revision 1.1
diff -u -r1.1 community_tags.info
--- community_tags.info	11 Apr 2007 12:31:32 -0000	1.1
+++ community_tags.info	17 Jul 2008 04:34:20 -0000
@@ -1,4 +1,5 @@
 ; $Id: community_tags.info,v 1.1 2007/04/11 12:31:32 unconed Exp $
 name = Community Tags
 description = "Allows users to 'tag' other users' content. Weighted tag lists or 'tag clouds' are generated for each piece of content to show the popularity of tags."
-dependencies = tagadelic
+dependencies[] = tagadelic
+core=6.x
\ No newline at end of file
