You are here

function hosting_alias_insert in Hosting 6.2

Same name and namespace in other branches
  1. 5 alias/hosting_alias.module \hosting_alias_insert()
  2. 7.4 alias/hosting_alias.module \hosting_alias_insert()
  3. 7.3 alias/hosting_alias.module \hosting_alias_insert()

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 alias/hosting_alias.module
Implementation of hook_nodeapi().
hosting_alias_update in alias/hosting_alias.module
Update stored aliases for an existing site.

File

alias/hosting_alias.module, line 282
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, '%s')", $node->vid, $node->nid, $alias, HOSTING_ALIAS_CUSTOM, $node->redirection);
        }
      }
    }
    if (sizeof($automatic)) {
      foreach ($automatic as $alias) {
        if (($alias = trim($alias)) && _hosting_valid_fqdn_wildcard($alias)) {
          db_query("INSERT INTO {hosting_site_alias} (vid, nid, alias, automatic, redirection) VALUES (%d, %d, '%s', %d, '%s')", $node->vid, $node->nid, $alias, HOSTING_ALIAS_AUTOMATIC, $node->redirection);
        }
      }
    }
  }
}