I found it was taking way too much time to delete un-wanted comments / spam.
So what I have done was add a checkbox feature so you are able to "mass delete" comments.
When you hit the "Delete Selected" button, a confirm dialog box will appear. As you can see in the screenshot, I've also added "Check All / Clear All" links.
The delete feature works exactly the same as if you were to delete the comment the old way - All replies attached to the comment will also be deleted.
I have extensively tested this and it works great, but with that said : ** Use at your own risk! **
Requirements
Commentics v2.3
Installation Instructions
1) Download the attached file at the bottom of this post
2) Backup your /comments/admin/includes/pages/manage_comments.php file
3) Copy the new manage_comments.php (overwriting the old file)
Feel free to let me know here if you run in to any bugs. Enjoy!
Really excellent work! I've been meaning to add this feature for a long time but there was one issue which was holding me back, and you seem to have overcome it, (whether it was on purpose or not I'm not sure). It's with the search feature. Let's say if you search and it filters the results down to a few, I was expecting that when I then clicked the 'Check All' link and hit delete it would delete all of the comments instead of just the ones that I had searched for. However it only deleted the ones that I had searched for and all of the rest were still there, which is great! Did you mean to code it like that?
There are a few suggestions that I want to make:
1. It only shows comments that are not approved. I had to change "WHERE is_approved = 0" to "WHERE is_approved = 0 OR 1" to show all of them. (The comments that I wanted to delete were approved).
2. The approve and delete buttons link to a 'moderate_comments' page which doesn't exist. I have a feeling this is linked to (1) - maybe you had created a 'moderate_comments' page which only shows comments that need approval.
3. I think the '<?=' will only work if the server has PHP short tags enabled, so it may be better to use '<?php echo' instead.
4. You can add class="button" to the button to make it look like the other ones.
5. I didn't test what happens with the 'Check All' if there are multiple pages, so not sure what would happen there?
6. Is it possible to convert the $_POST to a $_GET, so it's like the existing delete feature, or do you think $_POST is best in this case?
Quote:Really excellent work! I've been meaning to add this feature for a long time but there was one issue which was holding me back, and you seem to have overcome it, (whether it was on purpose or not I'm not sure). It's with the search feature. Let's say if you search and it filters the results down to a few, I was expecting that when I then clicked the 'Check All' link and hit delete it would delete all of the comments instead of just the ones that I had searched for. However it only deleted the ones that I had searched for and all of the rest were still there, which is great! Did you mean to code it like that?
Yes, I made it so the Check All / Clear All works for only what is currently showing on the screen. I've used that javascript code in another project and it worked great - so I decided to use it in here.
Quote:It only shows comments that are not approved. I had to change "WHERE is_approved = 0" to "WHERE is_approved = 0 OR 1" to show all of them. (The comments that I wanted to delete were approved).
Sorry about that .. I was excited to release this and forgot about that feature. What happened is I created a new admin page just for moderating comments and did not revert that setting.
Quote:The approve and delete buttons link to a 'moderate_comments' page which doesn't exist. I have a feeling this is linked to (1) - maybe you had created a 'moderate_comments' page which only shows comments that need approval.
I thought I changed that ... I guess not. Yikes.
Quote:I think the '<?=' will only work if the server has PHP short tags enabled, so it may be better to use '<?php echo' instead.
You're absolutely right - I will get that fixed.
Quote:You can add class="button" to the button to make it look like the other ones.
Ok great, I will add that to the code.
Quote:I didn't test what happens with the 'Check All' if there are multiple pages, so not sure what would happen there?
It should still work as intended, but I will double check on that.
Quote:Is it possible to convert the $_POST to a $_GET, so it's like the existing delete feature, or do you think $_POST is best in this case?
Why I tried using $_GET, it wasn't working for me. I'll look at that again today and see if I can figure out where I went wrong.