You are here

function content_access_get_type_grant in Content Access 6

Same name and namespace in other branches
  1. 8 content_access.module \content_access_get_type_grant()
  2. 7 content_access.module \content_access_get_type_grant()

Returns the default grants for a given node type.

1 call to content_access_get_type_grant()
content_access_node_access_records in ./content_access.module
Implementation of hook_node_access_records()

File

./content_access.module, line 270
Content access module file.

Code

function content_access_get_type_grant($node) {

  // Cache per type default grants in a static array
  static $defaults = array();
  if (!isset($defaults[$node->type])) {
    $grants = array();

    // Only process the 'view' op as node_access() will take care of edit and delete
    foreach (content_access_get_settings('view', $node->type) as $rid) {
      $grants[$rid]['grant_view'] = 1;
      $grants[$rid] = content_access_proccess_grant($grants[$rid], $rid, $node);
    }
    $defaults[$node->type] = $grants;
  }

  // Care for the author grant.
  $grant = $grants = array();
  $grant['grant_view'] = content_access_own_op($node, content_access_get_settings('view', $node->type), content_access_get_settings('view_own', $node->type));
  if ($grant['grant_view']) {
    $grant['realm'] = 'content_access_author';
    $grants = array(
      'author' => content_access_proccess_grant($grant, $node->uid, $node),
    );
  }
  return $defaults[$node->type] + $grants;
}