You are here

function hosting_ssl_server_cert_list in Hosting 7.3

Same name and namespace in other branches
  1. 6.2 web_server/ssl/hosting_ssl.module \hosting_ssl_server_cert_list()
  2. 7.4 web_server/ssl/hosting_ssl.module \hosting_ssl_server_cert_list()

List SSL certificates associated with the given server.

1 string reference to 'hosting_ssl_server_cert_list'
hosting_ssl_menu in web_server/ssl/hosting_ssl.module
Per-server, per-ip certificate listing.

File

web_server/ssl/hosting_ssl.module, line 140
Hook implementations for the Hosting SSL module.

Code

function hosting_ssl_server_cert_list($node) {
  drupal_set_title(t('Certificates installed on server @server', array(
    '@server' => $node->title,
  )), PASS_THROUGH);
  $header = array(
    array(
      'data' => t('Domain'),
      'field' => 'domain',
    ),
    array(
      'data' => t('IP address'),
      'field' => 'ip_address',
    ),
    array(
      'data' => t('Client'),
      'field' => 'client',
    ),
  );
  $query = db_select('hosting_ip_addresses', 'ips');
  $query = $query
    ->extend('PagerDefault');
  $query = $query
    ->extend('TableSort');
  $query
    ->join('hosting_ssl_cert_ips', 'cert_ip', 'cert_ip.ip_address = ips.id');
  $query
    ->join('hosting_ssl_cert', 'cert', 'cert.cid = cert_ip.cid');
  $query
    ->join('node', 'client', 'client.nid = cert.client');
  $query
    ->element(2);
  $query
    ->addField('ips', 'ip_address');
  $query
    ->addField('cert', 'ssl_key', 'domain');
  $query
    ->addField('cert', 'status');
  $query
    ->addField('client', 'title', 'client');
  $query
    ->condition('ips.nid', $node->nid)
    ->limit(25)
    ->orderByHeader($header)
    ->addTag('node_access');
  $result = $query
    ->execute();
  $rows = array();
  foreach ($result as $cert) {
    $row = array();
    $row[] = $cert->domain;
    $row[] = $cert->ip_address;
    $row[] = filter_xss($cert->client);
    $rows[] = $row;
  }
  return theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'class' => array(
        'hosting-table',
      ),
    ),
  )) . theme('pager', array(
    'tags' => NULL,
    'element' => 2,
  ));
}