domain_lookup_simple

Versions
domain
domain_lookup_simple($name, $reset = FALSE)

Determines a domain_id matching given $_name.

This function runs a lookup against the {domain} table matching the subdomain column against the given parameter $_name. If a match is found the function returns an array containing the domain requested and the matching domain_id from the {domain} table.

If no match is found domain_id is set to 0 for the default domain.

During the process hook_domain_bootstrap_lookup() is invoked to allow other modules to modify that result.

Parameters

$name The string representation of a {domain} entry.

$reset Set TRUE to ignore cached versions and look the name up again. Optional.

Return value

An array containing a domain_id from {domain} matching the given domainname

▾ 1 function calls domain_lookup_simple()

domain_resolve_host in ./domain.module
Tries to match the current (host) domain name to a domain in the {domain} table and returns a respective domain_id.

Code

./domain.module, line 2063

<?php
function domain_lookup_simple($name, $reset = FALSE) {
  static $cache = array();

  if (empty($name)) {
    return array();
  }

  if ($reset || !isset($cache[$name])) {
    // Lookup the given domain name against our allowed hosts record.
    $domain = db_fetch_array(db_query("SELECT domain_id, subdomain, sitename FROM {domain} WHERE subdomain = '%s'", $name));
    if (!is_array($domain)) {
      $domain = array();
    }
    // If no match => use default (0)
    if (!isset($domain['domain_id'])) {
      $domain['domain_id'] = 0;
    }
    $domain['subdomain'] = $name;
    // Invoke hook_domain_bootstrap_lookup()
    $domain_new = _domain_bootstrap_invoke_all('lookup', $domain);
    if (is_array($domain_new)) {
      $domain = array_merge($domain, $domain_new);
    }
    $cache[$name] = $domain;
  }
  return $cache[$name];
}
?>

Contact

  • agentrickard [at] gmail [dot] com

Donations

My Amazon.com Wish List