comment_unpublish_by_keyword_action($comment, $context)
drupal/modules/comment/comment.module, line 2151
Implementation of a configurable Drupal action.
Unpublish a comment if it contains a certain string.
$context An array providing more information about the context of the call to this action. Unused here, since this action currently only supports the insert and update ops of the comment hook, both of which provide a complete $comment object.
$comment A comment object.
function comment_unpublish_by_keyword_action($comment, $context) {
foreach ($context['keywords'] as $keyword) {
if (strstr($comment->comment, $keyword) || strstr($comment->subject, $keyword)) {
db_update('comment')
->fields(array('status' => COMMENT_NOT_PUBLISHED,))
->condition('cid', $comment->cid)
->execute();
watchdog('action', 'Unpublished comment %subject.', array('%subject' => $comment->subject));
break;
}
}
}