function comment_unpublish_by_keyword_action
7.x comment.module | comment_unpublish_by_keyword_action($comment, $context) |
6.x comment.module | comment_unpublish_by_keyword_action($comment, $context) |
Unpublishes a comment if it contains certain keywords.
Parameters
$comment: Comment object to modify.
array $context: Array with components:
- 'keywords': Keywords to look for. If the comment contains at least one of the keywords, it is unpublished.
See also
comment_unpublish_by_keyword_action_form()
comment_unpublish_by_keyword_action_submit()
Related topics
2 string references to 'comment_unpublish_by_keyword_action'
- comment_action_info in drupal-7.x/
modules/ comment/ comment.module - Implements hook_action_info().
- hook_action_info in drupal-7.x/
modules/ system/ system.api.php - Declares information about actions.
File
- drupal-7.x/
modules/ comment/ comment.module, line 2617 - Enables users to comment on published content.
Code
function comment_unpublish_by_keyword_action($comment, $context) {
foreach ($context['keywords'] as $keyword) {
$text = drupal_render($comment);
if (strpos($text, $keyword) !== FALSE) {
$comment->status = COMMENT_NOT_PUBLISHED;
watchdog('action', 'Unpublished comment %subject.', array('%subject' => $comment->subject));
break;
}
}
}