You are here

function hosting_ssl_get_keys in Hosting 7.3

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

Retrieve an associated array of possible keys.

Parameters

$client: The client to filter the keys by.

$ask_custom: Include the special 'generate new key' value used by the site form.

Return value

array

3 calls to hosting_ssl_get_keys()
hook_hosting_site_options_alter in site/hosting_site.api.php
Alters which site options are available.
hosting_ssl_hosting_site_options_alter in web_server/ssl/hosting_ssl.nodeapi.inc
Implemensts hook_hosting_site_options_alter
hosting_ssl_site_form in web_server/ssl/hosting_ssl.nodeapi.inc
Form API code to extend the site form with SSL fields.

File

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

Code

function hosting_ssl_get_keys($client = NULL, $ask_custom = FALSE) {
  $keys = array();
  if ($ask_custom == TRUE) {
    $keys[HOSTING_SSL_CUSTOM_KEY] = t("Generate a new encryption key.");
  }
  $args = array();
  $query = "SELECT cid, ssl_key FROM {hosting_ssl_cert}";
  if (!is_null($client)) {
    $client = hosting_get_client($client);
    if ($client) {
      $query .= " WHERE client = :client";
      $args[':client'] = $client->nid;
    }
  }
  $result = db_query($query, $args);
  while ($obj = $result
    ->fetchObject()) {
    if (count($obj->ssl_key)) {
      $keys[$obj->cid] = $obj->ssl_key;
    }
  }
  return $keys;
}