The idea is great which should be pushed forwards but currently the module doesn't work for me. No help or configuration screen.

Is there any special permissions which should be defined?

Comments

siliconmind’s picture

Status: Active » Postponed (maintainer needs more info)

There is no configuration or help. This module just needs to be enabled. That's it. If your comments work the module should too.
Can you post comments on your site? Have you checked with anonymous and authenticated user?

alberto56’s picture

Hi,

I'm having the same problem. Comments are enabled on my site. I have left a comment on one of my posts, as an anonymous user. Normally I would be notified by email and then moderate the comment. I have used another module, admin block, to display unpublished comments as a block, which works great, but it also shows unpublished nodes, which I don't want.

I installed and enabled su_comments to show only unpublished comments in a block, but I don't understand how to use it.

Once enabled, I was expecting a block to show up in my "blocks" page, which I could then render visible, but no block has been added by su_comments; in fact activating the module seems to do nothing at all. Like levavie, I seem to be missing something...

(I am running Drupal 6.10)

Any help would be greatly appreciated. Cheers,

Albert

siliconmind’s picture

Assigned: Unassigned » siliconmind
Priority: Critical » Minor
Status: Postponed (maintainer needs more info) » Closed (works as designed)

alberto56, this module is not for administrators! It is designed for normal users that leave comments on your site.
If you browse pages as an administrator nothing will change. There is no block with comments either. The only thing that this module does is to display unpublished comments to their authors. Consider this standard scenario:
1. You run site with moderated comments.
2. Anonymous user leaves a comment.
3. The comment awaits moderation hence it is not visible to anyone (apart from administrators)
4. You as an administrator have to publish the comment to make it visible to all users including the one who created this comment in first place.

With my module nothing will change except point 3.:
3. The comment awaits moderation hence it is not visible to anyone (apart from administrators and user that wrote the comment (even if it is anonymous user!)).

This is just a kind feedback to the commenting user, so he (or she) can see that his (or hers) comment has been saved and awaits moderation. Normally user would see just a plain text message "Your comment awaits moderation" (or something like that), but this message will disappear as soon as user reloads the page. When using su_comments that user can see his comment right away after comment form had been submitted.

If that is the case I'm setting this issue status to by design. If that's not the case, please reopen with more info.

wwwoliondorcom’s picture

Hi,

I don't know if it's related but I can see the unapproved comment ABOVE the content, it means that the comment doesn't show under the content as it should but print on the content text (superposition), and looks like a bug.

Maybe it's a theme problem, as I am using DRIGG module with it's own digg-like theme.

Thanks for help and for this soon useful module !

siliconmind’s picture

su_comments attaches itself to the node via hook_nodeapi adding unpublished nodes as part of a node's content. As far as i know that's the only way to do it. To make sure that comments are shown below page content I've set their weight to value the of 100 (one hundred).

The problem may occur if you are using modules that generate content with weight greater than this value. This way drupal will automatically render unpublished comments before heavier content. If that is the case, the easiest way to fix this is to manually edit file su_comments.module (line 52) and change comments weight to some greater value. Frankly I didn't thought that someone might be using greater weights for displaying node's content (that would be really wired) and assumed that value of 100 is a safe one :)

/* finally we render the unpublished node
 * unfortunately we have to put it at the top of all comments,
 * just below node content - this is all we can get from hook_nodeapi */
$node->content['su_comments_'.$comment->cid] = array(
	'#value' => theme('comment_view', $comment, $node, $links),
	'#weight' => 100 // SET THIS VALUE TO SOMETHING BIGGER (if needed)
	);

As for the themes... I'm not an expert but I think it might be possible that a theme can change order of displaying node content and it's unpublished comments. Can you provide a link to your website so I could take look at your theme and see how it handles unpublished comments?

wwwoliondorcom’s picture

Thank you, but it doesn't work also with 200 or 300 instead of 100.

I have sent you a message on your website and your module is working properly on your site when I use Firefox or IE8, so I guess it's a Drigg theme problem.

Thanks again.

siliconmind’s picture

