You are here

function _hosting_site_url in Hosting 7.4

Same name and namespace in other branches
  1. 6.2 site/hosting_site.module \_hosting_site_url()
  2. 7.3 site/hosting_site.module \_hosting_site_url()

Get site's URL.

2 calls to _hosting_site_url()
hosting_cron_queue in cron/hosting_cron.module
Implements hosting_QUEUE_TYPE_queue().
hosting_site_goto in site/hosting_site.module
Menu callback to go to your site.

File

site/hosting_site.module, line 243
Contains hook implementations for Hosting site module.

Code

function _hosting_site_url($node) {
  $schema = 'http';
  $port = NULL;
  $url = hosting_site_canonical_url($node);
  $platform = node_load($node->platform);
  $server = node_load($platform->web_server);
  if ($server->services['http']
    ->has_port()) {
    $port = $server->services['http']->port;
    if ($port == 80) {
      $port = NULL;
    }
  }

  // This is part of the ssl feature, but is better to implement here.
  // The 2 is a bit of a magic number, because we cant rely on the constants being available yet.
  // 2 == Only SSL is required, corresponding to HOSTING_SSL_REQUIRED and HOSTING_HTTPS_REQUIRED.
  $hosting_ssl_required = isset($node->ssl_enabled) && $node->ssl_enabled == 2;
  $hosting_https_required = isset($node->https_enabled) && $node->https_enabled == 2;
  if ($hosting_ssl_required || $hosting_https_required) {
    $schema = 'https';
    if ($server->services['http']
      ->has_port()) {
      $port = $server->services['http']->ssl_port;
      if ($port == 443) {
        $port = NULL;
      }
    }
  }
  if (is_numeric($port)) {
    return "{$schema}://{$url}:{$port}";
  }
  return "{$schema}://{$url}";
}