New Drupal comment_moderation module

Submitted by dag on Wed, 2009/02/04 - 03:27

A second module I wrote this weekend makes it easier to moderate your comments. This was another item high on my wishlist. I didn't found anything that comes close, so please let me know if I missed another module that scratches the same itch.

The comment_moderation module simplifies the work-flow of moderating comments. If you receive a lot of comment spam, the current approval queue is very limiting:

  • It forces you to click through to the comment. If you want to publish the comment you need to edit, change it to published and submit
  • Same for replying
  • If you want to report it to mollom, you have the additional step of selecting the type of spam
  • In every case you have to go back to the approval queue, reload it and move on to the next one
  • The comment view hides the URL behind the author name, while the URL is one of the key indicators the message is spam (often plausible comments are just there to promote a URL)

I found this very frustrating and ended up opening a lot of tabs from the approval queue, then click on the ones I thought were spam, then 'mark as abuse' link, move to the next tab, ad infinitum...

Then go back through all the tabs to select the type of spam. Sadly in the mollom selection form you have no clue at that point what the actual comment was about.

Very messy and time-consuming because of the many clicks. That is what the comment_moderation is there for. It fixes the work-flow by automatically advancing to the next comment after taking action on the previous. You can also move from one comment to the next in the queue without having to go back to the approval queue. Every action is in the same window as the comment.

At the moment a few things do not work as I like it to be, so it is a work in progress. The publish button has no target because currently the comment module does not have a path for it.

Also the mollom spam selection still needs to be done on the separate mollom page, but at least it advances to the next comment once you've selected an action.

The comment_moderation module also includes its own block with a custom number of your recent comments from which you can start moderating.

I would also like to add a moderate action to the approval queue, unfortunately I don't think hooks exist for modifying the approval queue. One option could be to add a new moderation queue tab. Currently that's what I am planning to do.

If you are like me struggling with comment moderation, please try out this new module and send me feedback (or patches). And also for this module, I very much appreciate advice and guidance on my coding style. I am new around here.

You can find the module at: http://svn.rpmforge.net/svn/trunk/tools/comment_moderation/

I plan to add this module to the Drupal website as soon as I am confident it deserves to be there.

Update: The comment_moderation module for Drupal is now at: http://drupal.org/project/comment_moderation

I use a view

I use a view for this. It doesn't result in quite as tight a workflow as your blog post suggest the module does, but didn't require any code and is pretty good for me. Here is the exported view:


$view = new view;
$view->name = 'comments_recent';
$view->description = 'Contains a block and a page to list recent comments; the block will automatically link to the page, which displays the comment body as well as a link to the node.';
$view->tag = 'default';
$view->view_php = '';
$view->base_table = 'comments';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
'nid' => array(
'id' => 'nid',
'table' => 'comments',
'field' => 'nid',
'label' => 'Node',
'required' => FALSE,
),
));
$handler->override_option('fields', array(
'subject' => array(
'id' => 'subject',
'table' => 'comments',
'field' => 'subject',
'label' => '',
'link_to_comment' => 1,
'relationship' => 'none',
),
'name' => array(
'id' => 'name',
'table' => 'comments',
'field' => 'name',
'label' => 'by',
'link_to_user' => 0,
'relationship' => 'none',
),
'title' => array(
'label' => 'in',
'link_to_node' => 1,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'nid',
'override' => array(
'button' => 'Override',
),
),
));
$handler->override_option('sorts', array(
'timestamp' => array(
'id' => 'timestamp',
'table' => 'comments',
'field' => 'timestamp',
'order' => 'DESC',
'granularity' => 'second',
'relationship' => 'none',
),
));
$handler->override_option('filters', array(
'status_extra' => array(
'id' => 'status_extra',
'table' => 'node',
'field' => 'status_extra',
'operator' => '=',
'value' => '',
'group' => 0,
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'relationship' => 'nid',
'expose_button' => array(
'button' => 'Expose',
),
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('title', 'Recent comments');
$handler->override_option('use_ajax', TRUE);
$handler->override_option('items_per_page', 3);
$handler->override_option('use_pager', 'mini');
$handler->override_option('use_more', 0);
$handler->override_option('style_plugin', 'list');
$handler->override_option('style_options', array(
'grouping' => '',
'type' => 'ul',
));
$handler->override_option('row_options', array(
'inline' => array(
'subject' => 'subject',
'name' => 'name',
'timestamp' => 'timestamp',
'title' => 'title',
),
'separator' => '',
));
$handler = $view->new_display('page', 'Page', 'page');
$handler->override_option('fields', array(
'title' => array(
'id' => 'title',
'table' => 'node',
'field' => 'title',
'label' => 'Reply to',
'relationship' => 'nid',
'link_to_node' => 1,
),
'timestamp' => array(
'id' => 'timestamp',
'table' => 'comments',
'field' => 'timestamp',
'label' => '',
'date_format' => 'time ago',
'custom_date_format' => '',
'relationship' => 'none',
),
'subject' => array(
'id' => 'subject',
'table' => 'comments',
'field' => 'subject',
'label' => '',
'link_to_comment' => 1,
'relationship' => 'none',
),
'comment' => array(
'id' => 'comment',
'table' => 'comments',
'field' => 'comment',
'label' => '',
'relationship' => 'none',
),
));
$handler->override_option('use_ajax', FALSE);
$handler->override_option('items_per_page', 10);
$handler->override_option('use_pager', '1');
$handler->override_option('style_plugin', 'default');
$handler->override_option('style_options', array());
$handler->override_option('row_plugin', 'comment');
$handler->override_option('row_options', array(
'links' => 1,
));
$handler->override_option('path', 'comments/recent');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'weight' => 0,
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'weight' => 0,
));
$handler = $view->new_display('block', 'Block', 'block');
$handler->override_option('block_description', 'Recent comments view');
$handler->override_option('block_caching', -1);

How do I install this module?

I put in the module folder and activated it, but then what?

What's it called in the Permissions section?

I'm sort of a newbie and don't know what to do from here. Any thoughts?

Thanks,
Stuart