You are here

function domain_get_node_match in Domain Access 7.3

Same name and namespace in other branches
  1. 6.2 domain.module \domain_get_node_match()
  2. 7.2 domain.module \domain_get_node_match()

Get the best matching domain for a node link.

Parameters

$nid: The node id.

Return value

The domain array for the best matching domain for links to this node.

5 calls to domain_get_node_match()
domain_block_view_information in ./domain.blocks.inc
Prints information about the current node.
domain_invalid_domain_requested in ./domain.module
Redirect a request to an invalid domain.
domain_source_node_view in domain_source/domain_source.module
Implements hook_node_view()
domain_tokens in ./domain.tokens.inc
Implements hook_tokens().
domain_url_outbound_alter in ./settings_custom_url.inc
Implements hook_url_outbound_alter().
1 string reference to 'domain_get_node_match'
_domain_store_grants in ./domain.module
Store node_access records in the {domain_access} table.

File

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

Code

function domain_get_node_match($nid) {
  $domain =& drupal_static(__FUNCTION__, array());
  if (isset($domain[$nid])) {
    return $domain[$nid];
  }

  // Load the domain data for this node -- but only take the first match.
  $id = db_query("SELECT gid FROM {domain_access} WHERE nid = :nid AND realm = :realm ORDER BY gid", array(
    ':nid' => $nid,
    ':realm' => 'domain_id',
  ))
    ->fetchField();

  // If a match was found, return it. Otherwise, we may be saving a node
  // in which case, let it fall through. See http://drupal.org/node/624360.
  $source = NULL;
  if ($id !== FALSE) {
    $source = domain_lookup($id);
  }
  else {
    $source = domain_get_domain();
  }

  // Allow other modules to intervene.
  drupal_alter('domain_source', $source, $nid);
  $domain[$nid] = $source;
  return $source;
}