You are here

function hosting_alias_insert in Hostmaster (Aegir) 6

Save stored aliases for a new site.

Parameters

$node: The node of the site containing the aliases to save.

2 calls to hosting_alias_insert()
hosting_alias_nodeapi in modules/hosting/alias/hosting_alias.module
Implementation of hook_nodeapi().
hosting_alias_update in modules/hosting/alias/hosting_alias.module
Update stored aliases for an existing site.

File

modules/hosting/alias/hosting_alias.module, line 143
Allow sites to have domain aliases that they can be accessed with.

Code

function hosting_alias_insert($node) {
  $automatic = hosting_alias_automatic_aliases(strtolower(trim($node->title)));
  if ($node->aliases || sizeof($automatic)) {
    $aliases = is_array($node->aliases) ? $node->aliases : explode("\n", str_replace(",", "\n", $node->aliases));
    if (is_array($aliases)) {
      foreach ($aliases as $alias) {
        if (($alias = trim($alias)) && !in_array($alias, $automatic)) {
          db_query("INSERT INTO {hosting_site_alias} (vid, nid, alias, automatic, redirection) VALUES (%d, %d, '%s', %d, %d)", $node->vid, $node->nid, $alias, HOSTING_ALIAS_CUSTOM, $node->redirection);
        }
      }
    }
    if (sizeof($automatic)) {
      foreach ($automatic as $alias) {
        if (($alias = trim($alias)) && _hosting_valid_fqdn($alias)) {
          db_query("INSERT INTO {hosting_site_alias} (vid, nid, alias, automatic, redirection) VALUES (%d, %d, '%s', %d, %d)", $node->vid, $node->nid, $alias, HOSTING_ALIAS_AUTOMATIC, $node->redirection);
        }
      }
    }
  }
}