Index: community_tags.ajax.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/community_tags/community_tags.ajax.inc,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 community_tags.ajax.inc
--- community_tags.ajax.inc 23 Aug 2008 03:04:47 -0000 1.1.2.3
+++ community_tags.ajax.inc 10 Jul 2009 14:57:50 -0000
@@ -23,10 +23,10 @@
// 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);
+ community_tags_taxonomy_node_save($node, array('tags' => array($vid => $tags)), FALSE, $user->uid, $_POST['xid']);
// 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, $_POST['xid']));
// Output JSON.
print drupal_json(array('status' => TRUE, 'tags' => $tags, 'sequence' => $_POST['sequence']));
Index: community_tags.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/community_tags/community_tags.install,v
retrieving revision 1.9
diff -u -r1.9 community_tags.install
--- community_tags.install 18 Jul 2008 03:32:55 -0000 1.9
+++ community_tags.install 10 Jul 2009 14:58:24 -0000
@@ -34,12 +34,14 @@
'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),
+ 'xid' => 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'),
+ 'xid' => array('uid'),
),
'primary key' => array('tid', 'uid', 'nid'),
);
Index: community_tags.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/community_tags/community_tags.js,v
retrieving revision 1.4.2.1
diff -u -r1.4.2.1 community_tags.js
--- community_tags.js 19 Jul 2008 17:13:54 -0000 1.4.2.1
+++ community_tags.js 10 Jul 2009 14:59:08 -0000
@@ -42,7 +42,7 @@
// Prepare the add Ajax handler and add the button.
var addHandler = function () {
// Send existing tags and new tag string.
- $.post(o.url, Drupal.serialize({ sequence: ++sequence, tags: o.tags, add: textfield[0].value }), function (data) {
+ $.post(o.url, Drupal.serialize({ sequence: ++sequence, tags: o.tags, add: textfield[0].value, xid: o.xid}), function (data) {
data = Drupal.parseJson(data);
if (data.status && sequence == data.sequence) {
o.tags = data.tags;
@@ -69,7 +69,7 @@
updateList();
// Send new tag list.
- $.post(o.url, Drupal.serialize({ sequence: ++sequence, tags: o.tags, add: '' }), function (data) {
+ $.post(o.url, Drupal.serialize({ sequence: ++sequence, tags: o.tags, add: '', xid: o.xid }), function (data) {
data = Drupal.parseJson(data);
if (data.status && sequence == data.sequence) {
o.tags = data.tags;
@@ -85,7 +85,7 @@
function updateList() {
list.empty();
for (i in o.tags) {
- list.append('
'+ Drupal.communityTags.checkPlain(o.tags[i]) +'');
+ list.append(''+ Drupal.communityTags.checkPlain(o.tags[i]) +'');
}
$('li', list).click(deleteHandler);
}
Index: community_tags.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/community_tags/community_tags.module,v
retrieving revision 1.37.2.5
diff -u -r1.37.2.5 community_tags.module
--- community_tags.module 23 Aug 2008 03:04:47 -0000 1.37.2.5
+++ community_tags.module 10 Jul 2009 14:59:26 -0000
@@ -238,9 +238,15 @@
/**
* 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, $xid = NULL) {
$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);
+ if (!$xid) {
+ $sql = "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 c.xid = 0 ORDER BY t.name";
+ }
+ else {
+ $sql = "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 c.xid = %d ORDER BY t.name";
+ }
+ $result = db_query($sql, $nid, $uid, $xid);
while ($term = db_fetch_object($result)) {
$tags[$term->tid] = $term;
}
@@ -251,7 +257,7 @@
/**
* Save community_tags term associations and counts for a given node.
*/
-function community_tags_taxonomy_node_save($node, $terms, $is_owner, $uid) {
+function community_tags_taxonomy_node_save($node, $terms, $is_owner, $uid, $xid = NULL) {
$community_tagged = variable_get('community_tags_vocabularies', array());
if (count($community_tagged) == 0) {
return;
@@ -263,7 +269,12 @@
// 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);
+ if (!$xid) {
+ $result = db_query('SELECT * FROM {community_tags} ttn WHERE nid = %d AND xid = 0', $nid);
+ }
+ else {
+ $result = db_query('SELECT * FROM {community_tags} ttn WHERE nid = %d AND xid = %d', $nid, $xid);
+ }
while ($old_tag_node = db_fetch_object($result)) {
$old_tags_by_uid[$old_tag_node->uid][$old_tag_node->tid] = $old_tag_node;
}
@@ -346,9 +357,15 @@
// 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);
+
+ if (!$xid) {
+ db_query('DELETE FROM {community_tags} WHERE nid = %d AND xid = 0', $nid);
+ }
+ else {
+ db_query('DELETE FROM {community_tags} WHERE nid = %d AND xid = %d', $nid, $xid);
+ }
foreach ($tag_nodes as $tag_node) {
- db_query('INSERT INTO {community_tags} (tid, nid, uid, date) VALUES (%d, %d, %d, %d)', $tag_node->tid, $tag_node->nid, $tag_node->uid, $tag_node->date);
+ db_query('INSERT INTO {community_tags} (tid, nid, uid, xid, date) VALUES (%d, %d, %d, %d, %d)', $tag_node->tid, $tag_node->nid, $tag_node->uid, $xid, $tag_node->date);
// Remember to insert term-node relation into term_node table if it doesn't exist already.
if (!isset($existing_term_nodes[$tag_node->tid])) {
@@ -405,7 +422,6 @@
*/
function _community_tags_get_tag_result($type = 'global', $limit = NULL, $arg1 = NULL, $arg2 = NULL) {
$sql = '';
-
switch ($type) {
case 'node':
$arg1 = (int)$arg1;
@@ -422,6 +438,11 @@
$arg2 = NULL;
$sql = "SELECT COUNT(c.tid) AS count, t.tid, t.name, t.vid FROM {term_data} t INNER JOIN {community_tags} c ON c.tid = t.tid WHERE c.uid = %d GROUP BY c.tid ORDER BY count DESC";
break;
+ case 'extra':
+ $arg1 = (int)$arg1;
+ $arg2 = (int)$arg2;
+ $sql = "SELECT COUNT(c.tid) AS count, t.tid, t.name, t.vid FROM {term_data} t INNER JOIN {community_tags} c ON c.tid = t.tid WHERE c.nid = %d AND c.xid = %d GROUP BY c.tid ORDER BY count DESC";
+ break;
case 'user_node':
$arg1 = (int)$arg1;
$arg2 = (int)$arg2;
@@ -442,7 +463,7 @@
/**
* Community tags callback for node view.
*/
-function community_tags_node_view($node, $inline = TRUE) {
+function community_tags_node_view($node, $inline = TRUE, $xid = NULL) {
global $user;
if (is_numeric($node)) {
$node = node_load($node);
@@ -451,11 +472,15 @@
if (!$inline) {
drupal_set_title(check_plain($node->title));
}
-
- $cloud = community_tags_display('node', NULL, $node->nid);
-
+ if (!$xid) {
+ $cloud = community_tags_display('node', NULL, $node->nid);
+ $tags = community_tags_get_user_node_tags($user->uid, $node->nid);
+ }
+ else {
+ $cloud = community_tags_display('extra', NULL, $node->nid, $xid);
+ $tags = community_tags_get_user_node_tags($user->uid, $node->nid, $xid);
+ }
$vid = array_shift(community_tags_vids_for_node($node));
- $tags = community_tags_get_user_node_tags($user->uid, $node->nid);
$names = array();
$output = '';
@@ -470,14 +495,16 @@
// 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));
+ $output .= drupal_get_form('community_tags_form', array('node' => $node, 'cloud' => $cloud, 'nid' => $node->nid, 'vid' => $vid, 'tags' => $tags, 'inline' => $inline, 'xid' => $xid));
}
else {
// Sorry, no more adding tags for you!
- $output .= ''. t('You have already tagged this post. Your tags: ') . theme('community_tags', $tags) .'
';
+ $destination = drupal_get_destination();
+ $output .= ''. t('You have already tagged this post. Your tags: ') . theme('community_tags', $tags) .'
+ '. t('
Login or
register to tag items', array('@login' => url('user/login', array('query' => $destination)), '@register' => url('user/register', array('query' => $destination)))) .'
';
}
- drupal_add_js(array('communityTags' => array('tags' => $names, 'url' => url('community-tags/js/'. $node->nid), 'add' => t('Add'))), 'setting');
+ drupal_add_js(array('communityTags' => array('tags' => $names, 'url' => url('community-tags/js/'. $node->nid), 'add' => t('Add'), 'xid' => $xid)), '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.1.2.3
diff -u -r1.1.2.3 community_tags.pages.inc
--- community_tags.pages.inc 8 Mar 2009 10:32:52 -0000 1.1.2.3
+++ community_tags.pages.inc 10 Jul 2009 14:59:22 -0000
@@ -41,7 +41,7 @@
$destination = drupal_get_destination();
$form['login'] = array(
'#type' => 'markup',
- '#value' => ''. t('
Login or
register to tag items', array('@login' => url('user/login', array('query' => $destination)), '@register' => url('user/register', array('query' => $destination)))) .'
',
+ '#value' => ''. t('
Login or
register to tag items.', array('@login' => url('user/login', array('query' => $destination)), '@register' => url('user/register', array('query' => $destination)))) .'
',
);
}
@@ -66,6 +66,11 @@
'#value' => $edit['vid'],
);
+ $form['xid'] = array(
+ '#type' => 'value',
+ '#value' => $edit['xid'],
+ );
+
return $form;
}