You are here

function hosting_alias_allow_domain in Hostmaster (Aegir) 6

Implementation of hook_allow_domain().

This function will check the existing aliases and the automatically generated aliases to ensure that this url has not been used before

File

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

Code

function hosting_alias_allow_domain($url, $params = array()) {
  $query = "SELECT COUNT(n.nid) FROM {node} n \n      LEFT JOIN {hosting_site} h ON h.nid=n.nid \n      LEFT JOIN {hosting_site_alias} a  ON n.vid = a.vid \n    WHERE \n      type='site' AND alias='%s' AND h.status <> %d";
  $args[] = $url;
  $args[] = HOSTING_SITE_DELETED;
  if (isset($params['nid'])) {
    $query .= ' AND n.nid <> %d';
    $args[] = $params['nid'];
  }
  $result = !db_result(db_query($query, $args));
  return $result;
}