You are here

function domain_node_access_update in Domain Access 7.3

Checks if a user can edit content of a specific type based on domain.

See also

domain_node_access().

1 call to domain_node_access_update()
domain_node_access_delete in ./domain.module
Checks if a user can delete content of a specific type based on domain.

File

./domain.module, line 2335
Core module functions for the Domain Access suite.

Code

function domain_node_access_update($type, $node, $op, $account) {
  domain_user_set($account);

  // The node must be assigned to a domain to continue.
  if (empty($node->domains)) {
    return NODE_ACCESS_IGNORE;
  }
  else {
    $ignore = TRUE;
    foreach ($node->domains as $domain_id) {
      if (isset($account->domain_user[$domain_id])) {
        $ignore = FALSE;
        break;
      }
    }
    if ($ignore) {
      return NODE_ACCESS_IGNORE;
    }
  }

  // Build the permission string.
  $permission = "{$op} {$type} content on assigned domains";

  // Run the access check.
  if (user_access($permission, $account)) {
    return NODE_ACCESS_ALLOW;
  }

  // If the check fails, do nothing.
  return NODE_ACCESS_IGNORE;
}