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
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.