I can confirm that the issue you are facing is caused by the DRIGG theme. It displays unpublished comment DIV inline which makes it look like a part of a node content. CSS code responsible for this is located in file http://www.drigg-france.com/themes/drigg_theme/css/nodes.css (currently line 38) and looks like this:

.node.ntype-drigg .story * {
   display:inline;
}

Simplest way to fix that is to modify your CSS to tell the browser to display comment as a block. Adding something like this will probably (partially) fix your problem:

.comment {
   display: block;
}

However this won't force the comment to be displayed in your "Comments" section below. As far as I know this is currently not possible with drupal 6.x API.

jrb’s picture

Priority: Minor » Normal
Status: Closed (works as designed) » Needs work

There's another reason that unpublished comments aren't showing up, and it's unrelated to the theme. The problem that I'm having is that when a user is logged in, $user->sid is not set. This makes it so that the comment information is not saved in the comments_sessions table by the su_comments_comment() function. I've fixed this by making a change in two places in su_comments.module.

First, in line 13, I changed this:

$sid = ($user->uid ? $user->sid : session_id());

To this:

$sid = ($user->uid ? md5($user->uid.drupal_get_private_key()) : session_id());

Then, in line 33, I changed this:

$result = db_query($query, ($user->uid ? $user->sid : session_id()));

To this:

 $result = db_query($query, ($user->uid ? md5($user->uid.drupal_get_private_key()) : session_id()));

This uses a key based on the user ID rather than the session ID to save comment information. A nice side effect of this change is that users will still be able to see their unpublished comments after they log out and then back in again.

siliconmind’s picture

Status: Needs work » Postponed (maintainer needs more info)

jrb, either you are wrong or I don't catch up with you. You say that when a user is logged in, $user->sid is not set. But logged user has $user->sid set correctly. $user->sid is not set when user is not logged hence my conditional expression that uses session_id() or $user->sid accordingly.

$sid = ($user->uid ? $user->sid : session_id());

As for the side effect you are mentioning - you are right, but then there is no point in using md5() to generate hash. You could just use $user->uid as it is also unique among users. It is also unlikely that UID would collide with 32 character session id :) You would had to have a hell lot of users and a huge dose of luck to make that happen :)

tuncalik’s picture

Category: bug » support

I installed today su_comments and it didn't work as I understood it should.

On the site I am now working, only registered users can submit comments, and all comments are moderated.

I've made some tests with an ordinary registered user with strange results. On some content types I could see the comments I've sent with the remark "awaiting approval", alright.

But on content types with custom template files (e.g. node-article.tpl.php for content type article) I didn't see the comments I'd submitted. As I understand from other forum messages the unapproved comments are linked to the node content, which may explain this situation. Maybe I've omitted some variables in my template files that include these unapproved comments.

But the strangest case was, I've seen my unapproved comments on other pages (nodes). That is, I submitted the comment to a node A, but saw the same comment attached to other nodes B, C, D etc.

Is there a bug, is there another explanation?

thanks
Tunc

siliconmind’s picture

tuncalik, can you post link to your site so i could test and see this "strange case" you are writing about?

mr.alinaki’s picture

I can approve it: if I made custom template for my node, unpublished comments are not show at all. For example: I have an Person node type. If I make template for it - node-person.tpl.php and post a comment as anonymous I didn't see my comment. But if I delete custom template, I see it.

Sorry for bad English)

mr.alinaki’s picture

Sorry, it's happens because I don't use $node->body, but take data from $node->content[] array.

mr.alinaki’s picture

I use that tricky construction:

    <?php foreach ($node->content as $key => $value): ?>
      <?php print preg_match("/su_comments_\d+/", $key)?$value['#value']:''; ?>
    <?php endforeach; ?>

Not very comfortable)

siliconmind’s picture

Status: Postponed (maintainer needs more info) » Fixed

Probably you are right, but as far as I remember, this is the way docs say it should be done. I mean, use of $node->content['....']; to display additional stuff.
But I've changed it a bit so it would be easier to use. Now there is always only one item:

$node->content['su_comments'];

Status: Fixed » Closed (fixed)

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