You are here

function hosting_ssl_hosting_site_options_alter in Hosting 7.4

Same name and namespace in other branches
  1. 6.2 web_server/ssl/hosting_ssl.nodeapi.inc \hosting_ssl_hosting_site_options_alter()
  2. 7.3 web_server/ssl/hosting_ssl.nodeapi.inc \hosting_ssl_hosting_site_options_alter()

Implemensts hook_hosting_site_options_alter

File

web_server/ssl/hosting_ssl.nodeapi.inc, line 88
NodeAPI functions for the Hosting SSL module.

Code

function hosting_ssl_hosting_site_options_alter(&$return, $node) {

  // Disable the ssl key fields by default.
  if (!count(hosting_ssl_get_servers())) {
    $return['ssl_enabled'] = FALSE;
  }
  $return['ssl_key'] = FALSE;
  $return['ssl_key_new'] = FALSE;

  // Test if ssl has been enabled.

  //if (isset($node->ssl_enabled)) {
  if (isset($node->ssl_enabled) && $node->ssl_enabled) {
    $keys = hosting_ssl_get_keys($node->client, TRUE);

    // Return the list of valid keys, including the special 'new key' option.
    $return['ssl_key'] = array_keys($keys);

    // Properly default this value so things dont fall apart later.
    if (count($return['ssl_key']) == 1) {
      $node->ssl_key = HOSTING_SSL_CUSTOM_KEY;
    }

    // the user has chosen to enter a new key
    if ($node->ssl_key == HOSTING_SSL_CUSTOM_KEY) {

      // default the new key to the site's domain name, after filtering.
      $default = hosting_ssl_filter_key($node->title);
      $return['ssl_key_new'] = !empty($default) ? $default : TRUE;
    }

    // we need to ensure that the return value is properly indexed, otherwise it
    // gets interpreted as an object by jquery.
    $return['profile'] = array_values(array_intersect($return['profile'], hosting_ssl_get_profiles()));
    $return['platform'] = array_values(array_intersect($return['platform'], hosting_ssl_get_platforms()));
  }
}