I’ve been really busy lately, and a minor thorn in my side has been some especially obnoxious blog spammers. To keep my readers from seeing them spam and to deny them the ability to benefit from their evil ways, I turned on approvals in my content list. One of the spammers decided to fight back by sending the same content over every few minutes. One of the downsides of using approval is that it also makes getting rid of items in bulk more difficult, so this really, really irritated me and I had to write a little feature to restore my own sanity.
The feature consists of a custom action and an application page. You can download the VS2005 solution and web solution package here.
Here’s how you use it.
If Has Got Spam
(sorry, I’ve been playing with LOLCODE again)
Activate the Feature
(If you don’t know how to install a web solution package, the Visual Studio project will do it for you when you build)
Refresh the Comments List and Use the new Menu
Click OK to Delete the Evil Spam
Be careful to approve the comments that are not evil spam before you do this. I know I deleted a couple good comments accidentally.
How it Works
The custom action itself is simple. It targets only comment lists and shows up only if you have permission to approve items.
Title="Delete Pending Comments"
Description="Combat spam by deleting all the unapproved comments."
When you use it, it sends you to the new application page. You can see it’s full code in the download, but the main function is shown below.
void BtnDeletePendingComments_Click(object sender, EventArgs e)
SPList list = SPContext.Current.List;
for (int i = list.Items.Count – 1; i >= 0; i–)
SPListItem comment = list.Items[i];
if (comment.ModerationInformation.Status == SPModerationStatusType.Pending)
Enjoy! I’ll put this up on CodePlex next week.
Author: Doug Ware