You are here

function domain_alias_list in Domain Access 6.2

Same name and namespace in other branches
  1. 7.3 domain_alias/domain_alias.module \domain_alias_list()
  2. 7.2 domain_alias/domain_alias.module \domain_alias_list()

Returns all aliases for one domain record (domain_id).

Parameters

$domain_id: The domain_id taken from {domain}.

$reset: A boolean flag indicating whether to reset the static array or not.

Return value

An array of all aliases defined for given domain_id, indexed by alias_id

2 calls to domain_alias_list()
domain_alias_domainload in domain_alias/domain_alias.module
Implement hook_domainload()
domain_alias_domainview in domain_alias/domain_alias.module
Implement hook_domainview().

File

domain_alias/domain_alias.module, line 272
Interface for advanced domain matching for Domain Access.

Code

function domain_alias_list($domain_id, $reset = FALSE) {
  static $aliases = array();
  if (empty($aliases) || $reset) {
    $aliases[$domain_id] = array();

    // Get all Domain Alias records from database.
    $domain_aliases = db_query("SELECT alias_id, domain_id, pattern, redirect FROM {domain_alias}");
    while ($data = db_fetch_array($domain_aliases)) {
      $data['pattern'] = _domain_alias_placeholders_from_sql($data['pattern']);
      $aliases[$data['domain_id']][$data['alias_id']] = $data;
    }
  }

  // No results (aliases) for our domain, set as an empty array to prevent
  // errors on functions calling domain_alias_list().
  if (!isset($aliases[$domain_id])) {
    $aliases[$domain_id] = array();
  }
  return $aliases[$domain_id];
}