node_unpublish_by_keyword_action
- Versions
- 6 – 7
node_unpublish_by_keyword_action($node, $context)
Implement a configurable Drupal action. Unpublish a node if it contains a certain string.
Parameters
$node A node object.
$context An array providing more information about the context of the call to this action.
Code
modules/node/node.module, line 3190
<?php
function node_unpublish_by_keyword_action($node, $context) {
foreach ($context['keywords'] as $keyword) {
if (strpos(drupal_render(node_build(clone $node)), $keyword) !== FALSE || strpos($node->title, $keyword) !== FALSE) {
$node->status = NODE_NOT_PUBLISHED;
watchdog('action', 'Set @type %title to unpublished.', array('@type' => node_type_get_name($node), '%title' => $node->title[LANGUAGE_NONE][0]['value']));
break;
}
}
}
?>Login or register to post comments 