You are here

function domain_get_node_match in Domain Access 6.2

Same name and namespace in other branches
  1. 7.3 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.

4 calls to domain_get_node_match()
domain_block in ./domain.module
Implement hook_block()
domain_invalid_domain_requested in ./domain.module
Redirect a request to an invalid domain.
domain_source_nodeapi in domain_source/domain_source.module
Implement hook_nodeapi()
domain_url_outbound_alter in ./settings_custom_url.inc
Implement hook_url_outbound_alter().

File

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

Code

function domain_get_node_match($nid) {
  static $domain = array();
  if (isset($domain[$nid])) {
    return $domain[$nid];
  }

  // Load the domain data for this node -- but only take the first match.
  $id = db_result(db_query_range("SELECT gid FROM {domain_access} WHERE nid = %d AND realm = '%s' ORDER BY gid", $nid, 'domain_id', 0, 1));

  // 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);
    drupal_alter('domain_source', $source, $nid);
    $domain[$nid] = $source;
  }
  return $source;
}