You are here

function biblio_node_access in Bibliography Module 7

Same name and namespace in other branches
  1. 7.2 biblio.module \biblio_node_access()

File

./biblio.module, line 444
Bibliography Module for Drupal.

Code

function biblio_node_access($node, $op, $account) {
  if (is_string($node)) {
    return NODE_ACCESS_IGNORE;
  }

  // We only care about biblio nodes.
  if ($node->type != 'biblio') {
    return NODE_ACCESS_IGNORE;
  }
  switch ($op) {
    case 'view':
      if (variable_get('biblio_view_only_own', 0) && $account->uid != $node->uid || !user_access('access biblio content')) {
        return NODE_ACCESS_DENY;
      }
      break;
    case 'update':
    case 'delete':
      if (user_access('edit by all biblio authors') && isset($node->biblio_contributors) && is_array($node->biblio_contributors)) {
        foreach ($node->biblio_contributors as $key => $author) {
          if (isset($author['drupal_uid']) && $author['drupal_uid'] == $account->uid || isset($account->data['biblio_contributor_id']) && $author['cid'] == $account->data['biblio_contributor_id']) {
            return NODE_ACCESS_ALLOW;
          }
        }
      }
      break;
    default:
  }
  return NODE_ACCESS_IGNORE;
}