I've added support for the comments-as-nodes by the Nodecomment module and committed this to the -dev version.

(Nodecomment is often used along with Advanced Forum.)

Comments

finex’s picture

That's good. I could try it soon.

salvis’s picture

If you have additional vocabularies on your forum nodes besides the Forum vocabulary, then you may get bitten by a long-standing core bug (#422218: $node->tid can get the wrong tid if a forum content type has additional vocabularies) that keeps FA from writing the required grants for the nodecomment nodes. This may happen on some nodes (actually some combinations of terms) but not on others, so even if you get lucky some of the time, it can strike anytime.

If you do have additional vocabularies, you can work around this core bug by installing Fix Core and turning on the Make sure $node->tid is the forum tid fix.

finex’s picture

Fortunatly it is not my case :-)

salvis’s picture

Unfortunately, the Nodecomments support does not work retroactively, i.e. the Edit and Delete links will only appear on new node comments.

Please try creating a new node comment, then the moderator should get the links.

finex’s picture

And what about forums with a lot of nodecomments? The forum I'm running have more than 5000 comments... fortunatly I didn't use nodecomments :-) :-) :-) :-) :-)

Could it be possible to rebuild the content access table fix retroactively nodecomments?

salvis’s picture

That would require a batch update routine. I doubt anyone wants to code or even only test that...

finex’s picture

lol ... :-)

salvis’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

finex’s picture

Status: Closed (fixed) » Needs work

@Salvis: about the "batch update"... I'm really thinking how to solve this issue: I've 8700 comments converted into node comments.

After some testing it looks that is is necessary to add some missing records on acl_node and node_access:

node_access
for each converted comment (from comment to nodecomment), a new record has to be added:

  • nid = the NID of the new node
  • gid = the ACL ID related to the specific forum term. For example if the forum TID is 150, you can get the GID with a simple query: "SELECT acl_id FROM acl WHERE name = 150;"
  • realm = acl
  • grant_view = 1
  • grant_update = 1
  • grant_delete = 1

acl_node
for each converted comment (from comment to nodecomment), a new record has to be added:

  • acl_id = like on the previous step: the ACL ID related to the specific forum term. For example if the forum TID is 150, you can get the GID with a simple query: "SELECT acl_id FROM acl WHERE name = 150;"
  • nid = The NID of the new node
  • realm = acl
  • grant_view = 1
  • grant_update = 1
  • grant_delete = 1
  • priority = 0

In this way, moderator users will be able to moderate the old replies :-)

finex’s picture

I've created a simple example update script:

$sql = "SELECT nc.cid AS cid, acl.acl_id AS aclid FROM node_comments AS nc LEFT JOIN term_node AS tn ON nc.nid = tn.nid LEFT JOIN acl ON acl.name = tn.tid WHERE nc.cid NOT in (SELECT nid from acl_node);";

$result = db_query($sql);
while ($row = db_fetch_object($result)) {
  $sql_insert = "INSERT INTO `acl_node` (`acl_id`, `nid`, `grant_view`, `grant_update`, `grant_delete`, `priority`) VALUES ('".$row->aclid."', '".$row->cid."', '1', '1', '1', '0');";
  db_query($sql_insert);

  $sql_insert = "INSERT INTO `node_access` (`nid`, `gid`, `realm`, `grant_view`, `grant_update`, `grant_delete`) VALUES ('".$row->cid."', '".$row->aclid."', 'acl', '1', '1', '1');";
  db_query($sql_insert);
}
salvis’s picture

Don't insert records into the {node_access} table! These records are created automatically by rebuilding permissions, which already is a batch process.

If your analysis is correct (and the grant and and priority constants are the same for all records), then you should be able to insert the {acl_node} records through a simple SQL statement like

INSERT INTO acl_node (acl_id, nid, grant_view, grant_update, grant_delete, priority)
SELECT acl.acl_id, nc.cid AS nid, 1, 1, 1, 0 FROM node_comments AS nc LEFT JOIN term_node AS tn ON nc.nid = tn.nid LEFT JOIN acl ON acl.name = tn.tid WHERE nc.cid NOT in (SELECT nid from acl_node);

NOTE: This is untested — be sure to test it yourself before you apply it on your live database!

Then rebuild permissions.

finex’s picture

I understand. I've used the script on #11 because I've done some manual test and I've found that the new node comment have exactly one additianl entry on acl_node an one on node_access (while the node comment from the migration didn't).

So you're saying I could insert the records only into the acl_node and the node_access will be correctly updated with the rebuild premissions?

I'll test it :-)

Thanks!

finex’s picture

I've rebuilded the permissions and the node_access table is quite similar, the difference are not relevant :-)

I'm quite sure that the right grants are "1, 1, 1" and the priority is "0" because, reading the forum access source code, it always do:

acl_node_add_acl($node->nid, $acl_id, 1, 1, 1);

(which has "0" as default for the priority parameter)

Probably the best thing to do is to report this issue to the nodecomment project in order to modify the migration procedure: if the forum access module is enabled, the acl_node records should be inserted and after a "rebuild permission" is required.

salvis’s picture

This requires some additional tuning: you need to JOIN with {term_data} to ensure that you only get tids from the Forum vocabulary, because FA (or ACL on behalf of FA) should only control forum comments, no other comments.

salvis’s picture

Status: Needs work » Fixed

This was reopened at #10 to discuss manual migration, but it seems we've exhausted the subject.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.