In the last post, I walked through the Views Bulk Operations module. My initial plan was to write this post about actions, but after researching how to best write about actions, I found a ton of detailed information about how to make an action.
- Chapter 3 of Pro Drupal Development.
So instead of walking through Actions in detail, I'm going to walk you through plan for the comments moderation feature. The next post will have the comment moderation actions and views, and the final post will discuss the integration with other modules.
Requirements for the comment moderation feature are:
- Integration with Mollom.
- Integration with Comment Moderation
- Search by IP.
- Search and moderate by email address.
Integration with Mollom
Mollom is easily integrated with comment forms; it's just a setting on the admin page (admin/settings/mollom). This will help stop spam related comments when the comment is entered. It also adds a "report to Mollom" link on each comment. But what if we want to report several comments to Mollom at a time? Enter Views Bulk Operations and a custom action. We will create 2 actions to use on the comment moderation page that integrate with Mollom: "Report to Mollom and Delete" and "Report to Mollom and Unpublish."
Integration with Comment Moderation Module
The Comment Moderation module provides several tools to moderate comments:
"The Comment Moderation module gives an alternative view to your approval queue with all actions directly available from the comment moderation view. This helps to analyze comments one by one, take action and move on to the next comment in the queue. You can also much easier browse through your comments without having to go back to the approval queue all the time"
By default, Comment Moderation uses a link to "comment/moderate/<cid>" on the comment approval page. The page displays the comment with two rows of links:
The "previous" and "next" links allow for navigation between comments. The other links allow for basic comment moderation, including Mollom integration. Since we are replacing this page with a view, we will need to be sure to create a field with that link.
Search and moderate by IP
While Drupal logs the IP address of every comment in the comment table, it's not exposed to views by default. So we have to use the views API to expose the IP address to the view. To make the comments searchable by IP, we just add the field as an exposed filter on the view.
There are a wide variety of methods to moderate by IP address. Along with server side security, there are a number of Drupal modules to assist with IP filtering (see http://drupal.org/node/645216). Selection and setup of IP moderation is beyond just comments and out of scope for this article.
Search and moderate by Email
Similar to IP addresses, email addresses are also stored in the comment table and not exposed to views. There is one more wrinkle with searching by email; email addresses for registered are not stored in the comments table. While we could easily add a relationship to the user table in the view, it wouldn't be as clean as using the same field. So along with exposing the email field to the view, we will be writing some custom code to add the email address to the comment table (covered in post #4 in this series).
Along with SPAM moderation with Mollom (and any other modules you choose - see here for a list of Drupal modules for catching spam), we would like to explicitly block by email addresses. The comment administration view will have an action to add the email address of a particular comment to the block list.
Tasks for Comment Moderation Feature
- Create View with 2 page panes.
- Approval Queue
- Fields: Subject, Author, email address, IP, Node Title, Post Time, edit and moderate links.
- Actions: Delete, Delete and block email, Publish, Report to Mollem and Delete.
- Exposed Filters: Email, IP
- Published Comment
- Fields: Subject, Author, email, Node title, Post Time, edit
- Actions: Delete, Delete and block email, unpublish, report to mollom and delete, report to mollom and unpublish.
- Exposed Filers: Email, IP
- Approval Queue
- Require fields on comment form
- Custom Code:
- Expose IP address and Email to views.
- Block comments by Email
- Update comment email address for register users
This is just a small list of ideas for comment moderation meant to give you a good start on creating your own comment moderation functionality. This feature will be available at the close of the final blog post.