I would like users to be able to modify whether or not people can comment on the posts they make. By default I want comments for all nodes to be Disabled, then the owner is able to set them to Read Only or Read/Write. This is for an online writing community where I would like the poster to be able to accept criticism, or not. I don't want to give authenticated users "moderate comments" to reach this end, because then (as I understand it) they can moderate/edit/delete othe people's posts/comments. That is not desirable. I just want the owner of a node to be able to modify the "User comments" section. Is this possible?

Comments

tclineks’s picture

I believe it would entail hacking an additional permission into comment.module.

I haven't looked closely myself but I imagine this is easily a <20 line addition.

If you need further direction please ask.

unkommon’s picture

I have edited 4 lines of code so far, and it is displaying correctly but the selection doesn't stick!

I have changed content_perm to:

function comment_perm() {
  return array('access comments', 'post comments', 'administer comments', 'moderate comments', 'modify comments for node', 'post comments without approval', 'administer moderation');
}

and inside comment_nodeapi()

    case 'form admin':
      if (user_access('administer comments') || user_access('modify comments for node')) {

then inside node.module I have edited node_form() to bring $extras out of the if(user_access['administer nodes')

  if (user_access('administer nodes')) {
     .... authored by and node_options stuff....
  }
  $extras .= implode('</div><div class="extra">', node_invoke_nodeapi($edit, 'form admin'));
  $output .= $extras ? '<div class="extra">'. $extras .'</div></div>' : '</div>';

So all is displaying well enough. But when i alter the value of the comments, it doesn't seem to stick. I have been looking everywhere to see where it is setting it back to the default, to no avail. Any ideas on where to go with this?

Ian Ward’s picture

I think you might need to do something in node_validate in the node module as well...which checks against the default node workflow/publishing settings...I believe

Ian

unkommon’s picture

Okay, now it works

change the primary if statement in the 'validate' of comment_nodeapi to

    case 'validate':
      if (!user_access('administer nodes') && !user_access('modify comments for node')) {

In conjunction with my changes listed above. All is well :).

Ian Ward’s picture

That's great. Now how about the idea of letting users administer comments that are only on posts that they made? Like delete, unpublish, publish comments...

unkommon’s picture

Yeah, that is ideal (especially with how I worded the additional permission). I believe that hack would take a bit more work, and I don't really need it for my site. But I will work on it anyway. It shouldn't be too time consuming now that comment.module and I are good friends. I'll post the edits once it is complete.

Ian Ward’s picture

This could be really convenient for sites where the are multiple bloggers, for example, but they're not trusted enough to have admin/comments privs to admin all comments, but they are trusted enough to admin comments that are on their own blogs. How do you imagine doing this? Just doing on-page publish/delete, so the comment shows up on the post only for those w/ administer comments privs and the post owner, and the command to publish, unpublish, or delete the comment is right there on the comment itself, or offer an overview screen much like the admin/comments overview, but like admin/comments/uid where uid is the userid for the post-owner who has comments on their posts and w/ privs to 'administer received comments' for example?

edming’s picture

testing

edming’s picture

testing 2

ToddZ-1’s picture

This feature would be very nice to have, and seems so obvious now that you mention it.
(I'm really commenting just so it's easier for me to revisit this thread. Wish we could mark threads or subscribe or something.)

tclineks’s picture

unkommon - please create a feature issue and post a patch to comment.module when you're done.

read http://drupal.org/patch if you're not familiar with patches.

zero-zero’s picture

Hi guys,
I hack my drupal commnets module, so now, for a user it shows only the comments posted on content created by himself, and for the administrator show all the comments.

For me, it looks to work fine, but however, I Have no php experience at all (actually this were my first php code lines)
so maybe it can be done in a better way.

How I did (I am using drupal 4.6.5):

I did all the chnages in the previous posts in comments.module and node. module plus the following one:

I change in comments.module line 1028:

$sql = 'SELECT c.subject, c.nid, c.cid, c.comment, c.timestamp, c.status, c.name, c.homepage, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE c.status = '. db_escape_string($status);

with the follwing lines of code

global $user;
  
  if(user_access('administer nodes')){
  		$sql = 'SELECT c.subject, c.nid, c.cid, c.comment, c.timestamp, c.status, c.name, c.homepage, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE c.status = '. db_escape_string($status);
  }else{
  		$sql = 'SELECT  c.subject, c.nid, c.cid, c.comment, c.timestamp, c.status, c.name, c.homepage FROM {comments} c INNER JOIN (SELECT n.*  from {users} u INNER JOIN  {node} n ON (u.uid = n.uid) WHERE u.uid ='. db_escape_string($user->uid). ') u ON (u.nid = c.nid) WHERE  c.status = '. db_escape_string($status);
  }

I repeat so far it looks to work fine, however any feedback from a php expert will be welcome!

Cheers