You are here

function simple_access_node_prepare in Simple Access 7.2

Implements hook_node_prepare().

File

./simple_access.module, line 144
This module allows administrators to make nodes viewable by specific 'access groups'. Each access group can contain any number of roles. If a node is not assigned to any access groups, it will remain viewable by all users.

Code

function simple_access_node_prepare($node) {

  // Only use the defaults if this is a new node.
  if (empty($node->nid)) {
    $defaults = variable_get('simple_access_' . $node->type, array(
      'simple_access' => array(),
      'simple_access_profiles' => array(),
      'simple_access_owner' => array(),
    ));
  }
  else {
    $defaults = array(
      'simple_access' => array(),
      'simple_access_profiles' => array(),
      'simple_access_owner' => array(),
    );
  }
  foreach ($defaults as $key => $value) {
    if (!isset($node->{$key})) {
      $node->{$key} = $value;
    }
  }
}