| 1 |
<?php |
<?php |
| 2 |
// $Id: comment_alter_taxonomy.module,v 1.11 2009/01/04 22:02:31 damz Exp $ |
// $Id: comment_alter_taxonomy.module,v 1.12 2009/01/05 02:21:00 damz Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 17 |
$name = check_plain($type->type); |
$name = check_plain($type->type); |
| 18 |
$perms[] = "alter taxonomy on $name content"; |
$perms[] = "alter taxonomy on $name content"; |
| 19 |
} |
} |
|
|
|
| 20 |
return $perms; |
return $perms; |
| 21 |
} |
} |
| 22 |
|
|
| 24 |
* Implementation of hook_menu(). |
* Implementation of hook_menu(). |
| 25 |
*/ |
*/ |
| 26 |
function comment_alter_taxonomy_menu($may_cache = TRUE) { |
function comment_alter_taxonomy_menu($may_cache = TRUE) { |
| 27 |
$items = array(); |
$items['admin/settings/comment_alter_taxonomy'] = array( |
| 28 |
|
'title' => 'Comment alter taxonomy', |
| 29 |
if ($may_cache) { |
'description' => 'Enable/disable vocabularies that users may alter from their comments.', |
| 30 |
$items[] = array( |
'page callback' => 'drupal_get_form', |
| 31 |
'path' => 'admin/settings/comment_alter_taxonomy', |
'page arguments' => array('comment_alter_taxonomy_admin_settings'), |
| 32 |
'title' => t('Comment alter taxonomy'), |
'access arguments' => array('administer site configuration'), |
| 33 |
'description' => t('Enable/disable vocabularies that users may alter from their comments.'), |
); |
|
'access' => user_access('administer site configuration'), |
|
|
'callback' => 'drupal_get_form', |
|
|
'callback arguments' => array('comment_alter_taxonomy_admin_settings'), |
|
|
); |
|
|
if (module_exists('project_issue')) { |
|
|
$items[] = array( |
|
|
'path' => 'project/issues-term', |
|
|
'title' => t('Issues for project'), |
|
|
'callback' => '_comment_alter_taxonomy_callback', |
|
|
'callback arguments' => array('project_issue_integration.inc', 'comment_alter_taxonomy_project_issue_page', NULL), |
|
|
'access' => $access, |
|
|
'type' => MENU_CALLBACK, |
|
|
); |
|
|
} |
|
|
} |
|
|
else { |
|
|
if (module_exists('project_issue') && preg_match('@project/issues/([0-9]+)/term@', $_GET['q'], $matches)) { |
|
|
list(, $nid) = $matches; |
|
|
|
|
|
$access_all = user_access('access project issues'); |
|
|
$access_own = user_access('access own project issues'); |
|
|
$access_admin = user_access('administer projects'); |
|
|
$access = $access_all || $access_own || $access_admin; |
|
|
|
|
|
$items[] = array( |
|
|
'path' => 'project/issues/'. $nid .'/term', |
|
|
'title' => t('Issues for project'), |
|
|
'callback' => '_comment_alter_taxonomy_callback', |
|
|
'callback arguments' => array('project_issue_integration.inc', 'comment_alter_taxonomy_project_issue_page', $nid), |
|
|
'access' => $access, |
|
|
'type' => MENU_CALLBACK, |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
| 34 |
return $items; |
return $items; |
| 35 |
} |
} |
| 36 |
|
|
| 59 |
/** |
/** |
| 60 |
* Implementation of hook_form_alter(). |
* Implementation of hook_form_alter(). |
| 61 |
*/ |
*/ |
| 62 |
function comment_alter_taxonomy_form_alter($form_id, &$form) { |
function comment_alter_taxonomy_form_alter(&$form, $form_state, $form_id) { |
| 63 |
switch ($form_id) { |
if ($form_id == 'comment_admin_overview') { |
| 64 |
case 'comment_admin_overview': |
// {comment_alter_taxonomy} may need to be updated if any comments are edited/deleted. |
| 65 |
// {comment_alter_taxonomy} may need to be updated if any comments are edited/deleted. |
$form['#submit'][] = 'comment_alter_taxonomy_comment_mass_update'; |
| 66 |
$form['#submit']['comment_alter_taxonomy_comment_mass_update'] = array(); |
} |
| 67 |
break; |
elseif (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id && isset($form['nid']['#value'])) { |
| 68 |
|
// Prevent user from changing the terms for any vocabulary that can be altered from a comment with this |
| 69 |
default: |
// module. |
| 70 |
// See if this is a node-form that is being edited. |
if (isset($form['taxonomy'])) { |
| 71 |
if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id && isset($form['nid']['#value'])) { |
$alterable_vids = array_keys(comment_alter_taxonomy_get_alterable_vocabularies($form['type']['#value'])); |
| 72 |
// Prevent user from changing the terms for any vocabulary that can be altered from a comment with this |
foreach ($alterable_vids as $vid) { |
| 73 |
// module. |
if (isset($form['taxonomy'][$vid])) { |
| 74 |
if (isset($form['taxonomy'])) { |
unset($form['taxonomy'][$vid]); |
| 75 |
$alterable_vids = array_keys(comment_alter_taxonomy_get_alterable_vocabularies($form['type']['#value'])); |
} |
| 76 |
foreach ($alterable_vids as $vid) { |
elseif (isset($form['taxonomy']['tags'][$vid])) { |
| 77 |
if (isset($form['taxonomy'][$vid])) { |
unset($form['taxonomy']['tags'][$vid]); |
|
unset($form['taxonomy'][$vid]); |
|
|
} |
|
|
elseif (isset($form['taxonomy']['tags'][$vid])) { |
|
|
unset($form['taxonomy']['tags'][$vid]); |
|
|
} |
|
|
} |
|
| 78 |
} |
} |
| 79 |
} |
} |
| 80 |
|
} |
| 81 |
|
} |
| 82 |
|
elseif ($form_id == 'comment_form') { |
| 83 |
|
comment_alter_taxonomy_comment_form($form); |
| 84 |
} |
} |
| 85 |
} |
} |
| 86 |
|
|
| 87 |
function comment_alter_taxonomy_comment_form($form) { |
function comment_alter_taxonomy_comment_form(&$form) { |
| 88 |
// Prepare some variables for later checking. |
// Prepare some variables for later checking. |
| 89 |
$node = node_load($form['nid']['#value']); |
$node = node_load($form['nid']['#value']); |
| 90 |
$access = user_access("alter taxonomy on ". check_plain($node->type) ." content"); |
$access = user_access("alter taxonomy on ". check_plain($node->type) ." content"); |
| 112 |
} |
} |
| 113 |
$form['taxonomy']['#weight'] = -3; |
$form['taxonomy']['#weight'] = -3; |
| 114 |
$form['taxonomy']['#tree'] = TRUE; |
$form['taxonomy']['#tree'] = TRUE; |
|
return $form; |
|
| 115 |
} |
} |
| 116 |
|
|
| 117 |
/** |
/** |
| 134 |
// Determine existing term assignments, if any. |
// Determine existing term assignments, if any. |
| 135 |
if (!isset($node->taxonomy)) { |
if (!isset($node->taxonomy)) { |
| 136 |
if ($node->nid) { |
if ($node->nid) { |
| 137 |
$terms = taxonomy_node_get_terms($node->nid); |
$terms = taxonomy_node_get_terms($node); |
| 138 |
} |
} |
| 139 |
else { |
else { |
| 140 |
$terms = array(); |
$terms = array(); |
| 226 |
function comment_alter_taxonomy_comment($arg, $op) { |
function comment_alter_taxonomy_comment($arg, $op) { |
| 227 |
// $arg can be a comment object, or a form or form_values. |
// $arg can be a comment object, or a form or form_values. |
| 228 |
switch ($op) { |
switch ($op) { |
|
case 'form': |
|
|
// Only allow metadata changes on new comments. |
|
|
if (isset($arg['cid']['#value'])) { |
|
|
return array(); |
|
|
} |
|
|
return comment_alter_taxonomy_comment_form($arg); |
|
|
|
|
| 229 |
case 'insert': |
case 'insert': |
| 230 |
if (isset($arg['taxonomy'])) { |
if (isset($arg['taxonomy'])) { |
| 231 |
// Fetch the cid of the previous comment and store the tids of the current node if necessary. |
// Fetch the cid of the previous comment and store the tids of the current node if necessary. |
| 232 |
$previous_cid = (int) db_result(db_query_range('SELECT cid FROM {comments} WHERE nid = %d AND cid < %d ORDER BY cid DESC', $arg['nid'], $arg['cid'], 0, 1)); |
$previous_cid = (int) db_result(db_query_range('SELECT cid FROM {comments} WHERE nid = %d AND cid < %d ORDER BY cid DESC', $arg['nid'], $arg['cid'], 0, 1)); |
| 233 |
_comment_alter_taxonomy_save_tids($arg['nid'], $previous_cid); |
$node = node_load($arg['nid']); |
| 234 |
|
_comment_alter_taxonomy_save_tids($node, $previous_cid); |
| 235 |
|
|
| 236 |
// Save the terms to the node itself. |
// Save the terms to the node itself. |
| 237 |
taxonomy_node_save($arg['nid'], $arg['taxonomy']); |
taxonomy_node_save($node, $arg['taxonomy']); |
| 238 |
|
|
| 239 |
// Load the node again so we can reset the internal node_load cache. |
// Load the node again so we can reset the internal node_load cache. |
| 240 |
node_load($arg['nid'], NULL, TRUE); |
$node = node_load($arg['nid'], NULL, TRUE); |
| 241 |
|
|
| 242 |
// Store the tids assigned to the node at this point to the {comment_alter_taxonomy} table. |
// Store the tids assigned to the node at this point to the {comment_alter_taxonomy} table. |
| 243 |
_comment_alter_taxonomy_save_tids($arg['nid'], $arg['cid']); |
_comment_alter_taxonomy_save_tids($node, $arg['cid']); |
| 244 |
} |
} |
| 245 |
break; |
break; |
| 246 |
|
|
| 263 |
* The cid of the comment. Set this to 0 if this is the original |
* The cid of the comment. Set this to 0 if this is the original |
| 264 |
* node and not an actual comment. |
* node and not an actual comment. |
| 265 |
*/ |
*/ |
| 266 |
function _comment_alter_taxonomy_save_tids($nid, $cid) { |
function _comment_alter_taxonomy_save_tids($node, $cid) { |
| 267 |
global $db_type; |
global $db_type; |
| 268 |
if (!db_result(db_query_range("SELECT cid FROM {comment_alter_taxonomy} WHERE nid = %d AND cid = %d", $nid, $cid, 0, 1))) { |
if (!db_result(db_query_range("SELECT cid FROM {comment_alter_taxonomy} WHERE nid = %d AND cid = %d", $node->nid, $cid, 0, 1))) { |
| 269 |
// Ignore is only supported on MySQL. |
// Ignore is only supported on MySQL. |
| 270 |
$ignore = $db_type == 'mysql' || $db_type == 'mysqli' ? 'IGNORE' : ''; |
$ignore = $db_type == 'mysql' || $db_type == 'mysqli' ? 'IGNORE' : ''; |
| 271 |
|
|
| 272 |
// Insert a dummy tid = 0 to ensure the table contain at least one row for this comment. |
// Insert a dummy tid = 0 to ensure the table contain at least one row for this comment. |
| 273 |
// Insert is first, do reduce possible concurrency issue. That query can |
// Insert is first, do reduce possible concurrency issue. That query can |
| 274 |
// fail in case of concurrent insert in some cases, suppress error display. |
// fail in case of concurrent insert in some cases, suppress error display. |
| 275 |
@db_query("INSERT $ignore INTO {comment_alter_taxonomy} (nid, cid, tid) VALUES (%d, %d, %d)", $nid, $cid, 0); |
@db_query("INSERT $ignore INTO {comment_alter_taxonomy} (nid, cid, tid) VALUES (%d, %d, %d)", $node->nid, $cid, 0); |
| 276 |
|
|
| 277 |
// Insert the real terms. |
// Insert the real terms. |
| 278 |
@db_query("INSERT $ignore INTO {comment_alter_taxonomy} (nid, cid, tid) SELECT nid, %d, tid FROM {term_node} WHERE nid = %d", $cid, $nid); |
@db_query("INSERT $ignore INTO {comment_alter_taxonomy} (nid, cid, tid) SELECT nid, %d, tid FROM {term_node} WHERE vid = %d", $cid, $node->vid); |
| 279 |
|
|
| 280 |
// If the previous query actually inserted terms, remove the dummy tid = 0. |
// If the previous query actually inserted terms, remove the dummy tid = 0. |
| 281 |
if (db_result(db_query_range("SELECT cid FROM {comment_alter_taxonomy} WHERE nid = %d AND cid = %d AND tid != 0", $nid, $cid, 0, 1))) { |
if (db_result(db_query_range("SELECT cid FROM {comment_alter_taxonomy} WHERE nid = %d AND cid = %d AND tid <> 0", $node->nid, $cid, 0, 1))) { |
| 282 |
db_query("DELETE FROM {comment_alter_taxonomy} WHERE nid = %d AND cid = %d and tid = 0", $nid, $cid); |
db_query("DELETE FROM {comment_alter_taxonomy} WHERE nid = %d AND cid = %d and tid = 0", $node->nid, $cid); |
| 283 |
} |
} |
| 284 |
} |
} |
| 285 |
} |
} |
| 292 |
* a node's taxonomy made in this module can be read back by other modules |
* a node's taxonomy made in this module can be read back by other modules |
| 293 |
* during the page load. |
* during the page load. |
| 294 |
* |
* |
| 295 |
* @param $nid |
* @param $node |
| 296 |
* The nid of the node object from which to get terms. |
* The node. |
| 297 |
* @param $key |
* @param $key |
| 298 |
* Key in the array to look for. |
* Key in the array to look for. |
| 299 |
* @param $reset_nid |
* @param $reset |
| 300 |
* If set to true, terms for the specified $nid stored in the static cache will |
* If set to true, terms for the specified $nid stored in the static cache will |
| 301 |
* be ignored and the terms will be re-retrieved from the database. |
* be ignored and the terms will be re-retrieved from the database. |
| 302 |
* @return |
* @return |
| 303 |
* An array of terms associated with the given node, ordered by vocabulary |
* An array of terms associated with the given node, ordered by vocabulary |
| 304 |
* and term weight. |
* and term weight. |
| 305 |
*/ |
*/ |
| 306 |
function comment_alter_taxonomy_taxonomy_node_get_terms($nid, $key = 'tid', $reset_nid = NULL) { |
function _comment_alter_taxonomy_taxonomy_node_get_terms($node, $key = 'tid', $reset = FALSE) { |
| 307 |
static $terms; |
static $terms; |
| 308 |
|
|
| 309 |
if (!isset($terms[$nid][$key]) || $reset_nid) { |
if (!isset($terms[$node->vid][$key]) || $reset) { |
| 310 |
$result = db_query(db_rewrite_sql('SELECT t.* FROM {term_node} r INNER JOIN {term_data} t ON r.tid = t.tid INNER JOIN {vocabulary} v ON t.vid = v.vid WHERE r.nid = %d ORDER BY v.weight, t.weight, t.name', 't', 'tid'), $nid); |
$result = db_query(db_rewrite_sql('SELECT t.* FROM {term_node} r INNER JOIN {term_data} t ON r.tid = t.tid INNER JOIN {vocabulary} v ON t.vid = v.vid WHERE r.vid = %d ORDER BY v.weight, t.weight, t.name', 't', 'tid'), $node->vid); |
| 311 |
$terms[$nid][$key] = array(); |
$terms[$node->vid][$key] = array(); |
| 312 |
while ($term = db_fetch_object($result)) { |
while ($term = db_fetch_object($result)) { |
| 313 |
$terms[$nid][$key][$term->$key] = $term; |
$terms[$node->vid][$key][$term->$key] = $term; |
| 314 |
} |
} |
| 315 |
} |
} |
| 316 |
return $terms[$nid][$key]; |
return $terms[$node->vid][$key]; |
| 317 |
} |
} |
| 318 |
|
|
| 319 |
/** |
/** |
| 398 |
); |
); |
| 399 |
} |
} |
| 400 |
|
|
| 401 |
$old_terms = _comment_alter_taxonomy_build_term_list($node->nid, $old_data); |
$old_terms = _comment_alter_taxonomy_build_term_list($node, $old_data); |
| 402 |
$new_terms = _comment_alter_taxonomy_build_term_list($node->nid, $new_data); |
$new_terms = _comment_alter_taxonomy_build_term_list($node, $new_data); |
| 403 |
|
|
| 404 |
if ($old_terms !== FALSE && $new_terms !== FALSE && (!empty($old_terms) || !empty($new_terms))) { |
if ($old_terms !== FALSE && $new_terms !== FALSE && (!empty($old_terms) || !empty($new_terms))) { |
| 405 |
// Merge all terms together. |
// Merge all terms together. |
| 456 |
} |
} |
| 457 |
|
|
| 458 |
/** |
/** |
| 459 |
|
* Implementation of hook_theme(). |
| 460 |
|
*/ |
| 461 |
|
function comment_alter_taxonomy_theme() { |
| 462 |
|
return array( |
| 463 |
|
'comment_alter_taxonomy_project_issue_metadata_term' => array( |
| 464 |
|
'arguments' => array('node' => NULL, 'term' => NULL), |
| 465 |
|
), |
| 466 |
|
); |
| 467 |
|
} |
| 468 |
|
|
| 469 |
|
/** |
| 470 |
* Theme a taxonomy term in a project issue metadata table. |
* Theme a taxonomy term in a project issue metadata table. |
| 471 |
* |
* |
| 472 |
* NOTE: This function (and any function that overrides it) |
* NOTE: This function (and any function that overrides it) |
| 480 |
function theme_comment_alter_taxonomy_project_issue_metadata_term($node, $term) { |
function theme_comment_alter_taxonomy_project_issue_metadata_term($node, $term) { |
| 481 |
if (isset($term->tid)) { |
if (isset($term->tid)) { |
| 482 |
if (module_exists('project_issue') && $node->type == 'project_issue') { |
if (module_exists('project_issue') && $node->type == 'project_issue') { |
| 483 |
$path = 'project/issues/'. $node->pid .'/term/'. $term->tid; |
$path = 'project/issues/'. $node->project_issue['pid'] .'/term/'. $term->tid; |
| 484 |
} |
} |
| 485 |
else { |
else { |
| 486 |
$path = taxonomy_term_path($term); |
$path = taxonomy_term_path($term); |
| 497 |
/** |
/** |
| 498 |
* Build a list of all taxonomy terms associated with a comment. |
* Build a list of all taxonomy terms associated with a comment. |
| 499 |
* |
* |
| 500 |
* @param $nid |
* @param $node |
| 501 |
* The nid of the node with which the comment is associated. |
* The node. |
| 502 |
* @param $comment |
* @param $comment |
| 503 |
* Either a comment object or the result of a posted comment. |
* Either a comment object or the result of a posted comment. |
| 504 |
* @return |
* @return |
| 510 |
* case where no information at all is saved in {comment_alter_taxonomy} |
* case where no information at all is saved in {comment_alter_taxonomy} |
| 511 |
* for a given comment, FALSE is returned. |
* for a given comment, FALSE is returned. |
| 512 |
*/ |
*/ |
| 513 |
function _comment_alter_taxonomy_build_term_list($nid, $comment) { |
function _comment_alter_taxonomy_build_term_list($node, $comment) { |
| 514 |
$term_list = array(); |
$term_list = array(); |
| 515 |
// For previews and validation, $comment->taxonomy should be set |
// For previews and validation, $comment->taxonomy should be set |
| 516 |
// and must be processed to get the terms. Otherwise, they can |
// and must be processed to get the terms. Otherwise, they can |
| 564 |
} |
} |
| 565 |
else { |
else { |
| 566 |
$cid = isset($comment->cid) ? $comment->cid : 0; |
$cid = isset($comment->cid) ? $comment->cid : 0; |
| 567 |
$result = db_query(db_rewrite_sql('SELECT cat.tid, t.* FROM {comment_alter_taxonomy} cat LEFT JOIN {term_data} t ON cat.tid = t.tid LEFT JOIN {vocabulary} v ON t.vid = v.vid WHERE cat.nid = %d AND cat.cid = %d ORDER BY v.weight, t.weight, t.name', 't', 'tid'), $nid, $cid); |
$result = db_query(db_rewrite_sql('SELECT cat.tid, t.* FROM {comment_alter_taxonomy} cat LEFT JOIN {term_data} t ON cat.tid = t.tid LEFT JOIN {vocabulary} v ON t.vid = v.vid WHERE cat.nid = %d AND cat.cid = %d ORDER BY v.weight, t.weight, t.name', 't', 'tid'), $node->nid, $cid); |
| 568 |
while ($term = db_fetch_object($result)) { |
while ($term = db_fetch_object($result)) { |
| 569 |
$term_list[$term->tid] = $term; |
$term_list[$term->tid] = $term; |
| 570 |
} |
} |
| 582 |
} |
} |
| 583 |
|
|
| 584 |
/** |
/** |
|
* Find all terms associated with a given node and cid, ordered by vocabulary and term weight. |
|
|
* This function is a modified version of taxonomy_node_get_terms(). |
|
|
* |
|
|
* @param $nid |
|
|
* The node id. |
|
|
* @param $cid |
|
|
* The comment id. The {comment_alter_taxonomy} table stores terms associated |
|
|
* with the original node by using $cid = 0. |
|
|
* @param $reset |
|
|
* To reset the $terms cache, set this to TRUE. |
|
|
* @return |
|
|
* An array of terms associated with the given $nid and $cid, ordered by vocabulary and term weight. |
|
|
*/ |
|
|
function comment_alter_taxonomy_get_terms($nid, $cid, $reset = FALSE) { |
|
|
static $terms; |
|
|
if ($reset) { |
|
|
$terms = array(); |
|
|
} |
|
|
|
|
|
if (!isset($terms[$nid][$cid])) { |
|
|
$result = db_query(db_rewrite_sql('SELECT t.* FROM {comment_alter_taxonomy} cat INNER JOIN {term_data} t ON cat.tid = t.tid INNER JOIN {vocabulary} v ON t.vid = v.vid WHERE cat.nid = %d AND cat.cid = %d ORDER BY v.weight, t.weight, t.name', 't', 'tid'), $nid, $cid); |
|
|
$terms[$nid][$cid] = array(); |
|
|
while ($term = db_fetch_array($result)) { |
|
|
$terms[$nid][$cid][$term['tid']] = $term; |
|
|
} |
|
|
} |
|
|
return $terms[$nid][$cid]; |
|
|
} |
|
|
|
|
|
/** |
|
| 585 |
* Implementation of hook_nodeapi(). |
* Implementation of hook_nodeapi(). |
| 586 |
* |
* |
| 587 |
* For this implementation of hook_nodeapi() to be effective, the taxonomy |
* Note that the taxonomy module must have a weight lighter |
| 588 |
* module must have a weight lighter than the comment_alter_taxonomy module, |
* than the comment_alter_taxonomy module, which itself must |
| 589 |
* which itself must be lighter than the project_issue module. |
* be lighter than the project_issue module. |
| 590 |
*/ |
*/ |
| 591 |
function comment_alter_taxonomy_nodeapi(&$node, $op, $arg = 0) { |
function comment_alter_taxonomy_nodeapi(&$node, $op, $arg = 0) { |
| 592 |
switch ($op) { |
switch ($op) { |
| 597 |
// were to call node_load() during the same page request and then call |
// were to call node_load() during the same page request and then call |
| 598 |
// node_save() on the same node, the changes in terms made by this module |
// node_save() on the same node, the changes in terms made by this module |
| 599 |
// would get eliminated. The project_issue module has this exact behavior. |
// would get eliminated. The project_issue module has this exact behavior. |
| 600 |
$output['taxonomy'] = comment_alter_taxonomy_taxonomy_node_get_terms($node->nid, 'tid', TRUE); |
$output['taxonomy'] = _comment_alter_taxonomy_taxonomy_node_get_terms($node, 'tid', TRUE); |
| 601 |
return $output; |
return $output; |
| 602 |
break; |
break; |
| 603 |
|
|
| 612 |
// That makes our job easier here, because we can just call |
// That makes our job easier here, because we can just call |
| 613 |
// comment_alter_taxonomy_taxonomy_node_get_terms() to get them |
// comment_alter_taxonomy_taxonomy_node_get_terms() to get them |
| 614 |
// back from the database. |
// back from the database. |
| 615 |
$tids = array_keys(comment_alter_taxonomy_taxonomy_node_get_terms($node->nid, 'tid', TRUE)); |
$tids = array_keys(_comment_alter_taxonomy_taxonomy_node_get_terms($node, 'tid', TRUE)); |
| 616 |
|
|
| 617 |
// Delete any records already in the table for this original node (for |
// Delete any records already in the table for this original node (for |
| 618 |
// original nodes, the cid is stored as 0). |
// original nodes, the cid is stored as 0). |
| 625 |
} |
} |
| 626 |
break; |
break; |
| 627 |
|
|
| 628 |
|
case 'delete revision': |
| 629 |
|
// We don't have anything to do here, |
| 630 |
|
// as we version terms by cid, not by vid. |
| 631 |
|
break; |
| 632 |
|
|
| 633 |
case 'delete': |
case 'delete': |
| 634 |
db_query("DELETE FROM {comment_alter_taxonomy} WHERE nid = %d", $node->nid); |
db_query("DELETE FROM {comment_alter_taxonomy} WHERE nid = %d", $node->nid); |
| 635 |
break; |
break; |
| 672 |
* |
* |
| 673 |
* Remove taxonomy links on project issues, when required. |
* Remove taxonomy links on project issues, when required. |
| 674 |
*/ |
*/ |
| 675 |
function comment_alter_taxonomy_link_alter(&$node, &$links) { |
function comment_alter_taxonomy_link_alter(&$links, $node) { |
| 676 |
if (module_exists('project_issue') && $node->type == 'project_issue') { |
if (module_exists('project_issue') && $node->type == 'project_issue') { |
| 677 |
$allowed = comment_alter_taxonomy_get_alterable_vocabularies('project_issue'); |
$allowed = comment_alter_taxonomy_get_alterable_vocabularies('project_issue'); |
| 678 |
if (empty($allowed) || empty($node->taxonomy)) { |
if (empty($allowed) || empty($node->taxonomy)) { |