You are here

function hosting_get_site_by_url in Hostmaster (Aegir) 6

Retrieve a node based on the url

File

modules/hosting/site/hosting_site.module, line 355

Code

function hosting_get_site_by_url($url) {

  // If the Aliases feature is enabled, try and get the site by its alias too
  if (hosting_feature('alias')) {
    $nid = db_result(db_query("SELECT n.nid FROM {node} n JOIN {hosting_site} h ON n.nid = h.nid LEFT JOIN {hosting_site_alias} ha ON h.vid = ha.vid WHERE (n.title = '%s' OR ha.alias = '%s') AND n.type = 'site' AND NOT (h.status = %d)", $url, $url, HOSTING_SITE_DELETED));
  }
  else {
    $nid = db_result(db_query("SELECT n.nid FROM {node} n JOIN {hosting_site} h ON n.nid = h.nid WHERE n.title='%s' AND n.type = 'site' AND NOT (h.status=%d)", $url, HOSTING_SITE_DELETED));
  }
  if ($nid) {
    return node_load($nid);
  }
  return false;
}