The following changes give comments the same forum taxonomy terms as the main post (while leaving others untouched). This helps a lot when using the module Taxonomy Access Control, allowing you to control access on both the posts and replies.
Around line 402, to be inserted in nodeforum_update:
$result = db_query('SELECT cid FROM {node_comments} WHERE nid = %d', $node->nid);
$first = true;
while ($nc = db_fetch_object($result)) {
$cids[] = $nc->cid;
$first ? $cid_values = "(" . $nc->cid . ", " . $node->tid . ")" : $cid_values .= ", (" . $nc->cid . ", " . $node->tid . ")";
$first = false;
}
if (count($cids)) {
db_query('DELETE tn FROM {term_node} tn, {term_data} td WHERE td.vid = %d AND td.tid = tn.tid AND tn.nid IN (%s)', _nodeforum_get_vid(), implode(', ', $cids));
db_query('INSERT INTO {term_node} (nid, tid) VALUES %s', $cid_values);
}
/* In case the forum post is being moved to another term, make sure
* all forum replies are moved as well.
*/
Around line 139, to be inserted into nodeforum_nodeapi:
case 'insert':
case 'update':
$comment_type = variable_get('comment_type_'. $node->type, variable_get('default_comment_type', ''));
if ($node->type = $comment_type && isset($node->comment_target_nid)) {
$result = db_fetch_object(db_query('SELECT * FROM {term_node} tn, {term_data} td WHERE vid = %d AND tn.tid = td.tid AND tn.nid = %d', _nodeforum_get_vid(), $node->comment_target_nid));
db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $node->nid, $result->tid);
}
break;
Sam
Comments
Comment #1
summit commentedHi, before commtting this, did somebody else also tested this?
Is this a community wanted add on?
greetings,
Martijn
Comment #2
summit commentedHi,
This is what I get back with testing this code:
Please correct code, so these errors do not occur. And please file a patch for this.
Thanks a lot in advance!
greetings,
Martijn