You are here

function private_node_load in Private 7.2

Same name and namespace in other branches
  1. 7 private.module \private_node_load()

Implements hook_node_load().

File

./private.module, line 237
A tremendously simple access control module -- it allows users to mark individual nodes as private; users with 'access private content' perms can read these nodes, while others cannot.

Code

function private_node_load($nodes, $types) {
  foreach ($nodes as $nid => $node) {

    // Get a default in case the database entry isn't set.
    private_get_default($node);
    if (!$node->privateLocked) {

      // Skip the query if the content type doesn't enable per node settings.
      $queryNids[] = $nid;
    }
  }
  if (isset($queryNids)) {
    $result = db_query('SELECT * FROM {private} WHERE nid IN(:nids)', array(
      ':nids' => $queryNids,
    ));
    foreach ($result as $record) {
      $nodes[$record->nid]->private = $record->private;
    }
  }
}