Unpublishes a comment if it contains certain keywords.
object $comment: Comment object to modify.
array $context: Array with components:
comment_unpublish_by_keyword_action_form()
comment_unpublish_by_keyword_action_submit()
function comment_unpublish_by_keyword_action($comment, $context) {
$node = node_load($comment->nid);
$build = comment_view($comment, $node);
$text = drupal_render($build);
foreach ($context['keywords'] as $keyword) {
if (strpos($text, $keyword) !== FALSE) {
$comment->status = COMMENT_NOT_PUBLISHED;
comment_save($comment);
watchdog('action', 'Unpublished comment %subject.', array(
'%subject' => $comment->subject,
));
break;
}
}
}