You are here

function sbp_test_node_update in Search by Page 7

Implements hook_node_update().

Manage the "private" flag on nodes. Code taken form the Node Access Example module on drupal.org.

File

tests/sbp_test.module, line 156
Module file for Search by Page testing.

Code

function sbp_test_node_update($node) {

  // Make sure we are saving an integer for this field!
  if (isset($node->test_private) && $node->test_private) {
    $node->test_private = 1;
  }
  else {
    $node->test_private = 0;
  }
  db_update('sbp_test_access')
    ->fields(array(
    'private' => $node->test_private,
  ))
    ->condition('nid', $node->nid)
    ->execute();
}