You are here

function hosting_get_site_by_url in Hosting 6.2

Same name and namespace in other branches
  1. 5 site/hosting_site.module \hosting_get_site_by_url()
  2. 7.4 site/hosting_site.module \hosting_get_site_by_url()
  3. 7.3 site/hosting_site.module \hosting_get_site_by_url()

Retrieve a node based on the url

File

site/hosting_site.module, line 499

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;
}