comment_unpublish_by_keyword_action
- Versions
- 6 – 7
comment_unpublish_by_keyword_action($comment, $context)
Implementation of a configurable Drupal action. Unpublish a comment if it contains a certain string.
Parameters
$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.
Code
modules/comment/comment.module, line 2100
<?php
function comment_unpublish_by_keyword_action($comment, $context) {
foreach ($context['keywords'] as $keyword) {
if (strstr($comment->comment, $keyword) || strstr($comment->subject, $keyword)) {
db_query('UPDATE {comments} SET status = %d WHERE cid = %d', COMMENT_NOT_PUBLISHED, $comment->cid);
watchdog('action', 'Unpublished comment %subject.', array('%subject' => $comment->subject));
break;
}
}
}
?>Login or register to post comments 