This is very good module for drupal 7 and I like to add additional feature to it.I want node authors[Not administrator user,Normal registered user who has permission to add content] to delete the unwanted comments under their content.
I have added and edited some code in this module to add that functionality.
In line 236,added the following code
//adding permission to delete comments of own content
'delete comments of own content' => array(
'title' => t('Delete comments of own content'),
'description' => t('Allows a user to delete comments of own content'),
),
In line 254,replaced the line
access = ($user->uid && $user->uid == $comment->uid && $comment->status == COMMENT_PUBLISHED && (user_access('delete own comments') || user_access('administer comments')));
and added the following lines
$node = node_load($comment->nid);
//commenting this line
//$access = ($user->uid && $user->uid == $comment->uid && $comment->status == COMMENT_PUBLISHED && (user_access('delete own comments') || user_access('administer comments')));
//permission to check the current user can access the delete comment page
$access = ($user->uid && $user->uid == $comment->uid && $comment->status == COMMENT_PUBLISHED && ( user_access('delete own comments') || user_access('administer comments') ) || ($user->uid && $comment->status == COMMENT_PUBLISHED && ($user->uid==$node->uid) && (user_access('delete comments of own content') || user_access('administer comments') ) ));
In line 285,added the following lines
global $user;
if($user->uid && ($user->uid==$node->uid)){
$comment->content['links']['comment']['#links']['comment-delete'] = array(
'title' => t('delete'),
'href' => "comment/$comment->cid/delete-own",
'html' => TRUE,
);
}
I hope ,it will help someone who need this functionality.
Comments
Comment #1
ace11 commentedThis is exactly what I need. But could not get this working. Can you be more spesific where to add those codes? Obviously to comment_goodness.module.
This is how my modified comment_goodness.module looks when added the first code.
This is second code
And where does the last code go? Because on the line 285 is:
'#type' => 'link',Can you post your whole comment_goodness.module code?
Thanks!
Comment #2
formatC'vt commentedwe have a lot criss-crossed feature requests =)
summary:
- add feature to unpublish instead of delete comment
- add ajax delete
- add support for comment access module
- add delete own comments
- add delete comments for current node owner