You are here

function content_access_get_default_grant in Content Access 5

1 call to content_access_get_default_grant()
content_access_node_access_records in ./content_access.module

File

./content_access.module, line 467

Code

function content_access_get_default_grant($node) {
  static $defaults = array();

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

    //apply the defaults
    foreach (array(
      'view',
      'update',
      'delete',
    ) as $op) {
      foreach (content_access_get_settings($op, $node->type) as $rid) {
        $grants[$rid]['grant_' . $op] = 1;
      }
    }
    foreach ($grants as $rid => $grant) {
      $grants[$rid] = content_access_proccess_grant($grant, $rid, $node);
    }
    $defaults[$node->type] = $grants;
  }
  else {
    if (isset($defaults[$node->type]['author'])) {
      $defaults[$node->type]['author']['gid'] = $node->uid;
    }
  }
  return $defaults[$node->type];
}