Comments separately are not blocked also it badly, for example in documents (node) other users comments of the blocked user will be visible.

Comments

nedjo’s picture

Yes, blocking comments will require additional work. I'd welcome a patch.

nedjo’s picture

There is no clean way to implement comment blocking in a module. Comments are not run through db_rewrite_sql(), so we have no method available. The only way I can think of would be a theme-level override of comment rendering. Here's a draft, assuming a phptemplate theme:


function phptemplate_comment_view($comment, $links = array(), $visible = 1) {
  global $user;
 
  // Render the comment only if the comment's author isn't blocked by the current user.
  if ($user->uid && !db_num_rows(db_query("SELECT id FROM {contentblocker} WHERE uid = %d AND id = %d AND type = 'user'", $user->uid, $comment->uid))) {
    return theme_comment_view($comment, $links, $visible);
  }
  return '';
}

You can copy this into your theme's template.php file (or into a new file in your theme's directory called tempate.php, if none exists) and see if it works. Please report back.

nedjo’s picture

Oops, previous version would block all comments for anonymous users. Here's another draft:


function phptemplate_comment_view($comment, $links = array(), $visible = 1) {
  global $user;

  // Render the comment only if the comment's author isn't blocked by the current user.
  if (!$user->uid || ($user->uid && !db_num_rows(db_query("SELECT id FROM {contentblocker} WHERE uid = %d AND id = %d AND type = 'user'", $user->uid, $comment->uid)))) {
    return theme_comment_view($comment, $links, $visible);
  }
  return '';
}

hade’s picture

works fine. but is there any way to put the "block content by user" message under all comments, not only nodes?

nedjo’s picture

Status: Active » Fixed

@hade: that would be a separate feature request issue. (And at present I don't have a lot of time for feature requests. Of course, I welcome patches.)

I've added this code snippet to the module's readme.

Marking fixed since this is the closest we can come for now. There is a patch in the queue to add comment SQL rewriting, so a fuller solution may be possible in D6.

Anonymous’s picture

Status: Fixed » Closed (fixed)