You are here

function hosting_alias_validate_alias in Hosting 6.2

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

Ensure that an alias is valid, and not already in use.

Parameters

object $site: A Hosting site node.

string $alias: An alias to have point to the site.

2 calls to hosting_alias_validate_alias()
hosting_alias_nodeapi in alias/hosting_alias.module
Implementation of hook_nodeapi().
hosting_subdirs_nodeapi in subdirs/hosting_subdirs.module
Implementation of hook_nodeapi().

File

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

Code

function hosting_alias_validate_alias($site, $alias) {
  if ($alias = trim($alias)) {
    if (!hosting_domain_allowed($alias, array(
      'nid' => $site->nid,
    )) || $alias == $site->title) {
      form_set_error('aliases', t('The domain name @alias is already in use', array(
        '@alias' => $alias,
      )));
    }
    if (!_hosting_valid_fqdn_wildcard($alias)) {
      form_set_error('aliases', t('The domain name @alias is not a valid url', array(
        '@alias' => $alias,
      )));
    }
  }
}