By steven9 on
Hi,
The comments awaiting moderation are not published yet, so they do not appear to anyone. How can I make the comments awaiting moderation appear to the author only? Currently just some text appears that says "Your comment is awaiting moderation." and that's it. It would be nice if the author could see what he posted.
For example with modr8 module the new nodes that are awaiting moderation CAN be seen by noone with the exception of the author. How can I make it the same for the comments?
Steven
Comments
_
Believe it or not, there's a module for it: http://drupal.org/project/su_comments. ;-)
Thank you WorldFallz for your
Thank you WorldFallz for your reply. I was ecstatic for a minute hoping this module will solve my problem. But it is not exactly what I need.
With this module when a user posts a new comment, the comment appears to him as part of the node itself, and the funny thing is that, if he clicks on a different node, the initial comment appears in the lower part of the second node as well etc. Nomatter which node he is viewing, the comment is there. Not pretty at all.
I would like the comment to appear like a normal comment, in it's proper node, at it's proper location in the list of other comments and in the "Recent comments" also. But just for the author.
_
Just because a module has a bug, doesn't mean it's not the module you need, lol. But my bad-- I should have mentioned there's a fix for this in the module's issue queue.
I added the patch. The
I added the patch. The comment appears now on the right node, but appended inside the node, and I needed it to be like a normal comment that appears as an independent comment in the right spot in the comment list after the node, in Recent comments (only for the author) etc. Do you have another idea how I can do that?
I just noticed that the admin
I just noticed that the admin sees all the unpublished comments as I would like it to be.
So there must be something in the comments module where it says something like show all the published comments to those who have the right permissions and if admin is logged in, show all published and unpublished posts.
To this I would need to add something like "to those with the right permissions show all published comments PLUS the unpublished ones that the user is the author of".
_
I believe this is tied to the administer comments permission-- but as you describe, users with that permission see all comments. Because of core permissions and the way comment module works it's not easy to circumvent and why the su_comments module works the way it does.
You might be able to use hook_nodeapi to override comment display, but I'm not sure. The only other thing you can do, and it's not recommended, is hack comment module.
Ok, so here is function that
I found the function that I would need to modify - comment_render. And I think it is particularly this part here:
// Multiple comment view
$query_count = 'SELECT COUNT(*) FROM {comments} c WHERE c.nid = %d';
$query = 'SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.signature_format, u.picture, u.data, c.thread, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d';
$query_args = array($nid);
if (!user_access('administer comments')) {
$query .= ' AND c.status = %d';
$query_count .= ' AND c.status = %d';
$query_args[] = COMMENT_PUBLISHED;
}
What this does is get all the comments from the database associated with a certain node. Then if the user logged-in does NOT have administer rights, leave only the published comments. To this I deed to add "but leave the unpublished comments that the user logged in is the author"
How can I write that?
_
Yeah-- I found that too. Try the following:
I played around with it and
I played around with it and so far this is the lucky combination :)
if (!user_access('administer comments')) {
$query .= ' AND (c.uid = %d OR c.status = %d)';
$query_count .= ' AND (c.uid = %d OR c.status = %d)';
$query_args[] = $user->uid;
$query_args[] = COMMENT_PUBLISHED;
}
It appears to be working, I will have to check it in some more situations.
WorldFallz, thank you very much for all your help, you are are real blessing on the forum.
_
Excellent-- glad it worked out.
And you're welcome-- happy to help ;-)
_
one other thing-- the 'reply' link appears on the unpublished comment but doesn't work. You can either test for comment status in comment.tpl.php and only print links for published comments (which will prevent the 'edit' link from appearing as well). Or make one additional change to comment module (around line 845) to prevent just the reply link from appearing on unpublished comments:
_
For convenience, here are the changes in the form of a patch:
I ended up doing this with an added comment permission of "view own unpublished comments".
WorldFallz, the patch looks
WorldFallz, the patch looks great. But in my trials I tried this part
+ $query .= ' AND c.status = %d OR c.uid = %d';
+ $query_count .= ' AND c.status = %d';
and it gives funny results because the OR goes against ALL the ANDs before, but just the preceding one, thus you need the parentheses. Query_count also needs the OR. I have something more like this:
+ $query .= ' AND (c.status = %d OR c.uid = %d)';
+ $query_count .= ' AND (c.status = %d OR c.uid = %d)';
_
odd-- i didn't notice any flakiness without the parens, but they're easy enough to add(i edited the patch and put them in). As for the node count-- I didn't want it to reflect unpublished nodes so I didn't alter that query, obviously ymmv. I've also got this working on a d7 dev site-- I'm going to post it as a patch, but at this point it wouldn't be viable until d8.
Actually you're right.
Actually you're right. Parentheses are not necessary in this case. They were necessary in my case because my solution was a bit different but I like yours more.
Thanks....! Folks. Nice
Thanks....! Folks.
Nice patch....worked exactly.
Keep rocking ... \m/
-
Chintan Umarani
Drupal Developer
www.umarani.com