function domain_lookup in Domain Access 5
Same name and namespace in other branches
- 6.2 domain.module \domain_lookup()
- 7.3 domain.module \domain_lookup()
- 7.2 domain.module \domain_lookup()
Runs a lookup against the {domain} table. One of the two values must be present
This function also calls hook_domainload(), which lets module developers overwrite or add to the $domain array.
Parameters
$domain_id: The domain_id taken from {domain}. Optional.
$subdomain: The string representation of a {domain} entry. Optional.
$reset: A boolean flag to clear the static variable if necessary.
Return value
An array containing the requested row from the {domain} table, plus the elements added by hook_domainload(). Returns -1 on failure.
24 calls to domain_lookup()
- domain_block in ./
domain.module - Implement hook_block()
- domain_conf_form_alter in domain_conf/
domain_conf.module - Implement hook_form_alter()
- domain_conf_page in domain_conf/
domain_conf.module - The domain conf page callback router.
- domain_conf_reset in domain_conf/
domain_conf.module - Resets configuration settings by removing the domain row from {domain_conf}.
- domain_content_form in domain_content/
domain_content.module - Rewrites node_admin_nodes() to use db_rewrite_sql().
File
- ./
domain.module, line 432 - Core module functions for the Domain Access suite.
Code
function domain_lookup($domain_id = NULL, $subdomain = NULL, $reset = FALSE) {
static $domains;
// If both are NULL, no lookup can be run.
if (is_null($domain_id) && is_null($subdomain)) {
return -1;
}
// Create a unique key so we can static cache all requests.
$key = $domain_id . $subdomain;
// Run the lookup, if needed.
if (!isset($domains[$key]) || $reset) {
if ($subdomain) {
$domain = db_fetch_array(db_query("SELECT domain_id, subdomain, sitename, scheme, valid FROM {domain} WHERE subdomain = '%s'", $subdomain));
}
else {
if ($domain_id == 0) {
$domain = domain_default();
}
else {
$domain = db_fetch_array(db_query("SELECT domain_id, subdomain, sitename, scheme, valid FROM {domain} WHERE domain_id = %d", $domain_id));
}
}
// Did we get a valid result?
if (isset($domain['domain_id'])) {
// Let Domain Access module extensions act to override the defaults.
$domains[$key] = domain_api($domain);
}
else {
$domains[$key] = -1;
}
}
return $domains[$key];
}