You are here

function sbp_test_node_insert in Search by Page 7

Implements hook_node_insert().

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

File

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

Code

function sbp_test_node_insert($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_insert('sbp_test_access')
    ->fields(array(
    'nid' => $node->nid,
    'private' => $node->test_private,
  ))
    ->execute();
}